Package javax.transaction.xa

Examples of javax.transaction.xa.Xid


        tm.rollback(tx);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }

    public void testOneResourceOnePhaseCommit() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tx.enlistResource(r1_1);
        tx.delistResource(r1_1, XAResource.TMSUCCESS);
        tm.commit(tx, true);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
View Full Code Here


        tm.commit(tx, true);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }

    public void testOneResourceTwoPhaseCommit() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tx.enlistResource(r1_1);
        tx.delistResource(r1_1, XAResource.TMSUCCESS);
        assertEquals(XAResource.XA_OK, tm.prepare(tx));
        assertTrue(!r1_1.isCommitted());
View Full Code Here

        assertTrue(r1_1.isPrepared());
        assertTrue(!r1_1.isRolledback());
    }

    public void testFourResourceTwoPhaseCommit() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tx.enlistResource(r1_1);
        tx.enlistResource(r1_2);
        tx.enlistResource(r2_1);
        tx.enlistResource(r2_2);
View Full Code Here

    protected void tearDown() throws Exception {
        transactionContextManager = null;
    }

    public void testImportedTxLifecycle() throws Exception {
        Xid xid = xidFactory.createXid();
        transactionContextManager.begin(xid, 1000);
        transactionContextManager.end(xid);
        transactionContextManager.begin(xid, 1000);
        transactionContextManager.end(xid);
        int readOnly = transactionContextManager.prepare(xid);
View Full Code Here

        assertEquals(XAResource.XA_RDONLY, readOnly);
//        transactionContextManager.commit(xid, false);
    }

    public void testNoConcurrentWorkSameXid() throws Exception {
        Xid xid = xidFactory.createXid();
        transactionContextManager.begin(xid, 1000);
        try {
            transactionContextManager.begin(xid, 1000);
            fail("should not be able begin same xid twice");
        } catch (ImportedTransactionActiveException e) {
View Full Code Here

            transactionContextManager.rollback(xid);
        }
    }

    public void testOnlyOneImportedTxAtATime() throws Exception {
        Xid xid1 = xidFactory.createXid();
        Xid xid2 = xidFactory.createXid();
        transactionContextManager.begin(xid1, 1000);
        try {
            transactionContextManager.begin(xid2, 1000);
            fail("should not be able to begin a 2nd tx without ending the first");
        } catch (IllegalStateException e) {
View Full Code Here

    }

    private void addBranch(MockTransactionInfo[] txInfos, MockXAResource xaRes) {
        for (int i = 0; i < txInfos.length; i++) {
            MockTransactionInfo txInfo = txInfos[i];
            Xid globalXid = txInfo.globalXid;
            Xid branchXid = xidFactory.createBranch(globalXid, branchCounter++);
            txInfo.branches.add(new MockTransactionBranchInfo(xaRes.getName(), branchXid));
        }
    }
View Full Code Here

    }

    private MockTransactionInfo[] makeTxInfos(Xid[] xids) {
        MockTransactionInfo[] txInfos = new MockTransactionInfo[xids.length];
        for (int i = 0; i < xids.length; i++) {
            Xid xid = xids[i];
            txInfos[i] = new MockTransactionInfo(xid, new ArrayList());
        }
        return txInfos;
    }
View Full Code Here

    //BE VERY CAREFUL!! the ResourceManager only "recovers" the LAST resource it creates.
    //This test depends on using the resource that will be recovered by the resource manager.
    public void testSimpleRecovery() throws Exception {
        //create a transaction in our own transaction manager
        Xid xid = tm.xidFactory.createXid();
        Transaction tx = tm.importXid(xid, 0);
        tm.resume(tx);
        assertSame(tx, tm.getTransaction());
        tx.enlistResource(r1_2);
        tx.enlistResource(r2_2);
View Full Code Here

    }

    public void testImportedXidRecovery() throws Exception {
        //create a transaction from an external transaction manager.
        XidFactory xidFactory2 = new XidFactoryImpl("tm2".getBytes());
        Xid xid = xidFactory2.createXid();
        Transaction tx = tm.importXid(xid, 0);
        tm.resume(tx);
        assertSame(tx, tm.getTransaction());
        tx.enlistResource(r1_2);
        tx.enlistResource(r2_2);
View Full Code Here

TOP

Related Classes of javax.transaction.xa.Xid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.