Search in sources :

Example 1 with XMLPackager

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

the class MD5FilterTest method testFilterThrowsNullPointerException.

@Test
public void testFilterThrowsNullPointerException() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    try {
        mD5Filter.filter(new GZIPChannel(new XMLPackager()), m, null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        if (isJavaVersionAtMost(JAVA_14)) {
            assertNull(ex.getMessage(), "ex.getMessage()");
        } else {
            assertEquals("Cannot invoke \"org.jpos.util.LogEvent.addMessage(Object)\" because \"evt\" is null", ex.getMessage(), "ex.getMessage()");
        }
        assertEquals(0, m.getDirection(), "m.getDirection()");
    }
}
Also used : XMLPackager(org.jpos.iso.packager.XMLPackager) ISOMsg(org.jpos.iso.ISOMsg) SimpleConfiguration(org.jpos.core.SimpleConfiguration) GZIPChannel(org.jpos.iso.channel.GZIPChannel) Test(org.junit.jupiter.api.Test)

Example 2 with XMLPackager

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

the class MD5FilterTest method testFilterThrowsVetoException.

@Test
public void testFilterThrowsVetoException() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration(new Properties()));
    int[] fields = new int[3];
    fields[1] = 57;
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    LogEvent evt = new LogEvent("testMD5FilterTag", new XMLPackager());
    try {
        mD5Filter.filter(new ASCIIChannel(null), m, evt);
        fail("Expected VetoException to be thrown");
    } catch (ISOFilter.VetoException ex) {
        assertEquals(4, 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 : XMLPackager(org.jpos.iso.packager.XMLPackager) ISOFilter(org.jpos.iso.ISOFilter) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ASCIIChannel(org.jpos.iso.channel.ASCIIChannel) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 3 with XMLPackager

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

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

the class MacroFilterTest method testFilterThrowsNullPointerException.

@Test
public void testFilterThrowsNullPointerException() throws Throwable {
    MacroFilter macroFilter = new MacroFilter();
    LogEvent evt = new LogEvent();
    try {
        macroFilter.filter(new PADChannel("testMacroFilterHost", 100, new XMLPackager()), null, evt);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        if (isJavaVersionAtMost(JAVA_14)) {
            assertNull(ex.getMessage(), "ex.getMessage()");
        } else {
            assertEquals("Cannot invoke \"org.jpos.iso.ISOMsg.getMaxField()\" because \"m\" is null", ex.getMessage(), "ex.getMessage()");
        }
        assertNull(macroFilter.cfg, "macroFilter.cfg");
        assertNull(macroFilter.seq, "macroFilter.seq");
    }
}
Also used : XMLPackager(org.jpos.iso.packager.XMLPackager) LogEvent(org.jpos.util.LogEvent) PADChannel(org.jpos.iso.channel.PADChannel) Test(org.junit.jupiter.api.Test)

Example 5 with XMLPackager

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

the class LogChannelTest method testConstructor2.

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

Aggregations

XMLPackager (org.jpos.iso.packager.XMLPackager)15 Test (org.junit.jupiter.api.Test)13 ISOMsg (org.jpos.iso.ISOMsg)6 LogEvent (org.jpos.util.LogEvent)5 SimpleConfiguration (org.jpos.core.SimpleConfiguration)3 ISOPackager (org.jpos.iso.ISOPackager)3 ServerSocket (java.net.ServerSocket)2 GZIPChannel (org.jpos.iso.channel.GZIPChannel)2 PADChannel (org.jpos.iso.channel.PADChannel)2 PostChannel (org.jpos.iso.channel.PostChannel)2 XMLChannel (org.jpos.iso.channel.XMLChannel)2 CTCSubFieldPackager (org.jpos.iso.packager.CTCSubFieldPackager)2 Properties (java.util.Properties)1 ISOFilter (org.jpos.iso.ISOFilter)1 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)1 X25Channel (org.jpos.iso.channel.X25Channel)1 BaseHeader (org.jpos.iso.header.BaseHeader)1 Base1SubFieldPackager (org.jpos.iso.packager.Base1SubFieldPackager)1 ThreadPool (org.jpos.util.ThreadPool)1