Search in sources :

Example 96 with JarOutputStream

use of java.util.jar.JarOutputStream in project fabric8 by jboss-fuse.

the class MavenProxyServletSupportTest method testWarUploadNoMvnPath.

@Test(timeout = 30000)
public void testWarUploadNoMvnPath() throws Exception {
    String warPath = "acme-ui-1.0.war";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JarOutputStream jas = new JarOutputStream(baos);
    addEntry(jas, "WEB-INF/web.xml", "<web/>".getBytes());
    jas.close();
    byte[] contents = baos.toByteArray();
    testUpload(warPath, contents, true);
}
Also used : JarOutputStream(java.util.jar.JarOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 97 with JarOutputStream

use of java.util.jar.JarOutputStream in project fabric8 by jboss-fuse.

the class MavenProxyServletSupportTest method testJarUploadWithMvnPom.

@Test(timeout = 30000)
public void testJarUploadWithMvnPom() throws Exception {
    String jarPath = "org.acme/acme-core/1.0/acme-core-1.0.jar";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JarOutputStream jas = new JarOutputStream(baos);
    addEntry(jas, "hello.txt", "Hello!".getBytes());
    addPom(jas, "org.acme", "acme-core", "1.0");
    jas.close();
    byte[] contents = baos.toByteArray();
    testUpload(jarPath, contents, false);
}
Also used : JarOutputStream(java.util.jar.JarOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 98 with JarOutputStream

use of java.util.jar.JarOutputStream in project fabric8 by jboss-fuse.

the class MavenProxyServletSupportTest method testWarUploadFullMvnPath.

@Test(timeout = 30000)
public void testWarUploadFullMvnPath() throws Exception {
    String warPath = "org.acme/acme-ui/1.0/acme-ui-1.0.war";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JarOutputStream jas = new JarOutputStream(baos);
    addEntry(jas, "WEB-INF/web.xml", "<web/>".getBytes());
    jas.close();
    byte[] contents = baos.toByteArray();
    testUpload(warPath, contents, false);
}
Also used : JarOutputStream(java.util.jar.JarOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 99 with JarOutputStream

use of java.util.jar.JarOutputStream in project fabric8 by jboss-fuse.

the class MavenProxyServletSupportTest method testJarUploadNoMvnPath.

@Test(timeout = 30000)
public void testJarUploadNoMvnPath() throws Exception {
    String jarPath = "acme-core-1.0.jar";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JarOutputStream jas = new JarOutputStream(baos);
    addEntry(jas, "hello.txt", "Hello!".getBytes());
    jas.close();
    byte[] contents = baos.toByteArray();
    testUpload(jarPath, contents, true);
}
Also used : JarOutputStream(java.util.jar.JarOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 100 with JarOutputStream

use of java.util.jar.JarOutputStream in project SimpleFlatMapper by arnaudroger.

the class OsgiTest method repackage.

private URL repackage(URL asm6) throws IOException {
    File tmpFile = File.createTempFile("bundle", "jar");
    try (InputStream fis = asm6.openStream();
        JarInputStream jis = new JarInputStream(fis)) {
        Manifest man = jis.getManifest();
        Attributes mainAttributes = man.getMainAttributes();
        System.out.println("mainAttributes = " + mainAttributes.keySet());
        mainAttributes.remove(new Attributes.Name("Bundle-RequiredExecutionEnvironment"));
        mainAttributes.remove(new Attributes.Name("Require-Capability"));
        try (FileOutputStream fos = new FileOutputStream(tmpFile);
            JarOutputStream jos = new JarOutputStream(fos, man)) {
            JarEntry zentry;
            while ((zentry = jis.getNextJarEntry()) != null) {
                jos.putNextEntry(zentry);
                IOUtils.copy(jis, jos);
            }
        }
    }
    return tmpFile.toURI().toURL();
}
Also used : JarInputStream(java.util.jar.JarInputStream) JarInputStream(java.util.jar.JarInputStream) Attributes(java.util.jar.Attributes) JarOutputStream(java.util.jar.JarOutputStream) Manifest(java.util.jar.Manifest) JarEntry(java.util.jar.JarEntry)

Aggregations

JarOutputStream (java.util.jar.JarOutputStream)485 FileOutputStream (java.io.FileOutputStream)308 File (java.io.File)265 JarEntry (java.util.jar.JarEntry)194 Manifest (java.util.jar.Manifest)140 IOException (java.io.IOException)130 ZipEntry (java.util.zip.ZipEntry)116 InputStream (java.io.InputStream)89 FileInputStream (java.io.FileInputStream)84 JarFile (java.util.jar.JarFile)82 ByteArrayOutputStream (java.io.ByteArrayOutputStream)76 ByteArrayInputStream (java.io.ByteArrayInputStream)55 Test (org.junit.Test)55 BufferedOutputStream (java.io.BufferedOutputStream)47 Path (java.nio.file.Path)42 JarInputStream (java.util.jar.JarInputStream)41 OutputStream (java.io.OutputStream)36 Attributes (java.util.jar.Attributes)36 ArrayList (java.util.ArrayList)35 Map (java.util.Map)27