endpoint.getEndpointConfiguration().setDestination(destination);
Map<String, Object> controlHeaders = new HashMap<String, Object>();
controlHeaders.put("Operation", "sayHello");
final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>", controlHeaders);
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("Operation", "sayHello");
reset(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
expect(connectionFactory.createConnection()).andReturn(connection).once();
expect(connection.createSession(anyBoolean(), anyInt())).andReturn(session).once();
expect(session.getTransacted()).andReturn(false).once();
expect(session.getAcknowledgeMode()).andReturn(Session.AUTO_ACKNOWLEDGE).once();
expect(session.createConsumer(destination, null)).andReturn(messageConsumer).once();
connection.start();
expectLastCall().once();
expect(messageConsumer.receive(5000L)).andReturn(new TextMessageImpl("<TestRequest><Message>Hello World!</Message></TestRequest>", headers)).once();
replay(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
Message receivedMessage = endpoint.createConsumer().receive(context);
Assert.assertEquals(receivedMessage.getPayload(), controlMessage.getPayload());
Assert.assertNotNull(receivedMessage.getHeader("Operation"));
Assert.assertTrue(receivedMessage.getHeader("Operation").equals("sayHello"));
verify(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
}