Package de.scoopgmbh.copper.tranzient

Examples of de.scoopgmbh.copper.tranzient.TransientScottyEngine


public class ExceptionHandlingTest {

  @Test
  public void testExceptionHandlingTestWF() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");
    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      String data = "data";

     
      final WorkflowInstanceDescr<String> descr = new WorkflowInstanceDescr<String>("de.scoopgmbh.copper.test.ExceptionHandlingTestWF");
      descr.setId("1234456");
      descr.setData(data);
     
      engine.run(descr);
     
      Thread.sleep(1000L);
     
      WorkflowInfo info = engine.queryWorkflowInstance(descr.getId());
     
      assertNull(info);
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here



  @Test
  public void testIssueClassCastExceptionWorkflow3() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");
    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      String data = "data";

     
      final WorkflowInstanceDescr<String> descr = new WorkflowInstanceDescr<String>("de.scoopgmbh.copper.test.IssueClassCastExceptionWorkflow3");
      descr.setId("1234456");
      descr.setData(data);
     
      engine.run(descr);
     
      Thread.sleep(1000L);
     
      WorkflowInfo info = engine.queryWorkflowInstance(descr.getId());
     
      assertNull(info);
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

public class SwitchCaseTest{

  @Test
  public void testWorkflow() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");
    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      SwitchCaseTestData data = new SwitchCaseTestData();
      data.testEnumValue = TestEnum.C;
      data.asyncResponseReceiver = new BlockingResponseReceiver<Integer>();
      engine.run("de.scoopgmbh.copper.test.SwitchCaseTestWF", data);
      data.asyncResponseReceiver.wait4response(5000L);
      assertEquals(0,data.asyncResponseReceiver.getResponse().intValue());
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

  }

  @Test
  public void testLatest() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine _engine = (TransientScottyEngine) context.getBean("transientEngine");
    assertEquals(EngineState.STARTED,_engine.getEngineState());
    ProcessingEngine engine = _engine;

    try {
      final BlockingResponseReceiver<String> brr = new BlockingResponseReceiver<String>();
      final WorkflowInstanceDescr<BlockingResponseReceiver<String>> descr = new WorkflowInstanceDescr<BlockingResponseReceiver<String>>(VersionTestWorkflowDef.NAME);
View Full Code Here

  }

  @Test
  public void testVersion() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine _engine = (TransientScottyEngine) context.getBean("transientEngine");
    assertEquals(EngineState.STARTED,_engine.getEngineState());
    ProcessingEngine engine = _engine;

    try {
      final BlockingResponseReceiver<String> brr = new BlockingResponseReceiver<String>();
      final WorkflowInstanceDescr<BlockingResponseReceiver<String>> descr = new WorkflowInstanceDescr<BlockingResponseReceiver<String>>(VersionTestWorkflowDef.NAME);
View Full Code Here

  private final int[] response = { -1 };

  @Test
  public void testWorkflow() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");
    context.getBeanFactory().registerSingleton("OutputChannel4711",new TestResponseReceiver<String, Integer>() {
      @Override
      public void setResponse(Workflow<String> wf, Integer r) {
        synchronized (response) {
          response[0] = r.intValue();
          response.notifyAll();
        }
      }
    });

    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      BlockingResponseReceiver<Integer> brr = new BlockingResponseReceiver<Integer>();
      engine.run("de.scoopgmbh.copper.test.tranzient.simple.WaitInMethodTestTransientWorkflow", brr);
      brr.wait4response(5000L);
      assertEquals(1,brr.getResponse().intValue());
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

   
  }

  private void doTest(String wfClassname, int expectedResult) throws CopperException, InterruptedException {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = context.getBean("transientEngine", TransientScottyEngine.class);
    context.getBeanFactory().registerSingleton("OutputChannel4711",new TestResponseReceiver<String, Integer>() {
      @Override
      public void setResponse(Workflow<String> wf, Integer r) {
        synchronized (response) {
          response[0] = r.intValue();
          response.notifyAll();
        }
      }
    });

    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      BlockingResponseReceiver<Integer> brr = new BlockingResponseReceiver<Integer>();
      engine.run(wfClassname, brr);
      synchronized (response) {
        if (response[0] == -1) {
          response.wait(30000);
        }
      }
      assertEquals(expectedResult, response[0]);
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
 
View Full Code Here

public class DerivedTransientEngineTest {

  @Test
  public void testWorkflow() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");

    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      final BlockingResponseReceiver<Integer> brr = new BlockingResponseReceiver<Integer>();
      engine.run("de.scoopgmbh.copper.test.tranzient.classhierarchy.DerivedDerived", brr);
      brr.wait4response(30000);
      assertEquals(10, brr.getResponse().intValue());
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

  private final int[] response = { -1 };

  @Test
  public void testWorkflow() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = context.getBean("transientEngine", TransientScottyEngine.class);
    context.getBeanFactory().registerSingleton("OutputChannel4711",new TestResponseReceiver<String, Integer>() {
      @Override
      public void setResponse(Workflow<String> wf, Integer r) {
        synchronized (response) {
          response[0] = r.intValue();
          response.notifyAll();
        }
      }
    });

    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      final CompletionIndicator data = new CompletionIndicator();
      engine.run("de.scoopgmbh.copper.test.tranzient.simple.IssueClassCastExceptionWorkflow", data);
     
      Thread.sleep(2500);
     
      assertTrue(data.done);
      assertFalse(data.error);
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

public class SupendPoolTransientEngineTest {

  @Test
  public void testWorkflow() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    TransientScottyEngine engine = (TransientScottyEngine) context.getBean("transientEngine");
    TransientProcessorPool processorPool = (TransientProcessorPool) context.getBean("T_ProcessorPool_DEFAULT");
    assertEquals(EngineState.STARTED,engine.getEngineState());
   
    try {
      final BlockingResponseReceiver<Integer> brr = new BlockingResponseReceiver<Integer>();
      Thread.sleep(10);
      assertFalse(brr.isResponseReceived());
     
      processorPool.suspend();
     
      engine.run("de.scoopgmbh.copper.test.tranzient.simple.NopTransientWorkflow", brr);

      brr.wait4response(100L);
     
      assertFalse(brr.isResponseReceived());

      processorPool.resume();
     
      brr.wait4response(100L);
     
      assertEquals(1,brr.getResponse().intValue());
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());
   
  }
View Full Code Here

TOP

Related Classes of de.scoopgmbh.copper.tranzient.TransientScottyEngine

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.