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.transport.jms.integration;
8   
9   import java.util.Properties;
10  
11  import org.junit.Test;
12  
13  public class JmsSingleTransactionAlwaysBeginConfigurationTestCase extends AbstractJmsFunctionalTestCase
14  {
15      public static final String JMS_QUEUE_INPUT_CONF_A = "in1";
16      public static final String JMS_QUEUE_OUTPUT_CONF_A = "out1";
17      public static final String JMS_QUEUE_INPUT_CONF_B = "in2";
18      public static final String JMS_QUEUE_OUTPUT_CONF_B = "out2";
19      public static final String JMS_QUEUE_INPUT_CONF_C = "in3";
20      public static final String JMS_QUEUE_OUTPUT_CONF_C = "out3";
21  
22      @Override
23      protected Properties getStartUpProperties()
24      {
25          Properties props = super.getStartUpProperties();
26          // Inject endpoint names into the config
27          props.put(INBOUND_ENDPOINT_KEY + "1", getJmsConfig().getInboundEndpoint() + "1");
28          props.put(INBOUND_ENDPOINT_KEY + "2", getJmsConfig().getInboundEndpoint() + "2");
29          props.put(INBOUND_ENDPOINT_KEY + "3", getJmsConfig().getInboundEndpoint() + "3");
30          props.put(OUTBOUND_ENDPOINT_KEY + "1", getJmsConfig().getOutboundEndpoint() + "1");
31          props.put(OUTBOUND_ENDPOINT_KEY + "2", getJmsConfig().getOutboundEndpoint() + "2");
32          props.put(OUTBOUND_ENDPOINT_KEY + "3", getJmsConfig().getOutboundEndpoint() + "3");
33          return props;
34      }
35  
36      protected String getConfigResources()
37      {
38          return "integration/jms-single-tx-ALWAYS_BEGIN.xml";
39      }
40  
41      @Test
42      public void testConfigurationA() throws Exception
43      {
44          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
45          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
46          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
47          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
48          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
49          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
50  
51          send(scenarioCommit);
52          receive(scenarioRollback);
53          receive(scenarioCommit);
54          receive(scenarioNotReceive);
55      }
56  
57      @Test
58      public void testConfigurationB() throws Exception
59      {
60          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
61          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
62          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
63          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
64          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
65          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
66  
67          send(scenarioCommit);
68          receive(scenarioRollback);
69          receive(scenarioCommit);
70          receive(scenarioNotReceive);
71      }
72  
73      @Test
74      public void testConfigurationC() throws Exception
75      {
76          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
77          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
78          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
79          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
80          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
81          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
82  
83          send(scenarioCommit);
84          receive(scenarioRollback);
85          receive(scenarioCommit);
86          receive(scenarioNotReceive);
87      }
88  }