use of org.jpos.iso.ISOMsg in project jPOS by jpos.
the class MacroFilterTest method testFilter.
@Test
public void testFilter() throws Throwable {
MacroFilter macroFilter = new MacroFilter();
ISOChannel channel = new GZIPChannel(new X92GenericPackager());
LogEvent evt = new LogEvent("testMacroFilterTag", "\u0000\u0000");
when(m.getMaxField()).thenReturn(0);
ISOMsg result = macroFilter.filter(channel, m, evt);
assertSame("result", m, result);
verify(m).hasField(0);
}
use of org.jpos.iso.ISOMsg in project jPOS by jpos.
the class StatefulFilterTest method testFilterThrowsNullPointerException5.
@Test
public void testFilterThrowsNullPointerException5() throws Throwable {
StatefulFilter statefulFilter = new StatefulFilter();
statefulFilter.setSpace((Space) null);
try {
statefulFilter.filter(new GZIPChannel(), new ISOMsg("testStatefulFilterMti"), new LogEvent());
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.jpos.iso.ISOMsg in project jPOS by jpos.
the class StatefulFilterTest method testFilter5.
@Test
public void testFilter5() throws Throwable {
StatefulFilter statefulFilter = new StatefulFilter();
BASE24TCPChannel iSOChannel = mock(BASE24TCPChannel.class);
LogEvent evt = mock(LogEvent.class);
ISOMsg m = mock(ISOMsg.class);
given(m.getString(11)).willReturn(null);
given(m.getString(41)).willReturn(null);
given(m.getDirection()).willReturn(0);
ISOMsg result = statefulFilter.filter(iSOChannel, m, evt);
assertSame("result", m, result);
}
use of org.jpos.iso.ISOMsg in project jPOS by jpos.
the class StatefulFilterTest method testFilterThrowsVetoException.
@Test
public void testFilterThrowsVetoException() throws Throwable {
StatefulFilter statefulFilter = new StatefulFilter();
statefulFilter.setSpace("testStatefulFilterUri");
int[] key = new int[0];
statefulFilter.setVetoUnmatched(true);
statefulFilter.setKey(key);
try {
statefulFilter.filter(new BASE24TCPChannel(), new ISOMsg("testStatefulFilterMti"), new LogEvent());
fail("Expected VetoException to be thrown");
} catch (ISOFilter.VetoException ex) {
assertEquals("ex.getMessage()", "unmatched iso message", ex.getMessage());
assertNull("ex.getNested()", ex.getNested());
}
}
use of org.jpos.iso.ISOMsg 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("result.getDirection()", 58, result.getDirection());
}
Aggregations