use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1416Test method testSystemRepositoryBundlePreferredProvider.
@Test
public void testSystemRepositoryBundlePreferredProvider() throws Exception {
Subsystem root = getRootSubsystem();
// Install bundle B providing capability b into the root subsystem's
// region.
Bundle bundleB = installBundleFromFile(BUNDLE_B, root);
try {
// Install application A containing content bundle A requiring
// capability b and dependency bundle B providing capability b.
// Bundle B is not content but will become part of the local
// repository. The preferred provider is bundle B. Bundle B from the
// system repository should be used. Bundle B from the local
// repository should not be provisioned.
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
uninstallSubsystemSilently(applicationA);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
} finally {
uninstallSilently(bundleB);
}
}
use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1383Test method test16c.
/*
* (16) Unscoped subsystem with a value of apache-aries-provision-dependencies
* that is the same as the scoped parent installs successfully.
*/
@Test
public void test16c() throws Exception {
Subsystem root = getRootSubsystem();
try {
Subsystem subsystem = installSubsystem(root, "application", new SubsystemArchiveBuilder().symbolicName("application").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).subsystem("feature", new SubsystemArchiveBuilder().symbolicName("feature").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).build()).build(), false);
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 Aries1419Test method testProvideCapability.
@Test
public void testProvideCapability() throws Exception {
Bundle bundleB = installBundleFromFile(BUNDLE_B);
try {
Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
uninstallSubsystemSilently(applicationB);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
} finally {
uninstallSilently(bundleB);
}
}
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();
}
}
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);
}
}
Aggregations