Search in sources :

Example 11 with ISOException

use of org.jpos.iso.ISOException 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 12 with ISOException

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

the class FSDProtectedLogListener method log.

public synchronized LogEvent log(LogEvent ev) {
    synchronized (ev.getPayLoad()) {
        final List<Object> payLoad = ev.getPayLoad();
        int size = payLoad.size();
        for (int i = 0; i < size; i++) {
            Object obj = payLoad.get(i);
            if (obj instanceof FSDISOMsg) {
                FSDISOMsg m = (FSDISOMsg) ((FSDISOMsg) obj).clone();
                try {
                    checkTruncated(m);
                    checkProtected(m);
                    checkHidden(m);
                } catch (ISOException e) {
                    ev.addMessage(e);
                }
                payLoad.set(i, m);
            }
        }
    }
    return ev;
}
Also used : ISOException(org.jpos.iso.ISOException) FSDISOMsg(org.jpos.iso.FSDISOMsg)

Example 13 with ISOException

use of org.jpos.iso.ISOException 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 14 with ISOException

use of org.jpos.iso.ISOException 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 15 with ISOException

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

ISOException (org.jpos.iso.ISOException)66 Test (org.junit.Test)36 ISOMsg (org.jpos.iso.ISOMsg)29 ISOField (org.jpos.iso.ISOField)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)8 IOException (java.io.IOException)7 ISOBinaryField (org.jpos.iso.ISOBinaryField)7 TEST0100 (org.jpos.iso.validator.TEST0100)7 Map (java.util.Map)6 ConfigurationException (org.jpos.core.ConfigurationException)6 ISOComponent (org.jpos.iso.ISOComponent)6 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 LogEvent (org.jpos.util.LogEvent)5 SAXParseException (org.xml.sax.SAXParseException)5 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)4 ISOVException (org.jpos.iso.validator.ISOVException)4 ISOTaggedField (org.jpos.tlv.ISOTaggedField)4 ArrayList (java.util.ArrayList)3