1
2
3
4
5
6
7 package org.mule.transport.http.functional;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12 import org.mule.tck.junit4.rule.DynamicPort;
13
14 import java.util.Collections;
15
16 import org.junit.Rule;
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.fail;
21
22 public class SessionPropertiesTestCase extends FunctionalTestCase
23 {
24
25 @Rule
26 public DynamicPort dynamicPort1 = new DynamicPort("port1");
27
28 @Rule
29 public DynamicPort dynamicPort2 = new DynamicPort("port2");
30
31 @Rule
32 public DynamicPort dynamicPort3 = new DynamicPort("port3");
33
34 @Rule
35 public DynamicPort dynamicPort4 = new DynamicPort("port4");
36
37 @Rule
38 public DynamicPort dynamicPort5 = new DynamicPort("port5");
39
40 @Rule
41 public DynamicPort dynamicPort6 = new DynamicPort("port6");
42
43
44 @Override
45 protected String getConfigResources()
46 {
47 return "session-properties.xml";
48 }
49
50 @Test
51 public void testHttp1ToHttp2ToHttp3SessionPropertiesTestCase() throws Exception
52 {
53 final MuleClient client = new MuleClient(muleContext);
54 MuleMessage response = client.send("http://localhost:" + dynamicPort1.getNumber() + "/Flow1s1", "some message", Collections.emptyMap());
55 assertNotNullAndNotExceptionResponse(response);
56 }
57
58 @Test
59 public void testHttp1ToHttp2ThenHttp1ToHttp3SessionPropertiesTestCase() throws Exception
60 {
61 final MuleClient client = new MuleClient(muleContext);
62 MuleMessage response = client.send("http://localhost:" + dynamicPort4.getNumber() + "/Flow1s2", "some message", Collections.emptyMap());
63 assertNotNullAndNotExceptionResponse(response);
64 }
65
66 private void assertNotNullAndNotExceptionResponse(MuleMessage response)
67 {
68 assertNotNull(response);
69 if (response.getExceptionPayload() != null)
70 {
71 fail(response.getExceptionPayload().getException().getCause().toString());
72 }
73 }
74 }