Search in sources :

Example 36 with CmppSubmitRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage in project SMSGate by Lihuanghe.

the class TestDiffrentMsgFmt method testDecode.

/**
 * 部分客户发送的长短信各个片断的msgfmt不相同。要先根据各自片断的字符编码转码后再合并长短信。
 */
@Test
public void testDecode() throws DecoderException {
    byte[] data = Hex.decodeHex("0000012b0000000455c51d4e43c0ee40261c1d50040100093130303836000000000002000000000000000000000000000000000000000000000108000000000000303130303030303000000000000000000000000000000000000000000000000000000000000000000000313030383600000000000000000000000000000000013133383030313338303030000000000000000000008c050003e404015c0a656c76845ba26237002c60a8597dff0160a84e8e0032003000310036002d00300033002d00320033002000310034003a00350031003a00330036901a8fc74e2d56fd79fb52a8003100300030003800359500552e4e137ebf8ba28d2d768430104e0052a0624b673a9ad86e059632522e4fdd62a4819c3011ff0c8bf770b951fb652f4ed800000000000000000000012b0000000455c51d5143c0ee40261c1d50040200093130303836000000000002000000000000000000000000000000000000000000000108000000000000303130303030303000000000000000000000000000000000000000000000000000000000000000000000313030383600000000000000000000000000000000013133383030313338303030000000000000000000008c050003e404020068007400740070003a002f002f007700770077002e00310030003000380035002e0063006e002f00770065006200380035002f0070006100670065002f007a0079007a0078007000610079002f007700610070005f006f0072006400650072002e00680074006d006c003f006f007200640065007200490064003d0037003600440045004600000000000000000000012b0000000455c51d5243c0ee40261c1d50040300093130303836000000000002000000000000000000000000000000000000000000000108000000000000303130303030303000000000000000000000000000000000000000000000000000000000000000000000313030383600000000000000000000000000000000013133383030313338303030000000000000000000008c050003e40403003900410045003100380030003800460035003000360046004400340045003600430042003700380032004500330042003800450037004500450038003700350045003700360036004400330044003300330035004300205b8c62104e0b535530028bf75728003600305206949f51855b8c6210652f4ed8ff0c59826709759195eeff0c8bf70000000000000000000000ad0000000455c51d5343c0ee40261c1d50040400093130303836000000000002000000000000000000000000000000000000000000000100000000000000303130303030303000000000000000000000000000000000000000000000000000000000000000000000313030383600000000000000000000000000000000013133383030313338303030000000000000000000000e050003e4040461626331303038350000000000000000".toCharArray());
    ByteBuf buf = Unpooled.wrappedBuffer(data);
    ch.writeInbound(buf);
    CmppSubmitRequestMessage result = null;
    boolean success = false;
    while (null != (result = (CmppSubmitRequestMessage) ch.readInbound())) {
        Assert.assertNotNull(result);
        System.out.println(result.getMsgContent());
        Assert.assertEquals(expect, result.getMsgContent());
        success = true;
    }
    Assert.assertTrue(success);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) Test(org.junit.Test)

Example 37 with CmppSubmitRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage in project SMSGate by Lihuanghe.

the class TestLongMessageFrameHolder method testDecode.

@Test
public void testDecode() {
    ByteBuf buf = Unpooled.wrappedBuffer(prepareMsgData());
    ch.writeInbound(buf);
    CmppSubmitRequestMessage result = null;
    boolean success = false;
    while (null != (result = (CmppSubmitRequestMessage) ch.readInbound())) {
        Assert.assertNotNull(result);
        System.out.println(result);
        ch.writeOutbound(result);
        success = true;
    }
    Assert.assertFalse(success);
    ByteBuf bufread;
    while ((bufread = (ByteBuf) ch.readOutbound()) != null) {
        bufread.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) Test(org.junit.Test)

Example 38 with CmppSubmitRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage in project SMSGate by Lihuanghe.

the class TestMsgDataSubmitRequestDecoder2 method testDecodedcsErr.

@Test
public void testDecodedcsErr() {
    byte[] expected = prepareMsgData();
    // 使fmt字段值
    expected[58] = (byte) 0xA8;
    byte[] actuals = new byte[expected.length];
    ByteBuf buf = Unpooled.wrappedBuffer(expected);
    int index = 0;
    ch.writeInbound(buf);
    CmppSubmitRequestMessage result = null;
    while (null != (result = (CmppSubmitRequestMessage) ch.readInbound())) {
        System.out.println(result);
        ByteBuf bytebuf = Unpooled.copiedBuffer(encode(result));
        int lenght = bytebuf.readableBytes();
        System.arraycopy(toArray(bytebuf, bytebuf.readableBytes()), 0, actuals, index, lenght);
        index = lenght;
    }
    Assert.assertArrayEquals(expected, actuals);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) Test(org.junit.Test)

Example 39 with CmppSubmitRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage in project SMSGate by Lihuanghe.

the class TestMsgDataSubmitRequestDecoder2 method testDecode.

// @Test
public void testDecode() {
    byte[] expected = prepareMsgData();
    byte[] actuals = new byte[expected.length];
    ByteBuf buf = Unpooled.wrappedBuffer(expected);
    int index = 0;
    ch.writeInbound(buf);
    CmppSubmitRequestMessage result = null;
    while (null != (result = (CmppSubmitRequestMessage) ch.readInbound())) {
        System.out.println(result);
        ByteBuf bytebuf = Unpooled.copiedBuffer(encode(result));
        int lenght = bytebuf.readableBytes();
        System.arraycopy(toArray(bytebuf, bytebuf.readableBytes()), 0, actuals, index, lenght);
        index = lenght;
    }
    Assert.assertArrayEquals(expected, actuals);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage)

Aggregations

CmppSubmitRequestMessage (com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage)39 Test (org.junit.Test)24 ByteBuf (io.netty.buffer.ByteBuf)21 MsgId (com.zx.sms.common.util.MsgId)9 SmsMessage (org.marre.sms.SmsMessage)6 SmsDcs (org.marre.sms.SmsDcs)5 SmsTextMessage (org.marre.sms.SmsTextMessage)4 SmsWapPushMessage (org.marre.wap.push.SmsWapPushMessage)4 CmppDeliverRequestMessage (com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage)3 CmppSubmitResponseMessage (com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage)3 CmppDeliverResponseMessage (com.zx.sms.codec.cmpp.msg.CmppDeliverResponseMessage)2 CmppQueryRequestMessage (com.zx.sms.codec.cmpp.msg.CmppQueryRequestMessage)2 CmppQueryResponseMessage (com.zx.sms.codec.cmpp.msg.CmppQueryResponseMessage)2 CmppReportRequestMessage (com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2