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);
}
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());
}
}
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);
}
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());
}
}
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);
}
Aggregations