Search in sources :

Example 1 with ISOValidator

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

the class CTCSubFieldPackagerTest method testValidateThrowsNullPointerException3.

@Test(expected = NullPointerException.class)
public void testValidateThrowsNullPointerException3() throws Throwable {
    CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager();
    cTCSubFieldPackager.setLogger(Logger.getLogger(""), "testCTCSubFieldPackagerRealm");
    ISOValidator[] fvlds = new ISOValidator[2];
    cTCSubFieldPackager.setFieldValidator(fvlds);
    cTCSubFieldPackager.validate(new ISOMsg("testCTCSubFieldPackagerMti"));
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) Test(org.junit.Test)

Example 2 with ISOValidator

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

Example 3 with ISOValidator

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

Example 4 with ISOValidator

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException5.

@Test
public void testValidateThrowsISOException5() throws Throwable {
    ISOValidator[] fvlds = new ISOValidator[1];
    fvlds[0] = new IVA_ALPHANUMNOZERO_NOBLANK();
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[1] = new TEST0100();
    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());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) IVA_ALPHANUMNOZERO_NOBLANK(org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK) Test(org.junit.Test)

Example 5 with ISOValidator

use of org.jpos.iso.ISOValidator 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)

Aggregations

ISOValidator (org.jpos.iso.ISOValidator)19 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)18 ISOMsg (org.jpos.iso.ISOMsg)18 Test (org.junit.Test)18 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)9 TEST0100 (org.jpos.iso.validator.TEST0100)8 ISOComponent (org.jpos.iso.ISOComponent)4 ISOVMsg (org.jpos.iso.ISOVMsg)4 MSGTEST (org.jpos.iso.validator.MSGTEST)4 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)4 ISOException (org.jpos.iso.ISOException)3 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)2 ISOVError (org.jpos.iso.ISOVError)1 IVA_ALPHANUMNOZERO_NOBLANK (org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK)1 ISOVException (org.jpos.iso.validator.ISOVException)1 LogEvent (org.jpos.util.LogEvent)1