Search in sources :

Example 1 with ISOBaseValidator

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

the class GenericValidatingPackagerTest method testValidateThrowsNullPointerException3.

@Test
public void testValidateThrowsNullPointerException3() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new MSGTEST02();
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[2];
    fvlds[0] = new IVA_ALPHANUMNOBLANK(100, "testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    try {
        genericValidatingPackager.validate(new ISOMsg());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 2 with ISOBaseValidator

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

the class GenericValidatingPackagerTest method testValidateThrowsNullPointerException4.

@Test
public void testValidateThrowsNullPointerException4() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOFieldValidator[] fvlds = new ISOFieldValidator[0];
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[1] = new MSGTEST02();
    genericValidatingPackager.setMsgValidator(msgVlds);
    try {
        genericValidatingPackager.validate(new ISOMsg());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 3 with ISOBaseValidator

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

the class GenericValidatingPackagerTest method testGenericValidatorContentHandlerMakeMsgValidatorArray.

@SuppressWarnings("unchecked")
@Test
public void testGenericValidatorContentHandlerMakeMsgValidatorArray() throws Throwable {
    GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler();
    Vector vector = new Vector();
    vector.add(null);
    Hashtable tab = new Hashtable(100);
    tab.put(Integer.valueOf(-3), vector);
    ISOBaseValidator[] result = genericValidatorContentHandler.makeMsgValidatorArray(tab);
    assertEquals("result.length", 1, result.length);
    assertNull("result[0]", result[0]);
}
Also used : Hashtable(java.util.Hashtable) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) Vector(java.util.Vector) Test(org.junit.Test)

Example 4 with ISOBaseValidator

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

the class GenericValidatingPackagerTest method testValidateThrowsISOException.

@Test
public void testValidateThrowsISOException() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUMNOBLANK("testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = new TEST0100();
    genericValidatingPackager.setMsgValidator(msgVlds);
    try {
        genericValidatingPackager.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 : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 5 with ISOBaseValidator

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

the class GenericValidatingPackagerTest method testValidate6.

@Test
public void testValidate6() throws Throwable {
    ISOBaseValidator mSGTEST = new MSGTEST(false);
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator mSGTEST2 = new MSGTEST(false);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = mSGTEST2;
    msgVlds[1] = mSGTEST;
    msgVlds[2] = mSGTEST2;
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUM("testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOVMsg result = (ISOVMsg) genericValidatingPackager.validate(new ISOMsg(100));
    assertNotNull("result", result);
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) 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) Test(org.junit.Test)

Aggregations

ISOBaseValidator (org.jpos.iso.ISOBaseValidator)32 Test (org.junit.Test)31 ISOMsg (org.jpos.iso.ISOMsg)30 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)22 ISOValidator (org.jpos.iso.ISOValidator)18 TEST0100 (org.jpos.iso.validator.TEST0100)12 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOException (org.jpos.iso.ISOException)8 ISOVMsg (org.jpos.iso.ISOVMsg)8 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)7 ISOComponent (org.jpos.iso.ISOComponent)5 IVA_ALPHANUM (org.jpos.iso.IVA_ALPHANUM)5 ISOVException (org.jpos.iso.validator.ISOVException)3 ISOVError (org.jpos.iso.ISOVError)2 IVA_ALPHANUMNOZERO_NOBLANK (org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK)2 Hashtable (java.util.Hashtable)1 Vector (java.util.Vector)1 LogEvent (org.jpos.util.LogEvent)1