Search in sources :

Example 26 with ISOBaseValidator

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

the class ISOBaseValidatingPackagerTest method testValidate10.

@Test
public void testValidate10() throws Throwable {
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new TEST0100(true);
    ISOValidator[] fvlds = new ISOValidator[0];
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    ISOComponent m = new ISOMsg("testISOBaseValidatingPackagerMti");
    ISOMsg result = (ISOMsg) iSOBaseValidatingPackager.validate(m);
    assertSame("result", m, result);
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) 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 27 with ISOBaseValidator

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsNullPointerException.

@Test
public void testValidateThrowsNullPointerException() throws Throwable {
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    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 : ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 28 with ISOBaseValidator

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

the class ISOBaseValidatingPackagerTest method testValidate3.

@Test
public void testValidate3() throws Throwable {
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[1];
    msgVlds[0] = new TEST0100();
    ISOValidator[] fvlds = new ISOValidator[0];
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    ISOMsg m = new ISOMsg("testISOBaseValidatingPackagerMti");
    m.setMTI("testISOBaseValidatingPackagerMti");
    ISOMsg result = (ISOMsg) iSOBaseValidatingPackager.validate(m);
    assertSame("result", m, result);
}
Also used : 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 29 with ISOBaseValidator

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsClassCastException.

@Test
public void testValidateThrowsClassCastException() throws Throwable {
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    ISOValidator[] fvlds = new ISOValidator[2];
    fvlds[0] = 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) Test(org.junit.Test)

Example 30 with ISOBaseValidator

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException3.

@Test
public void testValidateThrowsISOException3() throws Throwable {
    ISOFieldValidator iVA_ALPHANUMNOBLANK = new IVA_ALPHANUMNOBLANK(true, "testISOBaseValidatingPackagerDescription");
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[2] = new TEST0100(true);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[3];
    fvlds[0] = iVA_ALPHANUMNOBLANK;
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    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 : 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)

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