View Javadoc

1   /*
2    * $Id: XAJdbcMule1479TestCase.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  package org.mule.test.integration.transaction;
11  
12  import org.mule.module.client.MuleClient;
13  
14  import java.util.List;
15  
16  public class XAJdbcMule1479TestCase extends AbstractDerbyTestCase
17  {
18      
19      protected String getConfigResources()
20      {
21          return "org/mule/test/integration/transaction/jdbc-xatransaction-1479.xml";
22      }
23  
24      @Override
25      protected void emptyTable() throws Exception
26      {
27          try
28          {
29              execSqlUpdate("DELETE FROM TEST");
30          }
31          catch (Exception e)
32          {
33              execSqlUpdate("CREATE TABLE TEST(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,DATA VARCHAR(255))");
34          }
35      }
36  
37      public void testJdbcXa() throws Exception
38      {
39          MuleClient client = new MuleClient(muleContext);
40          client.dispatch("vm://in","test",null);
41          
42          for (int i = 0; i < 10; i++)
43          {
44              List results = execSqlQuery("SELECT * FROM TEST");
45              assertEquals(0, results.size());
46              
47              Thread.sleep(1000);
48          }
49      }    
50  
51      public void testJmsXa() throws Exception
52      {
53          MuleClient client = new MuleClient(muleContext);
54          client.dispatch("vm://in1", "test", null);
55          
56          List results = null;
57          for (int i = 0; i < 10; i++)
58          {
59              results = execSqlQuery("SELECT * FROM TEST");
60              if (results.size() > 0)
61              {
62                  break;
63              }
64              
65              Thread.sleep(1000);
66          }
67  
68          assertEquals(1, results.size());
69      }
70  
71  }