use of com.zx.sms.common.util.MsgId in project SMSGate by Lihuanghe.
the class TestSMPP2CMPPDeliverCodec method createTestReq.
private CmppDeliverRequestMessage createTestReq(String content) {
Header header = new DefaultHeader();
// 取时间,用来查看编码解码时间
CmppDeliverRequestMessage msg = new CmppDeliverRequestMessage(header);
msg.setDestId("13800138000");
msg.setLinkid("0000");
// 70个汉字
msg.setMsgContent(content);
msg.setMsgId(new MsgId());
msg.setServiceid("10086");
msg.setSrcterminalId("13800138000");
msg.setSrcterminalType((short) 1);
header.setSequenceId((int) System.nanoTime());
return msg;
}
use of com.zx.sms.common.util.MsgId in project SMSGate by Lihuanghe.
the class TestSMPP2CMPPSubmitCodec method testCodec.
@Test
public void testCodec() {
CmppSubmitRequestMessage msg = new CmppSubmitRequestMessage();
msg.setDestterminalId(new String[] { "13800138000" });
msg.setLinkID("0000");
msg.setMsgContent("123");
msg.setMsgid(new MsgId());
msg.setServiceId("10086");
msg.setSrcId("10086");
ByteBuf buf = encode(msg);
ByteBuf copybuf = buf.copy();
int length = buf.readableBytes();
CmppSubmitRequestMessage result = decode(copybuf);
Assert.assertEquals(msg.getHeader().getSequenceId(), result.getHeader().getSequenceId());
Assert.assertEquals(msg.getMsgContent(), result.getMsgContent());
}
use of com.zx.sms.common.util.MsgId in project SMSGate by Lihuanghe.
the class TestMsgId method testmsgid.
@Test
public void testmsgid() throws DecoderException, UnsupportedEncodingException {
// 迈远格式的msgId与标准格式互转
String maiyunMsgid = "9BD88980F32D1C3E";
// String maiyunMsgid = "53265100001FA118";
MsgId msgid = DefaultMsgIdUtil.bytes2MsgId(Hex.decodeHex(maiyunMsgid.toCharArray()));
System.out.println(msgid);
Assert.assertEquals(maiyunMsgid, msgid.toHexString(false));
System.out.println(Hex.encodeHex(SmsPduUtil.getSeptets("Hello world")));
}
use of com.zx.sms.common.util.MsgId in project SMSGate by Lihuanghe.
the class TestMsgId method testperformance.
@Test
public void testperformance() {
System.out.println(new MsgId());
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
new MsgId().toString();
}
long end = System.currentTimeMillis();
System.out.println(end - start);
}
use of com.zx.sms.common.util.MsgId in project SMSGate by Lihuanghe.
the class TestMsgCmppSubmit7FDecoder method testlongCodec.
public void testlongCodec(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");
Map<String, Object> map = new HashMap<String, Object>();
map.put("a", 1);
map.put("b", "adf");
msg.setAttachment((Serializable) map);
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());
Assert.assertTrue(result.getAttachment() instanceof Map);
Map retmap = (Map) result.getAttachment();
Assert.assertEquals("adf", retmap.get("b"));
}
Aggregations