1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.functional;
12
13 import org.mule.api.MuleEventContext;
14 import org.mule.api.MuleException;
15 import org.mule.api.MuleMessage;
16 import org.mule.api.client.MuleClient;
17 import org.mule.api.lifecycle.Callable;
18 import org.mule.tck.junit4.FunctionalTestCase;
19 import org.mule.tck.junit4.rule.DynamicPort;
20
21 import java.util.ArrayList;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.fail;
24
25 import org.junit.Rule;
26 import org.junit.Test;
27
28
29 public class SessionPropertiesWithMessageCollectionTestCase extends FunctionalTestCase
30 {
31
32 @Rule
33 public DynamicPort dynamicPort1 = new DynamicPort("port1");
34
35 @Override
36 protected String getConfigResources()
37 {
38 return "session-properties-with-message-collection.xml";
39 }
40
41 @Test
42 public void testSessionPropertyAfterSplitterAndAggregator() throws MuleException
43 {
44 final MuleClient client = muleContext.getClient();
45 MuleMessage response = client.send("http://localhost:" + dynamicPort1.getNumber() + "/test", TEST_MESSAGE, null);
46 assertNotNullAndNotExceptionResponse(response);
47 }
48
49 private void assertNotNullAndNotExceptionResponse(MuleMessage response)
50 {
51 assertNotNull(response);
52 if (response.getExceptionPayload() != null)
53 {
54 fail(response.getExceptionPayload().getException().getCause().toString());
55 }
56 }
57
58 public static class TestSplitterComponent implements Callable
59 {
60 public Object onCall(MuleEventContext eventContext) throws Exception
61 {
62 ArrayList<String> elements = new ArrayList<String>();
63 for(int index = 0; index < 5; index++)
64 {
65 elements.add("Element N" + index);
66 }
67 return elements;
68 }
69 }
70
71 }