use of org.apache.aries.subsystem.core.internal.BasicSubsystem in project aries by apache.
the class Aries1421Test method testRequireBundleVersionRanges.
@Test
public void testRequireBundleVersionRanges() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
Bundle bundleA = getConstituentAsBundle(applicationA, BUNDLE_A, null, null);
String expectedStr = bundleA.getHeaders().get(Constants.REQUIRE_BUNDLE);
RequireBundleHeader expected = new RequireBundleHeader(expectedStr);
Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
String actualStr = headers.get(Constants.REQUIRE_BUNDLE);
RequireBundleHeader actual = new RequireBundleHeader(actualStr);
assertEquals("Wrong header", expected, actual);
} finally {
uninstallSubsystemSilently(applicationA);
}
}
use of org.apache.aries.subsystem.core.internal.BasicSubsystem in project aries by apache.
the class Aries1421Test method testSubsystemImportService.
@Test
public void testSubsystemImportService() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
String expectedStr = "foo;resolution:=optional,bar;filter:=\"(a=b)\";resolution:=optional";
SubsystemImportServiceHeader expected = new SubsystemImportServiceHeader(expectedStr);
Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
String actualStr = headers.get(SubsystemConstants.SUBSYSTEM_IMPORTSERVICE);
SubsystemImportServiceHeader actual = new SubsystemImportServiceHeader(actualStr);
assertEquals("Wrong header", expected, actual);
} finally {
uninstallSubsystemSilently(applicationA);
}
}
use of org.apache.aries.subsystem.core.internal.BasicSubsystem in project aries by apache.
the class Aries1421Test method testRequireCapability.
@Test
public void testRequireCapability() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
Bundle bundleA = getConstituentAsBundle(applicationA, BUNDLE_A, null, null);
String expectedStr = bundleA.getHeaders().get(Constants.REQUIRE_CAPABILITY);
RequireCapabilityHeader expected = new RequireCapabilityHeader(expectedStr);
Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
String actualStr = headers.get(Constants.REQUIRE_CAPABILITY);
RequireCapabilityHeader actual = new RequireCapabilityHeader(actualStr);
assertEquals("Wrong header", expected, actual);
} finally {
uninstallSubsystemSilently(applicationA);
}
}
use of org.apache.aries.subsystem.core.internal.BasicSubsystem 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.apache.aries.subsystem.core.internal.BasicSubsystem in project aries by apache.
the class SubsystemTest method uninstallSubsystem.
protected void uninstallSubsystem(Subsystem subsystem, boolean quietly) throws Exception {
BasicSubsystem basicSubsystem = (BasicSubsystem) subsystem;
AriesProvisionDependenciesDirective directive = basicSubsystem.getAriesProvisionDependenciesDirective();
Bundle b = null;
Region region = null;
RegionDigraph digraph = context().getService(RegionDigraph.class);
if (!quietly) {
if (directive.isResolve()) {
assertState(EnumSet.of(State.INSTALLING, State.INSTALLED, State.RESOLVED), subsystem);
} else {
assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), subsystem);
}
subsystemEvents.clear();
if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
b = getRegionContextBundle(subsystem);
region = digraph.getRegion(b);
}
}
State state = subsystem.getState();
subsystem.uninstall();
if (quietly) {
return;
}
Collection<Subsystem> parents = subsystem.getParents();
if (!EnumSet.of(State.INSTALL_FAILED, State.INSTALLED, State.INSTALLING).contains(state)) {
assertEvent(subsystem, State.INSTALLED, 5000);
}
assertEvent(subsystem, State.UNINSTALLING, 5000);
assertEvent(subsystem, State.UNINSTALLED, 5000);
assertState(State.UNINSTALLED, subsystem);
for (Subsystem parent : parents) {
assertNotChild(parent, subsystem);
}
if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
assertEquals("Region context bundle not uninstalled", Bundle.UNINSTALLED, b.getState());
assertNull("Region not removed", digraph.getRegion(region.getName()));
}
}
Aggregations