@Test
  public void testXPathRouterNoChannelResolver() {

    // Build the route
    DirectChannel inputChannel = new DirectChannel();
    inputChannel.setBeanName("input");
    XPathRouter router = new XPathRouter("//subject/text()");
    router.setEvaluateAsString(true);
    inputChannel.subscribe(router);

    // Create message
    Object correlationId = "123-ABC";
    String xmlSource = "<xml><subject>test</subject></xml>";
    Message<String> message =
        MessageBuilder.withPayload(xmlSource).setCorrelationId(correlationId).build();

    // Send and receive message synchronously
    MessagingTemplate template = new MessagingTemplate(inputChannel);
    try {
      Message<?> reply = template.sendAndReceive(message);
      assertFalse("should fail", true);
    } catch (MessageHandlingException ex) {
      assertTrue(ex.getMessage().contains("error occurred in message handler"));
      assertTrue(
          ex.getCause()
              .getMessage()
              .contains("unable to resolve channel names, no ChannelResolver available"));
    }
  }
  @Test
  public void testXPathRouter() {
    // route to a channel determined by outcome of the xpath expression

    // Build the route
    DirectChannel inputChannel = new DirectChannel();
    inputChannel.setBeanName("input");
    XPathRouter router = new XPathRouter("//subject/text()");
    router.setEvaluateAsString(true);
    inputChannel.subscribe(router);
    QueueChannel testChannel = new QueueChannel();
    GenericApplicationContext context = new GenericApplicationContext();
    context.getBeanFactory().registerSingleton("testChannel", testChannel);

    router.setBeanFactory(context);
    context.refresh();

    // Create message
    Object correlationId = "123-ABC";
    String xmlSource = "<xml><subject>testChannel</subject></xml>";
    Message<String> message =
        MessageBuilder.withPayload(xmlSource).setCorrelationId(correlationId).build();

    // Send and receive message
    inputChannel.send(message);
    Message<?> reply = testChannel.receive(0);
    assertEquals(xmlSource, reply.getPayload());
  }