@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"));
  }
 /**
  * @param history a message history
  * @param componentName the name of a component to scan for
  * @param startingIndex the index to start scanning
  * @return the properties provided by the named component or null if none available
  */
 public static Properties locateComponentInHistory(
     MessageHistory history, String componentName, int startingIndex) {
   Assert.notNull(history, "'history' must not be null");
   Assert.isTrue(StringUtils.hasText(componentName), "'componentName' must be provided");
   Assert.isTrue(
       startingIndex < history.size(), "'startingIndex' can not be greater then size of history");
   Properties component = null;
   for (int i = startingIndex; i < history.size(); i++) {
     Properties properties = history.get(i);
     if (componentName.equals(properties.get("name"))) {
       component = properties;
       break;
     }
   }
   return component;
 }