Search in sources :

Example 81 with Subsystem

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

the class SubsystemDependency_4E2Test method test4E2A_where_S2isAComposite.

/* Repeat test [4e2a.app] with S2 as a composite 
	 * that imports package x, requires bundle A and required capability y
	 */
@Test
public void test4E2A_where_S2isAComposite() throws Exception {
    Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E2_S1_COMP);
    startSubsystem(s1);
    Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E2_S2_COMP);
    startSubsystem(s2);
    verifyBundlesInstalled(s1.getBundleContext(), "s1", BUNDLE_A, BUNDLE_B);
    // - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
    checkBundlesCDandEWiredToAandB(s2);
    stop(s1, s2);
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 82 with Subsystem

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

the class SubsystemDependency_4E2Test method test4E2A_where_S2isAFeature.

/*
	 * - Repeat test [4e2a.app] with S2 as a feature
	 */
@Test
public void test4E2A_where_S2isAFeature() throws Exception {
    Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E2_S1_COMP);
    startSubsystem(s1);
    Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E2_S2_FEATURE);
    startSubsystem(s2);
    verifyBundlesInstalled(s1.getBundleContext(), "s1", BUNDLE_A, BUNDLE_B);
    // - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
    checkBundlesCDandEWiredToAandB(s2);
    stop(s1, s2);
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 83 with Subsystem

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

the class ProvisionPolicyTest method testProvisionToRoot.

@Test
public void testProvisionToRoot() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem composite = installSubsystemFromFile(root, COMPOSITE_A);
    try {
        assertProvisionPolicy(composite, false);
        Subsystem feature = installSubsystemFromFile(composite, FEATURE_B);
        try {
            assertProvisionPolicy(feature, false);
            assertConstituent(feature, BUNDLE_A);
            assertNotConstituent(feature, BUNDLE_B);
            assertNotConstituent(composite, BUNDLE_A);
            assertNotConstituent(composite, BUNDLE_B);
            assertNotConstituent(root, BUNDLE_A);
            assertConstituent(root, BUNDLE_B);
        } finally {
            uninstallSubsystemSilently(feature);
        }
    } finally {
        uninstallSubsystemSilently(composite);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 84 with Subsystem

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

the class ResolutionTest method testContentWithNonConstituentDependencyWithNonConstituentDependency.

/*
	 * Test that the right regions are used when validating capabilities.
	 * 
	 * Application A contains a content bundle requiring capability A. Bundle B
	 * provides capability A and is available as an installable resource from a
	 * repository service. Bundle B also requires capability B. Bundle C is an
	 * already installed resource in the root subsystem providing capability B.
	 * When validating capability A, the subsystem should use the root region as
	 * the from region, and its own region as the to region. When validating 
	 * capability B, the subsystem should use the root region as the from region
	 * as well as for the to region.
	 */
@Test
public void testContentWithNonConstituentDependencyWithNonConstituentDependency() throws Exception {
    // Register a repository service containing bundle B requiring
    // capability B and providing capability A.
    registerRepositoryService(BUNDLE_B);
    Subsystem root = getRootSubsystem();
    // Install unmanaged bundle C providing capability B as a constituent
    // of the root subsystem.
    Bundle bundleC = installBundleFromFile(BUNDLE_C, root);
    try {
        // Install application A with content bundle A requiring
        // capability A.
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        // Make sure the Require-Capability exists for capability a...
        assertHeaderExists(applicationA, Constants.REQUIRE_CAPABILITY);
        // ...but not for capability b.
        RequireCapabilityHeader header = new RequireCapabilityHeader(applicationA.getSubsystemHeaders(null).get(Constants.REQUIRE_CAPABILITY));
        assertEquals("Wrong number of clauses", 1, header.getClauses().size());
        Clause clause = header.getClauses().iterator().next();
        assertEquals("Wrong path", "a", clause.getPath());
        assertEquals("Wrong resolution directive", Constants.RESOLUTION_MANDATORY, clause.getDirective(Constants.RESOLUTION_DIRECTIVE).getValue());
        assertEquals("Wrong effective directive", Constants.EFFECTIVE_RESOLVE, clause.getDirective(Constants.EFFECTIVE_DIRECTIVE).getValue());
        try {
            // Make sure the runtime resolution works as well.
            applicationA.start();
        } catch (SubsystemException e) {
            fail("Application A should have started");
        } finally {
            stopAndUninstallSubsystemSilently(applicationA);
        }
    } catch (SubsystemException e) {
        fail("Application A should have installed." + e.getMessage());
    } finally {
        uninstallSilently(bundleC);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) RequireCapabilityHeader(org.apache.aries.subsystem.core.archive.RequireCapabilityHeader) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) Clause(org.apache.aries.subsystem.core.archive.Clause) Test(org.junit.Test)

Example 85 with Subsystem

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

the class ResolutionTest method testMissingNativeCodeRequirement.

@Test
public void testMissingNativeCodeRequirement() throws Exception {
    Subsystem applicationE = null;
    try {
        applicationE = installSubsystemFromFile(APPLICATION_E);
    // TODO this should fail to intsall
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Installation should succeed for Bundle-NativeCode");
    }
    try {
        applicationE.start();
        fail("Expected to fail to install");
    } catch (Exception e) {
    // expected
    } finally {
        uninstallSubsystemSilently(applicationE);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemException(org.osgi.service.subsystem.SubsystemException) IOException(java.io.IOException) ResolutionException(org.osgi.service.resolver.ResolutionException) Test(org.junit.Test)

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