use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1429Test method testMissingParentChildEdgeNotTolerated.
@Test
public void testMissingParentChildEdgeNotTolerated() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
removeConnectionWithParent(applicationA);
try {
((AriesSubsystem) applicationA).addRequirements(Collections.singletonList((Requirement) new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).attribute(PackageNamespace.PACKAGE_NAMESPACE, "org.osgi.framework").build()));
fail("No exception received");
} catch (SubsystemException e) {
Throwable cause = e.getCause();
assertNotNull("Wrong cause", cause);
assertEquals("Wrong cause", IllegalStateException.class, cause.getClass());
}
} finally {
uninstallSubsystemSilently(applicationA);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1429Test method testMissingParentChildEdgeTolerated.
@Test
public void testMissingParentChildEdgeTolerated() throws Exception {
final AtomicBoolean weavingHookCalled = new AtomicBoolean();
final AtomicReference<FrameworkEvent> frameworkEvent = new AtomicReference<FrameworkEvent>();
bundleContext.registerService(WeavingHook.class, new WeavingHook() {
@Override
public void weave(WovenClass wovenClass) {
Bundle bundle = wovenClass.getBundleWiring().getBundle();
if (BUNDLE_A.equals(bundle.getSymbolicName())) {
wovenClass.getDynamicImports().add("com.acme.tnt");
weavingHookCalled.set(true);
}
}
}, null);
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
removeConnectionWithParent(applicationA);
BundleContext context = applicationA.getBundleContext();
Bundle bundleA = context.installBundle(BUNDLE_A, TinyBundles.bundle().add(getClass().getClassLoader().loadClass("a.A"), InnerClassStrategy.NONE).set(Constants.BUNDLE_SYMBOLICNAME, BUNDLE_A).build(TinyBundles.withBnd()));
bundleContext.addFrameworkListener(new FrameworkListener() {
@Override
public void frameworkEvent(FrameworkEvent event) {
if (FrameworkEvent.ERROR == event.getType() && getSubsystemCoreBundle().equals(event.getBundle())) {
frameworkEvent.set(event);
if (event.getThrowable() != null) {
event.getThrowable().printStackTrace();
}
}
}
});
bundleA.loadClass("a.A");
assertTrue("Weaving hook not called", weavingHookCalled.get());
Thread.sleep(1000);
assertNull("An exception was thrown", frameworkEvent.get());
} finally {
uninstallSubsystemSilently(applicationA);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1399Test method testBundleEventOrder.
@Test
public void testBundleEventOrder() throws Exception {
Subsystem root = getRootSubsystem();
BundleContext context = root.getBundleContext();
final List<BundleEvent> events = Collections.synchronizedList(new ArrayList<BundleEvent>());
context.addBundleListener(new SynchronousBundleListener() {
@Override
public void bundleChanged(BundleEvent event) {
events.add(event);
}
});
Bundle bundle = context.installBundle("bundle", TinyBundles.bundle().set(Constants.BUNDLE_SYMBOLICNAME, "bundle").build());
try {
bundle.start();
// INSTALLED, RESOLVED, STARTING, STARTED
assertEquals(4, events.size());
assertEquals(BundleEvent.INSTALLED, events.get(0).getType());
assertEquals(BundleEvent.RESOLVED, events.get(1).getType());
assertEquals(BundleEvent.STARTING, events.get(2).getType());
assertEquals(BundleEvent.STARTED, events.get(3).getType());
} finally {
uninstallSilently(bundle);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1408Test method testRequirementFromRemoteRepositoryConvertsToRequireCapability.
@Test
public void testRequirementFromRemoteRepositoryConvertsToRequireCapability() throws Exception {
Bundle bundleB = installBundleFromFile(BUNDLE_B);
try {
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.Subsystem in project aries by apache.
the class Aries1416Test method testSharedContentBundlePreferredProvider.
@Test
public void testSharedContentBundlePreferredProvider() throws Exception {
// Install feature A containing bundle B and application A both in the
// archive and as content into the root subsystem region. Bundle B
// provides capability b. Application A contains bundle A requiring
// capability b both in the archive and as content. Preferred provider
// bundle B is also included in the archive but not as content.
Subsystem featureA = installSubsystemFromFile(FEATURE_A);
try {
// Install feature B having the same characteristics as feature A
// described above into the root subsystem region. Bundle B will
// become shared content of features A and B. Shared content bundle
// B from the system repository should be used as the preferred
// provider. Bundle B from the local repository should not be
// provisioned.
Subsystem featureB = installSubsystemFromFile(FEATURE_B);
uninstallSubsystemSilently(featureB);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
} finally {
uninstallSubsystemSilently(featureA);
}
}
Aggregations