Search in sources :

Example 11 with ISOBaseValidatingPackager

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

the class MD5FilterTest method testFilterThrowsVetoException4.

@Test
public void testFilterThrowsVetoException4() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    fields[0] = -100;
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(1);
    LogEvent evt = new LogEvent("testMD5FilterTag");
    try {
        mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, evt);
        fail("Expected VetoException to be thrown");
    } catch (ISOFilter.VetoException ex) {
        assertEquals("evt.payLoad.size()", 3, evt.getPayLoad().size());
        assertEquals("ex.getMessage()", "org.jpos.iso.ISOFilter$VetoException: invalid MAC", ex.getMessage());
        assertEquals("ex.getNested().getMessage()", "invalid MAC", ex.getNested().getMessage());
        assertEquals("m.getDirection()", 1, m.getDirection());
    }
}
Also used : 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) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) Test(org.junit.Test)

Example 12 with ISOBaseValidatingPackager

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

the class MD5FilterTest method testFilterThrowsVetoException2.

@Test
public void testFilterThrowsVetoException2() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    fields[0] = -100;
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(3);
    LogEvent evt = new LogEvent("testMD5FilterTag");
    try {
        mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, evt);
        fail("Expected VetoException to be thrown");
    } catch (ISOFilter.VetoException ex) {
        assertEquals("evt.payLoad.size()", 3, evt.getPayLoad().size());
        assertEquals("ex.getMessage()", "org.jpos.iso.ISOFilter$VetoException: invalid MAC", ex.getMessage());
        assertEquals("ex.getNested().getMessage()", "invalid MAC", ex.getNested().getMessage());
        assertEquals("m.getDirection()", 3, m.getDirection());
    }
}
Also used : 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) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) Test(org.junit.Test)

Example 13 with ISOBaseValidatingPackager

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

the class MD5FilterTest method testFilter1.

@Test
public void testFilter1() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    fields[0] = -100;
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(2);
    ISOMsg result = mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMD5FilterTag"));
    assertEquals("m.getMaxField()", 128, m.getMaxField());
    assertSame("result", m, 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.Test)

Example 14 with ISOBaseValidatingPackager

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

the class MacroFilterTest method testFilter4.

@Test
public void testFilter4() throws Throwable {
    ISOMsg m = new ISOMsg(100);
    byte[] value = new byte[2];
    m.set(100, value);
    m.merge(new ISOMsg("testMacroFilterMti"));
    m.set(100, "");
    ISOMsg result = new MacroFilter().filter(new CSChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMacroFilterTag", ""));
    assertSame("result", m, result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) CSChannel(org.jpos.iso.channel.CSChannel) Test(org.junit.Test)

Example 15 with ISOBaseValidatingPackager

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

the class MacroFilterTest method testFilter1.

@Test
public void testFilter1() throws Throwable {
    ISOMsg m = new ISOMsg(100);
    m.merge(new ISOMsg("testMacroFilterMti"));
    m.set(1, "");
    ISOMsg result = new MacroFilter().filter(new CSChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMacroFilterTag", ""));
    assertEquals("result.getDirection()", 0, result.getDirection());
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) CSChannel(org.jpos.iso.channel.CSChannel) Test(org.junit.Test)

Aggregations

ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)15 Test (org.junit.Test)15 LogEvent (org.jpos.util.LogEvent)8 ISOMsg (org.jpos.iso.ISOMsg)7 ISOPackager (org.jpos.iso.ISOPackager)5 SimpleConfiguration (org.jpos.core.SimpleConfiguration)4 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)4 CSChannel (org.jpos.iso.channel.CSChannel)3 ServerSocket (java.net.ServerSocket)2 ISOFilter (org.jpos.iso.ISOFilter)2 GZIPChannel (org.jpos.iso.channel.GZIPChannel)2