Search in sources :

Example 16 with LogEvent

use of org.jpos.util.LogEvent 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("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()", 0, 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.Test)

Example 17 with LogEvent

use of org.jpos.util.LogEvent 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("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 18 with LogEvent

use of org.jpos.util.LogEvent 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("evt.payLoad.size()", 4, 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()", 0, 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.Test)

Example 19 with LogEvent

use of org.jpos.util.LogEvent 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) {
        assertNull("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.Test)

Example 20 with LogEvent

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

the class MacroFilterTest method testFilter5.

@Test
public void testFilter5() throws Throwable {
    MacroFilter macroFilter = new MacroFilter();
    LogEvent evt = new LogEvent();
    ISOChannel channel = new NACChannel();
    when(m.getMaxField()).thenReturn(0);
    when(m.hasField(0)).thenReturn(true);
    when(m.getValue(0)).thenReturn("N/A in Composite");
    ISOMsg result = macroFilter.filter(channel, m, evt);
    assertSame("result", m, result);
}
Also used : NACChannel(org.jpos.iso.channel.NACChannel) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOChannel(org.jpos.iso.ISOChannel) 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