Search in sources :

Example 11 with GenericPackager

use of org.jpos.iso.packager.GenericPackager in project jPOS by jpos.

the class ISOTaggedSequenceTest method testPacking.

@Test
public void testPacking() throws ISOException, FileNotFoundException {
    ISOMsg msg = new ISOMsg("0100");
    GenericTagSequence tagValueSequence = new GenericTagSequence();
    tagValueSequence.add(new LiteralTagValue("0012", "19960930000000"));
    tagValueSequence.add(new LiteralTagValue("0165", "M"));
    tagValueSequence.add(new LiteralTagValue("0023", "CT2"));
    ISOMsg field48 = new ISOMsg(48);
    tagValueSequence.writeTo(field48);
    msg.set(field48);
    msg.recalcBitMap();
    GenericPackager packager = new GenericPackager(new FileInputStream("build/resources/test/org/jpos/tlv/tagged-sequence-packager.xml"));
    msg.setPackager(packager);
    byte[] packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    byte[] field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 42, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000165001M0023003CT2", new String(field48Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    msg.recalcBitMap();
    packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 42, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000165001M0023003CT2", new String(field48Packed));
}
Also used : LiteralTagValue(org.jpos.tlv.LiteralTagValue) ISOMsg(org.jpos.iso.ISOMsg) GenericPackager(org.jpos.iso.packager.GenericPackager) GenericTagSequence(org.jpos.tlv.GenericTagSequence) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 12 with GenericPackager

use of org.jpos.iso.packager.GenericPackager in project jPOS by jpos.

the class ISOTaggedSequenceTest method testPackingWithISOField.

@Test
public void testPackingWithISOField() throws ISOException, FileNotFoundException {
    ISOMsg msg = new ISOMsg("0100");
    GenericTagSequence tagValueSequence = new GenericTagSequence();
    ISOMsg field48 = new ISOMsg(48);
    field48.set("12", "19960930000000");
    field48.set("0165", "M");
    field48.set("23", "CT2");
    tagValueSequence.writeTo(field48);
    msg.set(field48);
    msg.recalcBitMap();
    GenericPackager packager = new GenericPackager(new FileInputStream("build/resources/test/org/jpos/tlv/tagged-sequence-packager.xml"));
    msg.setPackager(packager);
    byte[] packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    byte[] field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 42, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000023003CT20165001M", new String(field48Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    msg.recalcBitMap();
    packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 42, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000023003CT20165001M", new String(field48Packed));
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) GenericPackager(org.jpos.iso.packager.GenericPackager) GenericTagSequence(org.jpos.tlv.GenericTagSequence) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 13 with GenericPackager

use of org.jpos.iso.packager.GenericPackager in project jPOS by jpos.

the class ISOTaggedSequenceTest method testPackingWithPrefixes.

@Test
public void testPackingWithPrefixes() throws ISOException, FileNotFoundException {
    ISOMsg msg = new ISOMsg("0100");
    GenericTagSequence tagValueSequence = new GenericTagSequence();
    tagValueSequence.add(new LiteralTagValue("0012", "19960930000000"));
    tagValueSequence.add(new LiteralTagValue("0165", "M"));
    tagValueSequence.add(new LiteralTagValue("0023", "CT2"));
    ISOMsg field63 = new ISOMsg(63);
    field63.set(new ISOField(0, "M"));
    tagValueSequence.writeTo(field63);
    msg.set(field63);
    msg.recalcBitMap();
    GenericPackager packager = new GenericPackager(new FileInputStream("build/resources/test/org/jpos/tlv/tagged-sequence-packager.xml"));
    msg.setPackager(packager);
    byte[] packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    byte[] field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 43, field48Packed.length);
    Assert.assertEquals("Pack error", "040M0012014199609300000000165001M0023003CT2", new String(field48Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    field48Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field48Packed, 0, field48Packed.length);
    Assert.assertEquals("Pack error", 43, field48Packed.length);
    Assert.assertEquals("Pack error", "040M0012014199609300000000165001M0023003CT2", new String(field48Packed));
}
Also used : LiteralTagValue(org.jpos.tlv.LiteralTagValue) ISOField(org.jpos.iso.ISOField) ISOMsg(org.jpos.iso.ISOMsg) GenericPackager(org.jpos.iso.packager.GenericPackager) GenericTagSequence(org.jpos.tlv.GenericTagSequence) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 14 with GenericPackager

use of org.jpos.iso.packager.GenericPackager in project jPOS by jpos.

the class ISOTaggedSequenceTest method testPacking2.

@Test
public void testPacking2() throws ISOException, FileNotFoundException {
    ISOMsg msg = new ISOMsg("0100");
    GenericTagSequence tagValueSequence = new GenericTagSequence();
    tagValueSequence.add(new LiteralTagValue("12", "A"));
    ISOMsg field64 = new ISOMsg(64);
    field64.set(new ISOField(0, "R"));
    tagValueSequence.writeTo(field64);
    msg.set(field64);
    msg.recalcBitMap();
    GenericPackager packager = new GenericPackager(new FileInputStream("build/resources/test/org/jpos/tlv/tagged-sequence-packager.xml"));
    msg.setPackager(packager);
    byte[] packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    byte[] field64Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field64Packed, 0, field64Packed.length);
    Assert.assertEquals("Pack error", 9, field64Packed.length);
    Assert.assertEquals("Pack error", "006R1201A", new String(field64Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    msg.recalcBitMap();
    packed = packager.pack(msg);
    // skip 4 byte MTI and 8 byte Primary BitMap
    field64Packed = new byte[packed.length - 12];
    System.arraycopy(packed, 12, field64Packed, 0, field64Packed.length);
    Assert.assertEquals("Pack error", 9, field64Packed.length);
    Assert.assertEquals("Pack error", "006R1201A", new String(field64Packed));
}
Also used : LiteralTagValue(org.jpos.tlv.LiteralTagValue) ISOField(org.jpos.iso.ISOField) ISOMsg(org.jpos.iso.ISOMsg) GenericPackager(org.jpos.iso.packager.GenericPackager) GenericTagSequence(org.jpos.tlv.GenericTagSequence) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 15 with GenericPackager

use of org.jpos.iso.packager.GenericPackager in project jPOS by jpos.

the class BaseChannelTest method testSetIncomingFiltersThrowsNullPointerException.

@Test
public void testSetIncomingFiltersThrowsNullPointerException() throws Throwable {
    byte[] TPDU = new byte[0];
    BaseChannel hEXChannel = new HEXChannel("testBaseChannelHost", 100, new GenericPackager(), TPDU);
    try {
        hEXChannel.setIncomingFilters(null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertEquals("(HEXChannel) hEXChannel.incomingFilters.size()", 0, ((HEXChannel) hEXChannel).incomingFilters.size());
    }
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) HEXChannel(org.jpos.iso.channel.HEXChannel) Test(org.junit.Test)

Aggregations

GenericPackager (org.jpos.iso.packager.GenericPackager)20 Test (org.junit.Test)20 ISOMsg (org.jpos.iso.ISOMsg)7 FileInputStream (java.io.FileInputStream)6 GenericTagSequence (org.jpos.tlv.GenericTagSequence)5 LiteralTagValue (org.jpos.tlv.LiteralTagValue)4 ISOPackager (org.jpos.iso.ISOPackager)3 ISOField (org.jpos.iso.ISOField)2 HEXChannel (org.jpos.iso.channel.HEXChannel)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectOutput (java.io.ObjectOutput)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Configuration (org.jpos.core.Configuration)1 SimpleConfiguration (org.jpos.core.SimpleConfiguration)1 SubConfiguration (org.jpos.core.SubConfiguration)1 EMVTagSequence (org.jpos.emv.EMVTagSequence)1 LiteralEMVTag (org.jpos.emv.LiteralEMVTag)1 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)1 CSChannel (org.jpos.iso.channel.CSChannel)1