Search in sources :

Example 16 with ZipFile

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

the class EbaMojoTest method testBasicEbaWithDescriptor.

public void testBasicEbaWithDescriptor() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-with-descriptor/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/MANIFEST.MF" );
    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());
    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 17 with ZipFile

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

the class EbaMojoTest method testArchiveContentConfigurationAllBundles.

public void testArchiveContentConfigurationAllBundles() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-all-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/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact03-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 18 with ZipFile

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

the class EbaMojoTest method testBasicEbaWithManifest.

public void testBasicEbaWithManifest() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-eba-with-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/MANIFEST.MF");
    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 19 with ZipFile

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

the class EsaMojoTest method testBasicEsa.

private void testBasicEsa(String path, String extraExpectedFiles) throws Exception {
    File testPom = new File(getBasedir(), path);
    EsaMojo mojo = (EsaMojo) lookupMojo("esa", 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 esa file
    File esaFile = new File(outputDir, finalName + ".esa");
    assertTrue(esaFile.exists());
    //expected files/directories inside the esa file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    expectedFiles.add("META-INF/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    if (extraExpectedFiles != null) {
        expectedFiles.add(extraExpectedFiles);
    }
    ZipFile esa = new ZipFile(esaFile);
    Enumeration entries = esa.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) ArrayList(java.util.ArrayList) List(java.util.List) ZipFile(org.codehaus.plexus.archiver.zip.ZipFile) File(java.io.File)

Example 20 with ZipFile

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

the class EsaMojoTest method testBasicEsaWithDescriptor.

public void testBasicEsaWithDescriptor() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-esa-with-descriptor/plugin-config.xml");
    EsaMojo mojo = (EsaMojo) lookupMojo("esa", 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 esa file
    File esaFile = new File(outputDir, finalName + ".esa");
    assertTrue(esaFile.exists());
    //expected files/directories inside the esa file
    List expectedFiles = new ArrayList();
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/pom.properties");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/pom.xml");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/maven-esa-test/");
    expectedFiles.add("META-INF/maven/org.apache.maven.test/");
    expectedFiles.add("META-INF/maven/");
    expectedFiles.add("META-INF/");
    expectedFiles.add("OSGI-INF/SUBSYSTEM.MF");
    expectedFiles.add("OSGI-INF/");
    expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar");
    expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar");
    ZipFile esa = new ZipFile(esaFile);
    Enumeration entries = esa.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) ArrayList(java.util.ArrayList) List(java.util.List) 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