@Test public void testBadQos() throws Exception { initHeaderQos(m_buff, 0xAABB, AbstractMessage.QOSType.LEAST_ONE, AbstractMessage.QOSType.MOST_ONE, AbstractMessage.QOSType.MOST_ONE); m_msgdec.decode(null, m_buff, m_results); 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()); }
@Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); SubAckMessage message = new SubAckMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } int remainingLength = message.getRemainingLength(); message.setMessageID(in.readUnsignedShort()); remainingLength -= 2; if (in.readableBytes() < remainingLength ) { in.resetReaderIndex(); return; } for (int i = 0; i < remainingLength; i++) { byte qos = in.readByte(); message.addType(AbstractMessage.QOSType.values()[qos]); } out.add(message); }
SubAckDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); SubAckMessage message = new SubAckMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } int remainingLength = message.getRemainingLength(); message.setMessageID(in.readUnsignedShort()); remainingLength -= 2; if (in.readableBytes() < remainingLength ) { in.resetReaderIndex(); return; } for (int i = 0; i < remainingLength; i++) { byte qos = in.readByte(); message.addType(AbstractMessage.QOSType.values()[qos]); } out.add(message); } }
SubAckDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); SubAckMessage message = new SubAckMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } int remainingLength = message.getRemainingLength(); message.setMessageID(in.readUnsignedShort()); remainingLength -= 2; if (in.readableBytes() < remainingLength ) { in.resetReaderIndex(); return; } for (int i = 0; i < remainingLength; i++) { byte qos = in.readByte(); message.addType(AbstractMessage.QOSType.values()[qos]); } out.add(message); }  }
SubAckDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); SubAckMessage message = new SubAckMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } int remainingLength = message.getRemainingLength(); message.setMessageID(in.readUnsignedShort()); remainingLength -= 2; if (in.readableBytes() < remainingLength ) { in.resetReaderIndex(); return; } for (int i = 0; i < remainingLength; i++) { byte qos = in.readByte(); message.addType(AbstractMessage.QOSType.values()[qos]); } out.add(message); }   }
SubAckDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); SubAckMessage message = new SubAckMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } int remainingLength = message.getRemainingLength(); message.setMessageID(in.readUnsignedShort()); remainingLength -= 2; if (in.readableBytes() < remainingLength ) { in.resetReaderIndex(); return; } for (int i = 0; i < remainingLength; i++) { byte qos = in.readByte(); message.addType(AbstractMessage.QOSType.values()[qos]); } out.add(message); }    }