Exemplo n.º 1
0
  @Test
  public void testBugBadRemainingCalculation() throws Exception {
    byte[] overallMessage =
        new byte[] {
          (byte) 0x90,
          0x03, // fixed header
          0x00,
          0x0A, // MSG ID
          0x01
        }; // QoS array
    m_buff = Unpooled.buffer(overallMessage.length);
    m_buff.writeBytes(overallMessage);

    // Exercise
    m_msgdec.decode(null, m_buff, m_results);

    assertFalse(m_results.isEmpty());
    SubAckMessage message = (SubAckMessage) m_results.get(0);
    assertNotNull(message);
    assertEquals(0x0A, message.getMessageID().intValue());
    assertEquals(1, message.types().size());
    assertEquals(AbstractMessage.QOSType.LEAST_ONE, message.types().get(0));
  }
Exemplo n.º 2
0
  @Test
  public void testBadQos() throws Exception {
    initHeaderQos(
        m_buff,
        0xAABB,
        AbstractMessage.QOSType.LEAST_ONE,
        AbstractMessage.QOSType.MOST_ONE,
        AbstractMessage.QOSType.MOST_ONE);

    // Excercise
    m_msgdec.decode(null, m_buff, m_results);

    // Verify
    assertFalse(m_results.isEmpty());
    SubAckMessage message = (SubAckMessage) m_results.get(0);
    assertNotNull(message);
    assertEquals(0xAABB, message.getMessageID().intValue());
    List<AbstractMessage.QOSType> qoses = message.types();
    assertEquals(3, qoses.size());
    assertEquals(AbstractMessage.QOSType.LEAST_ONE, qoses.get(0));
    assertEquals(AbstractMessage.QOSType.MOST_ONE, qoses.get(1));
    assertEquals(AbstractMessage.QOSType.MOST_ONE, qoses.get(2));
    assertEquals(AbstractMessage.SUBACK, message.getMessageType());
  }