Search in sources :

Example 21 with LogEvent

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

Example 22 with LogEvent

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

the class MacroFilterTest method testFilter6.

@Test
public void testFilter6() throws Throwable {
    ISOMsg m = new ISOMsg(100);
    m.set(100, "");
    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)

Example 23 with LogEvent

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

the class MacroFilterTest method testFilter.

@Test
public void testFilter() throws Throwable {
    MacroFilter macroFilter = new MacroFilter();
    ISOChannel channel = new GZIPChannel(new X92GenericPackager());
    LogEvent evt = new LogEvent("testMacroFilterTag", "\u0000\u0000");
    when(m.getMaxField()).thenReturn(0);
    ISOMsg result = macroFilter.filter(channel, m, evt);
    assertSame("result", m, result);
    verify(m).hasField(0);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOChannel(org.jpos.iso.ISOChannel) GZIPChannel(org.jpos.iso.channel.GZIPChannel) X92GenericPackager(org.jpos.iso.packager.X92GenericPackager) Test(org.junit.Test)

Example 24 with LogEvent

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

the class StatefulFilterTest method testFilterThrowsNullPointerException5.

@Test
public void testFilterThrowsNullPointerException5() throws Throwable {
    StatefulFilter statefulFilter = new StatefulFilter();
    statefulFilter.setSpace((Space) null);
    try {
        statefulFilter.filter(new GZIPChannel(), new ISOMsg("testStatefulFilterMti"), new LogEvent());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) GZIPChannel(org.jpos.iso.channel.GZIPChannel) Test(org.junit.Test)

Example 25 with LogEvent

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

the class StatefulFilterTest method testFilter5.

@Test
public void testFilter5() throws Throwable {
    StatefulFilter statefulFilter = new StatefulFilter();
    BASE24TCPChannel iSOChannel = mock(BASE24TCPChannel.class);
    LogEvent evt = mock(LogEvent.class);
    ISOMsg m = mock(ISOMsg.class);
    given(m.getString(11)).willReturn(null);
    given(m.getString(41)).willReturn(null);
    given(m.getDirection()).willReturn(0);
    ISOMsg result = statefulFilter.filter(iSOChannel, m, evt);
    assertSame("result", m, result);
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) 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