Search in sources :

Example 1 with BasicSubsystem

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);
    }
}
Also used : RequireBundleHeader(org.apache.aries.subsystem.core.archive.RequireBundleHeader) Bundle(org.osgi.framework.Bundle) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 2 with BasicSubsystem

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);
    }
}
Also used : BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemImportServiceHeader(org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 3 with BasicSubsystem

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);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) RequireCapabilityHeader(org.apache.aries.subsystem.core.archive.RequireCapabilityHeader) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 4 with BasicSubsystem

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");
    }
}
Also used : BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) File(java.io.File) Test(org.junit.Test)

Example 5 with BasicSubsystem

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()));
    }
}
Also used : RegionDigraph(org.eclipse.equinox.region.RegionDigraph) Bundle(org.osgi.framework.Bundle) CoreOptions.mavenBundle(org.ops4j.pax.exam.CoreOptions.mavenBundle) CoreOptions.streamBundle(org.ops4j.pax.exam.CoreOptions.streamBundle) State(org.osgi.service.subsystem.Subsystem.State) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) Region(org.eclipse.equinox.region.Region) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)

Aggregations

BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)7 Subsystem (org.osgi.service.subsystem.Subsystem)7 Test (org.junit.Test)6 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)5 Bundle (org.osgi.framework.Bundle)5 RequireCapabilityHeader (org.apache.aries.subsystem.core.archive.RequireCapabilityHeader)2 File (java.io.File)1 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)1 AriesProvisionDependenciesDirective (org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)1 ImportPackageHeader (org.apache.aries.subsystem.core.archive.ImportPackageHeader)1 RequireBundleHeader (org.apache.aries.subsystem.core.archive.RequireBundleHeader)1 SubsystemImportServiceHeader (org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader)1 Region (org.eclipse.equinox.region.Region)1 RegionDigraph (org.eclipse.equinox.region.RegionDigraph)1 CoreOptions.mavenBundle (org.ops4j.pax.exam.CoreOptions.mavenBundle)1 CoreOptions.streamBundle (org.ops4j.pax.exam.CoreOptions.streamBundle)1 State (org.osgi.service.subsystem.Subsystem.State)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1