@Test public void testResponseParsing() { Response response = new Response(ResponseCode.CONTENT); response.setDestinationContext(ENDPOINT_CONTEXT); response.setType(Type.NON); response.setMID(expectedMid); response.setToken(new byte[] { 22, -1, 0, 78, 100, 22 }); response.getOptions().addETag(new byte[] { 1, 0, 0, 0, 0, 1 }) .addLocationPath("/one/two/three/four/five/six/seven/eight/nine/ten") .addOption(new Option(57453, "Arbitrary".hashCode())).addOption(new Option(19205, "Arbitrary1")) .addOption(new Option(19205, "Arbitrary2")).addOption(new Option(19205, "Arbitrary3")); RawData rawData = serializer.serializeResponse(response); Response result = (Response) parser.parseMessage(rawData); assertEquals(response.getMID(), result.getMID()); assertEquals(response.getToken(), result.getToken()); assertEquals(response.getOptions().asSortedList(), result.getOptions().asSortedList()); }
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);  }