Search in sources :

Example 11 with LogEvent

use of org.jpos.util.LogEvent in project jPOS by jpos.

the class DelayFilterTest method testFilter1.

@Test
public void testFilter1() throws Throwable {
    LogEvent evt = new LogEvent(new BASE24TCPChannel("testDelayFilterHost", 100, new Base1SubFieldPackager()), "testDelayFilterTag", null);
    ISOMsg result = new DelayFilter(1).filter(new PADChannel(), null, evt);
    assertEquals("evt.payLoad.size()", 2, evt.getPayLoad().size());
    assertEquals("evt.payLoad.get(1)", "<delay-filter delay=\"1\"/>", evt.getPayLoad().get(1));
    assertNull("result", result);
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) Base1SubFieldPackager(org.jpos.iso.packager.Base1SubFieldPackager) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PADChannel(org.jpos.iso.channel.PADChannel) Test(org.junit.Test)

Example 12 with LogEvent

use of org.jpos.util.LogEvent in project jPOS by jpos.

the class DelayFilterTest method testFilter2.

@Test
public void testFilter2() throws Throwable {
    DelayFilter delayFilter = new DelayFilter(-1);
    ISOChannel channel = new PADChannel(new CTCSubFieldPackager());
    LogEvent evt = new LogEvent("testDelayFilterTag", "");
    ISOMsg result = delayFilter.filter(channel, m, evt);
    assertEquals("evt.payLoad.size()", 2, evt.getPayLoad().size());
    assertEquals("evt.payLoad.get(1)", "<delay-filter delay=\"-1\"/>", evt.getPayLoad().get(1));
    assertSame("result", m, result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PADChannel(org.jpos.iso.channel.PADChannel) CTCSubFieldPackager(org.jpos.iso.packager.CTCSubFieldPackager) ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.Test)

Example 13 with LogEvent

use of org.jpos.util.LogEvent 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("ex.getMessage()", "MD5Filter not configured", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
        assertEquals("m.getDirection()", 0, 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.Test)

Example 14 with LogEvent

use of org.jpos.util.LogEvent 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("m.getMaxField()", 128, m.getMaxField());
    assertSame("result", m, 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.Test)

Example 15 with LogEvent

use of org.jpos.util.LogEvent 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("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) PostPackager(org.jpos.iso.packager.PostPackager) SimpleConfiguration(org.jpos.core.SimpleConfiguration) PostChannel(org.jpos.iso.channel.PostChannel) Test(org.junit.Test)

Aggregations

LogEvent (org.jpos.util.LogEvent)189 Test (org.junit.Test)78 ConfigurationException (org.jpos.core.ConfigurationException)51 ISOMsg (org.jpos.iso.ISOMsg)41 SimpleMsg (org.jpos.util.SimpleMsg)40 NotFoundException (org.jpos.util.NameRegistrar.NotFoundException)38 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)18 SimpleConfiguration (org.jpos.core.SimpleConfiguration)14 CSChannel (org.jpos.iso.channel.CSChannel)12 Loggeable (org.jpos.util.Loggeable)11 Map (java.util.Map)9 ISOChannel (org.jpos.iso.ISOChannel)9 PostChannel (org.jpos.iso.channel.PostChannel)9 CTCSubFieldPackager (org.jpos.iso.packager.CTCSubFieldPackager)9 ISOFilter (org.jpos.iso.ISOFilter)8 BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)8 PADChannel (org.jpos.iso.channel.PADChannel)8 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)8 EOFException (java.io.EOFException)7