View Javadoc

1   /*
2    * $Id: ExpressionSplitterXPathWithFiltersTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.routing.outbound;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  import org.custommonkey.xmlunit.XMLUnit;
18  
19  public class ExpressionSplitterXPathWithFiltersTestCase extends FunctionalTestCase
20  {
21      MuleClient client;
22  
23      private final String MESSAGE = "<Foo>\n" +
24              "    <Bar>\n" +
25              "        <One>One</One>\n" +
26              "        <Three>Three</Three>\n" +
27              "        <Two>Two</Two>\n" +
28              "        <Three>Three</Three>\n" +
29              "        <Three>Three</Three>\n" +
30              "        <One>One</One>\n" +
31              "    </Bar>    \n" +
32              "</Foo>";
33  
34  
35  
36      public ExpressionSplitterXPathWithFiltersTestCase()
37      {
38          XMLUnit.setIgnoreWhitespace(true);
39      }
40  
41      protected String getConfigResources()
42      {
43          return "org/mule/test/integration/routing/outbound/expression-splitter-xpath-with-filters-test.xml";
44      }
45  
46      public void testRecipientList() throws Exception
47      {
48          client = new MuleClient(muleContext);
49          client.dispatch("vm://distributor.queue", MESSAGE, null);
50  
51          readFromQueue("vm://service1.out", 2, "One");
52          readFromQueue("vm://service2.out", 1, "Two");
53          readFromQueue("vm://service3.out", 3, "Three");
54      }
55  
56      public void readFromQueue(String name, int expectedNumber, String number) throws Exception
57      {
58          MuleMessage message;
59          for (int i = 0; i < expectedNumber; i++)
60          {
61              message = client.request(name, 2000L);
62              assertNotNull(message);
63              XMLUnit.compareXML("<" + number + ">" + number + "</" + number + ">", message.getPayloadAsString());
64          }
65  
66          assertNull(client.request(name, 1000L));
67      }
68  }