Search in sources :

Example 66 with ISOMsg

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

the class EuroSubFieldPackagerTest method testPack.

@Test
public void testPack() throws Throwable {
    EuroSubFieldPackager euroSubFieldPackager = new EuroSubFieldPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[4];
    euroSubFieldPackager.setFieldPackager(fld);
    byte[] result = euroSubFieldPackager.pack(new ISOMsg(100));
    assertEquals("result.length", 0, result.length);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 67 with ISOMsg

use of org.jpos.iso.ISOMsg 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 68 with ISOMsg

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

the class GenericSubFieldPackagerTest method testReturnsZero.

@Test
public void testReturnsZero() throws Throwable {
    byte[] b = new byte[0];
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setLogger(new Logger(), "testGenericSubFieldPackagerRealm");
    int l = genericSubFieldPackager.unpack(new ISOMsg("testGenericSubFieldPackagerMti"), b);
    assertEquals(0L, (long) l);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) Logger(org.jpos.util.Logger) Test(org.junit.Test)

Example 69 with ISOMsg

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

the class GenericSubFieldPackagerTest method testUnpackReturnsZero1.

@Test
public void testUnpackReturnsZero1() throws Throwable {
    byte[] b = new byte[0];
    ISOFieldPackager[] fld = new ISOFieldPackager[0];
    GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
    genericSubFieldPackager.setFieldPackager(fld);
    genericSubFieldPackager.setLogger(new Logger(), "testGenericSubFieldPackagerRealm");
    int l = genericSubFieldPackager.unpack(new ISOMsg("testGenericSubFieldPackagerMti"), b);
    assertEquals(0L, (long) l);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Logger(org.jpos.util.Logger) Test(org.junit.Test)

Example 70 with ISOMsg

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

the class GenericValidatingPackagerTest method testValidateThrowsNullPointerException3.

@Test
public void testValidateThrowsNullPointerException3() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new MSGTEST02();
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[2];
    fvlds[0] = new IVA_ALPHANUMNOBLANK(100, "testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    try {
        genericValidatingPackager.validate(new ISOMsg());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Aggregations

ISOMsg (org.jpos.iso.ISOMsg)223 Test (org.junit.Test)191 LogEvent (org.jpos.util.LogEvent)41 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)30 ISOException (org.jpos.iso.ISOException)29 ISOComponent (org.jpos.iso.ISOComponent)25 ISOVMsg (org.jpos.iso.ISOVMsg)22 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)21 Context (org.jpos.transaction.Context)20 ISOValidator (org.jpos.iso.ISOValidator)18 Result (org.jpos.rc.Result)17 SimpleConfiguration (org.jpos.core.SimpleConfiguration)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 TEST0100 (org.jpos.iso.validator.TEST0100)12 FileInputStream (java.io.FileInputStream)9 Vector (java.util.Vector)9 PostChannel (org.jpos.iso.channel.PostChannel)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOFilter (org.jpos.iso.ISOFilter)8