Java Code Examples for com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

The following are top voted examples for showing how to use com.mysql.jdbc.jdbc2.optional.MysqlXADataSource. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: the-vigilantes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 2
Project: the-vigilantes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 3
Project: the-vigilantes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 4
Project: the-vigilantes   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            System.out.println("The testBug20242() is ignored because required class isn't available:");
            ex.printStackTrace();
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 5
Project: OpenVertretung   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 6
Project: OpenVertretung   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 7
Project: OpenVertretung   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 8
Project: OpenVertretung   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            System.out.println("The testBug20242() is ignored because required class isn't available:");
            ex.printStackTrace();
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 9
Project: ProyectoPacientes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 10
Project: ProyectoPacientes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 11
Project: ProyectoPacientes   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 12
Project: ProyectoPacientes   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            System.out.println("The testBug20242() is ignored because required class isn't available:");
            ex.printStackTrace();
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 13
Project: BibliotecaPS   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 14
Project: BibliotecaPS   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 15
Project: BibliotecaPS   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 16
Project: BibliotecaPS   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            System.out.println("The testBug20242() is ignored because required class isn't available:");
            ex.printStackTrace();
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 17
Project: flowable-examples   File: Configuration.java   Source Code and License 6 votes vote down vote up
@Bean(initMethod = "init", destroyMethod = "close")
public DataSource dataSource() {
    MysqlXADataSource mysqlXaDataSource = new MysqlXADataSource();
    mysqlXaDataSource
            .setUrl("jdbc:mysql://localhost:3306/flowable?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC");
    mysqlXaDataSource.setPinGlobalTxToPhysicalConnection(true);
    mysqlXaDataSource.setPassword("flowable");
    mysqlXaDataSource.setUser("flowable");

    AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
    xaDataSource.setXaDataSource(mysqlXaDataSource);
    xaDataSource.setUniqueResourceName("xads");
    xaDataSource.setBorrowConnectionTimeout(30000);
    xaDataSource.setMinPoolSize(10);
    xaDataSource.setPoolSize(20);
    xaDataSource.setMaxPoolSize(50);
    return xaDataSource;
}
 
Example 18
Project: Geometry-wars   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 19
Project: Geometry-wars   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 20
Project: Geometry-wars   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 21
Project: Geometry-wars   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            System.out.println("The testBug20242() is ignored because required class isn't available:");
            ex.printStackTrace();
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 22
Project: TPKB   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 23
Project: TPKB   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 24
Project: TPKB   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 25
Project: spring-boot-jta-atomikos-sample   File: CustomerConfig.java   Source Code and License 6 votes vote down vote up
@Primary
	@Bean(name = "customerDataSource", initMethod = "init", destroyMethod = "close")
//	@Qualifier("customerDataSource")
	public DataSource customerDataSource() {
		MysqlXADataSource mysqlXaDataSource = new MysqlXADataSource();
		mysqlXaDataSource.setUrl(customerDatasourceProperties.getUrl());
		mysqlXaDataSource.setPinGlobalTxToPhysicalConnection(true);
		mysqlXaDataSource.setPassword(customerDatasourceProperties.getPassword());
		mysqlXaDataSource.setUser(customerDatasourceProperties.getUsername());
		mysqlXaDataSource.setPinGlobalTxToPhysicalConnection(true);

		AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
		xaDataSource.setXaDataSource(mysqlXaDataSource);
		xaDataSource.setUniqueResourceName("xads1");
		return xaDataSource;

	}
 
Example 26
Project: cloudera-cli-scripts   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 27
Project: cloudera-cli-scripts   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 28
Project: cloudera-cli-scripts   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);
    
    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example 29
Project: cloudera-cli-scripts   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 30
Project: fil_project_mgmt_app_v2   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
	MysqlXADataSource xads1 = new MysqlXADataSource();
	MysqlXADataSource xads2 = new MysqlXADataSource();

	Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

	xads1.setPinGlobalTxToPhysicalConnection(true);
	xads1.setUrl(dbUrl);

	xads2.setPinGlobalTxToPhysicalConnection(true);
	xads2.setUrl(dbUrl);

	XAConnection c1 = xads1.getXAConnection();
	assertTrue(c1 instanceof SuspendableXAConnection);
	// start a transaction on one connection
	c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
	c1.getXAResource().end(txid, XAResource.TMSUCCESS);

	XAConnection c2 = xads2.getXAConnection();
	assertTrue(c2 instanceof SuspendableXAConnection);
	// prepare on another one. Since we are using a "pinned" connection
	// we should have the same "currentXAConnection" for both
	// SuspendableXAConnection
	c2.getXAResource().prepare(txid); // this will fail without the fix.
	c2.getXAResource().commit(txid, false);
}
 
Example 31
Project: fil_project_mgmt_app_v2   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 *
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
	MysqlXADataSource dataSource = new MysqlXADataSource();

	dataSource.setUrl(dbUrl);

	XAConnection testXAConn1 = dataSource.getXAConnection();
	XAConnection testXAConn2 = dataSource.getXAConnection();

	Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

	testXAConn1.getXAResource().start(duplicateXID, 0);

	try {
		testXAConn2.getXAResource().start(duplicateXID, 0);
		fail("XAException was expected.");
	} catch (XAException e) {
		assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
	}
}
 
Example 32
Project: fil_project_mgmt_app_v2   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception if the test fails.
 */
public void testBug20242() throws Exception {
	if (versionMeetsMinimum(5, 0)) {
		try {
			Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
		} catch (Exception ex) {
			return; // class not available for testing
		}
		
		MysqlXADataSource xaDs = new MysqlXADataSource();
		xaDs.setUrl(dbUrl);
		
		MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
		assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
	}	
}
 
Example 33
Project: SMPT42   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 34
Project: SMPT42   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 35
Project: SMPT42   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 36
Project: ForYou   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
	MysqlXADataSource xads1 = new MysqlXADataSource();
	MysqlXADataSource xads2 = new MysqlXADataSource();

	Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

	xads1.setPinGlobalTxToPhysicalConnection(true);
	xads1.setUrl(dbUrl);

	xads2.setPinGlobalTxToPhysicalConnection(true);
	xads2.setUrl(dbUrl);

	XAConnection c1 = xads1.getXAConnection();
	assertTrue(c1 instanceof SuspendableXAConnection);
	// start a transaction on one connection
	c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
	c1.getXAResource().end(txid, XAResource.TMSUCCESS);

	XAConnection c2 = xads2.getXAConnection();
	assertTrue(c2 instanceof SuspendableXAConnection);
	// prepare on another one. Since we are using a "pinned" connection
	// we should have the same "currentXAConnection" for both
	// SuspendableXAConnection
	c2.getXAResource().prepare(txid); // this will fail without the fix.
	c2.getXAResource().commit(txid, false);
}
 
Example 37
Project: ForYou   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 *
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
	MysqlXADataSource dataSource = new MysqlXADataSource();

	dataSource.setUrl(dbUrl);

	XAConnection testXAConn1 = dataSource.getXAConnection();
	XAConnection testXAConn2 = dataSource.getXAConnection();

	Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

	testXAConn1.getXAResource().start(duplicateXID, 0);

	try {
		testXAConn2.getXAResource().start(duplicateXID, 0);
		fail("XAException was expected.");
	} catch (XAException e) {
		assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
	}
}
 
Example 38
Project: ForYou   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception if the test fails.
 */
public void testBug20242() throws Exception {
	if (versionMeetsMinimum(5, 0)) {
		try {
			Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
		} catch (Exception ex) {
			return; // class not available for testing
		}
		
		MysqlXADataSource xaDs = new MysqlXADataSource();
		xaDs.setUrl(dbUrl);
		
		MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
		assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
	}	
}
 
Example 39
Project: group-five   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 40
Project: group-five   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 41
Project: group-five   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 42
Project: locaviewer   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 43
Project: locaviewer   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 44
Project: locaviewer   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 45
Project: locaviewer   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();

    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

    xads1.setPinGlobalTxToPhysicalConnection(true);
    xads1.setUrl(dbUrl);

    xads2.setPinGlobalTxToPhysicalConnection(true);
    xads2.setUrl(dbUrl);

    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);

    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    c2.getXAResource().prepare(txid); // this will fail without the fix.
    c2.getXAResource().commit(txid, false);
}
 
Example 46
Project: locaviewer   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();

    dataSource.setUrl(dbUrl);

    XAConnection testXAConn1 = dataSource.getXAConnection();
    XAConnection testXAConn2 = dataSource.getXAConnection();

    Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

    testXAConn1.getXAResource().start(duplicateXID, 0);

    try {
        testXAConn2.getXAResource().start(duplicateXID, 0);
        fail("XAException was expected.");
    } catch (XAException e) {
        assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
    }
}
 
Example 47
Project: locaviewer   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20242() throws Exception {
    if (versionMeetsMinimum(5, 0)) {
        try {
            Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
        } catch (Exception ex) {
            return; // class not available for testing
        }

        MysqlXADataSource xaDs = new MysqlXADataSource();
        xaDs.setUrl(dbUrl);

        MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
        assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
    }
}
 
Example 48
Project: Gladiatus   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
	MysqlXADataSource xads1 = new MysqlXADataSource();
	MysqlXADataSource xads2 = new MysqlXADataSource();

	Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

	xads1.setPinGlobalTxToPhysicalConnection(true);
	xads1.setUrl(dbUrl);

	xads2.setPinGlobalTxToPhysicalConnection(true);
	xads2.setUrl(dbUrl);

	XAConnection c1 = xads1.getXAConnection();
	assertTrue(c1 instanceof SuspendableXAConnection);
	// start a transaction on one connection
	c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
	c1.getXAResource().end(txid, XAResource.TMSUCCESS);

	XAConnection c2 = xads2.getXAConnection();
	assertTrue(c2 instanceof SuspendableXAConnection);
	// prepare on another one. Since we are using a "pinned" connection
	// we should have the same "currentXAConnection" for both
	// SuspendableXAConnection
	c2.getXAResource().prepare(txid); // this will fail without the fix.
	c2.getXAResource().commit(txid, false);
}
 
Example 49
Project: Gladiatus   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 *
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
	MysqlXADataSource dataSource = new MysqlXADataSource();

	dataSource.setUrl(dbUrl);

	XAConnection testXAConn1 = dataSource.getXAConnection();
	XAConnection testXAConn2 = dataSource.getXAConnection();

	Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

	testXAConn1.getXAResource().start(duplicateXID, 0);

	try {
		testXAConn2.getXAResource().start(duplicateXID, 0);
		fail("XAException was expected.");
	} catch (XAException e) {
		assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
	}
}
 
Example 50
Project: Gladiatus   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception if the test fails.
 */
public void testBug20242() throws Exception {
	if (versionMeetsMinimum(5, 0)) {
		try {
			Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
		} catch (Exception ex) {
			return; // class not available for testing
		}
		
		MysqlXADataSource xaDs = new MysqlXADataSource();
		xaDs.setUrl(dbUrl);
		
		MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
		assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
	}	
}
 
Example 51
Project: Jspad   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
	MysqlXADataSource xads1 = new MysqlXADataSource();
	MysqlXADataSource xads2 = new MysqlXADataSource();

	Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

	xads1.setPinGlobalTxToPhysicalConnection(true);
	xads1.setUrl(dbUrl);

	xads2.setPinGlobalTxToPhysicalConnection(true);
	xads2.setUrl(dbUrl);

	XAConnection c1 = xads1.getXAConnection();
	assertTrue(c1 instanceof SuspendableXAConnection);
	// start a transaction on one connection
	c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
	c1.getXAResource().end(txid, XAResource.TMSUCCESS);

	XAConnection c2 = xads2.getXAConnection();
	assertTrue(c2 instanceof SuspendableXAConnection);
	// prepare on another one. Since we are using a "pinned" connection
	// we should have the same "currentXAConnection" for both
	// SuspendableXAConnection
	c2.getXAResource().prepare(txid); // this will fail without the fix.
	c2.getXAResource().commit(txid, false);
}
 
Example 52
Project: Jspad   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 *
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
	MysqlXADataSource dataSource = new MysqlXADataSource();

	dataSource.setUrl(dbUrl);

	XAConnection testXAConn1 = dataSource.getXAConnection();
	XAConnection testXAConn2 = dataSource.getXAConnection();

	Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

	testXAConn1.getXAResource().start(duplicateXID, 0);

	try {
		testXAConn2.getXAResource().start(duplicateXID, 0);
		fail("XAException was expected.");
	} catch (XAException e) {
		assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
	}
}
 
Example 53
Project: Jspad   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception if the test fails.
 */
public void testBug20242() throws Exception {
	if (versionMeetsMinimum(5, 0)) {
		try {
			Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
		} catch (Exception ex) {
			return; // class not available for testing
		}
		
		MysqlXADataSource xaDs = new MysqlXADataSource();
		xaDs.setUrl(dbUrl);
		
		MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
		assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
	}	
}
 
Example 54
Project: Trails   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
public void testBug46925() throws Exception {
	MysqlXADataSource xads1 = new MysqlXADataSource();
	MysqlXADataSource xads2 = new MysqlXADataSource();

	Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);

	xads1.setPinGlobalTxToPhysicalConnection(true);
	xads1.setUrl(dbUrl);

	xads2.setPinGlobalTxToPhysicalConnection(true);
	xads2.setUrl(dbUrl);

	XAConnection c1 = xads1.getXAConnection();
	assertTrue(c1 instanceof SuspendableXAConnection);
	// start a transaction on one connection
	c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
	c1.getXAResource().end(txid, XAResource.TMSUCCESS);

	XAConnection c2 = xads2.getXAConnection();
	assertTrue(c2 instanceof SuspendableXAConnection);
	// prepare on another one. Since we are using a "pinned" connection
	// we should have the same "currentXAConnection" for both
	// SuspendableXAConnection
	c2.getXAResource().prepare(txid); // this will fail without the fix.
	c2.getXAResource().commit(txid, false);
}
 
Example 55
Project: Trails   File: ConnectionRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#69506 - XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug69506() throws Exception {
	MysqlXADataSource dataSource = new MysqlXADataSource();

	dataSource.setUrl(dbUrl);
	
	XAConnection testXAConn1 = dataSource.getXAConnection();
	XAConnection testXAConn2 = dataSource.getXAConnection();

	Xid duplicateXID = new MysqlXid("1".getBytes(), "1".getBytes(), 1);

	testXAConn1.getXAResource().start(duplicateXID, 0);

	try {
		testXAConn2.getXAResource().start(duplicateXID, 0);
		fail("XAException was expected.");
	} catch (XAException e) {
		assertEquals("Wrong error code retured for duplicated XID.", XAException.XAER_DUPID, e.errorCode);
	}
}
 
Example 56
Project: Trails   File: DataSourceRegressionTest.java   Source Code and License 6 votes vote down vote up
/**
 * Tests fix for BUG#20242 - MysqlValidConnectionChecker for JBoss doesn't
 * work with MySQLXADataSources.
 * 
 * @throws Exception if the test fails.
 */
public void testBug20242() throws Exception {
	if (versionMeetsMinimum(5, 0)) {
		try {
			Class.forName("org.jboss.resource.adapter.jdbc.ValidConnectionChecker");
		} catch (Exception ex) {
			return; // class not available for testing
		}
		
		MysqlXADataSource xaDs = new MysqlXADataSource();
		xaDs.setUrl(dbUrl);
		
		MysqlValidConnectionChecker checker = new MysqlValidConnectionChecker();
		assertNull(checker.isValidConnection(xaDs.getXAConnection().getConnection()));
	}	
}
 
Example 57
Project: the-vigilantes   File: XATest.java   Source Code and License 5 votes vote down vote up
public XATest(String name) {
    super(name);

    this.xaDs = new MysqlXADataSource();
    this.xaDs.setUrl(BaseTestCase.dbUrl);
    this.xaDs.setRollbackOnPooledClose(true);
}
 
Example 58
Project: the-vigilantes   File: ConnectionRegressionTest.java   Source Code and License 5 votes vote down vote up
/**
 * Tests fix for BUG#67803 - XA commands sent twice to MySQL server
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug67803() throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();
    dataSource.setUrl(dbUrl);
    dataSource.setUseCursorFetch(true);
    dataSource.setDefaultFetchSize(50);
    dataSource.setUseServerPrepStmts(true);
    dataSource.setExceptionInterceptors("testsuite.regression.ConnectionRegressionTest$TestBug67803ExceptionInterceptor");

    XAConnection testXAConn1 = dataSource.getXAConnection();
    testXAConn1.getXAResource().start(new MysqlXid("2".getBytes(), "2".getBytes(), 1), 0);
}
 
Example 59
Project: the-vigilantes   File: ConnectionRegressionTest.java   Source Code and License 5 votes vote down vote up
private void testBug62577TestUrl(String url) throws Exception {
    MysqlXADataSource dataSource = new MysqlXADataSource();
    dataSource.setUrl(url);
    XAConnection xaConn = dataSource.getXAConnection();
    Statement st = xaConn.getConnection().createStatement();
    this.rs = st.executeQuery("SELECT 1;");
    xaConn.close();
}
 
Example 60
Project: OpenVertretung   File: XATest.java   Source Code and License 5 votes vote down vote up
public XATest(String name) {
    super(name);

    this.xaDs = new MysqlXADataSource();
    this.xaDs.setUrl(BaseTestCase.dbUrl);
    this.xaDs.setRollbackOnPooledClose(true);
}