Search in sources :

Example 16 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerTopLevelOSIActionUnitTest method testCommitOnePhase.

@Test
public void testCommitOnePhase() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
    act.commit_one_phase();
    assertTrue(act.type() != null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction) Test(org.junit.Test)

Example 17 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerTopLevelOSIActionUnitTest method testRollback.

@Test
public void testRollback() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
    assertEquals(act.prepare(), Vote.VoteReadOnly);
    try {
        act.rollback();
        fail();
    } catch (final INVALID_TRANSACTION ex) {
    }
    act.forget();
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction) Test(org.junit.Test)

Example 18 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method jtsRemoveTest.

/**
 * Similar to aaRemoveTest but uses a JTS transaction instead of an AtomicAction
 * @throws Exception if test fails unexpectedly
 */
@Test
public void jtsRemoveTest() throws Exception {
    ArjunaTransactionImple A = new ArjunaTransactionImple(null);
    ExtendedCrashRecord[] recs = startTest(A);
    int outcome = ActionStatus.COMMITTED;
    try {
        A.commit(true);
    } catch (HeuristicHazard e) {
        outcome = ActionStatus.H_HAZARD;
    }
    assertEquals(ActionStatus.H_HAZARD, outcome);
    finishTest(A, false, recs);
}
Also used : ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) Test(org.junit.Test)

Example 19 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method jtsMBeanTest.

/**
 * Test that MBeans corresponding to JTS record types are created
 * @throws Exception
 */
@Test
public void jtsMBeanTest() throws Exception {
    ArjunaTransactionImple A = new ArjunaTransactionImple(null);
    startTest(A);
    try {
        A.commit(true);
        fail("transaction commit should have produced a heuristic hazzard");
    } catch (HeuristicHazard e) {
    }
    // start an mbean server and object store browser
    createObjStoreBrowser(true);
    // there should now be an MBean entry corresponding to a JTS record, read it via JMX:
    MBeanServer mbs = JMXServer.getAgent().getServer();
    Set<ObjectInstance> transactions = mbs.queryMBeans(new ObjectName("jboss.jta:type=ObjectStore,*"), null);
    boolean foundJTSType = false;
    Pattern pattern = Pattern.compile("itype=(.*?),");
    for (ObjectInstance oi : transactions) {
        String id = oi.getObjectName().getCanonicalName();
        Matcher matcher = pattern.matcher(id);
        while (matcher.find()) // matched type is in matcher.group(1)
        foundJTSType = true;
    }
    assertTrue("MBean for JTS record type not found", foundJTSType);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ObjectInstance(javax.management.ObjectInstance) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 20 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class JTSInterpositionSynchronizationTest method test.

@Test
public void test() throws Exception {
    InterpositionCreator creator = new InterpositionCreator();
    jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
    jtaPropertyManager.getJTAEnvironmentBean().setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
    jtsPropertyManager.getJTSEnvironmentBean().setSupportInterposedSynchronization(true);
    javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
    tm.setTransactionTimeout(1000000);
    tm.begin();
    TransactionImple transaction = (TransactionImple) tm.getTransaction();
    transaction.enlistResource(new XAResource() {

        @Override
        public int prepare(Xid arg0) throws XAException {
            prepareCalled = true;
            beforeCompletionCalledFirst = beforeCompletionCalled;
            return 0;
        }

        @Override
        public void commit(Xid arg0, boolean arg1) throws XAException {
        }

        @Override
        public void end(Xid arg0, int arg1) throws XAException {
        }

        @Override
        public void forget(Xid arg0) throws XAException {
        }

        @Override
        public int getTransactionTimeout() throws XAException {
            return 0;
        }

        @Override
        public boolean isSameRM(XAResource arg0) throws XAException {
            return false;
        }

        @Override
        public Xid[] recover(int arg0) throws XAException {
            return null;
        }

        @Override
        public void rollback(Xid arg0) throws XAException {
        }

        @Override
        public boolean setTransactionTimeout(int arg0) throws XAException {
            return false;
        }

        @Override
        public void start(Xid arg0, int arg1) throws XAException {
        }
    });
    ControlWrapper controlWrapper = transaction.getControlWrapper();
    Uid get_uid = transaction.get_uid();
    ControlImple cont = controlWrapper.getImple();
    ArjunaTransactionImple tx = cont.getImplHandle();
    CurrentImple current = OTSImpleManager.current();
    Control get_control = current.get_control();
    PropagationContext ctx = cont.get_coordinator().get_txcontext();
    ControlImple recreateLocal = creator.recreateLocal(ctx);
    assertTrue(recreateLocal != null);
    Control recreate = creator.recreate(ctx);
    assertTrue(recreate != null);
    Object remove = ControlImple.allControls.remove(get_uid);
    ServerControl sc = new ServerControl(get_uid, get_control, null, cont.get_coordinator(), cont.get_terminator());
    ControlImple.allControls.put(get_uid, remove);
    ServerTopLevelAction serverTopLevelAction = new ServerTopLevelAction(sc);
    sc.getImplHandle().register_synchronization(new ManagedSynchronizationImple(new Synchronization() {

        @Override
        public void beforeCompletion() {
            beforeCompletionCalled = true;
        }

        @Override
        public void afterCompletion(int status) {
            afterCompletionCalled = true;
        }
    }).getSynchronization());
    transaction.commit();
    assertTrue(prepareCalled == true);
    assertTrue(beforeCompletionCalled);
    assertTrue(afterCompletionCalled);
    assertTrue(beforeCompletionCalledFirst == jtsPropertyManager.getJTSEnvironmentBean().isSupportInterposedSynchronization());
}
Also used : InterpositionCreator(com.arjuna.ats.internal.jts.interposition.resources.arjuna.InterpositionCreator) ManagedSynchronizationImple(com.arjuna.ats.internal.jta.resources.jts.orbspecific.ManagedSynchronizationImple) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) PropagationContext(org.omg.CosTransactions.PropagationContext) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) XAException(javax.transaction.xa.XAException) Synchronization(javax.transaction.Synchronization) Uid(com.arjuna.ats.arjuna.common.Uid) XAResource(javax.transaction.xa.XAResource) Xid(javax.transaction.xa.Xid) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) Test(org.junit.Test)

Aggregations

ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)33 Test (org.junit.Test)30 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 Control (org.omg.CosTransactions.Control)20 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)19 Uid (com.arjuna.ats.arjuna.common.Uid)9 ExtendedResourceRecord (com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord)7 DemoArjunaResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource)7 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)4 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)3 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)3 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)2 ServerStrictNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction)2 ExtendedCrashRecord (com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1