Package com.opengamma.engine.test

Examples of com.opengamma.engine.test.TestCalculationNode


    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());
View Full Code Here


    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 failingNode = new TestCalculationNode() {
     
      @Override
      public CalculationJobResult executeJob(CalculationJob job) {
        throw new OpenGammaRuntimeException ("Remote node not working");
      }
View Full Code Here

  public void testAddNodeWithCallbackPending() {
    final LocalNodeJobInvoker invoker = new LocalNodeJobInvoker();
    _invoker = null;
    assertFalse(invoker.notifyWhenAvailable(_register));
    assertNull(_invoker);
    invoker.addNode(new TestCalculationNode());
    assertEquals(invoker, _invoker);
  }
View Full Code Here

  }

  public void testAddCallbackWithNodePending() {
    final LocalNodeJobInvoker invoker = new LocalNodeJobInvoker();
    _invoker = null;
    invoker.addNode(new TestCalculationNode());
    assertTrue(invoker.notifyWhenAvailable(_register));
    assertNull(_invoker);
  }
View Full Code Here

    assertFalse(invoker.invoke(JobDispatcherTest.createTestJob(), receiver));
    assertNull(receiver.getCompletionResult());
  }

  public void testInvokeWithOneNode() {
    final LocalNodeJobInvoker invoker = new LocalNodeJobInvoker(new TestCalculationNode());
    final TestJobInvocationReceiver receiver = new TestJobInvocationReceiver();
    final CalculationJob job = JobDispatcherTest.createTestJob();
    assertTrue(invoker.invoke(job, receiver));
    final CalculationJobResult jobResult = receiver.waitForCompletionResult(TIMEOUT);
    assertNotNull(jobResult);
View Full Code Here

@Test(groups = TestGroup.UNIT)
public class CalculationNodeTest {

  public void mockFunctionInvocationOneInputMissing() throws Exception {
    final MockFunction mockFunction = CalculationNodeUtils.getMockFunction();
    final TestCalculationNode calcNode = CalculationNodeUtils.getTestCalcNode(mockFunction);
    final CalculationJob calcJob = CalculationNodeUtils.getCalculationJob(mockFunction);

    final long startTime = System.nanoTime();
    final CalculationJobResult jobResult = calcNode.executeJob(calcJob);
    final long endTime = System.nanoTime();
    assertNotNull(jobResult);
    assertTrue(jobResult.getDuration() >= 0);
    assertTrue(endTime - startTime >= jobResult.getDuration());
    assertEquals(1, jobResult.getResultItems().size());
View Full Code Here

    assertNull(executionLog.getExceptionStackTrace());
  }

  public void mockFunctionInvocationOneInputOneOutput() throws Exception {
    final MockFunction mockFunction = CalculationNodeUtils.getMockFunction();
    final TestCalculationNode calcNode = CalculationNodeUtils.getTestCalcNode(mockFunction);
    final CalculationJob calcJob = CalculationNodeUtils.getCalculationJob(mockFunction);
    final ValueSpecification inputSpec = CalculationNodeUtils.getMockFunctionInputs(mockFunction).iterator().next();
    final ComputedValue inputValue = new ComputedValue(inputSpec, "Just an input object");

    final ViewComputationCache cache = calcNode.getCache(calcJob.getSpecification());
    cache.putSharedValue(inputValue);

    final CalculationJobResult jobResult = calcNode.executeJob(calcJob);
    assertNotNull(jobResult);
    assertEquals(1, jobResult.getResultItems().size());
    final CalculationJobResultItem resultItem = jobResult.getResultItems().get(0);
    assertEquals(InvocationResult.SUCCESS, resultItem.getResult());
    assertEquals("Nothing we care about", cache.getValue(mockFunction.getResultSpec()));
View Full Code Here

  //-------------------------------------------------------------------------
  public void testLogIndicators() throws Exception {
    final MockFunction mockFunction = getMockLoggingFunction();
    final ThreadLocalLogEventListener logEventListener = new ThreadLocalLogEventListener();
    final TestCalculationNode calcNode = new TestCalculationNode(logEventListener);
    CalculationNodeUtils.configureTestCalcNode(calcNode, mockFunction);
    final CalculationJob calcJob = CalculationNodeUtils.getCalculationJob(mockFunction, ExecutionLogMode.INDICATORS);
    final CalculationJobResultItem resultItemLogIndicators = getResultWithLogging(mockFunction, logEventListener, calcNode, calcJob);

    final ExecutionLog executionLog = resultItemLogIndicators.getExecutionLog();
View Full Code Here

  }

  public void testLogFull() throws Exception {
    final MockFunction mockFunction = getMockLoggingFunction();
    final ThreadLocalLogEventListener logEventListener = new ThreadLocalLogEventListener();
    final TestCalculationNode calcNode = new TestCalculationNode(logEventListener);
    CalculationNodeUtils.configureTestCalcNode(calcNode, mockFunction);
    final CalculationJob calcJob = CalculationNodeUtils.getCalculationJob(mockFunction, ExecutionLogMode.FULL);
    final CalculationJobResultItem resultItemLogIndicators = getResultWithLogging(mockFunction, logEventListener, calcNode, calcJob);

    final ExecutionLog executionLog = resultItemLogIndicators.getExecutionLog();
View Full Code Here

TOP

Related Classes of com.opengamma.engine.test.TestCalculationNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.