View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.messaging.meps;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.transport.NullPayload;
13  
14  import java.util.HashMap;
15  import java.util.Map;
16  
17  import org.apache.activemq.broker.BrokerService;
18  import org.junit.AfterClass;
19  import org.junit.BeforeClass;
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  import static org.junit.Assert.assertNotNull;
24  
25  public class InOptionalOutOutOnlyJMSTestCase extends FunctionalTestCase
26  {
27  
28      public static final long TIMEOUT = 3000;
29  
30      private static BrokerService broker;
31  
32      @Override
33      protected String getConfigResources()
34      {
35          return "org/mule/test/integration/messaging/meps/pattern_In-Optional-Out_Out-Only_JMS.xml";
36      }
37  
38      @BeforeClass
39      public static void startBroker() throws Exception
40      {
41          broker = new BrokerService();
42          broker.addConnector("tcp://localhost:61616");
43          broker.start();
44      }
45  
46      @AfterClass
47      public static void stopBroker() throws Exception
48      {
49          broker.stop();
50      }
51  
52      @Test
53      public void testExchange() throws Exception
54      {
55          MuleClient client = new MuleClient(muleContext);
56  
57          MuleMessage result = client.send("inboundEndpoint", "some data", null);
58          assertNotNull(result);
59          assertEquals(NullPayload.getInstance(), result.getPayload());
60  
61          Map<String, String> props = new HashMap<String, String>();
62          props.put("foo", "bar");
63          result = client.send("inboundEndpoint", "some data", props, 20000);
64          
65          // Give JMS some time to dispatch
66          Thread.sleep(200);
67  
68          // No temporary queues should have been created, used, or be being waited on for a result 
69          // See MULE-4617
70          assertEquals(0, broker.getAdminView().getTemporaryQueues().length);
71  
72          assertNotNull(result);
73  
74          assertEquals("foo header received", result.getPayload());
75      }
76  }