@Test public void testDecompress_invalid() { boolean isException = false; String data = "data"; try { GZIPCompressor compressor = new GZIPCompressor(); compressor.decompress(new ByteArrayInputStream(data.getBytes())); } catch (CompressionException e) { isException = true; } Assert.assertTrue(isException); }
public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new GZIPInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { LOG.error("IOException while decompress the data using GZIP compression.", ioe); throw new CompressionException(ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }
GZIPCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new GZIPInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { LOG.error("IOException while decompress the data using GZIP compression.", ioe); throw new CompressionException(ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } } }
GZIPCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new GZIPInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { LOG.error("IOException while decompress the data using GZIP compression.", ioe); throw new CompressionException(ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  }
GZIPCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new GZIPInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { LOG.error("IOException while decompress the data using GZIP compression.", ioe); throw new CompressionException(ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  byte[] compress(final String data, byte[] uploadFile); OutputStream decompress(final InputStream in); }
GZIPCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new GZIPInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { LOG.error("IOException while decompress the data using GZIP compression.", ioe); throw new CompressionException(ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  byte[] compress(final String data, byte[] uploadFile); OutputStream decompress(final InputStream in);  }