use of org.firebirdsql.jaybird.xca.TestXABase.XidImpl in project jaybird by FirebirdSQL.
the class TestFBXADataSource method testInDistributed_setAutoCommit_true_inAutoCommit.
/**
* Tests if setting autoCommit(true) when autoCommit is true throws an exception when participating in a distributed transaction (JDBC 4.0 section 12.4).
*/
@Test
public void testInDistributed_setAutoCommit_true_inAutoCommit() throws Exception {
XAConnection pc = getXAConnection();
XAResource xa = pc.getXAResource();
Xid xid = new XidImpl();
try (Connection con = pc.getConnection()) {
con.setAutoCommit(true);
xa.start(xid, XAResource.TMNOFLAGS);
expectedException.expect(SQLException.class);
expectedException.expect(sqlStateEquals(SQLStateConstants.SQL_STATE_INVALID_TX_STATE));
con.setAutoCommit(true);
} finally {
xa.end(xid, XAResource.TMSUCCESS);
xa.rollback(xid);
}
}
use of org.firebirdsql.jaybird.xca.TestXABase.XidImpl in project jaybird by FirebirdSQL.
the class TestFBXADataSource method testInDistributed_commit.
/**
* Test if calling commit throws an exception when participating in a distributed transaction (JDBC 4.0 section 12.4).
*/
@Test
public void testInDistributed_commit() throws Exception {
XAConnection pc = getXAConnection();
XAResource xa = pc.getXAResource();
Xid xid = new XidImpl();
try (Connection con = pc.getConnection()) {
con.setAutoCommit(false);
xa.start(xid, XAResource.TMNOFLAGS);
expectedException.expect(SQLException.class);
expectedException.expect(sqlStateEquals(SQLStateConstants.SQL_STATE_INVALID_TX_STATE));
con.commit();
} finally {
xa.end(xid, XAResource.TMSUCCESS);
xa.rollback(xid);
}
}
Aggregations