Search in sources :

Example 6 with NotActiveException

use of java.io.NotActiveException in project jPOS by jpos.

the class TransactionManagerTest method testPrepareThrowsNullPointerException5.

@Test
public void testPrepareThrowsNullPointerException5() throws Throwable {
    LogEvent evt = new LogEvent("testTransactionManagerTag");
    List<TransactionParticipant> members = new ArrayList();
    List<TransactionParticipant> arrayList = new ArrayList();
    boolean abort = arrayList.add(new Trace());
    try {
        transactionManager.prepare(1, 100L, new NotActiveException(), members, arrayList.iterator(), abort, evt, null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertEquals("evt.payLoad.size()", 1, evt.getPayLoad().size());
        assertEquals("evt.payLoad.get(0)", "prepareForAbort: org.jpos.transaction.participant.Trace", evt.getPayLoad().get(0));
        assertNull("ex.getMessage()", ex.getMessage());
        assertNull("transactionManager.psp", transactionManager.psp);
        assertNull("transactionManager.groups", transactionManager.groups);
        assertEquals("(ArrayList) members.size()", 0, members.size());
    }
}
Also used : BSHTransactionParticipant(org.jpos.transaction.participant.BSHTransactionParticipant) Trace(org.jpos.transaction.participant.Trace) LogEvent(org.jpos.util.LogEvent) ArrayList(java.util.ArrayList) NotActiveException(java.io.NotActiveException) Test(org.junit.Test)

Example 7 with NotActiveException

use of java.io.NotActiveException in project jPOS by jpos.

the class TransactionManagerTest method testAbortThrowsNullPointerException.

@Test
public void testAbortThrowsNullPointerException() throws Throwable {
    LogEvent evt = new LogEvent("testTransactionManagerTag");
    try {
        transactionManager.abort(1, 100L, new NotActiveException("testTransactionManagerParam1"), members, members.add(null), evt, null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertEquals("(ArrayList) members.size()", 1, members.size());
    }
}
Also used : LogEvent(org.jpos.util.LogEvent) NotActiveException(java.io.NotActiveException) Test(org.junit.Test)

Example 8 with NotActiveException

use of java.io.NotActiveException in project jPOS by jpos.

the class BSHTransactionParticipantTest method testPrepare.

@Test
public void testPrepare() throws Throwable {
    int result = new BSHTransactionParticipant().prepare(100L, new NotActiveException());
    assertEquals("result", 129, result);
}
Also used : NotActiveException(java.io.NotActiveException) Test(org.junit.Test)

Example 9 with NotActiveException

use of java.io.NotActiveException in project j2objc by google.

the class OldObjectOutputStreamTest method test_putFields.

public void test_putFields() throws Exception {
    /*
         * "SerializableTestHelper" is an object created for these tests with
         * two fields (Strings) and simple implementations of readObject and
         * writeObject which simply read and write the first field but not the
         * second one.
         */
    SerializableTestHelper sth;
    try {
        oos.putFields();
        fail("Test 1: NotActiveException expected.");
    } catch (NotActiveException e) {
    // Expected.
    }
    oos.writeObject(new SerializableTestHelper("Gabba", "Jabba"));
    oos.flush();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    sth = (SerializableTestHelper) (ois.readObject());
    assertEquals("Test 2: readFields or writeFields failed; first field not set.", "Gabba", sth.getText1());
    assertNull("Test 3: readFields or writeFields failed; second field should not have been set.", sth.getText2());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NotActiveException(java.io.NotActiveException) ObjectInputStream(java.io.ObjectInputStream)

Example 10 with NotActiveException

use of java.io.NotActiveException in project jPOS by jpos.

the class TransactionManagerTest method testAbort6.

@Test
public void testAbort6() throws Throwable {
    LogEvent evt = new LogEvent();
    transactionManager.abort(1, 100L, new NotActiveException(), members, true, evt, null);
    assertEquals("(ArrayList) members.size()", 0, members.size());
}
Also used : LogEvent(org.jpos.util.LogEvent) NotActiveException(java.io.NotActiveException) Test(org.junit.Test)

Aggregations

NotActiveException (java.io.NotActiveException)10 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ObjectInputStream (java.io.ObjectInputStream)4 LogEvent (org.jpos.util.LogEvent)4 ArrayList (java.util.ArrayList)2 BSHTransactionParticipant (org.jpos.transaction.participant.BSHTransactionParticipant)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 CheckPoint (org.jpos.transaction.participant.CheckPoint)1 Debug (org.jpos.transaction.participant.Debug)1 HasEntry (org.jpos.transaction.participant.HasEntry)1 Trace (org.jpos.transaction.participant.Trace)1