Search in sources :

Example 1 with SMGPSubmitMessage

use of com.zx.sms.codec.smgp.msg.SMGPSubmitMessage in project SMSGate by Lihuanghe.

the class SMGPSessionConnectedHandler method createTestReq.

@Override
protected BaseMessage createTestReq(String content) {
    final EndpointEntity finalentity = getEndpointEntity();
    if (finalentity instanceof ServerEndpoint) {
        SMGPDeliverMessage pdu = new SMGPDeliverMessage();
        pdu.setDestTermId("10086");
        pdu.setMsgContent(content);
        pdu.setSrcTermId("13800138000");
        return pdu;
    } else {
        SMGPSubmitMessage pdu = new SMGPSubmitMessage();
        pdu.setSrcTermId("10086");
        pdu.setDestTermIdArray("13800138000");
        pdu.setMsgContent(content);
        return pdu;
    }
}
Also used : SMGPDeliverMessage(com.zx.sms.codec.smgp.msg.SMGPDeliverMessage) SMGPSubmitMessage(com.zx.sms.codec.smgp.msg.SMGPSubmitMessage) ServerEndpoint(com.zx.sms.connect.manager.ServerEndpoint) EndpointEntity(com.zx.sms.connect.manager.EndpointEntity)

Example 2 with SMGPSubmitMessage

use of com.zx.sms.codec.smgp.msg.SMGPSubmitMessage in project SMSGate by Lihuanghe.

the class TestSMGPSubmitMessage method testerr.

@Test
public // 网络反馈的一个报错的smgp报文
void testerr() {
    byte[] arr = new byte[] { 0, 0, 0, -17, 0, 0, 0, 2, 18, 61, 108, 18, 6, 1, 2, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 48, 49, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 48, 54, 53, 57, 50, 48, 53, 50, 51, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 49, 56, 48, 52, 54, 50, 55, 57, 48, 56, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 5, 0, 3, 52, 1, 1, 48, 16, 78, 45, 83, -97, -108, -10, -120, 76, 48, 17, 92, 10, -115, 53, 118, -124, 91, -94, 98, 55, 0, 44, 0, 32, 98, 17, -120, 76, 95, -82, 79, -31, -108, -10, -120, 76, 87, 48, 87, 64, 78, 58, -1, 26, -1, 12, 78, 45, 83, -97, -108, -10, -120, 76, 122, -19, -117, -38, 78, 58, 96, -88, 103, 13, 82, -95, -1, 12, 121, 93, 96, -88, 117, 31, 109, 59, 97, 9, 95, -21, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
    ByteBuf data = Unpooled.wrappedBuffer(arr);
    try {
        SMGPSubmitMessage result = decode(data);
    } catch (Exception ex) {
        Assert.assertTrue(ex instanceof DecoderException);
    }
}
Also used : DecoderException(io.netty.handler.codec.DecoderException) SMGPSubmitMessage(com.zx.sms.codec.smgp.msg.SMGPSubmitMessage) ByteBuf(io.netty.buffer.ByteBuf) DecoderException(io.netty.handler.codec.DecoderException) Test(org.junit.Test)

Example 3 with SMGPSubmitMessage

use of com.zx.sms.codec.smgp.msg.SMGPSubmitMessage in project SMSGate by Lihuanghe.

the class TestSMGPSubmitMessage method testlongCodec.

public void testlongCodec(SMGPSubmitMessage 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.getCommandId(), buf.readInt());
        buf = (ByteBuf) channel().readOutbound();
    }
    SMGPSubmitMessage result = decode(copybuf);
    Assert.assertNotNull(result);
    System.out.println(result);
    Assert.assertEquals(msg.getMsgContent(), result.getMsgContent());
    Assert.assertEquals(msg.getSrcTermId(), result.getSrcTermId());
    Assert.assertArrayEquals(msg.getDestTermIdArray(), result.getDestTermIdArray());
    Assert.assertEquals(msg.getSrcTermId(), result.getSrcTermId());
}
Also used : SMGPSubmitMessage(com.zx.sms.codec.smgp.msg.SMGPSubmitMessage) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with SMGPSubmitMessage

use of com.zx.sms.codec.smgp.msg.SMGPSubmitMessage in project SMSGate by Lihuanghe.

the class TestSMGPSubmitMessage method test2.

@Test
public void test2() {
    SMGPSubmitMessage msg = new SMGPSubmitMessage();
    msg.setDestTermIdArray(new String[] { "13800138000", "13800138001", "13800138002", "13800138003" });
    msg.setLinkId("1023rsd");
    msg.setMsgContent("第一种:通过注解@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作,第一种:通过注解@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作");
    msg.setSrcTermId("10086988");
    msg.setMsgSrc("901988");
    testlongCodec(msg);
}
Also used : SMGPSubmitMessage(com.zx.sms.codec.smgp.msg.SMGPSubmitMessage) Test(org.junit.Test)

Example 5 with SMGPSubmitMessage

use of com.zx.sms.codec.smgp.msg.SMGPSubmitMessage in project fastjson by alibaba.

the class Issue2685 method test_field.

public void test_field() throws Exception {
    SMGPSubmitMessage smgpSubmitMessage = new SMGPSubmitMessage();
    smgpSubmitMessage.setSequenceNo(1);
    smgpSubmitMessage.setServiceId("hell");
    // 注释掉可以正常
    smgpSubmitMessage.setMsgContent("hello");
    smgpSubmitMessage.setChargeTermId("123555");
    smgpSubmitMessage.setSrcTermId("10086");
    CmppSubmitResponseMessage submitResponseMessage = new CmppSubmitResponseMessage(1);
    submitResponseMessage.setResult(0);
    submitResponseMessage.setMsgId(new MsgId());
    String smsMsg = JSON.toJSONString(smgpSubmitMessage);
    // System.out.println(smsMsg);
    JSON.addMixInAnnotations(SMGPSubmitMessage.class, Mixin.class);
    smgpSubmitMessage = JSON.parseObject(smsMsg, SMGPSubmitMessage.class);
    assertEquals("hello", smgpSubmitMessage.getMsgContent());
}
Also used : SMGPSubmitMessage(com.zx.sms.codec.smgp.msg.SMGPSubmitMessage) CmppSubmitResponseMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage) MsgId(com.zx.sms.common.util.MsgId)

Aggregations

SMGPSubmitMessage (com.zx.sms.codec.smgp.msg.SMGPSubmitMessage)10 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 SMGPDeliverMessage (com.zx.sms.codec.smgp.msg.SMGPDeliverMessage)3 SMGPDeliverRespMessage (com.zx.sms.codec.smgp.msg.SMGPDeliverRespMessage)2 SMGPSubmitRespMessage (com.zx.sms.codec.smgp.msg.SMGPSubmitRespMessage)2 DecoderException (io.netty.handler.codec.DecoderException)2 CmppSubmitResponseMessage (com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage)1 SMGPActiveTestMessage (com.zx.sms.codec.smgp.msg.SMGPActiveTestMessage)1 SMGPActiveTestRespMessage (com.zx.sms.codec.smgp.msg.SMGPActiveTestRespMessage)1 SMGPBaseMessage (com.zx.sms.codec.smgp.msg.SMGPBaseMessage)1 SMGPExitMessage (com.zx.sms.codec.smgp.msg.SMGPExitMessage)1 SMGPExitRespMessage (com.zx.sms.codec.smgp.msg.SMGPExitRespMessage)1 SMGPLoginMessage (com.zx.sms.codec.smgp.msg.SMGPLoginMessage)1 SMGPLoginRespMessage (com.zx.sms.codec.smgp.msg.SMGPLoginRespMessage)1 SMGPUnknownMessage (com.zx.sms.codec.smgp.msg.SMGPUnknownMessage)1 MsgId (com.zx.sms.common.util.MsgId)1 EndpointEntity (com.zx.sms.connect.manager.EndpointEntity)1 ServerEndpoint (com.zx.sms.connect.manager.ServerEndpoint)1