@Test public void testParseMessageDetectsMissingPayload() { byte[] malformedGetRequest = new byte[] { 0b01000000, 0b00000001, 0x00, 0x10, (byte) 0xFF }; try { parser.parseMessage(malformedGetRequest); fail("Parser should have detected missing payload"); } catch (CoAPMessageFormatException e) { assertEquals(0b00000001, 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);  }