use of java.util.zip.ZipOutputStream in project che by eclipse.
the class ProjectManagerWriteTest method testImportProject.
@Test
public void testImportProject() throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
String fileContent = "to be or not to be";
ZipOutputStream zipOut = new ZipOutputStream(bout);
zipOut.putNextEntry(new ZipEntry("folder1/"));
zipOut.putNextEntry(new ZipEntry("folder1/file1.txt"));
zipOut.putNextEntry(new ZipEntry("file1"));
zipOut.write(fileContent.getBytes());
zipOut.close();
final InputStream zip = new ByteArrayInputStream(bout.toByteArray());
final String importType = "_123_";
registerImporter(importType, zip);
SourceStorage sourceConfig = DtoFactory.newDto(SourceStorageDto.class).withType(importType);
pm.importProject("/testImportProject", sourceConfig, false, () -> new ProjectImportOutputWSLineConsumer("BATCH", "ws", 300));
RegisteredProject project = projectRegistry.getProject("/testImportProject");
assertNotNull(project);
// BASE
//System.out.println(">>> "+project.getProjectType());
assertNotNull(project.getBaseFolder().getChild("file1"));
assertEquals(fileContent, project.getBaseFolder().getChild("file1").getVirtualFile().getContentAsString());
}
use of java.util.zip.ZipOutputStream in project elasticsearch by elastic.
the class JarHellTests method makeJar.
URL makeJar(Path dir, String name, Manifest manifest, String... files) throws IOException {
Path jarpath = dir.resolve(name);
ZipOutputStream out;
if (manifest == null) {
out = new JarOutputStream(Files.newOutputStream(jarpath, StandardOpenOption.CREATE));
} else {
out = new JarOutputStream(Files.newOutputStream(jarpath, StandardOpenOption.CREATE), manifest);
}
for (String file : files) {
out.putNextEntry(new ZipEntry(file));
}
out.close();
return jarpath.toUri().toURL();
}
use of java.util.zip.ZipOutputStream in project buck by facebook.
the class ClassNodeListSupplierTest method testOneJar.
@Test
public void testOneJar() throws IOException {
File jar = new File(tmpDir.getRoot(), "primary.jar");
ZipOutputStream jarOut = new JarOutputStream(new FileOutputStream(jar));
jarOut.putNextEntry(new JarEntry("com/facebook/buck/android/ClassNodeListSupplierTest.class"));
writeClassBytes(ClassNodeListSupplierTest.class, jarOut);
jarOut.close();
Supplier<ImmutableList<ClassNode>> supplier = ClassNodeListSupplier.createMemoized(ImmutableList.of(jar.toPath()));
ImmutableList<ClassNode> classNodes = supplier.get();
assertEquals(1, classNodes.size());
assertEquals(Type.getType(ClassNodeListSupplierTest.class).getInternalName(), classNodes.get(0).name);
// Memoized should always return the same object
assertSame(classNodes, supplier.get());
}
use of java.util.zip.ZipOutputStream in project buck by facebook.
the class HashingDeterministicJarWriterTest method setUp.
@Before
public void setUp() {
out = new ByteArrayOutputStream();
writer = new HashingDeterministicJarWriter(new ZipOutputStream(out));
}
use of java.util.zip.ZipOutputStream in project buck by facebook.
the class ClasspathTraversalTest method testZip.
@Test
public void testZip() throws IOException {
String[] files = { "test/foo.txt", "bar.txt", "test/baz.txt" };
File file = tempDir.newFile("test.zip");
try (ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
for (String filename : files) {
ZipEntry entry = new ZipEntry(filename);
zipOut.putNextEntry(entry);
zipOut.write(filename.getBytes(Charsets.UTF_8));
}
}
verifyFileLike(3, file);
}
Aggregations