OsmUser implements Storeable { public void store(StoreWriter sw, StoreClassRegister scr) { sw.writeString(name); sw.writeInteger(id); } OsmUser(int id, String userName);  OsmUser(StoreReader sr, StoreClassRegister scr); void store(StoreWriter sw, StoreClassRegister scr); @Override boolean equals(Object o); @Override int hashCode(); int getId(); String getName(); static final OsmUser NONE; }
@Test public final void testGetInstanceFromStore() { ByteArrayOutputStream out = new ByteArrayOutputStream(); StoreWriter sw = new DataOutputStoreWriter(new DataOutputStream(out)); StoreClassRegister scr = new DynamicStoreClassRegister(); OsmUser user1 = new OsmUser(12, "aUser"); OsmUser user3 = new OsmUser(13, "aUser2"); OsmUser user5 = new OsmUser(14, ""); user1.store(sw, scr); user3.store(sw, scr); user5.store(sw, scr); StoreReader sr = new DataInputStoreReader(new DataInputStream(new ByteArrayInputStream(out.toByteArray()))); OsmUser user2 = new OsmUser(sr, scr); OsmUser user4 = new OsmUser(sr, scr); OsmUser user6 = new OsmUser(sr, scr); assertEquals("Object not equal after retrieval from store", user1, user2); assertEquals("Object not equal after retrieval from store", user3, user4); assertEquals("Object not equal after retrieval from store", user5, user6); }