use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class DynamicImportTest method verifyThatDynamicImportNeedsHandling.
/*
* Install an .esa containing a bundle with a BundleActivator, and a
* DynamicImport-Package on org.apache.aries.subsystem.itests.hello.api.
* This app should fail to start because we've not yet intervened to permit
* this dynamic package wiring requirement from being met.
*/
@Test
public void verifyThatDynamicImportNeedsHandling() throws Exception {
Subsystem subsystem = installSubsystemFromFile("dynamicImport.esa");
try {
startSubsystem(subsystem);
Bundle[] bundles = subsystem.getBundleContext().getBundles();
for (Bundle b : bundles) {
System.out.println(b.getSymbolicName() + " -> " + b.getState());
}
fail("dynamicImport.esa started when we didn't expect it to");
} catch (SubsystemException sx) {
Throwable cause = sx.getCause();
assertTrue("BundleException expected", cause instanceof BundleException);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class InstallTest method testLocationAsDirectoryUrl.
/*
* Install a subsystem using a location string and a null input stream. The
* location string is a file URL pointing to a subsystem directory
* containing nested subsystem and bundle directories.
*/
@Test
public void testLocationAsDirectoryUrl() throws Exception {
File file = new File("compositeDir");
try {
Subsystem subsystem = installSubsystem(getRootSubsystem(), file.toURI().toString(), null, (Boolean[]) null);
try {
assertSymbolicName("org.apache.aries.subsystem.itests.composite.dir", subsystem);
assertConstituents(3, subsystem);
assertConstituent(subsystem, "org.apache.aries.subsystem.itests.composite.dir.bundle.a");
Bundle b = getConstituentAsBundle(subsystem, "org.apache.aries.subsystem.itests.composite.dir.bundle.a", null, null);
assertLocation(subsystem.getLocation() + "!/" + "a.jar", b.getLocation());
assertClassLoadable("a.A", b);
assertChildren(1, subsystem);
Subsystem child = subsystem.getChildren().iterator().next();
assertSymbolicName("org.apache.aries.subsystem.itests.application.dir", child);
assertConstituent(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b");
b = getConstituentAsBundle(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b", null, null);
assertLocation(child.getLocation() + "!/" + "b.jar", b.getLocation());
assertClassLoadable("b.B", b);
assertChildren(1, child);
child = child.getChildren().iterator().next();
assertSymbolicName("org.apache.aries.subsystem.itests.feature.dir", child);
assertConstituent(subsystem, "org.apache.aries.subsystem.itests.composite.dir.bundle.a");
b = getConstituentAsBundle(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.a", null, null);
assertLocation(child.getLocation() + "!/" + "a.jar", b.getLocation());
assertClassLoadable("a.A", b);
assertConstituent(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b", Version.parseVersion("1"));
b = getConstituentAsBundle(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b", Version.parseVersion("1"), null);
assertLocation(child.getLocation() + "!/" + "b.jar", b.getLocation());
assertClassLoadable("b.B", b);
} finally {
uninstallSubsystemSilently(subsystem);
}
} catch (Exception e) {
e.printStackTrace();
fail("Subsystem installation using directory URL as location failed");
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class InstallTest method testLocationAsEmptyString.
@Test
public void testLocationAsEmptyString() throws Exception {
try {
Subsystem a = installSubsystemFromFile(getRootSubsystem(), new File(APPLICATION_A), "");
try {
BasicSubsystem basic = (BasicSubsystem) a;
String location = basic.getLocation();
assertEquals("Location value should be an empty string", "", location);
} finally {
uninstallSubsystemSilently(a);
}
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class InstallTest method testGeneratedSymbolicNameWithoutManifest.
@Test
public void testGeneratedSymbolicNameWithoutManifest() throws Exception {
String expected = "org.apache.aries.subsystem.1";
Subsystem a = installSubsystemFromFile(APPLICATION_A);
try {
assertSymbolicName(expected, a);
assertSymbolicName(expected, a.getSubsystemHeaders(null).get(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME));
} finally {
uninstallSubsystemSilently(a);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class InstallTest method testSupportBundleResourcesNotEndingWithJar.
@Test
public void testSupportBundleResourcesNotEndingWithJar() throws Exception {
Subsystem featureA = installSubsystemFromFile(FEATURE_A);
try {
assertConstituents(1, featureA);
assertConstituent(featureA, BUNDLE_B);
} finally {
uninstallSubsystemSilently(featureA);
}
}
Aggregations