Search in sources :

Example 96 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class QMUXTest method testRequestThrowsNullPointerException.

@Test
public void testRequestThrowsNullPointerException() throws Throwable {
    QMUX qMUX = new QMUX();
    ISOMsg m = new ISOMsg("testQMUXMti");
    try {
        qMUX.request(m, 100L);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertNull("qMUX.sp", qMUX.sp);
        assertEquals("m.getDirection()", 0, m.getDirection());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 97 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class QMUXTest method testProcessUnhandled.

@Test
public void testProcessUnhandled() throws Throwable {
    ISOMsg m = new ISOMsg("testQMUXMti");
    m.setSource(new PADChannel(new EuroSubFieldPackager()));
    QMUX qMUX = new QMUX();
    qMUX.processUnhandled(m);
    assertEquals("qMUX.listeners.size()", 0, qMUX.listeners.size());
}
Also used : EuroSubFieldPackager(org.jpos.iso.packager.EuroSubFieldPackager) ISOMsg(org.jpos.iso.ISOMsg) PADChannel(org.jpos.iso.channel.PADChannel) Test(org.junit.Test)

Example 98 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class QMUXTestCase method createMsg.

private ISOMsg createMsg(String stan) throws ISOException {
    ISOMsg m = new ISOMsg("0800");
    m.set(11, stan);
    // our favourite test terminal
    m.set(41, "29110001");
    return m;
}
Also used : ISOMsg(org.jpos.iso.ISOMsg)

Example 99 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class QMUXTestCase method testMTIMapping.

@Test
public void testMTIMapping() throws ISOException {
    String[] requests = new String[] { "0100", "0101", "0400", "0401", "0420", "0800", "1100", "1800", "1804", "1820", "1820", "1200", "1220", "1240" };
    String[] responses = new String[] { "0110", "0110", "0410", "0410", "0430", "0810", "1110", "1810", "1814", "1824", "1830", "1210", "1230", "1250" };
    assertEquals("Request/Response string arrays must hold same number of entries", requests.length, responses.length);
    ISOMsg request = new ISOMsg();
    ISOMsg response = new ISOMsg();
    for (int i = 0; i < requests.length; i++) {
        request.setMTI(requests[i]);
        request.set(11, Integer.toString(i));
        response.setMTI(responses[i]);
        response.set(11, Integer.toString(i));
        assertEquals(((QMUX) mux).getKey(request), ((QMUX) mux).getKey(response));
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg)

Example 100 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class QMUXTestCase method testAnsweredMessage.

@Test
public void testAnsweredMessage() throws Exception {
    mux.request(createMsg("000002"), 500L, this, "Handback Two");
    assertFalse("expired called too fast", expiredCalled);
    ISOMsg m = (ISOMsg) sp.in("send", 500L);
    assertNotNull("Message not received by pseudo-channel", m);
    assertNotNull("Space doesn't contain message key", getInternalSpace(mux).rdp("send.0800000000029110001000002.req"));
    m.setResponseMTI();
    sp.out("receive", m);
    Thread.sleep(100L);
    assertNotNull("Response not received", responseMsg);
    Thread.sleep(1000L);
    assertFalse("Response received but expired was called", expiredCalled);
    assertNull("Cleanup failed, Space still contains message key", getInternalSpace(mux).rdp("send.0800000000029110001000002.req"));
    assertEquals("Handback Two not received", "Handback Two", receivedHandback);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg)

Aggregations

ISOMsg (org.jpos.iso.ISOMsg)223 Test (org.junit.Test)191 LogEvent (org.jpos.util.LogEvent)41 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)30 ISOException (org.jpos.iso.ISOException)29 ISOComponent (org.jpos.iso.ISOComponent)25 ISOVMsg (org.jpos.iso.ISOVMsg)22 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)21 Context (org.jpos.transaction.Context)20 ISOValidator (org.jpos.iso.ISOValidator)18 Result (org.jpos.rc.Result)17 SimpleConfiguration (org.jpos.core.SimpleConfiguration)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 TEST0100 (org.jpos.iso.validator.TEST0100)12 FileInputStream (java.io.FileInputStream)9 Vector (java.util.Vector)9 PostChannel (org.jpos.iso.channel.PostChannel)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOFilter (org.jpos.iso.ISOFilter)8