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