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.module.client.MuleClient;
15 import org.mule.tck.AbstractServiceAndFlowTestCase;
16 import org.mule.transport.NullPayload;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.apache.activemq.broker.BrokerService;
24 import org.junit.AfterClass;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.junit.runners.Parameterized.Parameters;
28
29 import static org.junit.Assert.assertEquals;
30 import static org.junit.Assert.assertNotNull;
31
32
33 public class InOptionalOutOutOnlyJMSTestCase extends AbstractServiceAndFlowTestCase
34 {
35 public static final long TIMEOUT = 3000;
36
37 private static BrokerService broker;
38
39 @BeforeClass
40 public static void startBroker() throws Exception
41 {
42 broker = new BrokerService();
43 broker.addConnector("tcp://localhost:61616");
44 broker.start();
45 }
46
47 @AfterClass
48 public static void stopBroker() throws Exception
49 {
50 broker.stop();
51 }
52
53 @Parameters
54 public static Collection<Object[]> parameters()
55 {
56 return Arrays.asList(new Object[][]{
57 {ConfigVariant.SERVICE,
58 "org/mule/test/integration/messaging/meps/pattern_In-Optional-Out_Out-Only_JMS-service.xml"},
59 {ConfigVariant.FLOW,
60 "org/mule/test/integration/messaging/meps/pattern_In-Optional-Out_Out-Only_JMS-flow.xml"}});
61 }
62
63 public InOptionalOutOutOnlyJMSTestCase(ConfigVariant variant, String configResources)
64 {
65 super(variant, configResources);
66 }
67
68 @Test
69 public void testExchange() throws Exception
70 {
71 MuleClient client = new MuleClient(muleContext);
72
73 MuleMessage result = client.send("inboundEndpoint", "some data", null);
74 assertNotNull(result);
75 assertEquals(NullPayload.getInstance(), result.getPayload());
76
77 Map<String, String> props = new HashMap<String, String>();
78 props.put("foo", "bar");
79 result = client.send("inboundEndpoint", "some data", props, 20000);
80
81
82 Thread.sleep(200);
83
84
85
86
87 assertEquals(0, broker.getAdminView().getTemporaryQueues().length);
88
89 assertNotNull(result);
90
91 assertEquals("foo header received", result.getPayload());
92 }
93 }