Package com.cloudhopper.smpp.tlv

Examples of com.cloudhopper.smpp.tlv.Tlv


        Assert.assertEquals(0x00, pdu0.getDefaultMsgId());
        Assert.assertEquals(0, pdu0.getShortMessageLength());
        Assert.assertArrayEquals(HexUtil.toByteArray(""), pdu0.getShortMessage());

        Assert.assertEquals(3, pdu0.getOptionalParameters().size());
        Tlv tlv0 = pdu0.getOptionalParameter(SmppConstants.TAG_SOURCE_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv0.getValueAsByte());
        Tlv tlv1 = pdu0.getOptionalParameter(SmppConstants.TAG_DEST_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv1.getValueAsByte());
        Tlv tlv2 = pdu0.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        Assert.assertArrayEquals(HexUtil.toByteArray("404d616964656e6d616e363634207761732069742073617070793f2026526f6d616e7469633f"), tlv2.getValue());

        // interesting -- this example has optional parameters it happened to skip...
        Assert.assertEquals(0, buffer.readableBytes());
    }
View Full Code Here


        Assert.assertEquals(0x00, pdu0.getDefaultMsgId());
        Assert.assertEquals(0, pdu0.getShortMessageLength());
        Assert.assertArrayEquals(HexUtil.toByteArray(""), pdu0.getShortMessage());

        Assert.assertEquals(3, pdu0.getOptionalParameters().size());
        Tlv tlv0 = pdu0.getOptionalParameter(SmppConstants.TAG_SOURCE_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv0.getValueAsByte());
        Tlv tlv1 = pdu0.getOptionalParameter(SmppConstants.TAG_DEST_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv1.getValueAsByte());
        Tlv tlv2 = pdu0.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        Assert.assertArrayEquals(HexUtil.toByteArray("4f6b"), tlv2.getValue());

        // interesting -- this example has optional parameters it happened to skip...
        Assert.assertEquals(0, buffer.readableBytes());
    }
View Full Code Here

        Assert.assertEquals(0x00, pdu0.getDefaultMsgId());
        Assert.assertEquals(0, pdu0.getShortMessageLength());
        Assert.assertArrayEquals(HexUtil.toByteArray(""), pdu0.getShortMessage());

        Assert.assertEquals(3, pdu0.getOptionalParameters().size());
        Tlv tlv0 = pdu0.getOptionalParameter(SmppConstants.TAG_SOURCE_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv0.getValueAsByte());
        Tlv tlv1 = pdu0.getOptionalParameter(SmppConstants.TAG_DEST_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv1.getValueAsByte());
        Tlv tlv2 = pdu0.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        Assert.assertArrayEquals(HexUtil.toByteArray("4f"), tlv2.getValue());

        // interesting -- this example has optional parameters it happened to skip...
        Assert.assertEquals(0, buffer.readableBytes());
    }
View Full Code Here

        Assert.assertEquals(0x00, pdu0.getDefaultMsgId());
        Assert.assertEquals(0, pdu0.getShortMessageLength());
        Assert.assertArrayEquals(HexUtil.toByteArray(""), pdu0.getShortMessage());

        Assert.assertEquals(3, pdu0.getOptionalParameters().size());
        Tlv tlv0 = pdu0.getOptionalParameter(SmppConstants.TAG_SOURCE_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv0.getValueAsByte());
        Tlv tlv1 = pdu0.getOptionalParameter(SmppConstants.TAG_DEST_NETWORK_TYPE);
        Assert.assertEquals(0x01, tlv1.getValueAsByte());
        Tlv tlv2 = pdu0.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        Assert.assertArrayEquals(HexUtil.toByteArray(""), tlv2.getValue());

        // interesting -- this example has optional parameters it happened to skip...
        Assert.assertEquals(0, buffer.readableBytes());
    }
View Full Code Here

        Assert.assertEquals(0x00, pdu0.getDefaultMsgId());
        Assert.assertEquals(0, pdu0.getShortMessageLength());
        Assert.assertNull(pdu0.getShortMessage());
       
       
        Tlv tlv0 = pdu0.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        Assert.assertArrayEquals("Test".getBytes("ISO-8859-1"), tlv0.getValue());

        // interesting -- this example has optional parameters it happened to skip...
        Assert.assertEquals(0, buffer.readableBytes());
    }
View Full Code Here

    public void encodeBindTransceiverRespWithOptionalParams() throws Exception {
        BindTransceiverResp pdu0 = new BindTransceiverResp();
        pdu0.setSequenceNumber(235843);
        pdu0.setCommandStatus(0);
        pdu0.setSystemId("Smsc GW");
        pdu0.setOptionalParameter(new Tlv(SmppConstants.TAG_SC_INTERFACE_VERSION, new byte[] { (byte)0x34 }));

        ChannelBuffer buffer = transcoder.encode(pdu0);
        Assert.assertArrayEquals(HexUtil.toByteArray("0000001d800000090000000000039943536d7363204757000210000134"), BufferHelper.createByteArray(buffer));
    }
View Full Code Here

    public void encodeBindTransmitterRespWithOptionalParams() throws Exception {
        BindTransmitterResp pdu0 = new BindTransmitterResp();
        pdu0.setSequenceNumber(235871);
        pdu0.setCommandStatus(0);
        pdu0.setSystemId("TWITTER");
        pdu0.setOptionalParameter(new Tlv(SmppConstants.TAG_SC_INTERFACE_VERSION, new byte[] { (byte)0x34 }));

        ChannelBuffer buffer = transcoder.encode(pdu0);
        Assert.assertArrayEquals(HexUtil.toByteArray("0000001d80000002000000000003995f54574954544552000210000134"), BufferHelper.createByteArray(buffer));
    }
View Full Code Here

    public void encodeBindReceiverRespWithOptionalParams() throws Exception {
        BindReceiverResp pdu0 = new BindReceiverResp();
        pdu0.setSequenceNumber(235874);
        pdu0.setCommandStatus(0);
        pdu0.setSystemId("twitter");
        pdu0.setOptionalParameter(new Tlv(SmppConstants.TAG_SC_INTERFACE_VERSION, new byte[] { (byte)0x34 }));

        ChannelBuffer buffer = transcoder.encode(pdu0);
        Assert.assertArrayEquals(HexUtil.toByteArray("0000001d80000001000000000003996274776974746572000210000134"), BufferHelper.createByteArray(buffer));
    }
View Full Code Here

        pdu0.setDataCoding((byte)0x00);
        pdu0.setDefaultMsgId((byte)0x00);
        pdu0.setShortMessage(HexUtil.toByteArray("4024232125262f3a"));

        // order is important
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_SOURCE_NETWORK_TYPE, new byte[] { (byte)0x01 }));
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_TYPE, new byte[] { (byte)0x01 }));

        ChannelBuffer buffer = transcoder.encode(pdu0);
        //logger.debug("{}", HexUtil.toHexString(BufferHelper.createByteArray(buffer)));
        Assert.assertArrayEquals(HexUtil.toByteArray("000000400000000500000000000000030002013837363534333231000409343034303400000000000000000000084024232125262F3A000E0001010006000101"), BufferHelper.createByteArray(buffer));
    }
View Full Code Here

        pdu0.setDataCoding((byte)0x00);
        pdu0.setDefaultMsgId((byte)0x00);
        pdu0.setShortMessage(HexUtil.toByteArray("69643a30303539313133393738207375623a30303120646c7672643a303031207375626d697420646174653a3130303231303137333020646f6e6520646174653a3130303231303137333120737461743a44454c49565244206572723a30303020746578743a4024232125262f3a"));

        // order is important
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_SOURCE_NETWORK_TYPE, new byte[] { (byte)0x01 }));
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_TYPE, new byte[] { (byte)0x01 }));
        // NOTE: VERY IMPORTANT -- THIS IS A C-STRING!
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_RECEIPTED_MSG_ID, "38601fa\u0000".getBytes()));
        pdu0.addOptionalParameter(new Tlv(SmppConstants.TAG_MSG_STATE, new byte[] { SmppConstants.STATE_DELIVERED }));

        ChannelBuffer buffer = transcoder.encode(pdu0);
        //logger.debug("{}", HexUtil.toHexString(BufferHelper.createByteArray(buffer)));
        Assert.assertArrayEquals(HexUtil.toByteArray("000000BA00000005000000000000000200010134343935313336313932300001013430343034000400000000000000006E69643A30303539313133393738207375623A30303120646C7672643A303031207375626D697420646174653A3130303231303137333020646F6E6520646174653A3130303231303137333120737461743A44454C49565244206572723A30303020746578743A4024232125262F3A000E0001010006000101001E000833383630316661000427000102"), BufferHelper.createByteArray(buffer));
    }
View Full Code Here

TOP

Related Classes of com.cloudhopper.smpp.tlv.Tlv

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.