context.addComponent("jms", context.getComponent("seda", SedaComponent.class));
// Add a mock that will act as the activiti component. We'll actually use this
// to verify the behavior of our route later.
ActivitiComponent activitiComponent = mock(ActivitiComponent.class);
ActivitiEndpoint activitiEndpoint = mock(ActivitiEndpoint.class);
when(activitiEndpoint.getEndpointKey()).thenReturn("activiti:open-account");
when(activitiEndpoint.getEndpointUri()).thenReturn("activiti:open-account");
when(activitiComponent.createEndpoint(anyString())).thenReturn(activitiEndpoint);
when(activitiComponent.getCamelContext()).thenReturn(context);
when(activitiEndpoint.getCamelContext()).thenReturn(context);
activitiProducer = mock(ActivitiProducer.class);
// This is the slightly tricky part, we need some kind of feedback when the
// activiti-camel component's producer is invoked. This will let us know that
// the routes were successfully executed up to the process start. And yes,
// we're misusing the doAnswer method of mockito here...
doAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
invoked = true;
return null;
}
}).when(activitiProducer).process((Exchange)anyObject());
when(activitiEndpoint.createProducer()).thenReturn(activitiProducer);
// and finally we add the mocked activiti component to the camel context
context.addComponent("activiti", activitiComponent);
return context;
}