Search in sources :

Example 61 with ISOMsg

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

the class CTCSubElementPackagerTest method testPackThrowsISOException.

@Test
public void testPackThrowsISOException() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    cTCSubElementPackager.setFieldPackager(fld);
    try {
        cTCSubElementPackager.pack(new ISOMsg("testCTCSubElementPackagerMti"));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getNested().getClass()", ClassCastException.class, ex.getNested().getClass());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 62 with ISOMsg

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

the class CTCSubElementPackagerTest method testPack1.

@Test
public void testPack1() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[0];
    cTCSubElementPackager.setFieldPackager(fld);
    byte[] result = cTCSubElementPackager.pack(new ISOMsg());
    assertEquals("result.length", 0, result.length);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 63 with ISOMsg

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

the class CTCSubElementPackagerTest method testUnpackThrowsISOException1.

@Test
public void testUnpackThrowsISOException1() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    cTCSubElementPackager.setFieldPackager(fld);
    cTCSubElementPackager.setFieldPackager(0, new IFA_LCHAR());
    byte[] b = new byte[3];
    try {
        cTCSubElementPackager.unpack(new ISOMsg(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem unpacking field 0", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : IFA_LCHAR(org.jpos.iso.IFA_LCHAR) ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 64 with ISOMsg

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

the class CTCSubFieldPackagerTest method testPackThrowsISOException2.

@Test
public void testPackThrowsISOException2() throws Throwable {
    CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[1];
    cTCSubFieldPackager.setFieldPackager(fld);
    try {
        cTCSubFieldPackager.pack(new ISOMsg("testCTCSubFieldPackagerMti"));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "null: null", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 65 with ISOMsg

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

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