stringsListener.inSync();
intListener.inSync();
replay(stringsListener);
replay(intListener);
Chronicle chronicle = new IndexedChronicle(name);
DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
ListWrapper<String> strings = new ListWrapper<String>(dataStore, "strings", String.class, new ArrayList<String>(), 8);
strings.addListener(stringsListener);
ListWrapper<Integer> ints = new ListWrapper<Integer>(dataStore, "ints", Integer.class, new ArrayList<Integer>(), 6);
ints.addListener(intListener);
dataStore.start();
ints.add(0);
strings.add("Hello");
ints.add(1);
strings.add("World");
ints.add(2);
strings.publishEvent("bye");
ints.publishEvent("now");
verify(stringsListener);
verify(intListener);
assertEquals("[Hello, World]", strings.toString());
assertEquals("[0, 1, 2]", ints.toString());
assertEquals(String[].class, strings.toArray().getClass());
chronicle.close();
}
{
ListListener stringsListener = createMock("strings", ListListener.class);
stringsListener.eventStart(7, "strings");
stringsListener.add("!");
stringsListener.eventEnd(true);
ListListener intListener = createMock("ints", ListListener.class);
intListener.eventStart(8, "ints");
intListener.add(3);
intListener.eventEnd(true);
stringsListener.inSync();
intListener.inSync();
replay(stringsListener);
replay(intListener);
Chronicle chronicle = new IndexedChronicle(name);
DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
ListWrapper<String> strings = new ListWrapper<String>(dataStore, "strings", String.class, new ArrayList<String>(), 8);
strings.addListener(stringsListener);
ListWrapper<Integer> ints = new ListWrapper<Integer>(dataStore, "ints", Integer.class, new ArrayList<Integer>(), 6);
ints.addListener(intListener);
// assume we have all the events written so far
dataStore.start(chronicle.size() - 1);
strings.add("!");
ints.add(3);
verify(stringsListener);
verify(intListener);
assertEquals("[Hello, World, !]", strings.toString());
assertEquals("[0, 1, 2, 3]", ints.toString());
chronicle.close();
}
}