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());
}
}
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());
}
}
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());
}
}
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);
}
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());
}
}
Aggregations