Search in sources :

Example 26 with ISOField

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

the class ISOMultiFieldPackagerTest method testPackList.

public void testPackList() throws Exception {
    Vector list = new Vector();
    list.add(new IFB_LLNUM(10, "Should not be this", true));
    list.add(new IFE_LLNUM(10, "Should be 041234"));
    list.add(new IFB_LLNUM(10, "The one to pack", true));
    ISOMultiFieldPackager packager = new ISOMultiFieldPackager("Should be 041234", list);
    packager.hint("The one to pack");
    ISOField field = new ISOField(12, "1234");
    TestUtils.assertEquals(new byte[] { (byte) 0x04, (byte) 0x12, (byte) 0x34 }, packager.pack(field));
}
Also used : ISOField(org.jpos.iso.ISOField) ISOMultiFieldPackager(org.jpos.iso.packager.ISOMultiFieldPackager) IFB_LLNUM(org.jpos.iso.IFB_LLNUM) Vector(java.util.Vector) IFE_LLNUM(org.jpos.iso.IFE_LLNUM)

Example 27 with ISOField

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

the class VISA1PackagerTest method testPackThrowsISOException.

public void testPackThrowsISOException() throws Throwable {
    int[] sequence = new int[0];
    try {
        new VISA1Packager(sequence, 100, "testVISA1PackagerBadResultCode", "testVISA1PackagerOkPattern").pack(new ISOField());
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "Can't call VISA1 packager on non ISOMsg", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException)

Example 28 with ISOField

use of org.jpos.iso.ISOField 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 29 with ISOField

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

Example 30 with ISOField

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

the class TEST01001Test method testValidateThrowsClassCastException.

@Test
public void testValidateThrowsClassCastException() throws Throwable {
    TEST0100 tEST0100 = new TEST0100();
    try {
        tEST0100.validate(new ISOField());
        fail("Expected ClassCastException to be thrown");
    } catch (ClassCastException ex) {
        assertEquals("ex.getClass()", ClassCastException.class, ex.getClass());
    }
}
Also used : ISOField(org.jpos.iso.ISOField) Test(org.junit.Test)

Aggregations

ISOField (org.jpos.iso.ISOField)50 Test (org.junit.Test)18 ISOException (org.jpos.iso.ISOException)15 ISOTaggedField (org.jpos.tlv.ISOTaggedField)15 IFB_LLNUM (org.jpos.iso.IFB_LLNUM)6 IFE_LLNUM (org.jpos.iso.IFE_LLNUM)6 ISOMsg (org.jpos.iso.ISOMsg)6 ISOMultiFieldPackager (org.jpos.iso.packager.ISOMultiFieldPackager)6 ISOComponent (org.jpos.iso.ISOComponent)5 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)5 ISOVField (org.jpos.iso.ISOVField)5 Vector (java.util.Vector)4 FileInputStream (java.io.FileInputStream)3 Map (java.util.Map)3 ISOBinaryField (org.jpos.iso.ISOBinaryField)3 ByteBuffer (java.nio.ByteBuffer)2 ISOVError (org.jpos.iso.ISOVError)2 GenericPackager (org.jpos.iso.packager.GenericPackager)2 GenericTagSequence (org.jpos.tlv.GenericTagSequence)2 LiteralTagValue (org.jpos.tlv.LiteralTagValue)2