Search in sources :

Example 1 with PostChannel

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

Example 2 with PostChannel

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

Example 3 with PostChannel

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()");
}
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.jupiter.api.Test)

Example 4 with PostChannel

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()");
        }
    }
}
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 5 with PostChannel

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()");
        }
    }
}
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)

Aggregations

PostChannel (org.jpos.iso.channel.PostChannel)10 Test (org.junit.jupiter.api.Test)10 ISOMsg (org.jpos.iso.ISOMsg)9 LogEvent (org.jpos.util.LogEvent)9 CTCSubFieldPackager (org.jpos.iso.packager.CTCSubFieldPackager)4 SimpleConfiguration (org.jpos.core.SimpleConfiguration)3 GenericSubFieldPackager (org.jpos.iso.packager.GenericSubFieldPackager)3 ISOFilter (org.jpos.iso.ISOFilter)2 XMLPackager (org.jpos.iso.packager.XMLPackager)2 PostPackager (org.jpos.iso.packager.PostPackager)1