Search in sources :

Example 11 with ISOComponent

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

the class VErrorParserTest method testGetVErrors1.

@SuppressWarnings("unchecked")
@Test
public void testGetVErrors1() throws Throwable {
    VErrorParser vErrorParser = new VErrorParser();
    ISOVError FirstError = new ISOVError("testVErrorParserDescription");
    ISOComponent c = new ISOVField(new ISOField(), FirstError);
    Vector result = vErrorParser.getVErrors(c);
    assertEquals("result.size()", 1, result.size());
    assertSame("result.get(0)", FirstError, result.get(0));
}
Also used : ISOField(org.jpos.iso.ISOField) ISOComponent(org.jpos.iso.ISOComponent) ISOVError(org.jpos.iso.ISOVError) ISOVField(org.jpos.iso.ISOVField) Vector(java.util.Vector) Test(org.junit.Test)

Example 12 with ISOComponent

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

the class Base1_BITMAP126Test method testUnpackThrowsArrayIndexOutOfBoundsException.

@Test
public void testUnpackThrowsArrayIndexOutOfBoundsException() throws Throwable {
    byte[] b = new byte[0];
    ISOComponent c = new ISOMsg();
    try {
        new Base1_BITMAP126().unpack(c, b, 100);
        fail("Expected ArrayIndexOutOfBoundsException to be thrown");
    } catch (ArrayIndexOutOfBoundsException ex) {
        assertEquals("ex.getMessage()", "100", ex.getMessage());
        assertEquals("(ISOMsg) c.getDirection()", 0, ((ISOMsg) c).getDirection());
    }
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 13 with ISOComponent

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

the class Base1_BITMAP126Test method testUnpackThrowsNullPointerException.

@Test
public void testUnpackThrowsNullPointerException() throws Throwable {
    Base1_BITMAP126 base1_BITMAP126 = new Base1_BITMAP126(100, "testBase1_BITMAP126Description");
    ISOComponent c = new ISOBinaryField(100);
    try {
        base1_BITMAP126.unpack(c, null, 100);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertNull("(ISOBinaryField) c.getBytes()", ((ISOBinaryField) c).getBytes());
    }
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) ISOBinaryField(org.jpos.iso.ISOBinaryField) Test(org.junit.Test)

Example 14 with ISOComponent

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsNullPointerException4.

@Test
public void testValidateThrowsNullPointerException4() throws Throwable {
    ISOVError FirstError = new ISOVError("testISOBaseValidatingPackagerDescription", "testISOBaseValidatingPackagerRejectCode");
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[1];
    msgVlds[0] = new MSGTEST02();
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUM("testISOBaseValidatingPackagerDescription");
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    ISOComponent m = new ISOVMsg(new ISOMsg(), FirstError);
    try {
        iSOBaseValidatingPackager.validate(m);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) ISOVError(org.jpos.iso.ISOVError) ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 15 with ISOComponent

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

the class CTCSubElementPackager method unpack.

public int unpack(ISOComponent m, byte[] b) throws ISOException {
    LogEvent evt = new LogEvent(this, "unpack");
    int consumed = 0;
    for (int i = 0; consumed < b.length; i++) {
        ISOComponent c = fld[i].createComponent(i);
        consumed += fld[i].unpack(c, b, consumed);
        if (logger != null) {
            evt.addMessage("<unpack fld=\"" + i + "\" packager=\"" + fld[i].getClass().getName() + "\">");
            if (c.getValue() instanceof ISOMsg)
                evt.addMessage(c.getValue());
            else
                evt.addMessage("  <value>" + c.getValue().toString() + "</value>");
            evt.addMessage("</unpack>");
        }
        m.set(c);
    }
    Logger.log(evt);
    return consumed;
}
Also used : ISOComponent(org.jpos.iso.ISOComponent) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent)

Aggregations

ISOComponent (org.jpos.iso.ISOComponent)34 ISOMsg (org.jpos.iso.ISOMsg)25 Test (org.junit.Test)23 ISOVMsg (org.jpos.iso.ISOVMsg)8 ISOException (org.jpos.iso.ISOException)6 LogEvent (org.jpos.util.LogEvent)6 Vector (java.util.Vector)5 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)5 ISOField (org.jpos.iso.ISOField)5 ISOVError (org.jpos.iso.ISOVError)5 Map (java.util.Map)4 ISOBinaryField (org.jpos.iso.ISOBinaryField)4 ISOValidator (org.jpos.iso.ISOValidator)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)3 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)3 ISOTaggedField (org.jpos.tlv.ISOTaggedField)3 TreeMap (java.util.TreeMap)2 ConfigurationException (org.jpos.core.ConfigurationException)2