Search in sources :

Example 1 with IFA_LCHAR

use of org.jpos.iso.IFA_LCHAR 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 2 with IFA_LCHAR

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException2.

@Test
public void testUnpackThrowsISOException2() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    fld[1] = new IFA_LCHAR(0, "testGenericSubFieldPackagerDescription");
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[3];
    try {
        genericSubFieldPackager.unpack(new ISOMsg(100), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem unpacking field -1", 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 3 with IFA_LCHAR

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

the class GenericSubFieldPackagerTest method testPackThrowsISOException2.

@Test
public void testPackThrowsISOException2() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[3];
    fld[1] = new IFA_LCHAR(0, "testGenericSubFieldPackagerDescription");
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    try {
        genericSubFieldPackager.pack(new ISOBinaryField(100));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem packing field unknown", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : IFA_LCHAR(org.jpos.iso.IFA_LCHAR) ISOBinaryField(org.jpos.iso.ISOBinaryField) ISOException(org.jpos.iso.ISOException) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Aggregations

IFA_LCHAR (org.jpos.iso.IFA_LCHAR)3 ISOException (org.jpos.iso.ISOException)3 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)3 Test (org.junit.Test)3 ISOMsg (org.jpos.iso.ISOMsg)2 ISOBinaryField (org.jpos.iso.ISOBinaryField)1