Search in sources :

Example 16 with ISOFieldPackager

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

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

the class Base1SubFieldPackagerTest method testUnpack.

@Test
public void testUnpack() throws Throwable {
    Base1SubFieldPackager base1SubFieldPackager = new Base1SubFieldPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[3];
    base1SubFieldPackager.setFieldPackager(fld);
    base1SubFieldPackager.setLogger(new Logger(), "testBase1SubFieldPackagerRealm");
    byte[] b = new byte[0];
    int result = base1SubFieldPackager.unpack(new ISOMsg(100), b);
    assertEquals("result", 0, result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Logger(org.jpos.util.Logger) Test(org.junit.Test)

Example 18 with ISOFieldPackager

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

the class CTCSubElementPackagerTest method testUnpackThrowsArrayIndexOutOfBoundsException.

@Test
public void testUnpackThrowsArrayIndexOutOfBoundsException() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[0];
    cTCSubElementPackager.setFieldPackager(fld);
    byte[] b = new byte[1];
    try {
        cTCSubElementPackager.unpack(new ISOMsg(), b);
        fail("Expected ArrayIndexOutOfBoundsException to be thrown");
    } catch (ArrayIndexOutOfBoundsException ex) {
        assertEquals("ex.getMessage()", "0", ex.getMessage());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 19 with ISOFieldPackager

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

the class CTCSubElementPackagerTest method testUnpackThrowsNullPointerException2.

@Test
public void testUnpackThrowsNullPointerException2() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    fld[0] = new IFA_AMOUNT();
    cTCSubElementPackager.setFieldPackager(fld);
    byte[] b = new byte[3];
    ISOComponent m = new ISOMsg("testCTCSubElementPackagerMti");
    try {
        cTCSubElementPackager.unpack(m, b);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) IFA_AMOUNT(org.jpos.iso.IFA_AMOUNT) ISOMsg(org.jpos.iso.ISOMsg) ISOFieldPackager(org.jpos.iso.ISOFieldPackager) Test(org.junit.Test)

Example 20 with ISOFieldPackager

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

the class CTCSubElementPackagerTest method testPack.

@Test
public void testPack() throws Throwable {
    CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
    ISOFieldPackager[] fld = new ISOFieldPackager[2];
    cTCSubElementPackager.setFieldPackager(fld);
    byte[] result = cTCSubElementPackager.pack(new ISOBinaryField());
    assertEquals("result.length", 0, result.length);
}
Also used : ISOBinaryField(org.jpos.iso.ISOBinaryField) 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