@Test public void testUnsignedFields() throws IOException { ClientProtocolBuffer buffer = new SafeBuffer(new byte[18]); ClientMessage cmEncode = ClientMessage.createForEncode(buffer, 0); cmEncode.setVersion((short) (Byte.MAX_VALUE + 10)); cmEncode.setMessageType(Short.MAX_VALUE + 10); cmEncode.setDataOffset((int) Short.MAX_VALUE + 10); cmEncode.setCorrelationId(Short.MAX_VALUE + 10); ClientMessage cmDecode = ClientMessage.createForDecode(buffer, 0); assertEquals(Byte.MAX_VALUE + 10, cmDecode.getVersion()); assertEquals(Short.MAX_VALUE + 10, cmDecode.getMessageType()); assertEquals((int) Short.MAX_VALUE + 10, cmDecode.getDataOffset()); }
@Test public void test_wrapForEncode_withLargeBuffer() { ClientMessage.createForEncode(new SafeBuffer(new byte[100]), 10); }
@Test(expected = IndexOutOfBoundsException.class) public void test_wrapForEncode_withSmallBuffer() { ClientMessage.createForEncode(new SafeBuffer(new byte[10]), 1); }
@Test public void test_wrapForEncode_withHeaderSizeBuffer() { ClientMessage.createForEncode(new SafeBuffer(new byte[ClientMessage.HEADER_SIZE]), 0); }
@Test public void test_MutableDirectBuffer_constructor_withLargeBuffer() { SafeBuffer buffer = new SafeBuffer(new byte[100]); ClientMessage.createForEncode(buffer, 10); }
@Test public void test_MutableDirectBuffer_constructor_withHeaderSizeBuffer() { SafeBuffer buffer = new SafeBuffer(new byte[ClientMessage.HEADER_SIZE]); ClientMessage.createForEncode(buffer, 0); }
@Test(expected = IndexOutOfBoundsException.class) public void test_MutableDirectBuffer_constructor_withSmallBuffer() { SafeBuffer buffer = new SafeBuffer(new byte[10]); ClientMessage.createForEncode(buffer, 1); }
@Test public void test_byteArray_constructor_withLargeBuffer() { ClientMessage.createForEncode(new SafeBuffer(new byte[100]), 10); }
@Test public void test_byteArray_constructor_withHeaderSizeBuffer() { ClientMessage.createForEncode(new SafeBuffer(new byte[ClientMessage.HEADER_SIZE]), 0); }