Search in sources :

Example 11 with ISOFieldPackager

use of org.jpos.iso.ISOFieldPackager 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 12 with ISOFieldPackager

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

the class EuroSubFieldPackagerTest method testUnpackThrowsNullPointerException1.

@Test
public void testUnpackThrowsNullPointerException1() throws Throwable {
    EuroSubFieldPackager euroSubFieldPackager = new EuroSubFieldPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[4];
    fld[0] = new IFB_LLLCHAR();
    euroSubFieldPackager.setFieldPackager(fld);
    byte[] b = new byte[3];
    try {
        euroSubFieldPackager.unpack(null, b);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : IFB_LLLCHAR(org.jpos.iso.IFB_LLLCHAR) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 13 with ISOFieldPackager

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

the class GenericPackagerTest method testGetFirstField.

@Test
public void testGetFirstField() throws Throwable {
    GenericPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[3];
    fld[1] = new IFA_BITMAP();
    genericValidatingPackager.setFieldPackager(fld);
    int result = genericValidatingPackager.getFirstField();
    assertEquals("result", 2, result);
}
Also used : IFA_BITMAP(org.jpos.iso.IFA_BITMAP) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 14 with ISOFieldPackager

use of org.jpos.iso.ISOFieldPackager 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 15 with ISOFieldPackager

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

Aggregations

ISOFieldPackager (org.jpos.iso.ISOFieldPackager)28 Test (org.junit.Test)24 ISOException (org.jpos.iso.ISOException)12 ISOMsg (org.jpos.iso.ISOMsg)12 ISOField (org.jpos.iso.ISOField)5 Logger (org.jpos.util.Logger)4 IOException (java.io.IOException)3 IFA_LCHAR (org.jpos.iso.IFA_LCHAR)3 ISOBinaryField (org.jpos.iso.ISOBinaryField)3 ISOComponent (org.jpos.iso.ISOComponent)3 ISOTaggedField (org.jpos.tlv.ISOTaggedField)3 LogEvent (org.jpos.util.LogEvent)3 IFA_AMOUNT (org.jpos.iso.IFA_AMOUNT)2 IFA_LLLLCHAR (org.jpos.iso.IFA_LLLLCHAR)2 IFE_CHAR (org.jpos.iso.IFE_CHAR)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConfigurationException (org.jpos.core.ConfigurationException)1