Search in sources :

Example 6 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class Trace method commit.

public void commit(long id, Serializable o) {
    Context ctx = (Context) o;
    ctx.checkPoint("commit:" + trace);
}
Also used : Context(org.jpos.transaction.Context)

Example 7 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class Trace method prepareForAbort.

public int prepareForAbort(long id, Serializable o) {
    Context ctx = (Context) o;
    ctx.checkPoint("prepareForAbort:" + trace);
    return PREPARED | READONLY;
}
Also used : Context(org.jpos.transaction.Context)

Example 8 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class JESpaceTestCase method testPersistentContext.

public void testPersistentContext() throws Exception {
    Context ctx = new Context();
    ctx.put("P", "ABC", true);
    ISOMsg m = new ISOMsg("0800");
    m.set(11, "000001");
    ctx.put("ISOMSG", m, true);
    sp.out("CTX", ctx);
    assertNotNull("entry should not be null", sp.in("CTX"));
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg)

Example 9 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class CheckFieldsTest method testMidAndTidWithSpaces.

@Test
public void testMidAndTidWithSpaces() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(41, "0001    ");
    m.set(42, "0000000001     ");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "MID, TID");
    int action = cf.prepare(1L, ctx);
    assertEquals(PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasFailures());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 10 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class CheckFieldsTest method testValidTimestamps.

@Test
public void testValidTimestamps() {
    Date now = new Date();
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(7, ISODate.getDateTime(now));
    m.set(12, ISODate.getDateTime(now));
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "7 12");
    int action = cf.prepare(1L, ctx);
    assertEquals(PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertFalse(rc.hasFailures());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Date(java.util.Date) ISODate(org.jpos.iso.ISODate) Result(org.jpos.rc.Result) Test(org.junit.Test)

Aggregations

Context (org.jpos.transaction.Context)45 Test (org.junit.Test)29 Result (org.jpos.rc.Result)26 ISOMsg (org.jpos.iso.ISOMsg)20 Date (java.util.Date)5 ISODate (org.jpos.iso.ISODate)3 SpaceSource (org.jpos.space.SpaceSource)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Element (org.jdom2.Element)1 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 ConfigurationException (org.jpos.core.ConfigurationException)1 ISOAmount (org.jpos.iso.ISOAmount)1 ISOSource (org.jpos.iso.ISOSource)1 LocalSpace (org.jpos.space.LocalSpace)1 Space (org.jpos.space.Space)1 SpaceFactory (org.jpos.space.SpaceFactory)1