Search in sources :

Example 1 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration 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 SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testFilter.

@Test
public void testFilter() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(2);
    ISOMsg result = mD5Filter.filter(new ASCIIChannel(new EuroSubFieldPackager()), m, new LogEvent());
    assertEquals(128, m.getMaxField(), "m.getMaxField()");
    assertSame(m, result, "result");
}
Also used : EuroSubFieldPackager(org.jpos.iso.packager.EuroSubFieldPackager) ISOMsg(org.jpos.iso.ISOMsg) ASCIIChannel(org.jpos.iso.channel.ASCIIChannel) LogEvent(org.jpos.util.LogEvent) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration 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 4 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testFilter2.

@Test
public void testFilter2() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(2);
    ISOMsg result = mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMD5FilterTag"));
    assertEquals(128, m.getMaxField(), "m.getMaxField()");
    assertSame(m, result, "result");
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ASCIIChannel(org.jpos.iso.channel.ASCIIChannel) LogEvent(org.jpos.util.LogEvent) SimpleConfiguration(org.jpos.core.SimpleConfiguration) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testFilterThrowsNullPointerException4.

@Test
public void testFilterThrowsNullPointerException4() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    LogEvent evt = new LogEvent();
    try {
        mD5Filter.filter(new BASE24TCPChannel(), 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.getDirection()\" because \"m\" is null", ex.getMessage(), "ex.getMessage()");
        }
    }
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) LogEvent(org.jpos.util.LogEvent) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleConfiguration (org.jpos.core.SimpleConfiguration)71 Test (org.junit.jupiter.api.Test)59 Configuration (org.jpos.core.Configuration)25 Properties (java.util.Properties)16 SubConfiguration (org.jpos.core.SubConfiguration)15 ISOMsg (org.jpos.iso.ISOMsg)14 LogEvent (org.jpos.util.LogEvent)14 ConfigurationException (org.jpos.core.ConfigurationException)9 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)7 Logger (org.jpos.util.Logger)7 ISOFilter (org.jpos.iso.ISOFilter)6 GZIPChannel (org.jpos.iso.channel.GZIPChannel)4 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)4 PostChannel (org.jpos.iso.channel.PostChannel)3 PostPackager (org.jpos.iso.packager.PostPackager)3 XMLPackager (org.jpos.iso.packager.XMLPackager)3 Element (org.jdom2.Element)2 BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)2 LogChannel (org.jpos.iso.channel.LogChannel)2 PADChannel (org.jpos.iso.channel.PADChannel)2