Search in sources :

Example 1 with PostPackager

use of org.jpos.iso.packager.PostPackager 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 PostPackager

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

the class MD5FilterTest method testFilterThrowsVetoException6.

@Test
public void testFilterThrowsVetoException6() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    mD5Filter.setFields(null);
    try {
        mD5Filter.filter(new PADChannel(new PostPackager()), null, null);
        fail("Expected VetoException to be thrown");
    } catch (ISOFilter.VetoException ex) {
        assertEquals("MD5Filter not configured", ex.getMessage(), "ex.getMessage()");
        assertNull(ex.getNested(), "ex.getNested()");
    }
}
Also used : ISOFilter(org.jpos.iso.ISOFilter) PostPackager(org.jpos.iso.packager.PostPackager) PADChannel(org.jpos.iso.channel.PADChannel) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with PostPackager

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

the class MD5FilterTest method testFilterThrowsVetoException3.

@Test
public void testFilterThrowsVetoException3() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    LogEvent evt = new LogEvent("testMD5FilterTag");
    int[] fields = new int[1];
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    try {
        mD5Filter.filter(new BASE24TCPChannel("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(0, m.getDirection(), "m.getDirection()");
    }
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) 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) Test(org.junit.jupiter.api.Test)

Example 4 with PostPackager

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

the class StatefulFilterTest method testFilterThrowsNullPointerException8.

@Test
public void testFilterThrowsNullPointerException8() throws Throwable {
    int[] key = new int[0];
    StatefulFilter statefulFilter = new StatefulFilter();
    statefulFilter.setKey(key);
    statefulFilter.setSpace((Space) null);
    statefulFilter.setMatchDirection(0);
    statefulFilter.setSavedFields(null);
    statefulFilter.setIgnoredFields(null);
    try {
        statefulFilter.filter(new CSChannel("testStatefulFilterHost", 100, new PostPackager()), new ISOMsg("testStatefulFilterMti"), 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) PostPackager(org.jpos.iso.packager.PostPackager) LogEvent(org.jpos.util.LogEvent) CSChannel(org.jpos.iso.channel.CSChannel) Test(org.junit.jupiter.api.Test)

Example 5 with PostPackager

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

the class XMLChannelTest method testConstructor1.

@Test
public void testConstructor1() throws Throwable {
    ServerSocket serverSocket = new ServerSocket();
    ISOPackager p = new PostPackager();
    XMLChannel xMLChannel = new XMLChannel(p, serverSocket);
    assertSame(p, xMLChannel.getPackager(), "xMLChannel.getPackager()");
    assertNull(xMLChannel.getLogger(), "xMLChannel.getLogger()");
    assertEquals(0, xMLChannel.getIncomingFilters().size(), "xMLChannel.getIncomingFilters().size()");
    assertEquals(0, xMLChannel.getPort(), "xMLChannel.getPort()");
    assertNull(xMLChannel.getHeader(), "xMLChannel.getHeader()");
    assertNull(xMLChannel.getSocketFactory(), "xMLChannel.getSocketFactory()");
    assertSame(serverSocket, xMLChannel.getServerSocket(), "xMLChannel.getServerSocket()");
    assertEquals("org.jpos.iso.channel.XMLChannel", xMLChannel.getOriginalRealm(), "xMLChannel.getOriginalRealm()");
    assertNull(xMLChannel.reader, "xMLChannel.reader");
    assertNull(xMLChannel.getHost(), "xMLChannel.getHost()");
    assertEquals(100000, xMLChannel.getMaxPacketLength(), "xMLChannel.getMaxPacketLength()");
    assertEquals("", xMLChannel.getName(), "xMLChannel.getName()");
    assertEquals(3, xMLChannel.getCounters().length, "xMLChannel.getCounters().length");
    assertEquals(0, xMLChannel.getOutgoingFilters().size(), "xMLChannel.getOutgoingFilters().size()");
    assertNull(xMLChannel.getRealm(), "xMLChannel.getRealm()");
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) PostPackager(org.jpos.iso.packager.PostPackager) ServerSocket(java.net.ServerSocket) Test(org.junit.jupiter.api.Test)

Aggregations

PostPackager (org.jpos.iso.packager.PostPackager)21 Test (org.junit.jupiter.api.Test)21 ISOMsg (org.jpos.iso.ISOMsg)8 CSChannel (org.jpos.iso.channel.CSChannel)8 LogEvent (org.jpos.util.LogEvent)7 SimpleConfiguration (org.jpos.core.SimpleConfiguration)3 ISOFilter (org.jpos.iso.ISOFilter)3 ISOPackager (org.jpos.iso.ISOPackager)3 ServerSocket (java.net.ServerSocket)2 BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)2 XMLChannel (org.jpos.iso.channel.XMLChannel)2 EOFException (java.io.EOFException)1 Collection (java.util.Collection)1 PADChannel (org.jpos.iso.channel.PADChannel)1 PostChannel (org.jpos.iso.channel.PostChannel)1 EuroSubFieldPackager (org.jpos.iso.packager.EuroSubFieldPackager)1