1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.issues;
12
13 import org.mule.api.MuleException;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.DynamicPortTestCase;
17 import org.mule.tck.FunctionalTestCase;
18 import org.mule.tck.functional.StringAppendTestTransformer;
19
20 public class HttpTransformersMule1822TestCase extends DynamicPortTestCase
21 {
22 public static final String OUTBOUND_MESSAGE = "Test message";
23
24 @Override
25 protected String getConfigResources()
26 {
27 return "http-transformers-mule-1822-test.xml";
28 }
29
30 private MuleMessage sendTo(String uri) throws MuleException
31 {
32 MuleClient client = new MuleClient(muleContext);
33 MuleMessage message = client.send(uri, OUTBOUND_MESSAGE, null);
34 assertNotNull(message);
35 return message;
36 }
37
38
39
40
41 public void testBase() throws Exception
42 {
43 assertEquals(OUTBOUND_MESSAGE + " Received",
44 sendTo("base").getPayloadAsString());
45 }
46
47
48
49
50 public void testResponse() throws Exception
51 {
52 assertEquals(
53 StringAppendTestTransformer.append(" response",
54 StringAppendTestTransformer.append(" response 2",
55 OUTBOUND_MESSAGE + " Received")),
56 sendTo("response").getPayloadAsString());
57 }
58
59
60
61
62 public void testBoth() throws Exception
63 {
64 assertEquals(
65 StringAppendTestTransformer.append(" response",
66 StringAppendTestTransformer.append(" response 2",
67 StringAppendTestTransformer.append(" transformed 2",
68 StringAppendTestTransformer.appendDefault(OUTBOUND_MESSAGE)) + " Received")),
69 sendTo("both").getPayloadAsString());
70 }
71
72 @Override
73 protected int getNumPortsToFind()
74 {
75 return 3;
76 }
77 }