Search in sources :

Example 6 with ISOFieldValidator

use of org.jpos.iso.ISOFieldValidator 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);
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) IVA_ALPHANUMNOZERO_NOBLANK(org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK) Test(org.junit.Test)

Example 7 with ISOFieldValidator

use of org.jpos.iso.ISOFieldValidator 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());
    }
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) ISOVError(org.jpos.iso.ISOVError) ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 8 with ISOFieldValidator

use of org.jpos.iso.ISOFieldValidator 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());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 9 with ISOFieldValidator

use of org.jpos.iso.ISOFieldValidator in project jPOS by jpos.

the class ISOBaseValidatingPackagerTest method testValidateThrowsClassCastException4.

@Test
public void testValidateThrowsClassCastException4() throws Throwable {
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    ISOValidator[] fvlds = new ISOValidator[3];
    fvlds[0] = new ISOFieldValidator("testISOBaseValidatingPackagerDescription");
    fvlds[1] = new ISOBaseValidator();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    try {
        iSOBaseValidatingPackager.validate(new ISOMsg());
        fail("Expected ClassCastException to be thrown");
    } catch (ClassCastException ex) {
        assertEquals("ex.getClass()", ClassCastException.class, ex.getClass());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 10 with ISOFieldValidator

use of org.jpos.iso.ISOFieldValidator in project jPOS by jpos.

the class ISOBaseValidatingPackagerTest method testValidate12.

@Test
public void testValidate12() throws Throwable {
    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);
    ISOVMsg result = (ISOVMsg) iSOBaseValidatingPackager.validate(new ISOMsg("testISOBaseValidatingPackagerMti"));
    assertNotNull("result", result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Aggregations

ISOFieldValidator (org.jpos.iso.ISOFieldValidator)26 Test (org.junit.Test)25 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)22 ISOMsg (org.jpos.iso.ISOMsg)21 ISOValidator (org.jpos.iso.ISOValidator)9 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)9 MSGTEST (org.jpos.iso.validator.MSGTEST)8 ISOVMsg (org.jpos.iso.ISOVMsg)7 TEST0100 (org.jpos.iso.validator.TEST0100)7 ISOException (org.jpos.iso.ISOException)6 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)6 IVA_ALPHANUM (org.jpos.iso.IVA_ALPHANUM)5 Hashtable (java.util.Hashtable)3 ISOComponent (org.jpos.iso.ISOComponent)3 ISOVException (org.jpos.iso.validator.ISOVException)3 Properties (java.util.Properties)1 ObjectName (javax.management.ObjectName)1 Element (org.jdom2.Element)1 ISOVError (org.jpos.iso.ISOVError)1 IVA_ALPHANUMNOZERO_NOBLANK (org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK)1