Search in sources :

Example 41 with Subsystem

use of org.osgi.service.subsystem.Subsystem 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 42 with Subsystem

use of org.osgi.service.subsystem.Subsystem 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 43 with Subsystem

use of org.osgi.service.subsystem.Subsystem 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 44 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1383Test method test10.

/*
	 * (10) Subsystem fails installation if the apache-aries-provision-dependencies 
	 * directive has a value other than "install" or "resolve".
	 */
@Test
public void test10() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, APPLICATION_INVALID_PROVISION_DEPENDENCIES, applicationInvalidProvisionDependencies(), false);
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 45 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1383Test method testFullLifeCycle.

@Test
public void testFullLifeCycle() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem subsystem = installSubsystem(root, APPLICATION_EMPTY, applicationEmpty(), false);
    startSubsystem(subsystem, false);
    stopSubsystem(subsystem);
    uninstallSubsystem(subsystem);
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)187 Test (org.junit.Test)151 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)78 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)52 SubsystemException (org.osgi.service.subsystem.SubsystemException)50 Bundle (org.osgi.framework.Bundle)48 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)19 IOException (java.io.IOException)11 Hashtable (java.util.Hashtable)8 BundleContext (org.osgi.framework.BundleContext)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5 FileInputStream (java.io.FileInputStream)4 Future (java.util.concurrent.Future)4