1
2
3
4
5
6
7
8
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.junit4.FunctionalTestCase;
16
17 import org.custommonkey.xmlunit.XMLUnit;
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertNull;
22
23 public class ExpressionSplitterXPathWithFiltersTestCase extends FunctionalTestCase
24 {
25 private static final String MESSAGE = "<Foo>\n" +
26 " <Bar>\n" +
27 " <One>One</One>\n" +
28 " <Three>Three</Three>\n" +
29 " <Two>Two</Two>\n" +
30 " <Three>Three</Three>\n" +
31 " <Three>Three</Three>\n" +
32 " <One>One</One>\n" +
33 " </Bar> \n" +
34 "</Foo>";
35
36 private MuleClient client;
37
38 public ExpressionSplitterXPathWithFiltersTestCase()
39 {
40 XMLUnit.setIgnoreWhitespace(true);
41 }
42
43 @Override
44 protected String getConfigResources()
45 {
46 return "org/mule/test/integration/routing/outbound/expression-splitter-xpath-with-filters-test.xml";
47 }
48
49 @Test
50 public void testRecipientList() throws Exception
51 {
52 client = new MuleClient(muleContext);
53 client.dispatch("vm://distributor.queue", MESSAGE, null);
54
55 readFromQueue("vm://service1.out", 2, "One");
56 readFromQueue("vm://service2.out", 1, "Two");
57 readFromQueue("vm://service3.out", 3, "Three");
58 }
59
60 public void readFromQueue(String name, int expectedNumber, String number) throws Exception
61 {
62 MuleMessage message;
63 for (int i = 0; i < expectedNumber; i++)
64 {
65 message = client.request(name, 2000L);
66 assertNotNull(message);
67 XMLUnit.compareXML("<" + number + ">" + number + "</" + number + ">", message.getPayloadAsString());
68 }
69
70 assertNull(client.request(name, 1000L));
71 }
72 }