Search in sources :

Example 16 with ISOException

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

the class GenericPackagerTest method testConstructorThrowsISOException1.

@Test
public void testConstructorThrowsISOException1() throws Throwable {
    try {
        new GenericPackager(new ByteArrayInputStream("".getBytes()));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getNested().getClass()", SAXParseException.class, ex.getNested().getClass());
        assertEquals("ex.getNested().getMessage()", "Premature end of file.", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParseException(org.xml.sax.SAXParseException) Test(org.junit.Test)

Example 17 with ISOException

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

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

the class GenericSubFieldPackagerTest method testUnpackThrowsISOException2.

@Test
public void testUnpackThrowsISOException2() throws Throwable {
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    fld[1] = new IFA_LCHAR(0, "testGenericSubFieldPackagerDescription");
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[3];
    try {
        genericSubFieldPackager.unpack(new ISOMsg(100), b);
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem unpacking field -1", 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 19 with ISOException

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

Example 20 with ISOException

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

the class GenericValidatingPackagerTest method testConstructorThrowsISOException1.

@Ignore("test fails - GenericValidatingPackager to be deprecated")
@Test
public void testConstructorThrowsISOException1() throws Throwable {
    try {
        new GenericValidatingPackager(new ByteArrayInputStream("x".getBytes()));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "org.xml.sax.SAXParseException: Content is not allowed in prolog.", ex.getMessage());
        assertEquals("ex.getNested().getMessage()", "Content is not allowed in prolog.", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ByteArrayInputStream(java.io.ByteArrayInputStream) Ignore(org.junit.Ignore) 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