Search in sources :

Example 26 with ControlImple

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

the class FactoryListUnitTest method test.

@SuppressWarnings("static-access")
@Test
public void test() throws Exception {
    FactoryList factory = new FactoryList();
    factory.removeDefault();
    try {
        assertNull(factory.recreate(null, FactoryList.DEFAULT_ID));
        fail();
    } catch (final INVALID_TRANSACTION ex) {
    } catch (final Throwable ex) {
        fail();
    }
    FactoryList.remove(Arjuna.restrictedXID());
    TransactionFactoryImple imple = new TransactionFactoryImple("test");
    ControlImple tx = imple.createLocal(1000);
    PropagationContext ctx = tx.get_coordinator().get_txcontext();
    Control cont = FactoryList.recreate(ctx, Arjuna.XID());
    assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
}
Also used : Control(org.omg.CosTransactions.Control) PropagationContext(org.omg.CosTransactions.PropagationContext) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) FactoryList(com.arjuna.ats.internal.jts.interposition.FactoryList) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 27 with ControlImple

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

the class ServerControlWrapperUnitTest method testEquality.

@Test
public void testEquality() throws Exception {
    TransactionFactoryImple imple = new TransactionFactoryImple("test");
    ControlImple tx = imple.createLocal(1000);
    ServerControlWrapper wrap1 = new ServerControlWrapper(tx);
    ServerControlWrapper wrap2 = new ServerControlWrapper(tx.getControl());
    assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
    wrap1 = new ServerControlWrapper(tx.getControl(), tx);
    wrap2 = new ServerControlWrapper(tx.getControl(), tx.get_uid());
    assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
}
Also used : ServerControlWrapper(com.arjuna.ats.internal.jts.interposition.ServerControlWrapper) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 28 with ControlImple

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

the class ServerFactoryUnitTest method test.

@Test
public void test() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    ControlImple tx = factory.createLocal(1000);
    Uid u = new Uid();
    ServerControl server = ServerFactory.create_transaction(u, null, null, tx.get_coordinator(), tx.get_terminator(), 1000);
    try {
        ServerFactory.getCurrentStatus(new Uid("", false));
        Assert.fail();
    } catch (final Throwable ex) {
    }
    Assert.assertEquals(ServerFactory.getStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusActive);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 29 with ControlImple

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

the class TransactionFactoryUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    arjPropertyManager.getCoordinatorEnvironmentBean().setEnableStatistics(true);
    try {
        factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    // fail();
    } catch (final Inactive ex) {
    } catch (final NoTransaction ex) {
    }
    ControlImple tx = factory.createLocal(1000);
    assertTrue(tx != null);
    org.omg.CosTransactions.otid_t[] txId = null;
    try {
        txId = factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    } catch (final Throwable ex) {
        fail();
    }
    try {
        if (factory.getChildTransactions(txId[0]) != null)
            fail();
    } catch (final Throwable ex) {
        fail();
    }
    org.omg.CosTransactions.Status status = factory.getCurrentStatus(txId[0]);
    assertTrue(status == org.omg.CosTransactions.Status.StatusActive);
    assertTrue(factory.getStatus(txId[0]) == org.omg.CosTransactions.Status.StatusActive);
    Control proxy = factory.createProxy(tx.get_coordinator(), tx.get_terminator());
    assertTrue(proxy != null);
    Control propagated = factory.createPropagatedControl(tx.get_coordinator());
    assertTrue(propagated != null);
    assertTrue(Utility.getUid(proxy).equals(Utility.getUid(propagated)));
    GlobalTransactionInfo info = factory.getGlobalInfo();
    assertTrue(info != null);
    assertEquals(info.totalNumberOfTransactions, 1);
    assertEquals(info.numberOfHeuristics, 0);
    factory.numberOfTransactions(TransactionType.TransactionTypeUnresolved);
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) CosTransactions.otid_t(org.omg.CosTransactions.otid_t) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) Control(org.omg.CosTransactions.Control) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) Status(org.omg.CosTransactions.Status) Inactive(org.omg.CosTransactions.Inactive) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 30 with ControlImple

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

the class TransactionFactoryUnitTest method testInfo.

@Test
public void testInfo() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    ControlImple tx = factory.createLocal(1000);
    TransactionInfo info = factory.getTransactionInfo(Utility.uidToOtid(tx.get_uid()));
    assertEquals(info.currentDepth, 1);
    assertEquals(info.timeout, 0);
    assertEquals(info.numberOfThreads, 0);
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) TransactionInfo(com.arjuna.ArjunaOTS.TransactionInfo) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)41 Test (org.junit.Test)30 Control (org.omg.CosTransactions.Control)24 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)21 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)19 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)10 Uid (com.arjuna.ats.arjuna.common.Uid)8 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)7 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)7 PropagationContext (org.omg.CosTransactions.PropagationContext)5 SystemException (org.omg.CORBA.SystemException)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)3 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)3 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 GlobalTransactionInfo (com.arjuna.ArjunaOTS.GlobalTransactionInfo)2 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)2 ServerControlWrapper (com.arjuna.ats.internal.jts.interposition.ServerControlWrapper)2 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)2