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());
}
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(""));
}
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;
}
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);
}
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;
}
Aggregations