Search in sources :

Example 1 with ASCIIChannel

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

the class BaseChannelTest method testGetChannel.

@Test
public void testGetChannel() throws Throwable {
    BaseChannel aSCIIChannel = new ASCIIChannel(new GenericPackager(), new ServerSocket());
    aSCIIChannel.setName("channel.");
    BaseChannel result = (BaseChannel) BaseChannel.getChannel("channel.");
    assertSame("result", aSCIIChannel, result);
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) ASCIIChannel(org.jpos.iso.channel.ASCIIChannel) Test(org.junit.Test)

Example 2 with ASCIIChannel

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

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

the class MD5FilterTest method testFilterThrowsNullPointerException2.

@Test
public void testFilterThrowsNullPointerException2() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    try {
        mD5Filter.filter(new ASCIIChannel(new GenericValidatingPackager()), m, null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertEquals("m.getDirection()", 0, m.getDirection());
    }
}
Also used : GenericValidatingPackager(org.jpos.iso.packager.GenericValidatingPackager) ISOMsg(org.jpos.iso.ISOMsg) ASCIIChannel(org.jpos.iso.channel.ASCIIChannel) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.Test)

Example 4 with ASCIIChannel

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

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

Aggregations

ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)8 Test (org.junit.Test)8 SimpleConfiguration (org.jpos.core.SimpleConfiguration)7 ISOMsg (org.jpos.iso.ISOMsg)7 LogEvent (org.jpos.util.LogEvent)6 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)4 ISOFilter (org.jpos.iso.ISOFilter)3 Properties (java.util.Properties)1 EuroSubFieldPackager (org.jpos.iso.packager.EuroSubFieldPackager)1 GenericPackager (org.jpos.iso.packager.GenericPackager)1 GenericValidatingPackager (org.jpos.iso.packager.GenericValidatingPackager)1 XMLPackager (org.jpos.iso.packager.XMLPackager)1