Search in sources :

Example 31 with CmppSubmitRequestMessage

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

the class TestCmppSubmitRequestMessageCodec method testlongCodec.

public void testlongCodec(CmppSubmitRequestMessage msg) {
    channel().writeOutbound(msg);
    ByteBuf buf = (ByteBuf) channel().readOutbound();
    ByteBuf copybuf = Unpooled.buffer();
    while (buf != null) {
        copybuf.writeBytes(buf.copy());
        int length = buf.readableBytes();
        Assert.assertEquals(length, buf.readInt());
        Assert.assertEquals(msg.getPacketType().getCommandId(), buf.readInt());
        buf = (ByteBuf) channel().readOutbound();
    }
    CmppSubmitRequestMessage result = decode(copybuf);
    System.out.println(result.getMsgContent());
    Assert.assertEquals(msg.getServiceId(), result.getServiceId());
    Assert.assertEquals(msg.getMsgContent(), result.getMsgContent());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage)

Example 32 with CmppSubmitRequestMessage

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

the class TestCmppSubmitRequestMessageCodec method testSIPUSH.

@Test
public void testSIPUSH() {
    CmppSubmitRequestMessage msg = createTestReq("");
    WapSIPush si = new WapSIPush("http://www.baidu.com", "baidu");
    SmsMessage wap = new SmsWapPushMessage(si);
    msg.setMsgContent(wap);
    CmppSubmitRequestMessage result = testWapCodec(msg);
    SmsWapPushMessage smsmsg = (SmsWapPushMessage) result.getSmsMessage();
    WapSIPush actsi = (WapSIPush) smsmsg.getWbxml();
    Assert.assertEquals(si.getUri(), actsi.getUri());
    Assert.assertEquals(si.getMessage(), actsi.getMessage());
}
Also used : SmsWapPushMessage(org.marre.wap.push.SmsWapPushMessage) SmsMessage(org.marre.sms.SmsMessage) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) WapSIPush(org.marre.wap.push.WapSIPush) Test(org.junit.Test)

Example 33 with CmppSubmitRequestMessage

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

the class TestCmppSubmitRequestMessageCodec method testWapCodec.

public CmppSubmitRequestMessage testWapCodec(CmppSubmitRequestMessage msg) {
    channel().writeOutbound(msg);
    ByteBuf buf = (ByteBuf) channel().readOutbound();
    ByteBuf copybuf = Unpooled.buffer();
    while (buf != null) {
        copybuf.writeBytes(buf.copy());
        int length = buf.readableBytes();
        Assert.assertEquals(length, buf.readInt());
        Assert.assertEquals(msg.getPacketType().getCommandId(), buf.readInt());
        buf = (ByteBuf) channel().readOutbound();
    }
    CmppSubmitRequestMessage result = decode(copybuf);
    System.out.println(result);
    Assert.assertEquals(msg.getServiceId(), result.getServiceId());
    Assert.assertTrue(result.getSmsMessage() instanceof SmsMessage);
    return result;
}
Also used : SmsMessage(org.marre.sms.SmsMessage) ByteBuf(io.netty.buffer.ByteBuf) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage)

Example 34 with CmppSubmitRequestMessage

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

the class TestCmppSubmitRequestMessageCodec method createTestReq.

private CmppSubmitRequestMessage createTestReq(String content) {
    // 取时间,用来查看编码解码时间
    CmppSubmitRequestMessage msg = new CmppSubmitRequestMessage();
    msg.setDestterminalId(new String[] { "13800138000" });
    msg.setLinkID("0000");
    msg.setMsgContent(content);
    msg.setMsgid(new MsgId());
    msg.setServiceId("10086");
    msg.setSrcId("10086");
    return msg;
}
Also used : CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) MsgId(com.zx.sms.common.util.MsgId)

Example 35 with CmppSubmitRequestMessage

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

the class Test10085MsgDataSubmitRequestDecoder 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.assertTrue(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)

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