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);
}
}
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);
}
}
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");
}
}
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);
}
}
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();
}
}
Aggregations