Search in sources :

Example 56 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    assertEquals("mD5Filter.key", "", mD5Filter.key);
    assertEquals("mD5Filter.fields.length", 0, mD5Filter.fields.length);
}
Also used : SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.Test)

Example 57 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testFilterThrowsVetoException2.

@Test
public void testFilterThrowsVetoException2() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    fields[0] = -100;
    mD5Filter.setFields(fields);
    ISOMsg m = new ISOMsg("testMD5FilterMti");
    m.setDirection(3);
    LogEvent evt = new LogEvent("testMD5FilterTag");
    try {
        mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), 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()", 3, m.getDirection());
    }
}
Also used : 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) ISOBaseValidatingPackager(org.jpos.iso.packager.ISOBaseValidatingPackager) Test(org.junit.Test)

Example 58 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class MD5FilterTest method testFilter1.

@Test
public void testFilter1() throws Throwable {
    MD5Filter mD5Filter = new MD5Filter();
    mD5Filter.setConfiguration(new SimpleConfiguration());
    int[] fields = new int[1];
    fields[0] = -100;
    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 59 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class StatefulFilterTest method testGetSavedFieldThrowsArrayIndexOutOfBoundsException.

@Test
public void testGetSavedFieldThrowsArrayIndexOutOfBoundsException() throws Throwable {
    StatefulFilter statefulFilter = new StatefulFilter();
    int[] ignoredFields = new int[0];
    statefulFilter.setIgnoredFields(ignoredFields);
    StatefulFilter statefulFilter2 = new StatefulFilter();
    int[] ignoredFields2 = new int[2];
    statefulFilter.setIgnoredFields(ignoredFields2);
    int[] key = new int[0];
    statefulFilter.setKey(key);
    int[] ignoredFields3 = new int[1];
    int[] key2 = new int[0];
    statefulFilter.setKey(key2);
    int[] ignoredFields4 = new int[0];
    statefulFilter.setIgnoredFields(ignoredFields4);
    statefulFilter.setIgnoredFields(ignoredFields3);
    StatefulFilter statefulFilter3 = new StatefulFilter();
    statefulFilter3.setOverwriteOriginalFields(true);
    int[] key3 = new int[3];
    statefulFilter3.setKey(key3);
    int[] ignoredFields5 = new int[0];
    statefulFilter3.setIgnoredFields(ignoredFields5);
    statefulFilter2.setIgnoredFields(ignoredFields5);
    int[] ignoredFields6 = new int[0];
    statefulFilter2.setIgnoredFields(ignoredFields6);
    statefulFilter2.setConfiguration(new SimpleConfiguration());
    statefulFilter2.setOverwriteOriginalFields(false);
    int[] key4 = new int[0];
    statefulFilter2.setKey(key4);
    try {
        statefulFilter2.getSavedField(100);
        fail("Expected ArrayIndexOutOfBoundsException to be thrown");
    } catch (ArrayIndexOutOfBoundsException ex) {
        assertEquals("ex.getMessage()", "100", ex.getMessage());
    }
}
Also used : SimpleConfiguration(org.jpos.core.SimpleConfiguration) Test(org.junit.Test)

Example 60 with SimpleConfiguration

use of org.jpos.core.SimpleConfiguration in project jPOS by jpos.

the class StatefulFilterTest method testFilter4.

@Test
public void testFilter4() throws Throwable {
    StatefulFilter statefulFilter = new StatefulFilter();
    statefulFilter.setConfiguration(new SimpleConfiguration());
    statefulFilter.setSavedFields(null);
    ISOMsg m = new ISOMsg("testStatefulFilterMti");
    m.setDirection(1);
    ISOMsg result = statefulFilter.filter(new LogChannel(), m, new LogEvent("testStatefulFilterTag", new Object()));
    assertSame("result", m, result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) SimpleConfiguration(org.jpos.core.SimpleConfiguration) LogChannel(org.jpos.iso.channel.LogChannel) Test(org.junit.Test)

Aggregations

SimpleConfiguration (org.jpos.core.SimpleConfiguration)65 Test (org.junit.Test)55 Configuration (org.jpos.core.Configuration)24 SubConfiguration (org.jpos.core.SubConfiguration)15 ISOMsg (org.jpos.iso.ISOMsg)15 Properties (java.util.Properties)14 LogEvent (org.jpos.util.LogEvent)14 ConfigurationException (org.jpos.core.ConfigurationException)9 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)7 ISOFilter (org.jpos.iso.ISOFilter)6 Logger (org.jpos.util.Logger)6 GZIPChannel (org.jpos.iso.channel.GZIPChannel)4 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)4 PostChannel (org.jpos.iso.channel.PostChannel)3 PostPackager (org.jpos.iso.packager.PostPackager)3 XMLPackager (org.jpos.iso.packager.XMLPackager)3 BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)2 LogChannel (org.jpos.iso.channel.LogChannel)2 PADChannel (org.jpos.iso.channel.PADChannel)2 Base1Packager (org.jpos.iso.packager.Base1Packager)2