use of org.springframework.context.support.AbstractXmlApplicationContext in project Activiti by Activiti.
the class SpringAutoDeployTest method testResourceRedeploymentAfterProcessDefinitionChange.
// Updating the bpmn20 file should lead to a new deployment when restarting
// the Spring container
public void testResourceRedeploymentAfterProcessDefinitionChange() throws Exception {
createAppContext(CTX_PATH);
assertEquals(1, repositoryService.createDeploymentQuery().count());
((AbstractXmlApplicationContext) applicationContext).destroy();
String filePath = "org/activiti/spring/test/autodeployment/autodeploy.a.bpmn20.xml";
String originalBpmnFileContent = IoUtil.readFileAsString(filePath);
String updatedBpmnFileContent = originalBpmnFileContent.replace("flow1", "fromStartToEndFlow");
assertTrue(updatedBpmnFileContent.length() > originalBpmnFileContent.length());
IoUtil.writeStringToFile(updatedBpmnFileContent, filePath);
// Classic produced/consumer problem here:
// The file is already written in Java, but not yet completely persisted by
// the OS
// Constructing the new app context reads the same file which is sometimes
// not yet fully written to disk
waitUntilFileIsWritten(filePath, updatedBpmnFileContent.length());
try {
applicationContext = new ClassPathXmlApplicationContext(CTX_NO_DROP_PATH);
repositoryService = (RepositoryService) applicationContext.getBean("repositoryService");
} finally {
// Reset file content such that future test are not seeing something funny
IoUtil.writeStringToFile(originalBpmnFileContent, filePath);
}
// Assertions come AFTER the file write! Otherwise the process file is
// messed up if the assertions fail.
assertEquals(2, repositoryService.createDeploymentQuery().count());
assertEquals(6, repositoryService.createProcessDefinitionQuery().count());
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringTestHelper method createSpringCamelContext.
public static CamelContext createSpringCamelContext(ContextTestSupport test, String classpathUri) throws Exception {
test.setUseRouteBuilder(false);
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(classpathUri);
test.setCamelContextService(new Service() {
public void start() throws Exception {
applicationContext.start();
}
public void stop() throws Exception {
applicationContext.stop();
}
});
return SpringCamelContext.springCamelContext(applicationContext);
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringMarshalOmitFieldsTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
setUseRouteBuilder(false);
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.xml");
setCamelContextService(new Service() {
public void start() throws Exception {
applicationContext.start();
}
public void stop() throws Exception {
applicationContext.stop();
}
});
return SpringCamelContext.springCamelContext(applicationContext);
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class RouteRefMultipleCamelContextRefsTest method testSpringTwoCamelContextDirectEndpoint.
public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
AbstractXmlApplicationContext ac = createApplicationContext();
ac.start();
CamelContext camel1 = ac.getBean("myCamel-1", CamelContext.class);
CamelContext camel2 = ac.getBean("myCamel-2", CamelContext.class);
Endpoint start1 = camel1.getEndpoint("direct:start");
Endpoint start2 = camel2.getEndpoint("direct:start");
assertNotSame(start1, start2);
MockEndpoint mock1 = camel1.getEndpoint("mock:result", MockEndpoint.class);
mock1.expectedBodiesReceived("Hello World");
MockEndpoint mock2 = camel2.getEndpoint("mock:result", MockEndpoint.class);
mock2.expectedBodiesReceived("Bye World");
camel1.createProducerTemplate().sendBody("direct:start", "Hello World");
camel2.createProducerTemplate().sendBody("direct:start", "Bye World");
mock1.assertIsSatisfied();
mock2.assertIsSatisfied();
ac.stop();
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringRouteNoFromTest method createApplicationContext.
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
AbstractXmlApplicationContext answer;
try {
answer = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/SpringRouteNoFromTest.xml");
fail("Should have thrown exception");
} catch (Exception e) {
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertEquals("Route myRoute has no inputs: Route(myRoute)[[] -> [To[mock:result]]]", iae.getMessage());
return null;
}
return answer;
}
Aggregations