View Javadoc

1   /*
2    * $Id: JmsXATransactionComponentTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
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 org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertNull;
21  
22  public class JmsXATransactionComponentTestCase extends AbstractJmsFunctionalTestCase
23  {
24  
25      public static final String CONNECTOR1_NAME = "jmsConnector";
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "integration/jms-xa-tx-component.xml";
31      }
32  
33      @Test
34      public void testOneGlobalTx() throws Exception
35      {
36          MuleMessage result;
37          MuleClient client = new MuleClient(muleContext);
38          client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
39          result = client.request("vm://out", getTimeout());
40          assertNotNull(result);
41          result = client.request("vm://out", getSmallTimeout());
42          assertNull(result);
43          muleContext.getRegistry().lookupConnector(CONNECTOR1_NAME).stop();
44          assertEquals(muleContext.getRegistry().lookupConnector(CONNECTOR1_NAME).isStarted(), false);
45          logger.info(CONNECTOR1_NAME + " is stopped");
46          client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
47          Thread.sleep(1000);
48          muleContext.getRegistry().lookupConnector(CONNECTOR1_NAME).start();
49          Thread.sleep(1000);
50          logger.info(CONNECTOR1_NAME + " is started");
51          result = client.request("vm://out", getTimeout());
52          assertNotNull(result);
53          result = client.request("vm://out", getSmallTimeout());
54          assertNull(result);
55      }
56  }