1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.messaging.meps;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.client.MuleClient;
15 import org.mule.tck.AbstractServiceAndFlowTestCase;
16
17 import java.util.Arrays;
18 import java.util.Collection;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.junit.Test;
23 import org.junit.runners.Parameterized.Parameters;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27
28
29 public class InOutOutOnlyTestCase extends AbstractServiceAndFlowTestCase
30 {
31 public static final long TIMEOUT = 3000;
32
33 @Parameters
34 public static Collection<Object[]> parameters()
35 {
36 return Arrays.asList(new Object[][]{
37 {ConfigVariant.SERVICE,
38 "org/mule/test/integration/messaging/meps/pattern_In-Out_Out-Only-service.xml"},
39 {ConfigVariant.FLOW, "org/mule/test/integration/messaging/meps/pattern_In-Out_Out-Only-flow.xml"}});
40 }
41
42 public InOutOutOnlyTestCase(ConfigVariant variant, String configResources)
43 {
44 super(variant, configResources);
45 }
46
47 @Test
48 public void testExchange() throws Exception
49 {
50 MuleClient client = muleContext.getClient();
51
52 MuleMessage result = client.send("inboundEndpoint", "some data", null);
53 assertNotNull(result);
54 assertEquals("foo header not received", result.getPayloadAsString());
55
56 Map<String, Object> props = new HashMap<String, Object>();
57 props.put("foo", "bar");
58 result = client.send("inboundEndpoint", "some data", props);
59 assertNotNull(result);
60 assertEquals("foo header received", result.getPayloadAsString());
61
62 result = client.request("receivedEndpoint", TIMEOUT);
63 assertNotNull(result);
64 assertEquals("foo header received", result.getPayloadAsString());
65
66 result = client.request("notReceivedEndpoint", TIMEOUT);
67 assertNotNull(result);
68 assertEquals("foo header not received", result.getPayloadAsString());
69 }
70 }