use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class ApplicationTest method testApplication1.
/*
* Subsystem application1 has content bundle tb1.jar.
* Bundle tb1.jar has an import package dependency on org.apache.aries.subsystem.itests.tb3.
*/
@Test
public void testApplication1() throws Exception {
Subsystem application1 = installSubsystemFromFile("application1.esa");
try {
assertSymbolicName("org.apache.aries.subsystem.application1", application1);
assertVersion("0.0.0", application1);
assertType(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, application1);
assertChildren(0, application1);
assertConstituents(2, application1);
startSubsystem(application1);
assertBundleState(Bundle.RESOLVED | Bundle.ACTIVE, "org.apache.aries.subsystem.itests.tb1", application1);
assertBundleState(Bundle.RESOLVED | Bundle.ACTIVE, "org.apache.aries.subsystem.itests.tb3", getRootSubsystem());
} finally {
stopSubsystemSilently(application1);
uninstallSubsystemSilently(application1);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class ApplicationTest method testRequireBundle.
@Test
public void testRequireBundle() throws Exception {
File file = new File(BUNDLE_B);
// The following input stream is closed by the bundle context.
Bundle b = getRootSubsystem().getBundleContext().installBundle(file.toURI().toString(), new FileInputStream(file));
try {
Subsystem application = installSubsystemFromFile(APPLICATION_B);
try {
startSubsystem(application);
} finally {
stopSubsystemSilently(application);
uninstallSubsystemSilently(application);
}
} finally {
uninstallSilently(b);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class AutostartTest method testStartCompositeWithUnresolvedDependency.
@Test
public /* Start a composite with a dependency on an installed, but unresolved subsystem.
* The unresolved dependency should be auto-resolved and started (test fix to
* bug ARIES-1348).
*
* composite b imports package exported by a bundle in composite.a.
* - install composite a
* - install composite b
* - start composite b
*/
void testStartCompositeWithUnresolvedDependency() throws Exception {
Subsystem compositeA = installSubsystemFromFile(COMPOSITE_A);
Subsystem compositeB = installSubsystemFromFile(COMPOSITE_B);
try {
startSubsystem(compositeB);
// A should be automatically resolved and started.
assertState(Subsystem.State.ACTIVE, compositeA);
} finally {
stopSubsystemSilently(compositeB);
stopSubsystemSilently(compositeA);
uninstallSubsystemSilently(compositeB);
uninstallSubsystemSilently(compositeA);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class AutostartTest method testAutostartScoped.
@Test
public void testAutostartScoped() throws Exception {
Subsystem subsystem = null;
try {
subsystem = installSubsystemFromFile(APPLICATION_A);
restartSubsystemsImplBundle();
subsystem = findSubsystemService(subsystem.getSubsystemId());
assertState(Subsystem.State.INSTALLED, subsystem);
assertBundleState(Bundle.INSTALLED | Bundle.RESOLVED, BUNDLE_A, subsystem);
startSubsystem(subsystem);
restartSubsystemsImplBundle();
subsystem = findSubsystemService(subsystem.getSubsystemId());
assertState(Subsystem.State.ACTIVE, subsystem);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, subsystem);
stopSubsystem(subsystem);
restartSubsystemsImplBundle();
subsystem = findSubsystemService(subsystem.getSubsystemId());
assertState(Subsystem.State.RESOLVED, subsystem);
assertBundleState(Bundle.RESOLVED, BUNDLE_A, subsystem);
} finally {
stopAndUninstallSubsystemSilently(subsystem);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class AutostartTest method testAutostartChildAsContentScoped.
@Test
public void testAutostartChildAsContentScoped() throws Exception {
Subsystem applicationB = null;
try {
applicationB = installSubsystemFromFile(APPLICATION_B);
Subsystem applicationA = applicationB.getChildren().iterator().next();
restartSubsystemsImplBundle();
applicationB = findSubsystemService(applicationB.getSubsystemId());
applicationA = findSubsystemService(applicationA.getSubsystemId());
assertState(Subsystem.State.INSTALLED, applicationB);
assertBundleState(Bundle.INSTALLED | Bundle.RESOLVED, BUNDLE_A, applicationB);
assertState(Subsystem.State.INSTALLED, applicationA);
assertBundleState(Bundle.INSTALLED | Bundle.RESOLVED, BUNDLE_A, applicationA);
startSubsystem(applicationB);
restartSubsystemsImplBundle();
applicationB = findSubsystemService(applicationB.getSubsystemId());
applicationA = findSubsystemService(applicationA.getSubsystemId());
;
assertState(Subsystem.State.ACTIVE, applicationB);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationB);
assertState(Subsystem.State.ACTIVE, applicationA);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationA);
stopSubsystem(applicationA);
restartSubsystemsImplBundle();
applicationB = findSubsystemService(applicationB.getSubsystemId());
applicationA = findSubsystemService(applicationA.getSubsystemId());
;
assertState(Subsystem.State.ACTIVE, applicationB);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationB);
assertState(Subsystem.State.ACTIVE, applicationA);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationA);
stopSubsystem(applicationB);
restartSubsystemsImplBundle();
applicationB = findSubsystemService(applicationB.getSubsystemId());
applicationA = findSubsystemService(applicationA.getSubsystemId());
;
assertState(Subsystem.State.RESOLVED, applicationB);
assertBundleState(Bundle.RESOLVED, BUNDLE_A, applicationB);
assertState(Subsystem.State.RESOLVED, applicationA);
assertBundleState(Bundle.RESOLVED, BUNDLE_A, applicationA);
} finally {
stopAndUninstallSubsystemSilently(applicationB);
}
}
Aggregations