use of org.jpos.iso.packager.XMLPackager in project jPOS by jpos.
the class MD5FilterTest method testFilterThrowsNullPointerException.
@Test
public void testFilterThrowsNullPointerException() throws Throwable {
MD5Filter mD5Filter = new MD5Filter();
mD5Filter.setConfiguration(new SimpleConfiguration());
int[] fields = new int[1];
mD5Filter.setFields(fields);
ISOMsg m = new ISOMsg("testMD5FilterMti");
try {
mD5Filter.filter(new GZIPChannel(new XMLPackager()), m, null);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
if (isJavaVersionAtMost(JAVA_14)) {
assertNull(ex.getMessage(), "ex.getMessage()");
} else {
assertEquals("Cannot invoke \"org.jpos.util.LogEvent.addMessage(Object)\" because \"evt\" is null", ex.getMessage(), "ex.getMessage()");
}
assertEquals(0, m.getDirection(), "m.getDirection()");
}
}
use of org.jpos.iso.packager.XMLPackager in project jPOS by jpos.
the class MD5FilterTest method testFilterThrowsVetoException.
@Test
public void testFilterThrowsVetoException() throws Throwable {
MD5Filter mD5Filter = new MD5Filter();
mD5Filter.setConfiguration(new SimpleConfiguration(new Properties()));
int[] fields = new int[3];
fields[1] = 57;
mD5Filter.setFields(fields);
ISOMsg m = new ISOMsg("testMD5FilterMti");
LogEvent evt = new LogEvent("testMD5FilterTag", new XMLPackager());
try {
mD5Filter.filter(new ASCIIChannel(null), m, evt);
fail("Expected VetoException to be thrown");
} catch (ISOFilter.VetoException ex) {
assertEquals(4, evt.getPayLoad().size(), "evt.payLoad.size()");
assertEquals("org.jpos.iso.ISOFilter$VetoException: invalid MAC", ex.getMessage(), "ex.getMessage()");
assertEquals("invalid MAC", ex.getNested().getMessage(), "ex.getNested().getMessage()");
assertEquals(0, m.getDirection(), "m.getDirection()");
}
}
use of org.jpos.iso.packager.XMLPackager in project jPOS by jpos.
the class StatefulFilterTest method testFilter6.
@Test
public void testFilter6() throws Throwable {
StatefulFilter statefulFilter = new StatefulFilter();
statefulFilter.setMatchDirection(58);
statefulFilter.setSavedFields(null);
statefulFilter.setIgnoredFields(null);
ISOMsg m = new ISOMsg("testStatefulFilterMti");
m.setDirection(58);
ISOMsg result = statefulFilter.filter(new PostChannel("testStatefulFilterHost", 100, new XMLPackager()), m, new LogEvent("testStatefulFilterTag", new CTCSubFieldPackager()));
assertEquals(58, result.getDirection(), "result.getDirection()");
}
use of org.jpos.iso.packager.XMLPackager in project jPOS by jpos.
the class MacroFilterTest method testFilterThrowsNullPointerException.
@Test
public void testFilterThrowsNullPointerException() throws Throwable {
MacroFilter macroFilter = new MacroFilter();
LogEvent evt = new LogEvent();
try {
macroFilter.filter(new PADChannel("testMacroFilterHost", 100, new XMLPackager()), null, evt);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
if (isJavaVersionAtMost(JAVA_14)) {
assertNull(ex.getMessage(), "ex.getMessage()");
} else {
assertEquals("Cannot invoke \"org.jpos.iso.ISOMsg.getMaxField()\" because \"m\" is null", ex.getMessage(), "ex.getMessage()");
}
assertNull(macroFilter.cfg, "macroFilter.cfg");
assertNull(macroFilter.seq, "macroFilter.seq");
}
}
use of org.jpos.iso.packager.XMLPackager in project jPOS by jpos.
the class LogChannelTest method testConstructor2.
@Test
public void testConstructor2() throws Throwable {
ISOPackager p = new XMLPackager();
ServerSocket serverSocket = new ServerSocket();
LogChannel logChannel = new LogChannel(p, serverSocket);
assertEquals(0, logChannel.getIncomingFilters().size(), "logChannel.getIncomingFilters().size()");
assertEquals(100000, logChannel.getMaxPacketLength(), "logChannel.getMaxPacketLength()");
assertSame(p, logChannel.getPackager(), "logChannel.getPackager()");
assertEquals(0, logChannel.getPort(), "logChannel.getPort()");
assertEquals("", logChannel.getName(), "logChannel.getName()");
assertEquals(3, logChannel.getCounters().length, "logChannel.getCounters().length");
assertNull(logChannel.getLogger(), "logChannel.getLogger()");
assertNull(logChannel.getSocketFactory(), "logChannel.getSocketFactory()");
assertNull(logChannel.getHeader(), "logChannel.getHeader()");
assertEquals(0, logChannel.getOutgoingFilters().size(), "logChannel.getOutgoingFilters().size()");
assertSame(serverSocket, logChannel.getServerSocket(), "logChannel.getServerSocket()");
assertEquals("org.jpos.iso.channel.LogChannel", logChannel.getOriginalRealm(), "logChannel.getOriginalRealm()");
assertNull(logChannel.getRealm(), "logChannel.getRealm()");
assertNull(logChannel.reader, "logChannel.reader");
assertNull(logChannel.getHost(), "logChannel.getHost()");
}
Aggregations