### Question:
RtspMessage { public byte[] getRawMessage() { if (body == null) header.removeField("content-length"); else header.addField(new ContentLengthField(body.length)); byte[] h = header.getBytes(); int bodyLen = body == null ? 0 : body.length; byte[] result = new byte[h.length + bodyLen]; System.arraycopy(h, 0, result, 0, h.length); if (body != null) System.arraycopy(body, 0, result, h.length, body.length); return result; } RtspMessage(RtspHeader header, byte[] body);  RtspMessage(int code, String message, int cseq);  RtspMessage(String method, String uri, int cseq); RtspHeader getHeader(); byte[] getBody(); void setBody(byte[] body); String getBodyText(Charset charset); void setBodyText(String text, Charset encoding); byte[] getRawMessage();  }### Answer:
@Test public void testGetRawMessage() { RtspMessage m = new RtspMessage("OPTIONS", "*", 1); m.setBodyText("body", Charset.forName("UTF-8")); byte[][] exp = new byte[][] { "OPTIONS * RTSP/1.0\r\nCSeq:1\r\nContent-Length:4\r\n\r\nbody".getBytes(Charset.forName("UTF-8")), "OPTIONS * RTSP/1.0\r\nContent-Length:4\r\nCSeq:1\r\n\r\nbody".getBytes(Charset.forName("UTF-8")), }; byte[] tmp = m.getRawMessage(); if (!Arrays.equals(exp[0], tmp) && !Arrays.equals(exp[1], tmp)) fail("raw message is not equal to the expected one"); m = new RtspMessage(200, "OK", 1); assertArrayEquals("RTSP/1.0 200 OK\r\nCSeq:1\r\n\r\n".getBytes(Charset.forName("UTF-8")), m.getRawMessage()); }