Search in sources :

Example 6 with ISOFieldPackager

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

the class CTCSubElementPackagerTest method testUnpackThrowsNegativeArraySizeException.

@Test
public void testUnpackThrowsNegativeArraySizeException() throws Throwable {
    byte[] b = new byte[3];
    ISOFieldPackager[] fld = new ISOFieldPackager[3];
    fld[0] = new IFA_LLBNUM();
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    cTCSubElementPackager.setFieldPackager(fld);
    try {
        cTCSubElementPackager.unpack(new ISOBinaryField(), b);
        fail("Expected NegativeArraySizeException to be thrown");
    } catch (NegativeArraySizeException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOBinaryField(org.jpos.iso.ISOBinaryField) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) IFA_LLBNUM(org.jpos.iso.IFA_LLBNUM) Test(org.junit.Test)

Example 7 with ISOFieldPackager

use of org.jpos.iso.ISOFieldPackager 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 8 with ISOFieldPackager

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

the class CTCSubFieldPackagerTest method testUnpackThrowsISOException.

@Test
public void testUnpackThrowsISOException() throws Throwable {
    CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[6];
    fld[0] = new IFA_LLLLCHAR(100, "testCTCSubFieldPackagerDescription");
    cTCSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[4];
    try {
        cTCSubFieldPackager.unpack(new ISOField(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LLLLCHAR: Problem unpacking field 0", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) IFA_LLLLCHAR(org.jpos.iso.IFA_LLLLCHAR) Test(org.junit.Test)

Example 9 with ISOFieldPackager

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

the class CTCSubFieldPackagerTest method testUnpackThrowsNullPointerException.

@Test(expected = NullPointerException.class)
public void testUnpackThrowsNullPointerException() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[4];
    fld[0] = new IFE_CHAR();
    CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager();
    cTCSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[2];
    cTCSubFieldPackager.unpack(null, b);
}
Also used : ISOFieldPackager(org.jpos.iso.ISOFieldPackager) IFE_CHAR(org.jpos.iso.IFE_CHAR) Test(org.junit.Test)

Example 10 with ISOFieldPackager

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

Aggregations

ISOFieldPackager (org.jpos.iso.ISOFieldPackager)28 Test (org.junit.Test)24 ISOException (org.jpos.iso.ISOException)12 ISOMsg (org.jpos.iso.ISOMsg)12 ISOField (org.jpos.iso.ISOField)5 Logger (org.jpos.util.Logger)4 IOException (java.io.IOException)3 IFA_LCHAR (org.jpos.iso.IFA_LCHAR)3 ISOBinaryField (org.jpos.iso.ISOBinaryField)3 ISOComponent (org.jpos.iso.ISOComponent)3 ISOTaggedField (org.jpos.tlv.ISOTaggedField)3 LogEvent (org.jpos.util.LogEvent)3 IFA_AMOUNT (org.jpos.iso.IFA_AMOUNT)2 IFA_LLLLCHAR (org.jpos.iso.IFA_LLLLCHAR)2 IFE_CHAR (org.jpos.iso.IFE_CHAR)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConfigurationException (org.jpos.core.ConfigurationException)1