View Javadoc

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