Search in sources :

Example 36 with Xid

use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.

the class XATester method deleteTestRow.

private void deleteTestRow(CloudSpannerXAConnection xaConnection) throws XAException, SQLException {
    Xid xid = prepareDeleteRow(xaConnection);
    xaConnection.commit(xid, false);
}
Also used : RecoveredXid(nl.topicus.jdbc.xa.RecoveredXid) Xid(javax.transaction.xa.Xid)

Example 37 with Xid

use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.

the class XATester method testXARollback.

private void testXARollback(CloudSpannerXAConnection xaConnection) throws SQLException, XAException {
    log.info("Starting XA rollback transaction test");
    Xid xid = prepareDeleteRow(xaConnection);
    xaConnection.rollback(xid);
    boolean found = false;
    try (ResultSet rs = xaConnection.getConnection().createStatement().executeQuery("select * from test where id=1000000")) {
        if (rs.next())
            found = true;
    }
    Assert.assertTrue(found);
    log.info("Finished XA rollback transaction test");
}
Also used : RecoveredXid(nl.topicus.jdbc.xa.RecoveredXid) Xid(javax.transaction.xa.Xid) ResultSet(java.sql.ResultSet)

Example 38 with Xid

use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.

the class CloudSpannerXAConnectionTest method testPrepareWithOtherXid.

@Test
public void testPrepareWithOtherXid() throws SQLException, XAException {
    thrown.expect(CloudSpannerXAException.class);
    thrown.expectMessage(CloudSpannerXAException.PREPARE_WITH_SAME);
    CloudSpannerXAConnection subject = createSubject();
    Xid xid = getRandomXid();
    subject.start(xid, XAResource.TMNOFLAGS);
    subject.end(xid, XAResource.TMSUCCESS);
    subject.prepare(getRandomXid());
}
Also used : Xid(javax.transaction.xa.Xid) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 39 with Xid

use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.

the class CloudSpannerXAConnectionTest method testEnd.

@Test
public void testEnd() throws SQLException, XAException {
    CloudSpannerXAConnection subject = createSubject();
    Xid xid = createXid();
    subject.start(xid, XAResource.TMNOFLAGS);
    subject.end(xid, XAResource.TMSUCCESS);
}
Also used : Xid(javax.transaction.xa.Xid) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 40 with Xid

use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.

the class CloudSpannerXAConnectionTest method testCommitOnePhase.

@Test
public void testCommitOnePhase() throws SQLException, XAException {
    CloudSpannerXAConnection subject = createSubject();
    Xid xid = createXid();
    subject.start(xid, XAResource.TMNOFLAGS);
    subject.end(xid, XAResource.TMSUCCESS);
    subject.commit(xid, true);
}
Also used : Xid(javax.transaction.xa.Xid) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Aggregations

Xid (javax.transaction.xa.Xid)82 Test (org.junit.Test)35 XAException (javax.transaction.xa.XAException)20 IOException (java.io.IOException)16 XAResource (javax.transaction.xa.XAResource)14 UnitTest (nl.topicus.jdbc.test.category.UnitTest)11 XidImpl (org.neo4j.kernel.impl.transaction.XidImpl)11 LinkedList (java.util.LinkedList)10 InOrder (org.mockito.InOrder)6 HashMap (java.util.HashMap)5 RecoveredXid (nl.topicus.jdbc.xa.RecoveredXid)5 RelationshipType (org.neo4j.graphdb.RelationshipType)5 HazelcastXAResource (com.hazelcast.transaction.HazelcastXAResource)4 ArrayList (java.util.ArrayList)4 RollbackException (javax.transaction.RollbackException)4 SystemException (javax.transaction.SystemException)4 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)4 XaResource (org.neo4j.kernel.impl.transaction.xaframework.XaResource)4 TransactionContext (com.hazelcast.transaction.TransactionContext)3 SerializableXID (com.hazelcast.transaction.impl.xa.SerializableXID)3