use of org.codehaus.plexus.archiver.zip.ZipEntry in project aries by apache.
the class EbaMojoTest method getSizeOfExpectedFiles.
private int getSizeOfExpectedFiles(Enumeration entries, List expectedFiles) {
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (expectedFiles.contains(entry.getName())) {
expectedFiles.remove(entry.getName());
assertFalse(expectedFiles.contains(entry.getName()));
} else {
fail(entry.getName() + " is not included in the expected files");
}
}
return expectedFiles.size();
}
use of org.codehaus.plexus.archiver.zip.ZipEntry in project aries by apache.
the class EsaMojoTest method testForHeader.
private void testForHeader(ZipFile esa, String header, String exactEntry) throws Exception {
Enumeration entries = esa.getEntries();
// Test Use-Bundle & Subsytem-Type inclusion
ZipEntry entry = esa.getEntry("OSGI-INF/SUBSYSTEM.MF");
BufferedReader br = new BufferedReader(new InputStreamReader(esa.getInputStream(entry)));
Boolean foundHeader = false;
String line;
while ((line = br.readLine()) != null) {
if (line.contains(header)) {
assertEquals(exactEntry, line);
foundHeader = true;
}
}
assertTrue("Found " + header + ":", foundHeader);
}
use of org.codehaus.plexus.archiver.zip.ZipEntry 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);
}
use of org.codehaus.plexus.archiver.zip.ZipEntry 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);
}
use of org.codehaus.plexus.archiver.zip.ZipEntry in project aries by apache.
the class EsaMojoTest method getSizeOfExpectedFiles.
private int getSizeOfExpectedFiles(Enumeration entries, List expectedFiles) {
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (expectedFiles.contains(entry.getName())) {
expectedFiles.remove(entry.getName());
assertFalse(expectedFiles.contains(entry.getName()));
} else {
fail(entry.getName() + " is not included in the expected files");
}
}
return expectedFiles.size();
}
Aggregations