use of javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM_TYPE in project component-runtime by Talend.
the class ComponentResourceTest method getDependency.
@Test
void getDependency(final TestInfo info, final TemporaryFolder folder) {
final Function<String, File> download = id -> {
final InputStream stream = base.path("component/dependency/{id}").resolveTemplate("id", id).request(APPLICATION_OCTET_STREAM_TYPE).get(InputStream.class);
final File file = new File(folder.getRoot(), info.getTestMethod().get().getName() + ".jar");
try (final OutputStream outputStream = new FileOutputStream(file)) {
IO.copy(stream, outputStream);
} catch (final IOException e) {
throw new IllegalStateException(e);
}
return file;
};
final Consumer<File> jarValidator = file -> {
assertTrue(file.exists());
try (final JarFile jar = new JarFile(file)) {
assertTrue(jar.entries().hasMoreElements());
} catch (final IOException e) {
fail(e.getMessage());
}
};
final File zipLock = download.apply("org.apache.tomee:ziplock:jar:7.0.4");
jarValidator.accept(zipLock);
final File component = download.apply(client.getJdbcId());
jarValidator.accept(component);
}
Aggregations