Search in sources :

Example 76 with ISOMsg

use of org.jpos.iso.ISOMsg 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 77 with ISOMsg

use of org.jpos.iso.ISOMsg 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 78 with ISOMsg

use of org.jpos.iso.ISOMsg 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 79 with ISOMsg

use of org.jpos.iso.ISOMsg 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 80 with ISOMsg

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

ISOMsg (org.jpos.iso.ISOMsg)223 Test (org.junit.Test)191 LogEvent (org.jpos.util.LogEvent)41 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)30 ISOException (org.jpos.iso.ISOException)29 ISOComponent (org.jpos.iso.ISOComponent)25 ISOVMsg (org.jpos.iso.ISOVMsg)22 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)21 Context (org.jpos.transaction.Context)20 ISOValidator (org.jpos.iso.ISOValidator)18 Result (org.jpos.rc.Result)17 SimpleConfiguration (org.jpos.core.SimpleConfiguration)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 TEST0100 (org.jpos.iso.validator.TEST0100)12 FileInputStream (java.io.FileInputStream)9 Vector (java.util.Vector)9 PostChannel (org.jpos.iso.channel.PostChannel)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOFilter (org.jpos.iso.ISOFilter)8