use of org.jpos.iso.ISOComponent in project jPOS by jpos.
the class VErrorParserTest method testGetVErrors1.
@SuppressWarnings("unchecked")
@Test
public void testGetVErrors1() throws Throwable {
VErrorParser vErrorParser = new VErrorParser();
ISOVError FirstError = new ISOVError("testVErrorParserDescription");
ISOComponent c = new ISOVField(new ISOField(), FirstError);
Vector result = vErrorParser.getVErrors(c);
assertEquals("result.size()", 1, result.size());
assertSame("result.get(0)", FirstError, result.get(0));
}
use of org.jpos.iso.ISOComponent in project jPOS by jpos.
the class Base1_BITMAP126Test method testUnpackThrowsArrayIndexOutOfBoundsException.
@Test
public void testUnpackThrowsArrayIndexOutOfBoundsException() throws Throwable {
byte[] b = new byte[0];
ISOComponent c = new ISOMsg();
try {
new Base1_BITMAP126().unpack(c, b, 100);
fail("Expected ArrayIndexOutOfBoundsException to be thrown");
} catch (ArrayIndexOutOfBoundsException ex) {
assertEquals("ex.getMessage()", "100", ex.getMessage());
assertEquals("(ISOMsg) c.getDirection()", 0, ((ISOMsg) c).getDirection());
}
}
use of org.jpos.iso.ISOComponent in project jPOS by jpos.
the class Base1_BITMAP126Test method testUnpackThrowsNullPointerException.
@Test
public void testUnpackThrowsNullPointerException() throws Throwable {
Base1_BITMAP126 base1_BITMAP126 = new Base1_BITMAP126(100, "testBase1_BITMAP126Description");
ISOComponent c = new ISOBinaryField(100);
try {
base1_BITMAP126.unpack(c, null, 100);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
assertNull("(ISOBinaryField) c.getBytes()", ((ISOBinaryField) c).getBytes());
}
}
use of org.jpos.iso.ISOComponent in project jPOS by jpos.
the class ISOBaseValidatingPackagerTest method testValidateThrowsNullPointerException4.
@Test
public void testValidateThrowsNullPointerException4() throws Throwable {
ISOVError FirstError = new ISOVError("testISOBaseValidatingPackagerDescription", "testISOBaseValidatingPackagerRejectCode");
ISOBaseValidator[] msgVlds = new ISOBaseValidator[1];
msgVlds[0] = new MSGTEST02();
ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
fvlds[0] = new IVA_ALPHANUM("testISOBaseValidatingPackagerDescription");
ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
iSOBaseValidatingPackager.setFieldValidator(fvlds);
iSOBaseValidatingPackager.setMsgValidator(msgVlds);
ISOComponent m = new ISOVMsg(new ISOMsg(), FirstError);
try {
iSOBaseValidatingPackager.validate(m);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.jpos.iso.ISOComponent in project jPOS by jpos.
the class CTCSubElementPackager method unpack.
public int unpack(ISOComponent m, byte[] b) throws ISOException {
LogEvent evt = new LogEvent(this, "unpack");
int consumed = 0;
for (int i = 0; consumed < b.length; i++) {
ISOComponent c = fld[i].createComponent(i);
consumed += fld[i].unpack(c, b, consumed);
if (logger != null) {
evt.addMessage("<unpack fld=\"" + i + "\" packager=\"" + fld[i].getClass().getName() + "\">");
if (c.getValue() instanceof ISOMsg)
evt.addMessage(c.getValue());
else
evt.addMessage(" <value>" + c.getValue().toString() + "</value>");
evt.addMessage("</unpack>");
}
m.set(c);
}
Logger.log(evt);
return consumed;
}
Aggregations