Search in sources :

Example 36 with ISOException

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

the class VISA1PackagerTest method testUnpackThrowsISOException1.

@Test
public void testUnpackThrowsISOException1() throws Throwable {
    int[] sequence = new int[3];
    VISA1Packager vISA1Packager = new VISA1Packager(sequence, 100, "testVISA1PackagerBadResultCode", "testVISA1PackagerOkPattern");
    byte[] b = new byte[3];
    try {
        vISA1Packager.unpack(new ISOBitMap(100), 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());
        assertSame("vISA1Packager.filter", vISA1Packager, vISA1Packager.filter);
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOBitMap(org.jpos.iso.ISOBitMap) Test(org.junit.Test)

Example 37 with ISOException

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

the class VISA1PackagerTest method testUnpackThrowsISOException.

@Test
public void testUnpackThrowsISOException() throws Throwable {
    int[] sequence = new int[2];
    VISA1Packager vISA1Packager = new VISA1Packager(sequence, 100, "testVISA1PackagerBadResultCode", "testVISA1PackagerOkPattern");
    byte[] bytes = new byte[3];
    try {
        vISA1Packager.unpack(new ISOMsg(100), new ByteArrayInputStream(bytes));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "not implemented", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 38 with ISOException

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

the class X92GenericPackagerTest method testConstructorThrowsISOException.

@Test
public void testConstructorThrowsISOException() throws Throwable {
    byte[] bytes = new byte[1];
    try {
        new X92GenericPackager(new ByteArrayInputStream(bytes));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getNested().getClass()", SAXParseException.class, ex.getNested().getClass());
        assertEquals("ex.getNested().getMessage()", "Content is not allowed in prolog.", ex.getNested().getMessage());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParseException(org.xml.sax.SAXParseException) Test(org.junit.Test)

Example 39 with ISOException

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

the class XMLPackagerTest method testPackException.

@Test
public void testPackException() {
    ISOField field = new ISOField();
    try {
        xMLPackager.pack(field);
        fail("Exception Expected - not an isomsg");
    } catch (ISOException e) {
        assertThat(e.getMessage(), is("cannot pack class org.jpos.iso.ISOField"));
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException) Test(org.junit.Test)

Example 40 with ISOException

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

the class MSGTEST021Test method testValidateThrowsISOException.

@Test
public void testValidateThrowsISOException() throws Throwable {
    try {
        new MSGTEST02().validate(new ISOField());
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "Can't call validate on non Composite", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException) 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