return new CalculationJob(JobDispatcherTest.createTestJobSpec(), 0L, VersionCorrection.LATEST, null, JobDispatcherTest.createTestJobItems(), CacheSelectHint.allShared());
}
public void simpleInvocation() {
final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
conduit.getEnd2().setFudgeMessageReceiver(messages);
final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
final SimpleCalculationNode node = new TestCalculationNode();
assertEquals(0, messages.getMessages().size());
client.addNode(node);
assertEquals(0, messages.getMessages().size());
client.start();
assertEquals(1, messages.getMessages().size());
final FudgeMsgEnvelope readyMsgEnvelope = messages.getMessages().get(0);
messages.clear();
final FudgeDeserializer dcontext = new FudgeDeserializer(s_fudgeContext);
final FudgeSerializer scontext = new FudgeSerializer(s_fudgeContext);
final RemoteCalcNodeMessage readyMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, readyMsgEnvelope.getMessage());
assertTrue(readyMessage instanceof Ready);
final Ready ready = (Ready) readyMessage;
assertEquals(1, ready.getCapacity());
conduit.getEnd2 ().getFudgeMessageSender().send (FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg (new Init(0)), Init.class, RemoteCalcNodeMessage.class));
final CalculationJob job = createTestCalculationJob();
AbstractIdentifierMap.convertIdentifiers(identifierMap, job);
conduit.getEnd2().getFudgeMessageSender().send(
FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg(new Execute(job)), Execute.class, RemoteCalcNodeMessage.class));
final FudgeMsgEnvelope resultMsgEnvelope = messages.waitForMessage(TIMEOUT);
assertNotNull(resultMsgEnvelope);
final RemoteCalcNodeMessage resultMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, resultMsgEnvelope.getMessage());
assertTrue(resultMessage instanceof Result);