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