endpointConfiguration.setEndpointUri(endpointUri);
CamelEndpoint camelEndpoint = new CamelEndpoint(endpointConfiguration);
camelEndpoint.setMessageListener(messageListeners);
Message requestMessage = new com.consol.citrus.message.DefaultMessage("Hello from Citrus!");
DefaultMessage message = new DefaultMessage();
message.setBody("Hello from Camel!");
Exchange exchange = new DefaultExchange(camelContext);
exchange.setIn(message);
reset(camelContext, producerTemplate, consumerTemplate, messageListeners);
expect(camelContext.createProducerTemplate()).andReturn(producerTemplate).once();
expect(producerTemplate.send(eq(endpointUri), anyObject(Processor.class))).andReturn(exchange).once();
expect(camelContext.createConsumerTemplate()).andReturn(consumerTemplate).once();
expect(camelContext.getUuidGenerator()).andReturn(new JavaUuidGenerator()).once();
expect(consumerTemplate.receive(endpointUri, endpointConfiguration.getTimeout())).andReturn(exchange).once();
messageListeners.onOutboundMessage(requestMessage, context);
expectLastCall().once();
messageListeners.onInboundMessage(anyObject(Message.class), eq(context));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
Message inboundMessage = (Message) getCurrentArguments()[0];
Assert.assertTrue(inboundMessage.getPayload(String.class).contains("Hello from Camel!"));
return null;
}
}).once();
replay(camelContext, producerTemplate, consumerTemplate, messageListeners);