View Javadoc

1   /*
2    * $Id$
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.jdbc.functional;
12  
13  import java.sql.Connection;
14  import java.sql.ResultSet;
15  import java.sql.Statement;
16  
17  import javax.sql.DataSource;
18  
19  import org.mule.tck.FunctionalTestCase;
20  
21  /**
22   * Test for MULE-3625, submitted by community member Guy Veraghtert
23   */
24  public class Mule3625FunctionalTest extends FunctionalTestCase
25  {
26  
27      protected String getConfigResources()
28      {
29          return "jdbc-mule-3625.xml";
30      }
31  
32      /**
33       * Test registering transaction manager for non-XA rtansaction
34       * 
35       * @throws Exception
36       */
37      public void testNonXaTx() throws Exception
38      {
39          DataSource dataSource = (DataSource) muleContext.getRegistry().lookupObject("hsqldbDataSource");
40          Connection connection = dataSource.getConnection();
41          Statement statement = connection.createStatement();
42          statement.executeUpdate("create table TABLE_A (value varchar(1))");
43          statement.executeUpdate("create table TABLE_B (value varchar(1))");
44          statement.executeUpdate("insert into TABLE_A(value) values('n')");
45          Thread.sleep(10000); //TODO DZ: sleeps in tests are not ideal
46          ResultSet resultSet = statement.executeQuery("select count(*) from TABLE_B where value='y'");
47          assertTrue(resultSet.next());
48          assertEquals(1, resultSet.getLong(1));
49      }
50  
51  }