Search in sources :

Example 41 with Xid

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

the class CloudSpannerXAConnectionTest method testPrepare.

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

Example 42 with Xid

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

the class CloudSpannerXAConnectionTest method testSuspend.

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

Example 43 with Xid

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

the class CloudSpannerXAConnectionTest method testStart.

@Test
public void testStart() throws SQLException, XAException {
    CloudSpannerXAConnection subject = createSubject();
    ICloudSpannerConnection connection = subject.getConnection();
    assertTrue(connection.getAutoCommit());
    Xid xid = createXid();
    subject.start(xid, XAResource.TMNOFLAGS);
    assertNotNull(connection);
    assertFalse(connection.getAutoCommit());
    thrown.expect(CloudSpannerSQLException.class);
    connection.commit();
}
Also used : Xid(javax.transaction.xa.Xid) ICloudSpannerConnection(nl.topicus.jdbc.ICloudSpannerConnection) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 44 with Xid

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

the class CloudSpannerXAConnectionTest method testJoin.

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

Example 45 with Xid

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

the class RecoveredXidTest method testHashCodeAndEquals.

@Test
public void testHashCodeAndEquals() {
    Xid xid1 = RecoveredXid.stringToXid("9999_Z3RyaWQ=_YnF1YWw=");
    Xid xid2 = RecoveredXid.stringToXid("9999_Z3RyaWQ=_YnF1YWw=");
    Xid xid3 = RecoveredXid.stringToXid("1234_Z3RyaWQ=_YnF1YWw=");
    assertEquals(xid1.hashCode(), xid2.hashCode());
    assertEquals(xid1, xid2);
    assertNotEquals(xid1.hashCode(), xid3.hashCode());
    assertNotEquals(xid1, xid3);
    xid1 = RecoveredXid.stringToXid("9999_AbCdEfG=_YnF1YWw=");
    xid2 = RecoveredXid.stringToXid("9999_AbCdEfG=_YnF1YWw=");
    xid3 = RecoveredXid.stringToXid("1234_abcdefg=_YnF1YWw=");
    assertEquals(xid1.hashCode(), xid2.hashCode());
    assertEquals(xid1, xid2);
    assertNotEquals(xid1.hashCode(), xid3.hashCode());
    assertNotEquals(xid1, xid3);
}
Also used : Xid(javax.transaction.xa.Xid) Test(org.junit.Test)

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