Search in sources :

Example 51 with ISOMsg

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);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOChannel(org.jpos.iso.ISOChannel) GZIPChannel(org.jpos.iso.channel.GZIPChannel) X92GenericPackager(org.jpos.iso.packager.X92GenericPackager) Test(org.junit.Test)

Example 52 with ISOMsg

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());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) GZIPChannel(org.jpos.iso.channel.GZIPChannel) Test(org.junit.Test)

Example 53 with ISOMsg

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);
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) Test(org.junit.Test)

Example 54 with ISOMsg

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());
    }
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) ISOFilter(org.jpos.iso.ISOFilter) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) Test(org.junit.Test)

Example 55 with ISOMsg

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());
}
Also used : XMLPackager(org.jpos.iso.packager.XMLPackager) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PostChannel(org.jpos.iso.channel.PostChannel) CTCSubFieldPackager(org.jpos.iso.packager.CTCSubFieldPackager) Test(org.junit.Test)

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