Search in sources :

Example 1 with GenericSubFieldPackager

use of org.jpos.iso.packager.GenericSubFieldPackager 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()");
        }
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PostChannel(org.jpos.iso.channel.PostChannel) GenericSubFieldPackager(org.jpos.iso.packager.GenericSubFieldPackager) Test(org.junit.jupiter.api.Test)

Example 2 with GenericSubFieldPackager

use of org.jpos.iso.packager.GenericSubFieldPackager 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()");
        }
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PostChannel(org.jpos.iso.channel.PostChannel) GenericSubFieldPackager(org.jpos.iso.packager.GenericSubFieldPackager) Test(org.junit.jupiter.api.Test)

Example 3 with GenericSubFieldPackager

use of org.jpos.iso.packager.GenericSubFieldPackager in project jPOS by jpos.

the class StatefulFilterTest method testFilterThrowsNullPointerException.

@Test
public void testFilterThrowsNullPointerException() 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);
    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()");
        }
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PostChannel(org.jpos.iso.channel.PostChannel) GenericSubFieldPackager(org.jpos.iso.packager.GenericSubFieldPackager) Test(org.junit.jupiter.api.Test)

Example 4 with GenericSubFieldPackager

use of org.jpos.iso.packager.GenericSubFieldPackager in project jPOS by jpos.

the class MacroFilterTest method testFilter3.

@Test
public void testFilter3() throws Throwable {
    MacroFilter macroFilter = new MacroFilter();
    ISOChannel channel = new PADChannel(new GenericSubFieldPackager());
    LogEvent evt = new LogEvent();
    when(m.getMaxField()).thenReturn(0);
    when(m.hasField(0)).thenReturn(false);
    ISOMsg result = macroFilter.filter(channel, m, evt);
    assertSame(m, result, "result");
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PADChannel(org.jpos.iso.channel.PADChannel) GenericSubFieldPackager(org.jpos.iso.packager.GenericSubFieldPackager) ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.jupiter.api.Test)

Aggregations

ISOMsg (org.jpos.iso.ISOMsg)4 GenericSubFieldPackager (org.jpos.iso.packager.GenericSubFieldPackager)4 LogEvent (org.jpos.util.LogEvent)4 Test (org.junit.jupiter.api.Test)4 PostChannel (org.jpos.iso.channel.PostChannel)3 ISOChannel (org.jpos.iso.ISOChannel)1 PADChannel (org.jpos.iso.channel.PADChannel)1