use of org.jpos.transaction.Context in project jPOS by jpos.
the class ContextMaker method run.
public void run() {
Thread.currentThread().setName(getName());
while (running()) {
Object o = sp.in(in, timeout);
if (o != null) {
Context ctx = new Context();
ctx.put(contextName, o);
if (contextValues != null) {
for (Element e : contextValues) {
ctx.put(e.getName(), e.getValue());
}
}
sp.out(out, ctx);
}
}
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class CheckFieldsTest method testAmounts.
@Test
public void testAmounts() throws ISOException {
Context ctx = new Context();
ISOMsg m = new ISOMsg();
ISOAmount local = new ISOAmount(4, 858, new BigDecimal("290.00"));
ISOAmount settlement = new ISOAmount(5, 840, new BigDecimal("10.00"));
m.set(local);
m.set(settlement);
ctx.put(ContextConstants.REQUEST.toString(), m);
cfg.put("mandatory", "AMOUNT");
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());
assertEquals(local, ctx.get(ContextConstants.LOCAL_AMOUNT.toString()));
assertEquals(settlement, ctx.get(ContextConstants.AMOUNT.toString()));
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class CheckFieldsTest method testInvalidMidAndTid.
@Test
public void testInvalidMidAndTid() {
Context ctx = new Context();
ISOMsg m = new ISOMsg();
m.set(41, "*1");
m.set(42, "*2");
ctx.put(ContextConstants.REQUEST.toString(), m);
cfg.put("mandatory", "MID, TID");
int action = cf.prepare(1L, ctx);
assertEquals(ABORTED | NO_JOIN | READONLY, action);
Result rc = ctx.getResult();
assertEquals(CMF.INVALID_FIELD, rc.failure().getIrc());
assertFalse(rc.hasInfo());
assertFalse(rc.hasWarnings());
assertTrue(rc.hasFailures());
assertEquals(2, rc.failureList().size());
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class CheckFieldsTest method testOriginalDataElements.
@Test
public void testOriginalDataElements() throws ISOException {
Context ctx = new Context();
ISOMsg m = new ISOMsg();
Date now = new Date();
m.set(56, "0200000000000001" + ISODate.formatDate(now, "yyyyMMddHHmmss"));
ctx.put(ContextConstants.REQUEST.toString(), m);
cfg.put("mandatory", "ORIGINAL_DATA_ELEMENTS");
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());
assertEquals("0200", ctx.get(ContextConstants.ORIGINAL_MTI.toString()));
assertEquals("000000000001", ctx.get(ContextConstants.ORIGINAL_STAN.toString()));
assertEquals(now.getTime() / 1000, ((Date) ctx.get(ContextConstants.ORIGINAL_TIMESTAMP.toString())).getTime() / 1000);
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class CheckFieldsTest method testValidCard.
@Test
public void testValidCard() {
Context ctx = new Context();
ISOMsg m = new ISOMsg();
m.set(2, "4111111111111111");
m.set(14, "2912");
m.set(35, "4111111111111111=2912");
m.set(45, "B4111111111111111^TEST CARDHOLDER^29120000000000000000");
ctx.put(ContextConstants.REQUEST.toString(), m);
cfg.put("mandatory", "CARD");
int action = cf.prepare(1L, ctx);
assertEquals(PREPARED | NO_JOIN | READONLY, action);
}
Aggregations