Search in sources :

Example 26 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1338Test method test.

private void test(String importPackage, String exportPackage, boolean shouldFail) throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage(importPackage).build()).bundle("b", new BundleArchiveBuilder().symbolicName("b").exportPackage(exportPackage).build()).build());
        uninstallableSubsystems.add(subsystem);
        if (shouldFail) {
            fail("Subsystem should not have installed");
        }
    } catch (SubsystemException e) {
        e.printStackTrace();
        if (!shouldFail) {
            fail("Subsystem should have installed");
        }
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 27 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1522Test method test.

private void test(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).content("org.apache.aries.subsystem.itests.aries1523host,org.apache.aries.subsystem.itests.aries1523fragment").bundle("aries1523host", getClass().getClassLoader().getResourceAsStream("aries1523/aries1523host.jar")).build(), flag);
        try {
            startSubsystem(subsystem, flag);
            stopSubsystem(subsystem);
        } catch (SubsystemException e) {
            e.printStackTrace();
            fail("Subsystem should have started");
        } finally {
            uninstallSubsystemSilently(subsystem);
        }
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 28 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1523Test method test.

private void test(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).content("org.apache.aries.subsystem.itests.aries1523host,org.apache.aries.subsystem.itests.aries1523fragment").bundle("aries1523fragment", getClass().getClassLoader().getResourceAsStream("aries1523/aries1523fragment.jar")).build(), flag);
        try {
            startSubsystem(subsystem, flag);
            stopSubsystem(subsystem);
        } catch (SubsystemException e) {
            e.printStackTrace();
            fail("Subsystem should have started");
        } finally {
            uninstallSubsystemSilently(subsystem);
        }
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 29 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1538Test method testHostFragmentCircularDependency.

private void testHostFragmentCircularDependency(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    BundleArchiveBuilder hostBuilder = new BundleArchiveBuilder();
    hostBuilder.symbolicName("host");
    hostBuilder.exportPackage("foo");
    hostBuilder.importPackage("bar");
    BundleArchiveBuilder fragmentBuilder = new BundleArchiveBuilder();
    fragmentBuilder.symbolicName("fragment");
    fragmentBuilder.exportPackage("bar");
    fragmentBuilder.importPackage("foo");
    fragmentBuilder.header("Fragment-Host", "host");
    Subsystem root = getRootSubsystem();
    Bundle host = root.getBundleContext().installBundle("host", hostBuilder.build());
    uninstallableBundles.add(host);
    Bundle fragment = root.getBundleContext().installBundle("fragment", fragmentBuilder.build());
    uninstallableBundles.add(fragment);
    startBundle(host);
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("foo").build()).build(), flag);
        uninstallableSubsystems.add(subsystem);
        startSubsystem(subsystem, flag);
        stoppableSubsystems.add(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed and started");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 30 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1538Test method testSubstitutableExport.

private void testSubstitutableExport(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    BundleArchiveBuilder hostBuilder = new BundleArchiveBuilder();
    hostBuilder.symbolicName("host");
    BundleArchiveBuilder fragmentBuilder = new BundleArchiveBuilder();
    fragmentBuilder.symbolicName("fragment");
    fragmentBuilder.exportPackage("foo");
    fragmentBuilder.importPackage("foo");
    fragmentBuilder.header("Fragment-Host", "host");
    Subsystem root = getRootSubsystem();
    Bundle host = root.getBundleContext().installBundle("host", hostBuilder.build());
    uninstallableBundles.add(host);
    Bundle fragment = root.getBundleContext().installBundle("fragment", fragmentBuilder.build());
    uninstallableBundles.add(fragment);
    startBundle(host);
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("foo").build()).build(), flag);
        uninstallableSubsystems.add(subsystem);
        startSubsystem(subsystem, flag);
        stoppableSubsystems.add(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed and started");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Aggregations

SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 Subsystem (org.osgi.service.subsystem.Subsystem)30 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)21 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)21 Test (org.junit.Test)21 SubsystemException (org.osgi.service.subsystem.SubsystemException)16 Bundle (org.osgi.framework.Bundle)5 Callable (java.util.concurrent.Callable)3 ExecutorService (java.util.concurrent.ExecutorService)3 Future (java.util.concurrent.Future)3 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)3 TestRepository (org.apache.aries.subsystem.itests.util.TestRepository)3 Repository (org.osgi.service.repository.Repository)3 TestRepositoryContent (org.apache.aries.subsystem.itests.util.TestRepositoryContent)2 TestRequirement (org.apache.aries.subsystem.itests.util.TestRequirement)1