Search in sources :

Example 11 with ZipFile

use of org.codehaus.plexus.archiver.zip.ZipFile in project aries by apache.

the class EbaMojoTest method testBasicEba.

public void testBasicEba() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-test/plugin-config.xml");
    EbaMojo mojo = (EbaMojo) lookupMojo("eba", testPom);
    assertNotNull(mojo);
    String finalName = (String) getVariableValueFromObject(mojo, "finalName");
    String workDir = (String) getVariableValueFromObject(mojo, "workDirectory");
    String outputDir = (String) getVariableValueFromObject(mojo, "outputDirectory");
    Boolean includeJar = (Boolean) getVariableValueFromObject(mojo, "includeJar");
    assertTrue(includeJar.booleanValue());
    //include the project jar to the eba
    File projectJar = new File(getBasedir(), "src/test/resources/unit/basic-eba-test/target/test-eba.jar");
    FileUtils.copyFileToDirectory(projectJar, new File(outputDir));
    mojo.execute();
    //check the generated eba file
    File ebaFile = new File(outputDir, finalName + ".eba");
    assertTrue(ebaFile.exists());
    //expected files/directories inside the eba file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    //        expectedFiles.add( "META-INF/MANIFEST.MF" );
    expectedFiles.add("META-INF/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    expectedFiles.add("test-eba.jar");
    ZipFile eba = new ZipFile(ebaFile);
    Enumeration entries = eba.getEntries();
    assertTrue(entries.hasMoreElements());
    assertTrue(entries.hasMoreElements());
    int missing = getSizeOfExpectedFiles(entries, expectedFiles);
    assertEquals("Missing files: " + expectedFiles, 0, missing);
}
Also used : Enumeration(java.util.Enumeration) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) File(java.io.File)

Example 12 with ZipFile

use of org.codehaus.plexus.archiver.zip.ZipFile in project aries by apache.

the class EbaMojoTest method testArchiveContentConfigurationApplicationContentBundles.

public void testArchiveContentConfigurationApplicationContentBundles() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-content-bundles-only/plugin-config.xml");
    EbaMojo mojo = (EbaMojo) lookupMojo("eba", testPom);
    assertNotNull(mojo);
    String finalName = (String) getVariableValueFromObject(mojo, "finalName");
    String workDir = (String) getVariableValueFromObject(mojo, "workDirectory");
    String outputDir = (String) getVariableValueFromObject(mojo, "outputDirectory");
    mojo.execute();
    //check the generated eba file
    File ebaFile = new File(outputDir, finalName + ".eba");
    assertTrue(ebaFile.exists());
    //expected files/directories inside the eba file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    expectedFiles.add("META-INF/APPLICATION.MF");
    expectedFiles.add("META-INF/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    ZipFile eba = new ZipFile(ebaFile);
    Enumeration entries = eba.getEntries();
    assertTrue(entries.hasMoreElements());
    int missing = getSizeOfExpectedFiles(entries, expectedFiles);
    assertEquals("Missing files: " + expectedFiles, 0, missing);
}
Also used : Enumeration(java.util.Enumeration) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) File(java.io.File)

Example 13 with ZipFile

use of org.codehaus.plexus.archiver.zip.ZipFile in project jangaroo-tools by CoreMedia.

the class PackageApplicationMojo method includeJangarooModuleScript.

private void includeJangarooModuleScript(File scriptDirectory, Artifact artifact, Writer jangarooApplicationWriter, Writer jangarooApplicationAllWriter) throws IOException {
    ZipFile zipFile = new ZipFile(artifact.getFile());
    ZipEntry zipEntry = zipFile.getEntry(computeModuleJsFileName(artifact.getArtifactId()));
    ModuleSource jooModuleSource = zipEntry != null ? new ZipEntryModuleSource(zipFile, zipEntry) : null;
    writeJangarooModuleScript(scriptDirectory, artifact, jooModuleSource, jangarooApplicationWriter, jangarooApplicationAllWriter);
}
Also used : ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) ZipEntry(org.codehaus.plexus.archiver.zip.ZipEntry)

Example 14 with ZipFile

use of org.codehaus.plexus.archiver.zip.ZipFile in project aries by apache.

the class EbaMojoTest method testApplicationManifestGeneration.

public void testApplicationManifestGeneration() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-without-manifest/plugin-config.xml");
    EbaMojo mojo = (EbaMojo) lookupMojo("eba", testPom);
    assertNotNull(mojo);
    String finalName = (String) getVariableValueFromObject(mojo, "finalName");
    String workDir = (String) getVariableValueFromObject(mojo, "workDirectory");
    String outputDir = (String) getVariableValueFromObject(mojo, "outputDirectory");
    mojo.execute();
    //check the generated eba file
    File ebaFile = new File(outputDir, finalName + ".eba");
    assertTrue(ebaFile.exists());
    //expected files/directories inside the eba file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    expectedFiles.add("META-INF/APPLICATION.MF");
    expectedFiles.add("META-INF/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    ZipFile eba = new ZipFile(ebaFile);
    Enumeration entries = eba.getEntries();
    assertTrue(entries.hasMoreElements());
    int missing = getSizeOfExpectedFiles(entries, expectedFiles);
    assertEquals("Missing files: " + expectedFiles, 0, missing);
    //Test Application-ImportService Application-ExportService and Use-Bundle inclusion
    ZipEntry entry = eba.getEntry("META-INF/APPLICATION.MF");
    BufferedReader br = new BufferedReader(new InputStreamReader(eba.getInputStream(entry)));
    String appServiceExport = new String("Application-ExportService: test.ExportService");
    String appServiceImport = new String("Application-ImportService: test.ImportService");
    String useBundle = new String("Use-Bundle: org.apache.aries.test.Bundle;version=1.0.0-SNAPSHOT");
    Boolean foundAppExport = false;
    Boolean foundAppImport = false;
    Boolean foundUseBundle = false;
    String line;
    while ((line = br.readLine()) != null) {
        if (line.contains(new String("Application-ExportService"))) {
            assertEquals(appServiceExport, line);
            foundAppExport = true;
        }
        if (line.contains(new String("Application-ImportService"))) {
            assertEquals(appServiceImport, line);
            foundAppImport = true;
        }
        if (line.contains(new String("Use-Bundle"))) {
            assertEquals(useBundle, line);
            foundUseBundle = true;
        }
    }
    assertTrue("Found Application-ExportService:", foundAppExport);
    assertTrue("Found Application-ImportService:", foundAppImport);
    assertTrue("Found Use-Bundle:", foundUseBundle);
}
Also used : Enumeration(java.util.Enumeration) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) InputStreamReader(java.io.InputStreamReader) ZipEntry(org.codehaus.plexus.archiver.zip.ZipEntry) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) List(java.util.List) ArrayList(java.util.ArrayList) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) File(java.io.File)

Example 15 with ZipFile

use of org.codehaus.plexus.archiver.zip.ZipFile in project aries by apache.

the class EbaMojoTest method testArchiveContentConfigurationNoBundles.

public void testArchiveContentConfigurationNoBundles() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-no-bundles/plugin-config.xml");
    EbaMojo mojo = (EbaMojo) lookupMojo("eba", testPom);
    assertNotNull(mojo);
    String finalName = (String) getVariableValueFromObject(mojo, "finalName");
    String workDir = (String) getVariableValueFromObject(mojo, "workDirectory");
    String outputDir = (String) getVariableValueFromObject(mojo, "outputDirectory");
    mojo.execute();
    //check the generated eba file
    File ebaFile = new File(outputDir, finalName + ".eba");
    assertTrue(ebaFile.exists());
    //expected files/directories inside the eba file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-eba-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    expectedFiles.add("META-INF/APPLICATION.MF");
    expectedFiles.add("META-INF/");
    ZipFile eba = new ZipFile(ebaFile);
    Enumeration entries = eba.getEntries();
    assertTrue(entries.hasMoreElements());
    int missing = getSizeOfExpectedFiles(entries, expectedFiles);
    assertEquals("Missing files: " + expectedFiles, 0, missing);
}
Also used : Enumeration(java.util.Enumeration) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) File(java.io.File)

Aggregations

ZipFile (org.codehaus.plexus.archiver.zip.ZipFile)21 File (java.io.File)20 ArrayList (java.util.ArrayList)18 Enumeration (java.util.Enumeration)18 List (java.util.List)18 Map (java.util.Map)4 Manifest (java.util.jar.Manifest)4 ZipEntry (org.codehaus.plexus.archiver.zip.ZipEntry)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1