Search in sources :

Example 1 with BASE24TCPChannel

use of org.jpos.iso.channel.BASE24TCPChannel in project jPOS by jpos.

the class BaseChannelTest method testRemoveFilter.

@Test
public void testRemoveFilter() throws Throwable {
    BaseChannel bASE24TCPChannel = new BASE24TCPChannel();
    bASE24TCPChannel.removeFilter(new StatefulFilter(), 100);
    assertEquals("(BASE24TCPChannel) bASE24TCPChannel.incomingFilters.size()", 0, ((BASE24TCPChannel) bASE24TCPChannel).incomingFilters.size());
    assertEquals("(BASE24TCPChannel) bASE24TCPChannel.outgoingFilters.size()", 0, ((BASE24TCPChannel) bASE24TCPChannel).outgoingFilters.size());
}
Also used : BASE24TCPChannel(org.jpos.iso.channel.BASE24TCPChannel) StatefulFilter(org.jpos.iso.filter.StatefulFilter) Test(org.junit.Test)

Example 2 with BASE24TCPChannel

use of org.jpos.iso.channel.BASE24TCPChannel 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 3 with BASE24TCPChannel

use of org.jpos.iso.channel.BASE24TCPChannel 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 4 with BASE24TCPChannel

use of org.jpos.iso.channel.BASE24TCPChannel 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 5 with BASE24TCPChannel

use of org.jpos.iso.channel.BASE24TCPChannel 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

BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)11 Test (org.junit.Test)11 LogEvent (org.jpos.util.LogEvent)8 ISOMsg (org.jpos.iso.ISOMsg)6 SimpleConfiguration (org.jpos.core.SimpleConfiguration)2 ISOFilter (org.jpos.iso.ISOFilter)2 PostPackager (org.jpos.iso.packager.PostPackager)2 PADChannel (org.jpos.iso.channel.PADChannel)1 DelayFilter (org.jpos.iso.filter.DelayFilter)1 StatefulFilter (org.jpos.iso.filter.StatefulFilter)1 Base1SubFieldPackager (org.jpos.iso.packager.Base1SubFieldPackager)1 EuroSubFieldPackager (org.jpos.iso.packager.EuroSubFieldPackager)1 GenericValidatingPackager (org.jpos.iso.packager.GenericValidatingPackager)1