InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
conduit.connectEnd2(server);
RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
FudgeMessageStore dataStore = new RemoteFudgeMessageStore(client, new ViewComputationCacheKey(UniqueId.of("Test", "ViewCycle1"), "Config1"));
// Single value
final MutableFudgeMsg inputValue1 = s_fudgeContext.newMessage();
for (int i = 0; i < 32; i++) {
inputValue1.add(i, Integer.toString(i));
}
long identifier1 = 1L;
dataStore.put(identifier1, inputValue1);
FudgeMsg outputValue = dataStore.get(identifier1);
assertNotNull(outputValue);
assertEquals(inputValue1.getAllFields(), outputValue.getAllFields());
outputValue = dataStore.get(identifier1 + 1);
assertNull(outputValue);
outputValue = dataStore.get(identifier1);
assertNotNull(outputValue);
assertEquals(inputValue1.getAllFields(), outputValue.getAllFields());
// Multiple value
final MutableFudgeMsg inputValue2 = s_fudgeContext.newMessage();
for (int i = 32; i < 64; i++) {
inputValue2.add(i, Integer.toString(i));
}
final Map<Long, FudgeMsg> inputMap = new HashMap<Long, FudgeMsg>();
identifier1++;
long identifier2 = identifier1 + 1;
inputMap.put(identifier1, inputValue1);
inputMap.put(identifier2, inputValue2);
dataStore.put(inputMap);
final Map<Long, FudgeMsg> outputMap = dataStore.get(Arrays.asList(identifier1, identifier2));
assertEquals(2, outputMap.size());
assertEquals(inputValue1.getAllFields(), outputMap.get(identifier1).getAllFields());
assertEquals(inputValue2.getAllFields(), outputMap.get(identifier2).getAllFields());
}