Search in sources :

Example 46 with Subsystem

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

the class Aries1408Test method testRequirementFromRemoteRepositoryConvertsToRequireCapability.

@Test
public void testRequirementFromRemoteRepositoryConvertsToRequireCapability() throws Exception {
    Bundle bundleB = installBundleFromFile(BUNDLE_B);
    try {
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        uninstallSubsystemSilently(applicationA);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    } finally {
        uninstallSilently(bundleB);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 47 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 48 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 49 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 50 with Subsystem

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

the class Aries1425Test method testFragmentResolved.

@Test
public void testFragmentResolved() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        applicationA.start();
        try {
            Bundle bundleA = getConstituentAsBundle(applicationA, BUNDLE_A, null, IdentityNamespace.TYPE_FRAGMENT);
            assertBundleState(bundleA, Bundle.RESOLVED);
        } finally {
            stopSubsystemSilently(applicationA);
        }
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)202 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)13 Hashtable (java.util.Hashtable)9 ServiceReference (org.osgi.framework.ServiceReference)8 File (java.io.File)7 BundleContext (org.osgi.framework.BundleContext)7 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FileInputStream (java.io.FileInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5