Search in sources :

Example 11 with ZipFixture

use of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture in project aries by apache.

the class InstallTest method createCompositeDirEsa.

private void createCompositeDirEsa() throws IOException, FileNotFoundException {
    ZipFixture feature = ArchiveFixture.newZip().binary("OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/OSGI-INF/SUBSYSTEM.MF")).binary("a.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/a.jar/META-INF/MANIFEST.MF")).binary("a.jar/a/A.class", getResourceAsStream("a/A.class")).binary("applicationDir.esa/OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/applicationDir/OSGI-INF/SUBSYSTEM.MF")).binary("applicationDir.esa/b.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/b.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/b.jar/b/B.class", getResourceAsStream("b/B.class")).binary("applicationDir.esa/featureDir.esa/OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/OSGI-INF/SUBSYSTEM.MF")).binary("applicationDir.esa/featureDir.esa/a.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/featureDir.esa/a.jar/a/A.class", getResourceAsStream("a/A.class")).binary("applicationDir.esa/featureDir.esa/b.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/featureDir.esa/b.jar/b/B.class", getResourceAsStream("b/B.class"));
    feature.end();
    FileOutputStream fos = new FileOutputStream("compositeDir" + ".esa");
    try {
        feature.writeOut(fos);
    } finally {
        Utils.closeQuietly(fos);
    }
    File userDir = new File(System.getProperty("user.dir"));
    IDirectory idir = FileSystem.getFSRoot(userDir);
    File compositeDir = new File(userDir, "compositeDir");
    compositeDir.mkdir();
    IOUtils.unpackZip(idir.getFile("compositeDir.esa"), compositeDir);
}
Also used : ZipFixture(org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture) FileOutputStream(java.io.FileOutputStream) IDirectory(org.apache.aries.util.filesystem.IDirectory) File(java.io.File)

Example 12 with ZipFixture

use of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture in project aries by apache.

the class WabConverterITest method createTestWar.

private void createTestWar(File warFile) throws IOException {
    ZipFixture testWar = ArchiveFixture.newJar().binary("WEB-INF/classes/org/apache/aries/web/test/TestClass.class", getClass().getClassLoader().getResourceAsStream("org/apache/aries/web/test/TestClass.class"));
    FileOutputStream fout = new FileOutputStream(warFile);
    testWar.writeOut(fout);
    fout.close();
}
Also used : ZipFixture(org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture) FileOutputStream(java.io.FileOutputStream)

Example 13 with ZipFixture

use of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture in project aries by apache.

the class UpdateAppTest method createApplications.

@Before
public void createApplications() throws Exception {
    if (createdApplications) {
        return;
    }
    ZipFixture testEba = ArchiveFixture.newZip().binary("META-INF/APPLICATION.MF", UpdateAppTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF")).jar("sample.jar").manifest().symbolicName("org.apache.aries.isolated.sample").attribute("Bundle-Version", "1.0.0").end().binary("org/apache/aries/isolated/sample/HelloWorld.class", UpdateAppTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class")).binary("org/apache/aries/isolated/sample/HelloWorldImpl.class", UpdateAppTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/aries.xml", UpdateAppTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml")).end();
    FileOutputStream fout = new FileOutputStream("test.eba");
    testEba.writeOut(fout);
    fout.close();
    ZipFixture sample2 = ArchiveFixture.newJar().manifest().symbolicName("org.apache.aries.isolated.sample").attribute("Bundle-Version", "2.0.0").end().binary("org/apache/aries/isolated/sample/HelloWorld.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class")).binary("org/apache/aries/isolated/sample/HelloWorldImpl.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/aries.xml", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml")).end();
    fout = new FileOutputStream("sample_2.0.0.jar");
    sample2.writeOut(fout);
    fout.close();
    createdApplications = true;
}
Also used : ZipFixture(org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture) FileOutputStream(java.io.FileOutputStream) Before(org.junit.Before)

Example 14 with ZipFixture

use of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture in project aries by apache.

the class IsolatedRuntimeTest method createApplications.

@Before
public void createApplications() throws Exception {
    if (createdApplications) {
        return;
    }
    ZipFixture testEba = ArchiveFixture.newZip().jar("sample.jar").manifest().symbolicName("org.apache.aries.isolated.sample").attribute("Bundle-Version", "1.0.0").attribute("Import-Package", "org.osgi.service.blueprint, org.apache.aries.isolated.shared").attribute("Bundle-ActivationPolicy", "lazy").end().binary("org/apache/aries/isolated/sample/HelloWorld.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class")).binary("org/apache/aries/isolated/sample/HelloWorldImpl.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class")).binary("org/apache/aries/isolated/sample/SharedImpl.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/SharedImpl.class")).binary("OSGI-INF/blueprint/sample-blueprint.xml", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml")).end().jar("shared.jar").manifest().symbolicName("org.apache.aries.isolated.shared").attribute("Bundle-Version", "1.0.0").attribute("Export-Package", "org.apache.aries.isolated.shared").end().binary("org/apache/aries/isolated/shared/Shared.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/shared/Shared.class")).end();
    FileOutputStream fout = new FileOutputStream("test.eba");
    testEba.writeOut(fout);
    fout.close();
    ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF")).end();
    fout = new FileOutputStream("test2.eba");
    testEba2.writeOut(fout);
    fout.close();
    ZipFixture sampleJar2 = ArchiveFixture.newJar().manifest().symbolicName("org.apache.aries.isolated.sample").attribute("Bundle-Version", "2.0.0").end().binary("org/apache/aries/isolated/sample/HelloWorld.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class")).binary("org/apache/aries/isolated/sample/HelloWorldImpl.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/aries.xml", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml")).end();
    fout = new FileOutputStream("sample_2.0.0.jar");
    sampleJar2.writeOut(fout);
    fout.close();
    ZipFixture ebaWithFragment = ArchiveFixture.newZip().jar("sample.jar").manifest().symbolicName("org.apache.aries.isolated.sample").attribute("Bundle-Version", "1.0.0").end().end().jar("fragment.jar").manifest().symbolicName("org.apache.aries.isolated.fragment").attribute("Bundle-Version", "1.0.0").attribute("Fragment-Host", "org.apache.aries.isolated.sample").end().binary("org/apache/aries/isolated/sample/HelloWorld.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class")).binary("org/apache/aries/isolated/sample/HelloWorldImpl.class", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/sample-blueprint.xml", IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml")).end();
    fout = new FileOutputStream("withFragment.eba");
    ebaWithFragment.writeOut(fout);
    fout.close();
    createdApplications = true;
}
Also used : ZipFixture(org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture) FileOutputStream(java.io.FileOutputStream) Before(org.junit.Before)

Example 15 with ZipFixture

use of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture in project aries by apache.

the class OBRResolverAdvancedTest method createApplications.

/* Use @Before not @BeforeClass so as to ensure that these resources
     * are created in the paxweb temp directory, and not in the svn tree
     */
@Before
public void createApplications() throws Exception {
    ZipFixture bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming").attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
    FileOutputStream fout = new FileOutputStream(CORE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_VALUE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.EXPORT_PACKAGE, "p.q.r").attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_REFERENCE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.EXPORT_PACKAGE, "x.y.z").attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.EXPORT_PACKAGE, "d.e.f").attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.EXPORT_PACKAGE, "d.e.f").end();
    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
    bundle.writeOut(fout);
    fout.close();
    // jar up a use bundle
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, USE_BUNDLE_BY_REFERENCE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute(Constants.EXPORT_PACKAGE, "a.b.c").attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
    fout = new FileOutputStream(USE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    // Create the EBA application
    ZipFixture testEba = ArchiveFixture.newZip().binary("META-INF/APPLICATION.MF", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION-UseBundle.MF")).end().binary(CORE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE_BY_VALUE + ".jar")).end().binary(TRANSITIVE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar")).end();
    fout = new FileOutputStream("demo.eba");
    testEba.writeOut(fout);
    fout.close();
    //create the bundle
    bundle = ArchiveFixture.newJar().binary("META-INF/MANIFEST.MF", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/aries.bundle1/META-INF/MANIFEST.MF")).end().binary("OSGI-INF/blueprint/blueprint.xml", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml")).end().binary("OSGI-INF/blueprint/anotherBlueprint.xml", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/aries.bundle1/OSGI-INF/blueprint/sample-blueprint.xml")).end();
    fout = new FileOutputStream(REPO_BUNDLE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    ///////////////////////////////////////////////
    //create an eba with a helloworld client, which get all 'HelloWorld' services
    //create a helloworld client
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_CLIENT_BUNDLE).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute("Import-Package", "org.apache.aries.sample").attribute(Constants.BUNDLE_VERSION, "1.0.0").end().binary("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class")).binary("OSGI-INF/blueprint/helloClient.xml", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml")).end();
    fout = new FileOutputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    //create two helloworld services
    // create the 1st helloworld service
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE1).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute("Import-Package", "org.apache.aries.sample").attribute(Constants.BUNDLE_VERSION, "1.0.0").end().binary("org/apache/aries/sample/impl/HelloWorldImpl.class", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/sample-blueprint.xml", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml")).end();
    //create the 2nd helloworld service
    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE1 + ".jar");
    bundle.writeOut(fout);
    fout.close();
    bundle = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE2).attribute(Constants.BUNDLE_MANIFESTVERSION, "2").attribute("Import-Package", "org.apache.aries.sample").attribute(Constants.BUNDLE_VERSION, "1.0.0").end().binary("org/apache/aries/sample/impl/HelloWorldImpl.class", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class")).binary("OSGI-INF/blueprint/sample-blueprint.xml", BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml")).end();
    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
    bundle.writeOut(fout);
    fout.close();
    //Create a helloworld eba with the client included
    ZipFixture multiServiceHelloEba = ArchiveFixture.newZip().binary(HELLO_WORLD_CLIENT_BUNDLE + ".jar", new FileInputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar")).end();
    fout = new FileOutputStream("hello.eba");
    multiServiceHelloEba.writeOut(fout);
    fout.close();
}
Also used : ZipFixture(org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture) FileOutputStream(java.io.FileOutputStream) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Aggregations

ZipFixture (org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture)15 FileOutputStream (java.io.FileOutputStream)13 Before (org.junit.Before)9 File (java.io.File)6 FileInputStream (java.io.FileInputStream)4 BufferedReader (java.io.BufferedReader)2 FileWriter (java.io.FileWriter)2 InputStreamReader (java.io.InputStreamReader)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)1 RichBundleContext (org.apache.aries.itest.RichBundleContext)1 IDirectory (org.apache.aries.util.filesystem.IDirectory)1 MavenArtifactProvisionOption (org.ops4j.pax.exam.options.MavenArtifactProvisionOption)1 BundleException (org.osgi.framework.BundleException)1