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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations