}
}
@Test
public void testCreateRemoveApplication() throws Exception {
CamelRoutingEngine routingEngine = new CamelRoutingEngine();
try {
routingEngine.start();
Connector connector = mock(Connector.class);
ConnectorService cs1 = routingEngine.addApplication("test1", connector);
cs1.start();
// check that the application was created successfully
Assert.assertNotNull(cs1);
Assert.assertEquals(Service.State.STARTED, cs1.getState());
// check that there is only one application
Collection<ConnectorService> applications = routingEngine.getApplications();
Assert.assertEquals(1, applications.size());
// create a second and third receiver
ConnectorService cs2 = routingEngine.addApplication("test2", connector);
cs2.start();
ConnectorService cs3 = routingEngine.addApplication("test3", connector);
cs3.start();
applications = routingEngine.getApplications();
Assert.assertEquals(3, applications.size());
// check that all applications are contained
Assert.assertTrue(applications.contains(cs1));
Assert.assertTrue(applications.contains(cs2));
Assert.assertTrue(applications.contains(cs3));
// remove one of the applications
routingEngine.removeApplication("test3");
applications = routingEngine.getApplications();
Assert.assertEquals(2, applications.size());
Assert.assertTrue(applications.contains(cs1));
Assert.assertTrue(applications.contains(cs2));
Assert.assertFalse(applications.contains(cs3));
} finally {
routingEngine.shutdown();
}
}