Search in sources :

Example 11 with Subsystem

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

the class DynamicImportTest method verifyThatDynamicImportNeedsHandling.

/*
	 * Install an .esa containing a bundle with a BundleActivator, and a 
	 * DynamicImport-Package on org.apache.aries.subsystem.itests.hello.api.
	 * This app should fail to start because we've not yet intervened to permit 
	 * this dynamic package wiring requirement from being met. 
	 */
@Test
public void verifyThatDynamicImportNeedsHandling() throws Exception {
    Subsystem subsystem = installSubsystemFromFile("dynamicImport.esa");
    try {
        startSubsystem(subsystem);
        Bundle[] bundles = subsystem.getBundleContext().getBundles();
        for (Bundle b : bundles) {
            System.out.println(b.getSymbolicName() + " -> " + b.getState());
        }
        fail("dynamicImport.esa started when we didn't expect it to");
    } catch (SubsystemException sx) {
        Throwable cause = sx.getCause();
        assertTrue("BundleException expected", cause instanceof BundleException);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) BundleException(org.osgi.framework.BundleException) Test(org.junit.Test)

Example 12 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 13 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 14 with Subsystem

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

the class ApplicationTest method testApplication1.

/*
	 * Subsystem application1 has content bundle tb1.jar.
	 * Bundle tb1.jar has an import package dependency on org.apache.aries.subsystem.itests.tb3.
	 */
@Test
public void testApplication1() throws Exception {
    Subsystem application1 = installSubsystemFromFile("application1.esa");
    try {
        assertSymbolicName("org.apache.aries.subsystem.application1", application1);
        assertVersion("0.0.0", application1);
        assertType(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, application1);
        assertChildren(0, application1);
        assertConstituents(2, application1);
        startSubsystem(application1);
        assertBundleState(Bundle.RESOLVED | Bundle.ACTIVE, "org.apache.aries.subsystem.itests.tb1", application1);
        assertBundleState(Bundle.RESOLVED | Bundle.ACTIVE, "org.apache.aries.subsystem.itests.tb3", getRootSubsystem());
    } finally {
        stopSubsystemSilently(application1);
        uninstallSubsystemSilently(application1);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 15 with Subsystem

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

the class ApplicationTest method testRequireBundle.

@Test
public void testRequireBundle() throws Exception {
    File file = new File(BUNDLE_B);
    // The following input stream is closed by the bundle context.
    Bundle b = getRootSubsystem().getBundleContext().installBundle(file.toURI().toString(), new FileInputStream(file));
    try {
        Subsystem application = installSubsystemFromFile(APPLICATION_B);
        try {
            startSubsystem(application);
        } finally {
            stopSubsystemSilently(application);
            uninstallSubsystemSilently(application);
        }
    } finally {
        uninstallSilently(b);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) File(java.io.File) FileInputStream(java.io.FileInputStream) 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