Lines Matching refs:buffer

43      * Helper function for writing a ProtocolPortTuple into a buffer.
45 * @param buffer The buffer to write to
48 private void appendProtocolPortTuple(ByteBuffer buffer, ProtocolPortTuple tuple) {
49 buffer.put((byte) tuple.getProtocol());
50 buffer.putShort((short) tuple.getPort());
51 buffer.put((byte) tuple.getStatus());
55 * Helper function for generating a buffer with test data.
57 * @param tuples Tuples to put in the buffer
61 ByteBuffer buffer = ByteBuffer.allocate(tuples.length * ProtocolPortTuple.RAW_BYTE_SIZE)
64 appendProtocolPortTuple(buffer, tuple);
66 buffer.position(0);
67 return buffer;
72 * when parsing an empty buffer.
84 * Verify that BufferUnderflowException will be thrown when parsing a buffer without
91 ByteBuffer buffer = ByteBuffer.allocate(ProtocolPortTuple.RAW_BYTE_SIZE - 1);
92 buffer.put(new byte[ProtocolPortTuple.RAW_BYTE_SIZE - 1]);
93 buffer.position(0);
94 HSConnectionCapabilityElement.parse(buffer);
98 * Verify that BufferUnderflowException will be thrown when parsing a buffer that contained
105 // Construct a buffer which will contained a tuple and an extra byte at the end.
106 ByteBuffer buffer = ByteBuffer.allocate(ProtocolPortTuple.RAW_BYTE_SIZE + 1);
107 appendProtocolPortTuple(buffer, TEST_TUPLE1);
108 buffer.put((byte) 0);
109 buffer.position(0);
110 HSConnectionCapabilityElement.parse(buffer);
115 * a buffer containing the test data.
121 ByteBuffer buffer = getTestBuffer(new ProtocolPortTuple[] {TEST_TUPLE1, TEST_TUPLE2});
129 assertEquals(expected, HSConnectionCapabilityElement.parse(buffer));