InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
conduit.connectEnd2(server);
IdentifierMap identifierMap = new RemoteIdentifierMap(client);
final ValueSpecification[] valueSpec = new ValueSpecification[10];
for (int i = 0; i < valueSpec.length; i++) {
valueSpec[i] = new ValueSpecification("Test Value", ComputationTargetSpecification.of(UniqueId.of("Kirk", "Value" + i)),
ValueProperties.with(ValuePropertyNames.FUNCTION, "mockFunctionId").get());
}
// Make single value calls
s_logger.debug("Begin single value lookup");
final BitSet seenIds = new BitSet();
for (int i = 0; i < valueSpec.length; i++) {
long id = identifierMap.getIdentifier(valueSpec[i]);
assertTrue(id <= Integer.MAX_VALUE);
assertFalse(seenIds.get((int) id));
seenIds.set((int) id);
}
s_logger.debug("End single value lookup");
// Make a bulk lookup call
s_logger.debug("Begin bulk lookup");
final Map<ValueSpecification, Long> identifiers = identifierMap.getIdentifiers(Arrays.asList(valueSpec));
assertNotNull(identifiers);
assertEquals(valueSpec.length, identifiers.size());
for (ValueSpecification spec : valueSpec) {
assertTrue(identifiers.containsKey(spec));
assertTrue(seenIds.get((int) (long) identifiers.get(spec)));