### Question:
AmqpJmsBytesMessageFacade extends AmqpJmsMessageFacade implements JmsBytesMessageFacade { @Override public InputStream getInputStream() throws JMSException { if (bytesOut != null) { throw new IllegalStateException("Body is being written to, cannot perform a read."); } if (bytesIn == null) { Binary body = getBinaryFromBody(); bytesIn = new ByteBufInputStream( Unpooled.wrappedBuffer(body.getArray(), body.getArrayOffset(), body.getLength())); } return bytesIn; }  @Override AmqpJmsBytesMessageFacade copy(); @Override byte getJmsMsgType(); @Override void clearBody(); @Override InputStream getInputStream(); @Override OutputStream getOutputStream(); @Override void reset(); @Override int getBodyLength(); @Override boolean hasBody(); @Override JmsBytesMessage asJmsMessage(); @Override byte[] copyBody(); @Override void onSend(long producerTtl);  }### Answer:
@Test public void testGetInputStreamWithNewMessageReturnsEmptyInputStream() throws Exception { AmqpJmsBytesMessageFacade amqpBytesMessageFacade = createNewBytesMessageFacade(); InputStream byteArrayInputStream = amqpBytesMessageFacade.getInputStream(); assertNotNull(byteArrayInputStream); assertEquals("Expected input stream to be at end but data was returned", END_OF_STREAM, byteArrayInputStream.read(new byte[1])); }
@Test public void testGetInputStreamReturnsSameStream() throws Exception { AmqpJmsBytesMessageFacade amqpBytesMessageFacade = createNewBytesMessageFacade(); InputStream is1 = amqpBytesMessageFacade.getInputStream(); InputStream is2 = amqpBytesMessageFacade.getInputStream(); assertSame("Got different input streams", is1, is2); }
@Test public void testGetInputStreamUsingReceivedMessageWithNoBodySectionReturnsEmptyInputStream() throws Exception { Message message = Message.Factory.create(); AmqpJmsBytesMessageFacade amqpBytesMessageFacade = createReceivedBytesMessageFacade(createMockAmqpConsumer(), message); InputStream byteArrayInputStream = amqpBytesMessageFacade.getInputStream(); assertNotNull(byteArrayInputStream); assertEquals("Expected input stream to be at end but data was returned", END_OF_STREAM, byteArrayInputStream.read(new byte[1])); }
@Test public void testInputStreamUsingReceivedMessageWithAmqpValueSectionContainingBinary() throws Exception { byte[] bytes = "myBytes".getBytes(); Message message = Message.Factory.create(); message.setBody(new AmqpValue(new Binary(bytes))); AmqpJmsBytesMessageFacade amqpBytesMessageFacade = createReceivedBytesMessageFacade(createMockAmqpConsumer(), message); InputStream bytesStream = amqpBytesMessageFacade.getInputStream(); byte[] receivedBytes = new byte[bytes.length]; bytesStream.read(receivedBytes); assertTrue(Arrays.equals(bytes, receivedBytes)); assertEquals("Expected input stream to be at end but data was returned", END_OF_STREAM, bytesStream.read(new byte[1])); }
@Test public void testInputStreamUsingReceivedMessageWithDataSection() throws Exception { byte[] bytes = "myBytes".getBytes(); Message message = Message.Factory.create(); message.setBody(new Data(new Binary(bytes))); AmqpJmsBytesMessageFacade amqpBytesMessageFacade = createReceivedBytesMessageFacade(createMockAmqpConsumer(), message); InputStream bytesStream = amqpBytesMessageFacade.getInputStream(); assertNotNull(bytesStream); byte[] receivedBytes = new byte[bytes.length]; bytesStream.read(receivedBytes); assertTrue(Arrays.equals(bytes, receivedBytes)); assertEquals("Expected input stream to be at end but data was returned", END_OF_STREAM, bytesStream.read(new byte[1])); }