Search in sources :

Example 6 with ISOBinaryField

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

the class CTCSubElementPackagerTest method testPackThrowsISOException2.

@Test
public void testPackThrowsISOException2() throws Throwable {
    try {
        new CTCSubElementPackager().pack(new ISOBinaryField(100));
        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 : ISOBinaryField(org.jpos.iso.ISOBinaryField) ISOException(org.jpos.iso.ISOException) Test(org.junit.Test)

Example 7 with ISOBinaryField

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

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

the class EuroSubFieldPackagerTest method testUnpackThrowsNullPointerException.

@Test
public void testUnpackThrowsNullPointerException() throws Throwable {
    byte[] b = new byte[3];
    try {
        new EuroSubFieldPackager().unpack(new ISOBinaryField(100), b);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOBinaryField(org.jpos.iso.ISOBinaryField) Test(org.junit.Test)

Example 9 with ISOBinaryField

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException5.

@Test
public void testUnpackThrowsISOException5() throws Throwable {
    byte[] b = new byte[2];
    try {
        new GenericSubFieldPackager().unpack(new ISOBinaryField(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "Can't call packager on non Composite", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOBinaryField(org.jpos.iso.ISOBinaryField) ISOException(org.jpos.iso.ISOException) Test(org.junit.Test)

Example 10 with ISOBinaryField

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

ISOBinaryField (org.jpos.iso.ISOBinaryField)14 Test (org.junit.Test)11 ISOException (org.jpos.iso.ISOException)7 ISOComponent (org.jpos.iso.ISOComponent)4 ISOField (org.jpos.iso.ISOField)3 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)3 ISOMsg (org.jpos.iso.ISOMsg)3 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Vector (java.util.Vector)1 IFA_LCHAR (org.jpos.iso.IFA_LCHAR)1 IFA_LLBNUM (org.jpos.iso.IFA_LLBNUM)1 TLVDataFormat (org.jpos.tlv.TLVDataFormat)1