use of org.jpos.iso.channel.PostChannel in project jPOS by jpos.
the class MD5FilterTest method testFilterThrowsVetoException1.
@Test
public void testFilterThrowsVetoException1() throws Throwable {
MD5Filter mD5Filter = new MD5Filter();
mD5Filter.setConfiguration(new SimpleConfiguration());
ISOMsg m = new ISOMsg("testMD5FilterMti");
m.setDirection(3);
LogEvent evt = new LogEvent();
try {
mD5Filter.filter(new PostChannel("testMD5FilterHost", 100, new PostPackager()), m, evt);
fail("Expected VetoException to be thrown");
} catch (ISOFilter.VetoException ex) {
assertEquals(3, 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(3, m.getDirection(), "m.getDirection()");
}
}
use of org.jpos.iso.channel.PostChannel in project jPOS by jpos.
the class MD5FilterTest method testFilterThrowsVetoException5.
@Test
public void testFilterThrowsVetoException5() throws Throwable {
ISOMsg m = new ISOMsg("testMD5FilterMti");
LogEvent evt = new LogEvent();
try {
new MD5Filter().filter(new PostChannel(), m, evt);
fail("Expected VetoException to be thrown");
} catch (ISOFilter.VetoException ex) {
assertEquals("MD5Filter not configured", ex.getMessage(), "ex.getMessage()");
assertNull(ex.getNested(), "ex.getNested()");
assertEquals(0, m.getDirection(), "m.getDirection()");
}
}
use of org.jpos.iso.channel.PostChannel 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.channel.PostChannel in project jPOS by jpos.
the class StatefulFilterTest method testFilterThrowsNullPointerException9.
@Test
public void testFilterThrowsNullPointerException9() throws Throwable {
ISOMsg m = new ISOMsg(100);
m.setDirection(100);
int[] key = new int[0];
StatefulFilter statefulFilter = new StatefulFilter();
statefulFilter.setKey(key);
statefulFilter.setSpace((Space) null);
statefulFilter.setMatchDirection(100);
statefulFilter.setSavedFields(null);
try {
statefulFilter.filter(new PostChannel("testStatefulFilterHost", 100, new GenericSubFieldPackager()), m, new LogEvent());
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
if (isJavaVersionAtMost(JAVA_14)) {
assertNull(ex.getMessage(), "ex.getMessage()");
} else {
assertEquals("Cannot invoke \"org.jpos.space.Space.out(Object, Object, long)\" because the return value of \"org.jpos.iso.filter.StatefulFilter.getSpace()\" is null", ex.getMessage(), "ex.getMessage()");
}
}
}
use of org.jpos.iso.channel.PostChannel in project jPOS by jpos.
the class StatefulFilterTest method testFilterThrowsNullPointerException4.
@Test
public void testFilterThrowsNullPointerException4() throws Throwable {
ISOMsg m = new ISOMsg(100);
m.setDirection(100);
StatefulFilter statefulFilter = new StatefulFilter();
statefulFilter.setSpace((Space) null);
statefulFilter.setMatchDirection(100);
statefulFilter.setSavedFields(null);
try {
statefulFilter.filter(new PostChannel("testStatefulFilterHost", 100, new GenericSubFieldPackager()), m, new LogEvent());
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
if (isJavaVersionAtMost(JAVA_14)) {
assertNull(ex.getMessage(), "ex.getMessage()");
} else {
assertEquals("Cannot invoke \"org.jpos.space.Space.out(Object, Object, long)\" because the return value of \"org.jpos.iso.filter.StatefulFilter.getSpace()\" is null", ex.getMessage(), "ex.getMessage()");
}
}
}
Aggregations