Search in sources :

Example 46 with ISOMsg

use of org.jpos.iso.ISOMsg 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 47 with ISOMsg

use of org.jpos.iso.ISOMsg 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 48 with ISOMsg

use of org.jpos.iso.ISOMsg 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 49 with ISOMsg

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

Example 50 with ISOMsg

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

Aggregations

ISOMsg (org.jpos.iso.ISOMsg)223 Test (org.junit.Test)191 LogEvent (org.jpos.util.LogEvent)41 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)30 ISOException (org.jpos.iso.ISOException)29 ISOComponent (org.jpos.iso.ISOComponent)25 ISOVMsg (org.jpos.iso.ISOVMsg)22 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)21 Context (org.jpos.transaction.Context)20 ISOValidator (org.jpos.iso.ISOValidator)18 Result (org.jpos.rc.Result)17 SimpleConfiguration (org.jpos.core.SimpleConfiguration)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 TEST0100 (org.jpos.iso.validator.TEST0100)12 FileInputStream (java.io.FileInputStream)9 Vector (java.util.Vector)9 PostChannel (org.jpos.iso.channel.PostChannel)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOFilter (org.jpos.iso.ISOFilter)8