Search in sources :

Example 46 with ISOException

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException8.

@Test
public void testUnpackThrowsISOException8() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    fld[1] = new IFA_LLLLCHAR();
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    genericSubFieldPackager.setLogger(new Logger(), "testGenericSubFieldPackagerRealm");
    byte[] b = new byte[5];
    try {
        genericSubFieldPackager.unpack(new ISOMsg(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LLLLCHAR: Problem unpacking field -1", 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) IFA_LLLLCHAR(org.jpos.iso.IFA_LLLLCHAR) Logger(org.jpos.util.Logger) Test(org.junit.Test)

Example 47 with ISOException

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException1.

@Test
public void testUnpackThrowsISOException1() throws Throwable {
    byte[] b = new byte[2];
    try {
        new GenericSubFieldPackager().unpack(new ISOMsg(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 48 with ISOException

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException.

@Test
public void testUnpackThrowsISOException() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[0];
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[2];
    try {
        genericSubFieldPackager.unpack(new ISOMsg(), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
    // assertEquals("ex.getMessage()", "java.lang.ArrayIndexOutOfBoundsException: 1", ex.getMessage());
    // assertEquals("ex.getNested().getMessage()", "1", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 49 with ISOException

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

the class GenericSubFieldPackagerTest method testPackThrowsISOException.

@Test
public void testPackThrowsISOException() throws Throwable {
    try {
        new GenericSubFieldPackager().pack(new ISOMsg());
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 50 with ISOException

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException3.

@Test
public void testUnpackThrowsISOException3() throws Throwable {
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setLogger(new Logger(), "testGenericSubFieldPackagerRealm");
    try {
        genericSubFieldPackager.unpack(new ISOMsg(), (byte[]) null);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage());
        assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) Logger(org.jpos.util.Logger) 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