Search in sources :

Example 6 with GenericPackager

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

the class VAPChannelTest method testConstructor2.

@Test
public void testConstructor2() throws Throwable {
    ISOPackager p = new GenericPackager();
    VAPChannel vAPChannel = new VAPChannel(p);
    assertEquals("vAPChannel.getIncomingFilters().size()", 0, vAPChannel.getIncomingFilters().size());
    assertEquals("vAPChannel.getMaxPacketLength()", 100000, vAPChannel.getMaxPacketLength());
    assertSame("vAPChannel.getPackager()", p, vAPChannel.getPackager());
    assertEquals("vAPChannel.getPort()", 0, vAPChannel.getPort());
    assertEquals("vAPChannel.getName()", "", vAPChannel.getName());
    assertEquals("vAPChannel.getCounters().length", 3, vAPChannel.getCounters().length);
    assertNull("vAPChannel.getLogger()", vAPChannel.getLogger());
    assertNull("vAPChannel.getSocketFactory()", vAPChannel.getSocketFactory());
    assertNull("vAPChannel.getHeader()", vAPChannel.getHeader());
    assertEquals("vAPChannel.getOutgoingFilters().size()", 0, vAPChannel.getOutgoingFilters().size());
    assertNull("vAPChannel.getServerSocket()", vAPChannel.getServerSocket());
    assertEquals("vAPChannel.getOriginalRealm()", "org.jpos.iso.channel.VAPChannel", vAPChannel.getOriginalRealm());
    assertNull("vAPChannel.getRealm()", vAPChannel.getRealm());
    assertNull("vAPChannel.getHost()", vAPChannel.getHost());
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) GenericPackager(org.jpos.iso.packager.GenericPackager) Test(org.junit.Test)

Example 7 with GenericPackager

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

the class ISOMsg2Test method testSetThrowsNullPointerException.

@Test
public void testSetThrowsNullPointerException() throws Throwable {
    ISOMsg iSOMsg = new ISOMsg();
    iSOMsg.setPackager(new GenericPackager());
    try {
        iSOMsg.set(100, "testISOMsgValue");
    // fixed in 1.6.8 fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
        assertEquals("iSOMsg.fields.size()", 0, iSOMsg.fields.size());
        assertEquals("iSOMsg.maxField", -1, iSOMsg.maxField);
        assertTrue("iSOMsg.dirty", iSOMsg.dirty);
        assertTrue("iSOMsg.maxFieldDirty", iSOMsg.maxFieldDirty);
    }
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) Test(org.junit.Test)

Example 8 with GenericPackager

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

the class ISOMsg2Test method testWriteExternal.

@Test
public void testWriteExternal() throws Throwable {
    ObjectOutput out = new ObjectOutputStream(new ByteArrayOutputStream());
    ISOMsg iSOMsg = new ISOMsg("testISOMsgMti");
    iSOMsg.setPackager(new GenericPackager());
    iSOMsg.writeExternal(out);
    assertNull("iSOMsg.header", iSOMsg.header);
// int actual = ;
}
Also used : ObjectOutput(java.io.ObjectOutput) GenericPackager(org.jpos.iso.packager.GenericPackager) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Test(org.junit.Test)

Example 9 with GenericPackager

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

the class EMVTagSequenceTest method testPacking.

@Test
public void testPacking() throws ISOException, FileNotFoundException, UnknownTagNumberException {
    ISOMsg msg = new ISOMsg("0100");
    EMVTagSequence tagValueSequence = new EMVTagSequence();
    tagValueSequence.add(new LiteralEMVTag(EMVStandardTagType.APPLICATION_PRIMARY_ACCOUNT_NUMBER_0x5A, "999999123456789"));
    tagValueSequence.add(new LiteralEMVTag(EMVStandardTagType.APPLICATION_PREFERRED_NAME_0x9F12, "JPOS"));
    tagValueSequence.add(new LiteralEMVTag(EMVStandardTagType.APPLICATION_LABEL_0x50, "Q2"));
    tagValueSequence.add(new LiteralEMVTag(EMVStandardTagType.TRANSACTION_CURRENCY_CODE_0x5F2A, "840"));
    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/emv-tlv-packager.xml"));
    msg.setPackager(packager);
    byte[] packed = packager.pack(msg);
    // 30313030
    // 00 00 00 00 00 01 00 00
    // 30 32 30
    // 50 02 51 32
    // 5a 07 19 96 09 30 00 00 00
    // 9f 12 04 4a 50 4f 53
    System.out.println("Packed: " + ISOUtil.byte2hex(packed));
    // 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", 29, field48Packed.length);
    Assert.assertEquals("Pack error", "3032365a08999999123456789f9f12044a504f53500251325f2a020840", ISOUtil.byte2hex(field48Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    msg.recalcBitMap();
    tagValueSequence = new EMVTagSequence();
    tagValueSequence.readFrom((ISOMsg) msg.getComponent(48));
    Assert.assertEquals("Unpack error", 4, tagValueSequence.getAll().size());
    String tag1 = EMVStandardTagType.APPLICATION_PRIMARY_ACCOUNT_NUMBER_0x5A.getTagNumberHex();
    LiteralEMVTag pan = (LiteralEMVTag) tagValueSequence.getFirst(tag1);
    Assert.assertEquals("Unpack error", "999999123456789", pan.getValue());
    String tag2 = EMVStandardTagType.APPLICATION_PREFERRED_NAME_0x9F12.getTagNumberHex();
    LiteralEMVTag name = (LiteralEMVTag) tagValueSequence.getFirst(tag2);
    Assert.assertEquals("Unpack error", "JPOS", name.getValue());
    String tag3 = EMVStandardTagType.APPLICATION_LABEL_0x50.getTagNumberHex();
    LiteralEMVTag label = (LiteralEMVTag) tagValueSequence.getFirst(tag3);
    Assert.assertEquals("Unpack error", "Q2", label.getValue());
    String tag4 = EMVStandardTagType.TRANSACTION_CURRENCY_CODE_0x5F2A.getTagNumberHex();
    LiteralEMVTag currency = (LiteralEMVTag) tagValueSequence.getFirst(tag4);
    Assert.assertEquals("Unpack error", "840", currency.getValue());
    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", 29, field48Packed.length);
    Assert.assertEquals("Pack error", "3032365a08999999123456789f9f12044a504f53500251325f2a020840", ISOUtil.byte2hex(field48Packed));
}
Also used : EMVTagSequence(org.jpos.emv.EMVTagSequence) ISOMsg(org.jpos.iso.ISOMsg) GenericPackager(org.jpos.iso.packager.GenericPackager) LiteralEMVTag(org.jpos.emv.LiteralEMVTag) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 10 with GenericPackager

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

the class ISOTaggedSequenceTest method testPackingSpanningMultipleFields.

@Test
public void testPackingSpanningMultipleFields() 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"));
    tagValueSequence.add(new LiteralTagValue("0170", "1-800-555-1212"));
    ISOMsg field48 = new ISOMsg(48);
    tagValueSequence.writeTo(field48);
    ISOMsgRef isoMsgRef = new ISOMsgRef(field48);
    msg.set(isoMsgRef.reference(48));
    msg.set(isoMsgRef.reference(62));
    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", 66, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000165001M0023003CT202101700141-800-555-1212", new String(field48Packed));
    msg = new ISOMsg();
    packager.unpack(msg, packed);
    tagValueSequence = new GenericTagSequence();
    tagValueSequence.readFrom((ISOMsg) msg.getComponent(48));
    tagValueSequence.readFrom((ISOMsg) msg.getComponent(62));
    Assert.assertEquals("Unpack error", 4, tagValueSequence.getAll().size());
    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", 66, field48Packed.length);
    Assert.assertEquals("Pack error", "0390012014199609300000000165001M0023003CT202101700141-800-555-1212", 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) ISOMsgRef(org.jpos.tlv.ISOMsgRef) FileInputStream(java.io.FileInputStream) 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