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.transport.jms;
8   
9   import static org.junit.Assert.assertFalse;
10  import static org.junit.Assert.assertNotNull;
11  import static org.junit.Assert.assertNull;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.client.MuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  import org.mule.tck.junit4.rule.DynamicPort;
18  import org.mule.transport.NullPayload;
19  
20  import java.util.Arrays;
21  import java.util.Collection;
22  
23  import org.junit.Rule;
24  import org.junit.Test;
25  import org.junit.runners.Parameterized;
26  
27  /**
28   * Test that static outbound endpoints behave in the same way when
29   * they are preceded by a JMS inbound endpoint.
30   */
31  public class JmsRequestResponseReplyToTestCase extends AbstractServiceAndFlowTestCase
32  {
33  
34      @Rule
35      public DynamicPort dynamicPort = new DynamicPort("port1");
36  
37      public JmsRequestResponseReplyToTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Parameterized.Parameters
43      public static Collection<Object[]> parameters()
44      {
45          return Arrays.asList(new Object[][] {
46                  {ConfigVariant.SERVICE, "org/mule/test/integration/transport/jms/jms-request-response-reply-to-config-service.xml"},
47                  {ConfigVariant.FLOW, "org/mule/test/integration/transport/jms/jms-request-response-reply-to-config-flow.xml"}});
48      }
49  
50      @Test
51      public void testStaticHttpOutboundRepliesToJmsInbound() throws Exception
52      {
53          doTest("jms://jms.static");
54      }
55  
56      @Test
57      public void testDynamicHttpOutboundRepliesToJmsInbound() throws Exception
58      {
59          doTest("jms://jms.dynamic");
60      }
61  
62      private void doTest(String jmsRequestUrl) throws MuleException
63      {
64          MuleClient client = muleContext.getClient();
65  
66          MuleMessage result = client.send(jmsRequestUrl, "localhost:" + dynamicPort.getNumber() + "/test", null);
67  
68          assertNotNull(result);
69          assertNull(result.getExceptionPayload());
70          assertFalse("Response payload shouldn't be null", result.getPayload() instanceof NullPayload);
71      }
72  }