Search in sources :

Example 1 with SubsystemException

use of org.osgi.service.subsystem.SubsystemException in project aries by apache.

the class Aries1383Test method test15b.

/*
	 * (15) Unscoped subsystem with a value of apache-aries-provision-dependencies 
	 * that is different than the scoped parent fails installation.
	 */
@Test
public void test15b() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem application = installSubsystem(root, APPLICATION_PROVISION_DEPENDENCIES_INSTALL, applicationProvisionDependenciesInstall(), true);
    try {
        Subsystem feature = installSubsystem(application, FEATURE_PROVISION_DEPENDENCIES_RESOLVE, featureProvisionDependenciesResolve(), false);
        uninstallSubsystemSilently(feature);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    } finally {
        uninstallSubsystemSilently(application);
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 2 with SubsystemException

use of org.osgi.service.subsystem.SubsystemException in project aries by apache.

the class Aries1383Test method test11.

/*
	 * (11) Subsystem with apache-aries-provision-dependencies:=resolve undergoes 
	 * the following state transitions when starting fails due to a runtime 
	 * resolution failure: INSTALLING -> INSTALLED -> RESOLVING -> INSTALLED.
	 */
@Test
public void test11() throws Exception {
    Subsystem root = getRootSubsystem();
    subsystemEvents.clear();
    Subsystem subsystem = root.install(APPLICATION_DEPENDENCY_IN_ARCHIVE, applicationDependencyInArchive());
    ServiceRegistration<ResolverHookFactory> registration = bundleContext.registerService(ResolverHookFactory.class, new ResolverHookFactory() {

        @Override
        public ResolverHook begin(Collection<BundleRevision> triggers) {
            return new ResolverHook() {

                @Override
                public void filterResolvable(Collection<BundleRevision> candidates) {
                    for (Iterator<BundleRevision> i = candidates.iterator(); i.hasNext(); ) {
                        BundleRevision revision = i.next();
                        if (revision.getSymbolicName().equals(BUNDLE_B)) {
                            i.remove();
                        }
                    }
                }

                @Override
                public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
                // Nothing.
                }

                @Override
                public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
                // Nothing.
                }

                @Override
                public void end() {
                // Nothing.
                }
            };
        }
    }, null);
    try {
        subsystem.start();
        stopSubsystemSilently(subsystem);
        fail("Subsystem should not have started");
    } catch (SubsystemException e) {
        e.printStackTrace();
        long id = lastSubsystemId();
        assertEvent(id, APPLICATION_DEPENDENCY_IN_ARCHIVE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLING, subsystemEvents.poll(id, 5000), ServiceEvent.REGISTERED);
        assertEvent(id, APPLICATION_DEPENDENCY_IN_ARCHIVE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_DEPENDENCY_IN_ARCHIVE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_DEPENDENCY_IN_ARCHIVE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
    } finally {
        registration.unregister();
        uninstallSubsystemSilently(subsystem);
    }
}
Also used : ResolverHookFactory(org.osgi.framework.hooks.resolver.ResolverHookFactory) ResolverHook(org.osgi.framework.hooks.resolver.ResolverHook) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) BundleRevision(org.osgi.framework.wiring.BundleRevision) Iterator(java.util.Iterator) BundleCapability(org.osgi.framework.wiring.BundleCapability) BundleRequirement(org.osgi.framework.wiring.BundleRequirement) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 3 with SubsystemException

use of org.osgi.service.subsystem.SubsystemException in project aries by apache.

the class Aries1383Test method test16a.

/*
	 * (16) Unscoped subsystem with a value of apache-aries-provision-dependencies 
	 * that is the same as the scoped parent installs successfully.
	 */
@Test
public void test16a() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, FEATURE_PROVISION_DEPENDENCIES_INSTALL, new SubsystemArchiveBuilder().symbolicName("application").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.INSTALL.toString()).build(), true);
        uninstallSubsystemSilently(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 4 with SubsystemException

use of org.osgi.service.subsystem.SubsystemException in project aries by apache.

the class Aries1383Test method testInstallChildIntoInstallingParent.

@Test
public void testInstallChildIntoInstallingParent() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem subsystem = installSubsystem(root, APPLICATION_DEPENDENCY_IN_ARCHIVE, applicationDependencyInArchive(), false);
    try {
        assertState(State.INSTALLING, subsystem);
        installSubsystem(subsystem, APPLICATION_A, applicationA(), false);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    } finally {
        uninstallSubsystemSilently(subsystem);
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 5 with SubsystemException

use of org.osgi.service.subsystem.SubsystemException in project aries by apache.

the class Aries1383Test method test10.

/*
	 * (10) Subsystem fails installation if the apache-aries-provision-dependencies 
	 * directive has a value other than "install" or "resolve".
	 */
@Test
public void test10() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, APPLICATION_INVALID_PROVISION_DEPENDENCIES, applicationInvalidProvisionDependencies(), false);
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

SubsystemException (org.osgi.service.subsystem.SubsystemException)61 Subsystem (org.osgi.service.subsystem.Subsystem)39 Test (org.junit.Test)32 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)23 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)19 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)15 Bundle (org.osgi.framework.Bundle)11 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)7 Resource (org.osgi.resource.Resource)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)5 BundleException (org.osgi.framework.BundleException)5 Requirement (org.osgi.resource.Requirement)5 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)3 BundleRevision (org.osgi.framework.wiring.BundleRevision)3 Repository (org.osgi.service.repository.Repository)3 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 DeploymentManifest (org.apache.aries.subsystem.core.archive.DeploymentManifest)2