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());
}
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());
}
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;
}
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;
}
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();
}
}
Aggregations