use of org.jpos.iso.ISOBaseValidator in project jPOS by jpos.
the class GenericValidatingPackagerTest method testValidate1.
@Test
public void testValidate1() throws Throwable {
GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
ISOFieldValidator[] fvlds = new ISOFieldValidator[2];
fvlds[0] = new ISOFieldValidator();
fvlds[1] = new IVA_ALPHANUMNOZERO_NOBLANK();
genericValidatingPackager.setFieldValidator(fvlds);
ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
msgVlds[0] = new MSGTEST();
msgVlds[1] = new ISOBaseValidator();
genericValidatingPackager.setMsgValidator(msgVlds);
ISOMsg m = new ISOMsg("testGenericValidatingPackagerMti");
m.setMTI("testGenericValidatingPackagerMti");
ISOVMsg result = (ISOVMsg) genericValidatingPackager.validate(m);
assertNotNull("result", result);
}
use of org.jpos.iso.ISOBaseValidator in project jPOS by jpos.
the class ISOBaseValidatingPackagerTest method testValidateThrowsNullPointerException2.
@Test
public void testValidateThrowsNullPointerException2() throws Throwable {
ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
msgVlds[0] = new TEST0100();
msgVlds[1] = new MSGTEST();
msgVlds[2] = new MSGTEST02();
ISOValidator[] fvlds = new ISOValidator[0];
iSOBaseValidatingPackager.setFieldValidator(fvlds);
iSOBaseValidatingPackager.setMsgValidator(msgVlds);
ISOMsg m = new ISOMsg();
m.setMTI("testISOBaseValidatingPackagerMti");
m.setRetransmissionMTI();
try {
iSOBaseValidatingPackager.validate(m);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.jpos.iso.ISOBaseValidator 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.ISOBaseValidator in project jPOS by jpos.
the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException.
@Test
public void testValidateThrowsISOException() throws Throwable {
ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
msgVlds[1] = new TEST0100();
ISOValidator[] fvlds = new ISOValidator[0];
iSOBaseValidatingPackager.setFieldValidator(fvlds);
iSOBaseValidatingPackager.setMsgValidator(msgVlds);
try {
iSOBaseValidatingPackager.validate(new ISOMsg());
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "MTI not available", ex.getMessage());
assertNull("ex.getNested()", ex.getNested());
}
}
use of org.jpos.iso.ISOBaseValidator in project jPOS by jpos.
the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException1.
@Test
public void testValidateThrowsISOException1() throws Throwable {
ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
msgVlds[0] = new TEST0100(true);
ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
iSOBaseValidatingPackager.setMsgValidator(msgVlds);
ISOFieldValidator[] fvlds = new ISOFieldValidator[3];
fvlds[0] = new IVA_ALPHANUM();
iSOBaseValidatingPackager.setFieldValidator(fvlds);
try {
iSOBaseValidatingPackager.validate(new ISOMsg(100));
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "can't getMTI on inner message", ex.getMessage());
assertNull("ex.getNested()", ex.getNested());
}
}
Aggregations