Package org.springframework.context

Examples of org.springframework.context.ConfigurableApplicationContext


  }

  public void testAuditTrailCustomSeqNr(String dsContext) throws Exception {
    assumeFalse(skipTests());
    logger.info("running testAuditTrailCustomSeqNr");
    final ConfigurableApplicationContext context = createContext(dsContext);
    try {
      cleanDB(context.getBean(DataSource.class));
      de.scoopgmbh.copper.audit.BatchingAuditTrail auditTrail = context.getBean(de.scoopgmbh.copper.audit.BatchingAuditTrail.class);
      auditTrail.setMessagePostProcessor(new DummyPostProcessor());
      long seqNr = 1;
      auditTrail.synchLog(new AuditTrailEvent(1, new Date(), "4711", dsContext, "4711", "4711", "4711", null, "TEXT", seqNr++));
      auditTrail.synchLog(new AuditTrailEvent(1, new Date(), "4711", dsContext, "4711", "4711", "4711", createTestMessage(500), "TEXT", seqNr++));
      auditTrail.synchLog(new AuditTrailEvent(1, new Date(), "4711", dsContext, "4711", "4711", "4711", createTestMessage(5000), "TEXT", seqNr++));
      auditTrail.synchLog(new AuditTrailEvent(1, new Date(), "4711", dsContext, "4711", "4711", "4711", createTestMessage(50000), "TEXT", seqNr++));
      //check
      new RetryingTransaction<Void>(context.getBean(DataSource.class)) {
        @Override
        protected Void execute() throws Exception {
          Statement stmt = createStatement(getConnection());
          ResultSet rs = stmt.executeQuery("select seq_id from cop_audit_trail_event order by seq_id");
          assertTrue(rs.next());
View Full Code Here


  }

  public void testNotifyWithoutEarlyResponseHandling(String dsContext) throws Exception {
    assumeFalse(skipTests());
    logger.info("running testNotifyWithoutEarlyResponseHandling");
    final ConfigurableApplicationContext context = createContext(dsContext);
    cleanDB(context.getBean(DataSource.class));
    final PersistentScottyEngine engine = context.getBean(PersistentScottyEngine.class);
    try {
      engine.startup();
      new RetryingTransaction<Void>(context.getBean(DataSource.class)) {
        @Override
        protected Void execute() throws Exception {
          try {
            Response<?> response = new Response<String>("CID#withEarlyResponse", "TEST", null);
            engine.notify(response, getConnection());
View Full Code Here

   
    assertTrue("DBMS not available",dbmsAvailable);

    logger.info("running testMultipleEngines");
    final int NUMB = 50;
    final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/CopperTxnPersistentWorkflowTest/multiengine-oracle-unittest-context.xml"});
    cleanDB(context.getBean(DataSource.class));
    final PersistentScottyEngine engineRed = context.getBean("persistent.engine.red",PersistentScottyEngine.class);
    final PersistentScottyEngine engineBlue = context.getBean("persistent.engine.blue",PersistentScottyEngine.class);
    final BackChannelQueue backChannelQueue = context.getBean(BackChannelQueue.class);
    engineRed.startup();
    engineBlue.startup();
    try {
      assertEquals(EngineState.STARTED,engineRed.getEngineState());
      assertEquals(EngineState.STARTED,engineBlue.getEngineState());

      for (int i=0; i<NUMB; i++) {
        ProcessingEngine engine = i % 2 == 0 ? engineRed : engineBlue;
        engine.run(PersistentUnitTestWorkflow_NAME,null);
      }

      int x=0;
      long startTS = System.currentTimeMillis();
      while (x < NUMB && startTS+60000 > System.currentTimeMillis()) {
        WorkflowResult wfr = backChannelQueue.poll();
        if (wfr != null) {
          assertNull(wfr.getResult());
          assertNull(wfr.getException());
          x++;
        }
        else {
          Thread.sleep(50);
        }
      }
      assertSame("Test failed - Timeout - "+x+" responses so far",x, NUMB);

      Thread.sleep(1000);

      // check for late queue entries
      assertNull(backChannelQueue.poll());

      // check AuditTrail Log
      new RetryingTransaction<Void>(context.getBean(DataSource.class)) {
        @Override
        protected Void execute() throws Exception {
          ResultSet rs = getConnection().createStatement().executeQuery("SELECT count(*) FROM COP_AUDIT_TRAIL_EVENT");
          rs.next();
          int count = rs.getInt(1);
          assertEquals(NUMB*6, count);
          rs.close();
          return null;
        }
      }.run();
    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engineRed.getEngineState());
    assertEquals(EngineState.STOPPED,engineBlue.getEngineState());
    assertEquals(0,engineRed.getNumberOfWorkflowInstances());
    assertEquals(0,engineBlue.getNumberOfWorkflowInstances());
View Full Code Here

  }


  public void testSpringTxnUnitTestWorkflow(String dsContext) throws Exception {
    assumeFalse(skipTests());
    final ConfigurableApplicationContext context = createContext(dsContext);
    cleanDB(context.getBean(DataSource.class));
    final PersistentScottyEngine engine = context.getBean(PersistentScottyEngine.class);
    final BackChannelQueue backChannelQueue = context.getBean(BackChannelQueue.class);
    try {
      engine.startup();
      engine.run("de.scoopgmbh.copper.test.persistent.springtxn.SpringTxnUnitTestWorkflow", "TestData");
      WorkflowResult x = backChannelQueue.dequeue(60, TimeUnit.SECONDS);
      assertNotNull(x);
      assertNotNull(x.getResult());
      assertNull(x.getException());

      //check
      new RetryingTransaction<Void>(context.getBean(DataSource.class)) {
        @Override
        protected Void execute() throws Exception {
          Statement stmt = getConnection().createStatement();
          ResultSet rs = stmt.executeQuery("select count(*) from cop_audit_trail_event");
          assertTrue(rs.next());
View Full Code Here

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 VersioningTest {

  @Test
  public void testFindLatest() throws Exception {
    final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
    try {
      final WorkflowRepository repo = context.getBean(WorkflowRepository.class);
      WorkflowVersion v = repo.findLatestMajorVersion(VersionTestWorkflowDef.NAME, 9);
      assertEquals(new WorkflowVersion(9, 3, 1), v);
     
      v = repo.findLatestMinorVersion(VersionTestWorkflowDef.NAME, 9, 1);
      assertEquals(new WorkflowVersion(9, 1, 1), v);
    }
    finally {
      context.close();
    }
  }
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);
      descr.setData(brr);

      engine.run(descr);

      brr.wait4response(5000);
      final String workflowClassname = brr.getResponse();

      assertEquals("de.scoopgmbh.copper.test.versioning.VersionTestWorkflow_14_5_67", workflowClassname);

    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());

  }
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);
      descr.setVersion(new WorkflowVersion(1, 0, 1));
      descr.setData(brr);

      engine.run(descr);

      brr.wait4response(5000);
      final String workflowClassname = brr.getResponse();

      assertEquals("de.scoopgmbh.copper.test.versioning.VersionTestWorkflow_1_0_1", workflowClassname);

    }
    finally {
      context.close();
    }
    assertEquals(EngineState.STOPPED,engine.getEngineState());

 
View Full Code Here

TOP

Related Classes of org.springframework.context.ConfigurableApplicationContext

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.