### Question:
JMSMessage implements Message { @Override public void readMessage(final MessageReader messageReader) { if (blobStoreAPI != null) { BlobStoreLink blobStoreLink; SerializationReader<BlobStoreLink> reader = serializationManager.getReader(BlobStoreLink.class); try (InputStream inputStream = getInputStream(false)) { blobStoreLink = reader.readObject(inputStream); } catch (IOException e) { throw new IllegalStateException(e); } if (blobStoreAPI.isExists(blobStoreLink.getNamespace(), blobStoreLink.getKey())) { blobStoreAPI.readBlob(blobStoreLink.getNamespace(), blobStoreLink.getKey(), in -> { if (gzip) { try (GZIPInputStream gzipInputStream = new GZIPInputStream(in)) { messageReader.read(gzipInputStream); } catch (IOException e) { throw new IllegalStateException(e); } } else { messageReader.read(in); } }); } else { throw new IllegalStateException( "Failed reading message with id (id doesn't exist)" + blobStoreLink.getNamespace() + ':' + blobStoreLink.getKey()); } } else { try (InputStream jmsBytesMessageInputStream = getInputStream(gzip)) { messageReader.read(jmsBytesMessageInputStream); } catch (IOException e) { throw new IllegalStateException(e); } } } JMSMessage(
            SerializationManager serializationManager,
            javax.jms.Message msg,
            BlobStoreAPI blobStoreAPI,
            boolean logMessageWhileReading,
            boolean gzip); @Override String getMessageHeader(String headerName); @Override Map<String, String> getMessageHeaders(); @Override String getContextValue(String key); @Override Map<String, String> getMessageContext(); @Override void readMessage(final MessageReader messageReader); @Override Object getUnderlyingMessageObject(); @Override T readObject(Class<T> format);  }### Answer:
@Test public void testThatWeGetGZipStream() throws Exception { try (ByteArrayOutputStream bstream = new ByteArrayOutputStream()) { try (GZIPOutputStream out = new GZIPOutputStream(bstream)) { out.write("{\"a\":1}".getBytes("UTF-8")); out.finish(); JMSMessage jmsMsg = new JMSMessage( new SerializationManagerImpl(), new TestMessage(bstream.toByteArray()), null, false, true); jmsMsg.readMessage(in -> assertTrue(in instanceof GZIPInputStream)); } } }
@Test public void testThatWeGetLoggingStream() throws Exception { try (ByteArrayOutputStream bstream = new ByteArrayOutputStream()) { try (GZIPOutputStream out = new GZIPOutputStream(bstream)) { out.write("{\"a\":1}".getBytes("UTF-8")); out.finish(); JMSMessage jmsMsg = new JMSMessage( new SerializationManagerImpl(), new TestMessage(bstream.toByteArray()), null, true, true); jmsMsg.readMessage(in -> assertTrue(in instanceof LoggingInputStream)); } } }
@Test public void testThatWeGetNormalStream() throws Exception { Message msg = new TestMessage("{\"a\":1}".getBytes("UTF-8")); JMSMessage jmsMsg = new JMSMessage(new SerializationManagerImpl(), msg, null, true, false); jmsMsg.readMessage(in -> assertFalse(in instanceof GZIPInputStream)); }