MessageIdFactory { protected long getTimestamp() { long timestamp = System.currentTimeMillis(); return timestamp / HOUR; }  void close(); String getNextId(); String getNextId(String domain); void initialize(String domain); int getIndex(); synchronized void saveMark(); void setDomain(String domain); void setIpAddress(String ipAddress); static final long HOUR; }
@Test public void test() { String id = "UNKNOWN-c0a82050-376665-314"; MessageId message = MessageId.parse(id); Assert.assertEquals(1355994000000L, message.getTimestamp()); Assert.assertEquals("192.168.32.80", message.getIpAddress()); Assert.assertEquals(id, message.toString()); id = "ARCH-UNKNOWN-c0a82050-376665-314"; message = MessageId.parse(id); Assert.assertEquals(1355994000000L, message.getTimestamp()); Assert.assertEquals("192.168.32.80", message.getIpAddress()); Assert.assertEquals("ARCH-UNKNOWN", message.getDomain()); Assert.assertEquals(id, message.toString()); }