View Javadoc

1   /*
2    * $Id: JmsSingleTransactionAlwaysBeginConfigurationTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.jms.integration;
12  
13  import java.util.Properties;
14  
15  import org.junit.Test;
16  
17  public class JmsSingleTransactionAlwaysBeginConfigurationTestCase extends AbstractJmsFunctionalTestCase
18  {
19      public static final String JMS_QUEUE_INPUT_CONF_A = "in1";
20      public static final String JMS_QUEUE_OUTPUT_CONF_A = "out1";
21      public static final String JMS_QUEUE_INPUT_CONF_B = "in2";
22      public static final String JMS_QUEUE_OUTPUT_CONF_B = "out2";
23      public static final String JMS_QUEUE_INPUT_CONF_C = "in3";
24      public static final String JMS_QUEUE_OUTPUT_CONF_C = "out3";
25  
26      @Override
27      protected Properties getStartUpProperties()
28      {
29          Properties props = super.getStartUpProperties();
30          // Inject endpoint names into the config
31          props.put(INBOUND_ENDPOINT_KEY + "1", getJmsConfig().getInboundEndpoint() + "1");
32          props.put(INBOUND_ENDPOINT_KEY + "2", getJmsConfig().getInboundEndpoint() + "2");
33          props.put(INBOUND_ENDPOINT_KEY + "3", getJmsConfig().getInboundEndpoint() + "3");
34          props.put(OUTBOUND_ENDPOINT_KEY + "1", getJmsConfig().getOutboundEndpoint() + "1");
35          props.put(OUTBOUND_ENDPOINT_KEY + "2", getJmsConfig().getOutboundEndpoint() + "2");
36          props.put(OUTBOUND_ENDPOINT_KEY + "3", getJmsConfig().getOutboundEndpoint() + "3");
37          return props;
38      }
39  
40      protected String getConfigResources()
41      {
42          return "integration/jms-single-tx-ALWAYS_BEGIN.xml";
43      }
44  
45      @Test
46      public void testConfigurationA() throws Exception
47      {
48          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
49          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
50          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_A);
51          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
52          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
53          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_A);
54  
55          send(scenarioCommit);
56          receive(scenarioRollback);
57          receive(scenarioCommit);
58          receive(scenarioNotReceive);
59      }
60  
61      @Test
62      public void testConfigurationB() throws Exception
63      {
64          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
65          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
66          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_B);
67          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
68          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
69          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_B);
70  
71          send(scenarioCommit);
72          receive(scenarioRollback);
73          receive(scenarioCommit);
74          receive(scenarioNotReceive);
75      }
76  
77      @Test
78      public void testConfigurationC() throws Exception
79      {
80          scenarioCommit.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
81          scenarioRollback.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
82          scenarioNotReceive.setInputDestinationName(JMS_QUEUE_INPUT_CONF_C);
83          scenarioCommit.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
84          scenarioRollback.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
85          scenarioNotReceive.setOutputDestinationName(JMS_QUEUE_OUTPUT_CONF_C);
86  
87          send(scenarioCommit);
88          receive(scenarioRollback);
89          receive(scenarioCommit);
90          receive(scenarioNotReceive);
91      }
92  }