@Test
  public void testWithMessageHistory() throws Exception {
    GemfireMessageStore store = new GemfireMessageStore(this.cache);
    store.afterPropertiesSet();

    store.getMessageGroup(1);

    Message<?> message = new GenericMessage<String>("Hello");
    DirectChannel fooChannel = new DirectChannel();
    fooChannel.setBeanName("fooChannel");
    DirectChannel barChannel = new DirectChannel();
    barChannel.setBeanName("barChannel");

    message = MessageHistory.write(message, fooChannel);
    message = MessageHistory.write(message, barChannel);
    store.addMessageToGroup(1, message);

    message = store.getMessageGroup(1).getMessages().iterator().next();

    MessageHistory messageHistory = MessageHistory.read(message);
    assertNotNull(messageHistory);
    assertEquals(2, messageHistory.size());
    Properties fooChannelHistory = messageHistory.get(0);
    assertEquals("fooChannel", fooChannelHistory.get("name"));
    assertEquals("channel", fooChannelHistory.get("type"));
  }
 @Test
 public void adapterWithJmsTemplate() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext("jmsInboundWithJmsTemplate.xml", this.getClass());
   PollableChannel output = (PollableChannel) context.getBean("output");
   Message<?> message = output.receive(timeoutOnReceive);
   MessageHistory history = MessageHistory.read(message);
   assertNotNull(history);
   Properties componentHistoryRecord =
       TestUtils.locateComponentInHistory(history, "inboundAdapter", 0);
   assertNotNull(componentHistoryRecord);
   assertEquals("jms:inbound-channel-adapter", componentHistoryRecord.get("type"));
   assertNotNull("message should not be null", message);
   assertEquals("polling-test", message.getPayload());
   context.stop();
 }
 @Test
 public void adapterWithMessageSelector() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext("jmsInboundWithMessageSelector.xml", this.getClass());
   PollableChannel output = (PollableChannel) context.getBean("output2");
   Message<?> message = output.receive(timeoutOnReceive);
   MessageHistory history = MessageHistory.read(message);
   assertNotNull(history);
   Properties componentHistoryRecord =
       TestUtils.locateComponentInHistory(history, "messageDrivenAdapter", 0);
   assertNotNull(componentHistoryRecord);
   JmsMessageDrivenEndpoint endpoint =
       context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
   assertEquals("jms:message-driven-channel-adapter", componentHistoryRecord.get("type"));
   assertNotNull("message should not be null", message);
   assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
   endpoint.stop();
   context.close();
 }
 @Test
 public void testGatewayWithConnectionFactoryAndDestination() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext(
           "jmsGatewayWithConnectionFactoryAndDestination.xml", this.getClass());
   PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
   JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
   assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
   context.start();
   Message<?> message = channel.receive(3000);
   MessageHistory history = MessageHistory.read(message);
   assertNotNull(history);
   Properties componentHistoryRecord =
       TestUtils.locateComponentInHistory(history, "jmsGateway", 0);
   assertNotNull(componentHistoryRecord);
   assertEquals("jms:inbound-gateway", componentHistoryRecord.get("type"));
   assertNotNull("message should not be null", message);
   assertEquals("message-driven-test", message.getPayload());
   context.stop();
 }
  @Test
  public void postRequestWithTextContentOk() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("POST");
    request.setContent("test".getBytes());

    // request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but not in Spring
    // 3.0.7.RELEASE
    // Instead use:
    request.addHeader("Content-Type", "text/plain");

    MockHttpServletResponse response = new MockHttpServletResponse();
    postOnlyAdapter.handleRequest(request, response);
    assertEquals(HttpServletResponse.SC_OK, response.getStatus());
    Message<?> message = requests.receive(0);
    MessageHistory history = MessageHistory.read(message);
    assertNotNull(history);
    Properties componentHistoryRecord =
        TestUtils.locateComponentInHistory(history, "postOnlyAdapter", 0);
    assertNotNull(componentHistoryRecord);
    assertEquals("http:inbound-channel-adapter", componentHistoryRecord.get("type"));
    assertNotNull(message);
    assertEquals("test", message.getPayload());
  }