@Test public void testParseMessageDetectsIllegalCode() { byte code = 0b00001000; byte[] malformedRequest = new byte[] { 0b01000000, code, 0x00, 0x10 }; try { parser.parseMessage(malformedRequest); fail("Parser should have detected that message is not a request"); } catch (CoAPMessageFormatException e) { assertEquals(code, e.getCode()); assertEquals(true, e.isConfirmable()); } }
public final Message parseMessage(final RawData raw) { if (raw == null) { throw new NullPointerException("raw-data must not be null!"); } Message message = parseMessage(raw.getBytes()); message.setSourceContext(raw.getEndpointContext()); message.setNanoTimestamp(raw.getReceiveNanoTimestamp()); return message; }
DataParser { public final Message parseMessage(final RawData raw) { if (raw == null) { throw new NullPointerException("raw-data must not be null!"); } Message message = parseMessage(raw.getBytes()); message.setSourceContext(raw.getEndpointContext()); message.setNanoTimestamp(raw.getReceiveNanoTimestamp()); return message; } }
DataParser { public final Message parseMessage(final RawData raw) { if (raw == null) { throw new NullPointerException("raw-data must not be null!"); } Message message = parseMessage(raw.getBytes()); message.setSourceContext(raw.getEndpointContext()); message.setNanoTimestamp(raw.getReceiveNanoTimestamp()); return message; }  }
DataParser { public final Message parseMessage(final RawData raw) { if (raw == null) { throw new NullPointerException("raw-data must not be null!"); } Message message = parseMessage(raw.getBytes()); message.setSourceContext(raw.getEndpointContext()); message.setNanoTimestamp(raw.getReceiveNanoTimestamp()); return message; }  final Message parseMessage(final RawData raw); final Message parseMessage(final byte[] msg); static void parseOptionsAndPayload(DatagramReader reader, Message message); }
DataParser { public final Message parseMessage(final RawData raw) { if (raw == null) { throw new NullPointerException("raw-data must not be null!"); } Message message = parseMessage(raw.getBytes()); message.setSourceContext(raw.getEndpointContext()); message.setNanoTimestamp(raw.getReceiveNanoTimestamp()); return message; }  final Message parseMessage(final RawData raw); final Message parseMessage(final byte[] msg); static void parseOptionsAndPayload(DatagramReader reader, Message message);  }