1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.vm.issues;
12
13 import org.mule.tck.FunctionalTestCase;
14 import org.mule.extras.client.MuleClient;
15 import org.mule.umo.UMOException;
16 import org.mule.umo.UMOMessage;
17
18 public class ResponseTransformerMule2165TestCase extends FunctionalTestCase
19 {
20
21 public static final long TIMEOUT = 1000L;
22 public static final String MESSAGE = "a message";
23
24
25 public static final String LOCAL_RESPONSE = MESSAGE + " outbound outbound inbound response";
26
27
28 public static final String GLOBAL_RESPONSE = MESSAGE + " outbound outbound response response";
29
30 protected String getConfigResources()
31 {
32 return "response-transformer-mule-2165-test.xml";
33 }
34
35 protected MuleClient send(String endpoint) throws UMOException
36 {
37 MuleClient client = new MuleClient();
38 client.dispatch(endpoint, MESSAGE, null);
39 return client;
40 }
41
42 protected String receive(MuleClient client, String endpoint) throws Exception
43 {
44 UMOMessage message = client.receive(endpoint, TIMEOUT);
45 assertNotNull("no response from " + endpoint, message);
46 assertNotNull(message.getPayloadAsString());
47 return message.getPayloadAsString();
48 }
49
50 protected void testTransformered(String endpoint, String response) throws Exception
51 {
52 String message = receive(send("in-" + endpoint), "out-" + endpoint);
53 assertEquals("bad response (" + message + ") for " + endpoint, response, message);
54 }
55
56 public void testGlobalNameGlobalTransformer() throws Exception
57 {
58 testTransformered("global-name-global-transformer", GLOBAL_RESPONSE);
59 }
60
61 public void testGlobalNameUrlTransformer() throws Exception
62 {
63 testTransformered("global-name-url-transformer", GLOBAL_RESPONSE);
64 }
65
66 public void testGlobalNameLocalTransformer() throws Exception
67 {
68 testTransformered("global-name-local-transformer", LOCAL_RESPONSE);
69 }
70
71 public void testLocalNameLocalTransformer() throws Exception
72 {
73 testTransformered("local-name-local-transformer", LOCAL_RESPONSE);
74 }
75
76 public void testLocalNameUrlTransformer() throws Exception
77 {
78 testTransformered("local-name-url-transformer", LOCAL_RESPONSE);
79 }
80
81 }