1   /*
2    * $Id: JmsMuleSideDurableTopicXATxTestCase.java 9392 2007-10-26 11:05:57Z akuzmin $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  package org.mule.test.integration.providers.jms.functional;
11  
12  import org.mule.MuleManager;
13  import org.mule.extras.client.MuleClient;
14  import org.mule.umo.UMOMessage;
15  
16  /**
17   * Testing durable topic
18   * with XA transactions
19   */
20  public class JmsMuleSideDurableTopicXATxTestCase extends AbstractJmsFunctionalTestCase
21  {
22  
23      public static final String CONNECTOR1_NAME = "jmsConnectorC1";
24  
25      protected String getConfigResources()
26      {
27          return "providers/activemq/jms-muleside-durable-topic-xa-tx.xml";
28      }
29  
30      public void testMuleXaTopic() throws Exception
31      {
32          UMOMessage result = null;
33          MuleClient client = new MuleClient();
34          client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
35          result = client.receive("vm://out", TIMEOUT);
36          assertNotNull(result);
37          logger.info(result.getPayload());
38          result = client.receive("vm://out", TIMEOUT);
39          assertNotNull(result);
40          logger.info(result.getPayload());
41          result = client.receive("vm://out", SMALL_TIMEOUT);
42          assertNull(result);
43  
44          MuleManager.getInstance().lookupConnector(CONNECTOR1_NAME).stopConnector();
45          assertEquals(MuleManager.getInstance().lookupConnector(CONNECTOR1_NAME).isStarted(), false);
46          logger.info(CONNECTOR1_NAME + " is stopped");
47          client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
48          Thread.sleep(1000);
49          MuleManager.getInstance().lookupConnector(CONNECTOR1_NAME).startConnector();
50          Thread.sleep(1000);
51          logger.info(CONNECTOR1_NAME + " is started");
52          result = client.receive("vm://out", TIMEOUT);
53          assertNotNull(result);
54          logger.info("!!!!! " + result.getPayload());
55          result = client.receive("vm://out", TIMEOUT);
56          assertNotNull(result);
57          logger.info("!!!!! " + result.getPayload());
58          result = client.receive("vm://out", SMALL_TIMEOUT);
59          assertNull(result);
60  
61      }
62  }