当前位置: 首页>>代码示例>>Java>>正文


Java MessageDecoder类代码示例

本文整理汇总了Java中org.apache.mina.filter.codec.demux.MessageDecoder的典型用法代码示例。如果您正苦于以下问题:Java MessageDecoder类的具体用法?Java MessageDecoder怎么用?Java MessageDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageDecoder类属于org.apache.mina.filter.codec.demux包,在下文中一共展示了MessageDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBadFlagUserPwd

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testBadFlagUserPwd() throws UnsupportedEncodingException, Exception {
    m_buff = IoBuffer.allocate(14);
    m_buff.clear().put((byte)(AbstractMessage.CONNECT << 4)).put((byte)12);
    //Proto name
    encodeString(m_buff, "MQIsdp");
    //version
    m_buff.put((byte)3);
    //conn flags
    m_buff.put((byte)0x4E); //sets user to false and password to true
    //keepAlive
    m_buff.put((byte)0).put((byte) 0x0A);
    m_buff.flip();
    
    //Excercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);
    
    assertNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.NOT_OK, res);
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:21,代码来源:ConnectDecoderTest.java

示例2: testBugBadRemainingCalculation

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testBugBadRemainingCalculation() throws Exception {
    byte[] overallMessage = new byte[] {(byte)0x90, 0x03, //fixed header
         0x00, 0x0A, //MSG ID
         0x01}; //QoS array
     m_buff = IoBuffer.allocate(overallMessage.length).setAutoExpand(true);
     m_buff.put(overallMessage);
     m_buff.flip();
     
     //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    SubAckMessage message = (SubAckMessage) m_mockProtoDecoder.getMessage();
    assertEquals(0x0A, message.getMessageID().intValue());
    assertEquals(1, message.types().size());
    assertEquals(AbstractMessage.QOSType.LEAST_ONE, message.types().get(0));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:20,代码来源:SubAckDecoderTest.java

示例3: testHeaderWithMessageID_Payload

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testHeaderWithMessageID_Payload() throws Exception {
    m_buff = IoBuffer.allocate(14).setAutoExpand(true);
    int messageID = 123;
    byte[] payload = new byte[]{0x0A, 0x0B, 0x0C};
    initHeaderWithMessageID_Payload(m_buff, messageID, payload);
    m_buff.flip();

    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    assertEquals("Fake Topic", m_mockProtoDecoder.getMessage().getTopicName());
    assertEquals(messageID, (int) m_mockProtoDecoder.getMessage().getMessageID());
    TestUtils.verifyEquals(payload, m_mockProtoDecoder.getMessage().getPayload());
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:18,代码来源:PublishDecoderTest.java

示例4: testBugOnRealCase

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testBugOnRealCase() throws Exception {
    byte[] overallMessage = new byte[]{0x30, 0x17, //fixed header, 25 byte lenght
        0x00, 0x06, 0x2f, 0x74, 0x6f, 0x70, 0x69, 0x63, //[/topic] string 2 len + 6 content
        0x54, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x79, // [Test my payload] encoding
        0x20, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64};
    m_buff = IoBuffer.allocate(overallMessage.length).setAutoExpand(true);
    m_buff.put(overallMessage);
    m_buff.flip();

    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:17,代码来源:PublishDecoderTest.java

示例5: testDecodeBigContent

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodeBigContent() throws Exception {
    int size = 129;
    IoBuffer payload = TestUtils.generateRandomPayload(size);

    IoBuffer firstPublish = generatePublishQoS0(payload);
    IoBuffer secondPublish = generatePublishQoS0(TestUtils.generateRandomPayload(size));

    IoBuffer doubleMessageBuf = IoBuffer.allocate(size * 2).setAutoExpand(true);
    doubleMessageBuf.put(firstPublish).put(secondPublish).flip();


    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, doubleMessageBuf, m_mockProtoDecoder);

    assertEquals(MessageDecoder.OK, res);
    PublishMessage pubMsg = m_mockProtoDecoder.getMessage();
    assertNotNull(pubMsg);

    res = m_msgdec.decode(null, doubleMessageBuf, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);

    m_buff.flip();
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:27,代码来源:PublishDecoderTest.java

示例6: testDecodable_OK

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodable_OK() {
    m_buff.put((byte)(AbstractMessage.CONNECT << 4))
            .put((byte)0) //0 length
            .flip();
    assertEquals(MessageDecoder.OK , m_msgdec.decodable(null, m_buff));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:8,代码来源:ConnectDecoderTest.java

示例7: testDecodable_NOT_OK

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodable_NOT_OK() {
    m_buff.put((byte)(AbstractMessage.CONNACK << 4))
            .put((byte)0) //0 length
            .flip();
    assertEquals(MessageDecoder.NOT_OK , m_msgdec.decodable(null, m_buff));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:8,代码来源:ConnectDecoderTest.java

示例8: testHeader

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testHeader() throws Exception {
    m_buff = IoBuffer.allocate(14);
    int messageId = 0xAABB;
    initHeader(m_buff, messageId);
    m_buff.flip();
    
    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);
    
    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    assertEquals(messageId, m_mockProtoDecoder.getMessage().getMessageID().intValue());
    assertEquals(AbstractMessage.PUBACK, m_mockProtoDecoder.getMessage().getMessageType());
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:16,代码来源:PubAckDecoderTest.java

示例9: testDecodable_OK

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodable_OK() {
    m_buff.put((byte)(AbstractMessage.CONNACK << 4))
            .put((byte)0) //0 length
            .flip();
    assertEquals(MessageDecoder.OK , m_msgdec.decodable(null, m_buff));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:8,代码来源:ConnAckDecoderTest.java

示例10: testDecodable_NOT_OK

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodable_NOT_OK() {
    m_buff.put((byte)(AbstractMessage.CONNECT << 4))
            .put((byte)0) //0 length
            .flip();
    assertEquals(MessageDecoder.NOT_OK , m_msgdec.decodable(null, m_buff));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:8,代码来源:ConnAckDecoderTest.java

示例11: testHeader

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testHeader() throws Exception {
    m_buff = IoBuffer.allocate(14);
    initHeader(m_buff);
    m_buff.flip();
    
    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);
    
    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    assertEquals(ConnAckMessage.CONNECTION_ACCEPTED, m_mockProtoDecoder.getMessage().getReturnCode());
    assertEquals(AbstractMessage.CONNACK, m_mockProtoDecoder.getMessage().getMessageType());
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:15,代码来源:ConnAckDecoderTest.java

示例12: testDecodable_OK

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testDecodable_OK() {
    m_buff.put((byte) (AbstractMessage.PUBLISH << 4))
            .put((byte) 0) //0 length
            .flip();
    assertEquals(MessageDecoder.OK, m_msgdec.decodable(null, m_buff));
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:8,代码来源:PublishDecoderTest.java

示例13: testHeader

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testHeader() throws Exception {
    m_buff = IoBuffer.allocate(14);
    initHeader(m_buff);
    m_buff.flip();

    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    assertEquals("Fake Topic", m_mockProtoDecoder.getMessage().getTopicName());
    assertNull(m_mockProtoDecoder.getMessage().getMessageID());
    assertEquals(AbstractMessage.PUBLISH, m_mockProtoDecoder.getMessage().getMessageType());
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:16,代码来源:PublishDecoderTest.java

示例14: testHeaderWithMessageID

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
@Test
public void testHeaderWithMessageID() throws Exception {
    m_buff = IoBuffer.allocate(14).setAutoExpand(true);
    int messageID = 123;
    initHeaderWithMessageID(m_buff, messageID);
    m_buff.flip();

    //Exercise
    MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder);

    assertNotNull(m_mockProtoDecoder.getMessage());
    assertEquals(MessageDecoder.OK, res);
    assertEquals("Fake Topic", m_mockProtoDecoder.getMessage().getTopicName());
    assertEquals(messageID, (int) m_mockProtoDecoder.getMessage().getMessageID());
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:16,代码来源:PublishDecoderTest.java

示例15: addDecoder

import org.apache.mina.filter.codec.demux.MessageDecoder; //导入依赖的package包/类
public static void addDecoder(Class t, MessageDecoder encoder){
	if (decoderMap == null ){
		decoderMap = new HashMap<Class, MessageDecoder>();
	}
	decoderMap.put(t, encoder);
}
 
开发者ID:langxianwei,项目名称:iot-plat,代码行数:7,代码来源:MessageCodecRegister.java


注:本文中的org.apache.mina.filter.codec.demux.MessageDecoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。