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