Search in sources :

Example 11 with ISOField

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

the class VErrorParserTest method testGetVErrors1.

@SuppressWarnings("unchecked")
@Test
public void testGetVErrors1() throws Throwable {
    VErrorParser vErrorParser = new VErrorParser();
    ISOVError FirstError = new ISOVError("testVErrorParserDescription");
    ISOComponent c = new ISOVField(new ISOField(), FirstError);
    Vector result = vErrorParser.getVErrors(c);
    assertEquals("result.size()", 1, result.size());
    assertSame("result.get(0)", FirstError, result.get(0));
}
Also used : ISOField(org.jpos.iso.ISOField) ISOComponent(org.jpos.iso.ISOComponent) ISOVError(org.jpos.iso.ISOVError) ISOVField(org.jpos.iso.ISOVField) Vector(java.util.Vector) Test(org.junit.Test)

Example 12 with ISOField

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

the class VErrorParserTest method testGetVErrorsThrowsNullPointerException3.

@Test
public void testGetVErrorsThrowsNullPointerException3() throws Throwable {
    VErrorParser vErrorParser = new VErrorParser();
    ISOVField c = new ISOVField(new ISOField(100, "testVErrorParserv"));
    c.addISOVError(null);
    try {
        vErrorParser.getVErrors(c);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOVField(org.jpos.iso.ISOVField) Test(org.junit.Test)

Example 13 with ISOField

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

the class CTCSubElementPackagerTest method testUnpackThrowsISOException.

@Test
public void testUnpackThrowsISOException() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    cTCSubElementPackager.setFieldPackager(fld);
    cTCSubElementPackager.setLogger(new Logger(), "testCTCSubElementPackagerRealm");
    cTCSubElementPackager.setFieldPackager(0, new IFE_CHAR());
    byte[] b = new byte[2];
    try {
        cTCSubElementPackager.unpack(new ISOVField(new ISOField(100, "testCTCSubElementPackagerv"), null), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "Can't add to Leaf", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException) ISOVField(org.jpos.iso.ISOVField) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Logger(org.jpos.util.Logger) IFE_CHAR(org.jpos.iso.IFE_CHAR) Test(org.junit.Test)

Example 14 with ISOField

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

the class CTCSubElementPackagerTest method testUnpackThrowsNullPointerException.

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

Example 15 with ISOField

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

Aggregations

ISOField (org.jpos.iso.ISOField)50 Test (org.junit.Test)18 ISOException (org.jpos.iso.ISOException)15 ISOTaggedField (org.jpos.tlv.ISOTaggedField)15 IFB_LLNUM (org.jpos.iso.IFB_LLNUM)6 IFE_LLNUM (org.jpos.iso.IFE_LLNUM)6 ISOMsg (org.jpos.iso.ISOMsg)6 ISOMultiFieldPackager (org.jpos.iso.packager.ISOMultiFieldPackager)6 ISOComponent (org.jpos.iso.ISOComponent)5 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)5 ISOVField (org.jpos.iso.ISOVField)5 Vector (java.util.Vector)4 FileInputStream (java.io.FileInputStream)3 Map (java.util.Map)3 ISOBinaryField (org.jpos.iso.ISOBinaryField)3 ByteBuffer (java.nio.ByteBuffer)2 ISOVError (org.jpos.iso.ISOVError)2 GenericPackager (org.jpos.iso.packager.GenericPackager)2 GenericTagSequence (org.jpos.tlv.GenericTagSequence)2 LiteralTagValue (org.jpos.tlv.LiteralTagValue)2