Search in sources :

Example 16 with Context

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

the class QueryHostTest method testNoDestination.

@Test
public void testNoDestination() throws Exception {
    Context ctx = new Context();
    cfg.put("continuations", "no");
    queryHost.setConfiguration(cfg);
    ctx.put(ContextConstants.REQUEST.toString(), createDummyRequest());
    int action = queryHost.prepare(1L, ctx);
    assertTrue(action == FAIL);
    assertNull(ctx.get(ContextConstants.RESPONSE.toString()));
    assertTrue("has Failures", ctx.getResult().hasFailures());
    assertTrue(ctx.getResult().failure().getIrc() == CMF.MISCONFIGURED_ENDPOINT);
}
Also used : Context(org.jpos.transaction.Context) Test(org.junit.Test)

Example 17 with Context

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

the class QueryHostTest method testNoRequest.

@Test
public void testNoRequest() throws Exception {
    Context ctx = new Context();
    cfg.put("continuations", "no");
    queryHost.setConfiguration(cfg);
    ctx.put(ContextConstants.DESTINATION.toString(), "TEST");
    int action = queryHost.prepare(1L, ctx);
    assertTrue(action == FAIL);
    assertNull(ctx.get(ContextConstants.RESPONSE.toString()));
    assertTrue("has Failures", ctx.getResult().hasFailures());
    assertTrue(ctx.getResult().failure().getIrc() == CMF.INVALID_REQUEST);
}
Also used : Context(org.jpos.transaction.Context) Test(org.junit.Test)

Example 18 with Context

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

the class SelectDestinationTest method testNetwork6.

@Test
public void testNetwork6() {
    cfg.put("ignore-luhn", "true");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("6111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("No failures", rc.hasFailures());
    assertEquals("Invalid Destination", "N6", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 19 with Context

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

the class SelectDestinationTest method testNetwork_V.

@Test
public void testNetwork_V() {
    cfg.put("ignore-luhn", "false");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("4111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("No failures", rc.hasFailures());
    assertEquals("Invalid Destination", "V", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 20 with Context

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

the class SelectDestinationTest method testNetwork7.

@Test
public void testNetwork7() {
    cfg.put("ignore-luhn", "true");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("7111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("No failures", rc.hasFailures());
    assertEquals("Invalid Destination", "N7", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) 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