CompressionUtil { static int seemsCompressible(@NotNull Artifact artifact) { try (InputStream stream = artifact.getInputStream()) { byte[] sample = IOUtils.toByteArray(stream, SAMPLE_LENGTH); return isCompressible(sample, SAMPLE_LENGTH) ? 1 : -1; } catch (RepositoryException | IOException e) { log.warn(e.getMessage(), e); } return 0; }  static int isCompressible(@NotNull Artifact artifact); static final boolean ENV_SUPPORTS_COMPRESSION_LEVEL_CHANGE; }
@Test @Ignore("Because it does not always succeed due to usage of random bytes") public void testCompressibilityEstimation() throws IOException, RepositoryException { assertTrue(seemsCompressible(newArtifact(incompressibleData(50*1024), null)) < 0); assertTrue(seemsCompressible(newArtifact(compressibleData(50*1024), null)) > 0); }