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 import static org.junit.Assert.assertNull;
28
29 public class InOnlyOptionalOutTestCase 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-Only_Optional-Out-service.xml"},
39 {ConfigVariant.FLOW,
40 "org/mule/test/integration/messaging/meps/pattern_In-Only_Optional-Out-flow.xml"}});
41 }
42
43 public InOnlyOptionalOutTestCase(ConfigVariant variant, String configResources)
44 {
45 super(variant, configResources);
46 }
47
48 @Test
49 public void testExchange() throws Exception
50 {
51 MuleClient client = muleContext.getClient();
52
53 client.dispatch("inboundEndpoint", "some data", null);
54 Map<String, Object> props = new HashMap<String, Object>();
55 props.put("foo", "bar");
56 client.dispatch("inboundEndpoint", "some data", props);
57
58 MuleMessage result = client.request("receivedEndpoint", TIMEOUT);
59 assertNotNull(result);
60 assertEquals("foo header received", result.getPayloadAsString());
61
62 result = client.request("notReceivedEndpoint", TIMEOUT);
63 assertNull(result);
64 }
65 }