@Test(expected = IOException.class) public void getIOExceptionFromTempBlob() throws Exception { when(tempBlob.get()).thenReturn(inputStream); when(inputStream.read()).thenThrow(new IOException()); underTest.getJarFromPackGz(tempBlob); }
public InputStream getJarFromPackGz(final TempBlob tempBlob) throws IOException { Path tempFile = createTempFile("pack-file", "jar.pack"); try (GZIPInputStream gzis = new GZIPInputStream(tempBlob.get()); OutputStream os = newOutputStream(tempFile)) { Unpacker unpacker = Pack200.newUnpacker(); try (JarOutputStream jos = new JarOutputStream(os)) { unpacker.unpack(gzis, jos); return newInputStream(tempFile); } } finally { Files.delete(tempFile); } }
TempBlobConverter extends ComponentSupport { public InputStream getJarFromPackGz(final TempBlob tempBlob) throws IOException { Path tempFile = createTempFile("pack-file", "jar.pack"); try (GZIPInputStream gzis = new GZIPInputStream(tempBlob.get()); OutputStream os = newOutputStream(tempFile)) { Unpacker unpacker = Pack200.newUnpacker(); try (JarOutputStream jos = new JarOutputStream(os)) { unpacker.unpack(gzis, jos); return newInputStream(tempFile); } } finally { Files.delete(tempFile); } } }
TempBlobConverter extends ComponentSupport { public InputStream getJarFromPackGz(final TempBlob tempBlob) throws IOException { Path tempFile = createTempFile("pack-file", "jar.pack"); try (GZIPInputStream gzis = new GZIPInputStream(tempBlob.get()); OutputStream os = newOutputStream(tempFile)) { Unpacker unpacker = Pack200.newUnpacker(); try (JarOutputStream jos = new JarOutputStream(os)) { unpacker.unpack(gzis, jos); return newInputStream(tempFile); } } finally { Files.delete(tempFile); } } TempBlobConverter(); }
TempBlobConverter extends ComponentSupport { public InputStream getJarFromPackGz(final TempBlob tempBlob) throws IOException { Path tempFile = createTempFile("pack-file", "jar.pack"); try (GZIPInputStream gzis = new GZIPInputStream(tempBlob.get()); OutputStream os = newOutputStream(tempFile)) { Unpacker unpacker = Pack200.newUnpacker(); try (JarOutputStream jos = new JarOutputStream(os)) { unpacker.unpack(gzis, jos); return newInputStream(tempFile); } } finally { Files.delete(tempFile); } } TempBlobConverter(); InputStream getJarFromPackGz(final TempBlob tempBlob); }
TempBlobConverter extends ComponentSupport { public InputStream getJarFromPackGz(final TempBlob tempBlob) throws IOException { Path tempFile = createTempFile("pack-file", "jar.pack"); try (GZIPInputStream gzis = new GZIPInputStream(tempBlob.get()); OutputStream os = newOutputStream(tempFile)) { Unpacker unpacker = Pack200.newUnpacker(); try (JarOutputStream jos = new JarOutputStream(os)) { unpacker.unpack(gzis, jos); return newInputStream(tempFile); } } finally { Files.delete(tempFile); } } TempBlobConverter(); InputStream getJarFromPackGz(final TempBlob tempBlob);  }