Search in sources :

Example 31 with Context

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

the class CheckFieldsTest method testGenericFieldsExtraPresent.

@Test
public void testGenericFieldsExtraPresent() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(48, "Mandatory field 48");
    m.set(60, "Extra field 60");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "48");
    int action = cf.prepare(1L, ctx);
    // ctx.dump (System.out, "");
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals(CMF.EXTRA_FIELD, rc.failure().getIrc());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 32 with Context

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

the class CheckFieldsTest method testInvalidCard.

@Test
public void testInvalidCard() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(2, "4111111111111111");
    m.set(14, "2912");
    m.set(35, "4111111111111112=2912");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "CARD");
    int action = cf.prepare(1L, ctx);
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertEquals(CMF.INVALID_CARD_NUMBER, rc.failure().getIrc());
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals("track2 PAN mismatch", rc.failure().getMessage());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 33 with Context

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

the class CheckFieldsTest method testPDC.

@Test
public void testPDC() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(22, new byte[16]);
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "POS_DATA_CODE");
    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) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 34 with Context

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

the class QueryHostTest method testSimpleQuerySync.

@Test
public void testSimpleQuerySync() throws Exception {
    Context ctx = new Context();
    cfg.put("continuations", "no");
    queryHost.setConfiguration(cfg);
    ctx.put(ContextConstants.REQUEST.toString(), createDummyRequest());
    ctx.put(ContextConstants.DESTINATION.toString(), "TEST");
    int action = queryHost.prepare(1L, ctx);
    assertTrue(action == (PREPARED | READONLY | NO_JOIN));
    assertNotNull(ctx.get(ContextConstants.RESPONSE.toString(), 1000));
    assertFalse("Should not have failures", ctx.getResult().hasFailures());
}
Also used : Context(org.jpos.transaction.Context) Test(org.junit.Test)

Example 35 with Context

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

the class QueryHostTest method testSimpleQueryAsync.

@Test
public void testSimpleQueryAsync() throws Exception {
    Context ctx = new Context();
    cfg.put("continuations", "yes");
    queryHost.setConfiguration(cfg);
    ctx.put(ContextConstants.REQUEST.toString(), createDummyRequest());
    ctx.put(ContextConstants.DESTINATION.toString(), "TEST");
    int action = queryHost.prepare(1L, ctx);
    assertTrue(action == (PREPARED | READONLY | PAUSE | NO_JOIN));
    assertNotNull(ctx.get(ContextConstants.RESPONSE.toString(), 1000));
    assertFalse("Should not have failures", ctx.getResult().hasFailures());
}
Also used : Context(org.jpos.transaction.Context) 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