Search in sources :

Example 41 with ISOException

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

the class TEST01001Test method testValidateThrowsISOException.

@Test
public void testValidateThrowsISOException() throws Throwable {
    TEST0100 tEST0100 = new TEST0100();
    try {
        tEST0100.validate(new ISOMsg());
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "MTI not available", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 42 with ISOException

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

the class LoopbackChannelTest method testSendThrowsISOException.

@Test
public void testSendThrowsISOException() throws Throwable {
    LoopbackChannel loopbackChannel = new LoopbackChannel();
    loopbackChannel.setUsable(false);
    try {
        loopbackChannel.send(new ISOMsg(100));
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "unconnected ISOChannel", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
        assertEquals("loopbackChannel.queue.consumerCount()", 0, loopbackChannel.queue.consumerCount());
        assertEquals("loopbackChannel.getCounters().length", 3, loopbackChannel.getCounters().length);
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 43 with ISOException

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

the class CTCSubFieldPackagerTest method testPackThrowsISOException1.

@Test
public void testPackThrowsISOException1() throws Throwable {
    try {
        new CTCSubFieldPackager().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 44 with ISOException

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

the class EuroSubFieldPackagerTest method testPackThrowsISOException1.

@Test
public void testPackThrowsISOException1() throws Throwable {
    try {
        new EuroSubFieldPackager().pack(new ISOMsg("testEuroSubFieldPackagerMti"));
        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 45 with ISOException

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

the class GenericPackagerTest method testReadFileThrowsISOException.

@Test
public void testReadFileThrowsISOException() throws Throwable {
    try {
        new GenericSubFieldPackager().readFile(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)

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