1
2
3
4
5
6
7 package org.mule.transport.http.issues;
8
9 import org.mule.api.MuleException;
10 import org.mule.api.MuleMessage;
11 import org.mule.module.client.MuleClient;
12 import org.mule.tck.functional.StringAppendTestTransformer;
13 import org.mule.tck.junit4.FunctionalTestCase;
14 import org.mule.tck.junit4.rule.DynamicPort;
15
16 import org.junit.Rule;
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNotNull;
21
22 public class HttpTransformersMule1815TestCase extends FunctionalTestCase
23 {
24
25 public static final String OUTBOUND_MESSAGE = "Test message";
26
27 @Rule
28 public DynamicPort dynamicPort1 = new DynamicPort("port1");
29
30 @Rule
31 public DynamicPort dynamicPort2 = new DynamicPort("port2");
32
33 @Rule
34 public DynamicPort dynamicPort3 = new DynamicPort("port3");
35
36 @Rule
37 public DynamicPort dynamicPort4 = new DynamicPort("port4");
38
39 @Override
40 protected String getConfigResources()
41 {
42 return "http-transformers-mule-1815-test.xml";
43 }
44
45 private MuleMessage sendTo(String uri) throws MuleException
46 {
47 MuleClient client = new MuleClient(muleContext);
48 MuleMessage message = client.send(uri, OUTBOUND_MESSAGE, null);
49 assertNotNull(message);
50 return message;
51 }
52
53
54
55
56
57
58 @Test
59 public void testBase() throws Exception
60 {
61 assertEquals(OUTBOUND_MESSAGE + " Received", sendTo("base").getPayloadAsString());
62 }
63
64
65
66
67
68
69 @Test
70 public void testAdapted() throws Exception
71 {
72 assertEquals(OUTBOUND_MESSAGE + " Received", sendTo("adapted").getPayloadAsString());
73 }
74
75
76
77
78
79
80
81 @Test
82 public void testIgnored() throws Exception
83 {
84 assertEquals(OUTBOUND_MESSAGE +" transformed" +" transformed 2" + " Received",
85 sendTo("ignored").getPayloadAsString());
86 }
87
88
89
90
91
92
93 @Test
94 public void testInbound() throws Exception
95 {
96 assertEquals(
97
98 StringAppendTestTransformer.append(" transformed 2",
99 StringAppendTestTransformer.appendDefault(OUTBOUND_MESSAGE)) + " Received",
100 sendTo("inbound").getPayloadAsString());
101 }
102
103 }