1
2
3
4
5
6
7 package org.mule.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
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19
20 public class EndpointTransformerMule2131TestCase extends FunctionalTestCase
21 {
22
23 public static final String MESSAGE = "a message";
24
25 public EndpointTransformerMule2131TestCase()
26 {
27 setDisposeContextPerClass(true);
28 }
29
30 @Override
31 protected String getConfigResources()
32 {
33 return "issues/endpoint-transformer-mule-2131-test.xml";
34 }
35
36 protected MuleClient send() throws MuleException
37 {
38 MuleClient client = new MuleClient(muleContext);
39 client.dispatch("in", MESSAGE, null);
40 return client;
41 }
42
43 @Test
44 public void testDirect() throws Exception
45 {
46 String response = request(send(), "direct");
47 assertEquals(MESSAGE, response);
48 }
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 @Test
65 public void testGlobalNameLocalTransformer() throws Exception
66 {
67 doTestTransformed("global-name-local-transformer");
68 }
69
70 @Test
71 public void testNoNameLocalTransformer() throws Exception
72 {
73 doTestTransformed("vm://no-name-local-transformer");
74 }
75
76 @Test
77 public void testLocalNameLocalTransformer() throws Exception
78 {
79 doTestTransformed("vm://local-name-local-transformer");
80 }
81
82 protected void doTestTransformed(String endpoint) throws Exception
83 {
84 String response = request(send(), endpoint);
85 assertEquals(MESSAGE + StringAppendTestTransformer.DEFAULT_TEXT, response);
86 }
87
88 protected String request(MuleClient client, String endpoint) throws Exception
89 {
90 MuleMessage message = client.request(endpoint, RECEIVE_TIMEOUT);
91 assertNotNull(message);
92 assertNotNull(message.getPayloadAsString());
93 return message.getPayloadAsString();
94 }
95
96 }