CamelJbiComponent component = new CamelJbiComponent();
container.activateComponent(component, "#ServiceMixComponent#");
URL url = getClass().getResource(serviceUnitConfiguration);
File path = new File(new URI(url.toString()));
path = path.getParentFile();
ServiceMixClient client = new DefaultServiceMixClient(container);
try {
for (int i = 0; i < 2; i++) {
LOG.info("Loop counter: " + i);
// Deploy and start su
component.getServiceUnitManager().deploy(suName,
path.getAbsolutePath());
component.getServiceUnitManager().init(suName,
path.getAbsolutePath());
component.getServiceUnitManager().start(suName);
// Send message
MessageExchange exchange = createExchange(client);
configureExchange(client, exchange);
populateExchange(exchange);
client.sendSync(exchange);
assertNotNull(exchange.getMessage("out"));
//assertNotNull(exchange.getMessage("out").getContent());
// TODO: check out
client.done(exchange);
// Stop and undeploy
component.getServiceUnitManager().stop(suName);
component.getServiceUnitManager().shutDown(suName);
component.getServiceUnitManager().undeploy(suName,
path.getAbsolutePath());
// Send message
exchange = createExchange(client);
try {
configureExchange(client, exchange);
client.send(exchange);
fail("Should have failed to send to a no longer deployed component");
} catch (Throwable e) {
LOG.debug(
"Caught expected exception as the component is undeployed: "
+ e, e);