### Question:
WebSocketUtils { public static byte[] buildResponse(Map<String, String> headers, byte[] data, int offset, int length) { ByteArrayBuilder sb = new ByteArrayBuilder(); String v = headers.get(SC_KEY); if (v != null) { sb.append(v).append(CRLF); } sb.append(headers); if (data != null && length > 0) { sb.append(CRLF).append(data, offset, length); } return sb.toByteArray(); } private  WebSocketUtils(); static Map<String, String> readHeaders(InputStream in, boolean req); static Map<String, String> readHeaders(InputStream in); static String readLine(InputStream in); static byte[] readBody(InputStream in); static byte[] buildResponse(Map<String, String> headers, byte[] data, int offset, int length); static byte[] buildResponse(byte[] headers, byte[] data, int offset, int length); static byte[] buildResponse(byte[] data, int offset, int length); static byte[] buildHeaderLine(String name, String value); static byte[] buildRequest(String method, String url, Map<String, String> headers,
                                      byte[] data, int offset, int length); static boolean isContainingCRLF(String value); static final String URI_KEY; static final String METHOD_KEY; static final String SC_KEY; static final String FLUSHED_KEY; }### Answer:
@Test public void testBuildResponse() { byte[] r = WebSocketUtils.buildResponse(TEST_BODY_BYTES, 0, TEST_BODY_BYTES.length); verifyBytes(CRLF, 0, r, 0, 2); verifyBytes(TEST_BODY_BYTES, 0, r, 2, TEST_BODY_BYTES.length); assertEquals(2 + TEST_BODY_BYTES.length, r.length); r = WebSocketUtils.buildResponse(TEST_HEADERS_BYTES, TEST_BODY_BYTES, 0, TEST_BODY_BYTES.length); verifyBytes(TEST_HEADERS_BYTES, 0, r, 0, TEST_HEADERS_BYTES.length); verifyBytes(CRLF, 0, r, TEST_HEADERS_BYTES.length, 2); verifyBytes(TEST_BODY_BYTES, 0, r, TEST_HEADERS_BYTES.length + 2, TEST_BODY_BYTES.length); assertEquals(TEST_HEADERS_BYTES.length + 2 + TEST_BODY_BYTES.length, r.length); r = WebSocketUtils.buildResponse(TEST_HEADERS_MAP, TEST_BODY_BYTES, 0, TEST_BODY_BYTES.length); verifyBytes(TEST_HEADERS_BYTES, 0, r, 0, TEST_HEADERS_BYTES.length); verifyBytes(TEST_ID_BYTES, 0, r, TEST_HEADERS_BYTES.length, TEST_ID_BYTES.length); verifyBytes(CRLF, 0, r, TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length, 2); verifyBytes(TEST_BODY_BYTES, 0, r, TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length + 2, TEST_BODY_BYTES.length); assertEquals(TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length + 2 + TEST_BODY_BYTES.length, r.length); r = WebSocketUtils.buildResponse(TEST_BODY_BYTES, 3, 3); verifyBytes(CRLF, 0, r, 0, 2); verifyBytes(TEST_BODY_BYTES, 3, r, 2, 3); assertEquals(2 + 3, r.length); }