Search in sources :

Example 11 with ISOMsg

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

the class XMLPackagerTest method testCreateISOMsg.

@Test
public void testCreateISOMsg() throws Throwable {
    ISOMsg result = new XMLPackager().createISOMsg();
    assertEquals("result.getDirection()", 0, result.getDirection());
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) Test(org.junit.Test)

Example 12 with ISOMsg

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

the class XMLPackagerTest method testUnpackStream.

@Test
public void testUnpackStream() throws IOException, ISOException {
    String input = "<isomsg><!-- org.jpos.iso.packager.XMLPackager --><header>686561646572</header><field id=\"0\" value=\"0800\"/>" + "<field id=\"7\" value=\"7654321\"/><field id=\"11\" value=\"12345678\"/>" + "<field id=\"12\" value=\"20110224112759\"/><field id=\"24\" value=\"\"/></isomsg>";
    isoMsg.setHeader("header".getBytes());
    isoMsg.setMTI("0800");
    isoMsg.set(7, "7654321");
    isoMsg.set(11, "12345678");
    isoMsg.set(12, "20110224112759");
    isoMsg.set(24, "831");
    ISOMsg result = xMLPackager.createISOMsg();
    xMLPackager.unpack(result, new ByteArrayInputStream(input.getBytes()));
    assertThat(result.getHeader(), is("header".getBytes()));
    assertThat(result.getMTI(), is("0800"));
    assertThat(result.getString(7), is("7654321"));
    assertThat(result.getString(11), is("12345678"));
    assertThat(result.getString(12), is("20110224112759"));
    assertThat(result.getString(24), is(""));
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ByteArrayInputStream(java.io.ByteArrayInputStream) String(java.lang.String) Test(org.junit.Test)

Example 13 with ISOMsg

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

the class PackagerTestCase method updatePackAndUnpack.

private ISOMsg updatePackAndUnpack(ISOMsg m, ISOPackager p) throws Exception {
    Date now = new Date();
    m.setPackager(p);
    m.set(7, ISODate.getDateTime(now));
    m.set(12, ISODate.formatDate(now, "HHmmss"));
    m.set(13, ISODate.formatDate(now, "MMdd"));
    int stan = Integer.parseInt(m.getString(11)) % 1000000;
    if (++stan == 0L)
        stan++;
    m.set(11, Integer.toString(stan));
    m.set(4, Integer.toString(stan));
    ISOMsg m1 = new ISOMsg();
    m1.setPackager(p);
    m1.unpack(m.pack());
    return m1;
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) Date(java.util.Date) ISODate(org.jpos.iso.ISODate)

Example 14 with ISOMsg

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

the class PackagerTestCase method unpack.

private void unpack(byte[] buf, ISOPackager p) throws Exception {
    ISOMsg m = new ISOMsg();
    m.setPackager(p);
    m.unpack(buf);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg)

Example 15 with ISOMsg

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

the class PackagerTestCase method getMsg.

private ISOMsg getMsg(String message) throws Exception {
    FileInputStream fis = new FileInputStream(PREFIX + message + ".xml");
    ISOMsg m = null;
    try {
        byte[] b = new byte[fis.available()];
        fis.read(b);
        m = new ISOMsg();
        m.setPackager(xmlPackager);
        m.unpack(b);
    } finally {
        fis.close();
    }
    return m;
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) FileInputStream(java.io.FileInputStream)

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