Search in sources :

Example 56 with Subsystem

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

the class Aries1435Test method testChildExportsPackage.

@Test
public void testChildExportsPackage() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        Subsystem compositeE = installSubsystemFromFile(applicationB, COMPOSITE_E);
        try {
            startSubsystem(compositeE);
            try {
                testSharingPolicy(applicationB, "b", true);
                testDynamicImport(applicationB, "b.B");
                testSharingPolicy(applicationB, "b", true);
                testSharingPolicy(compositeE, "b", false);
                testSharingPolicy(getRootSubsystem(), "b", false);
            } finally {
                stopSubsystemSilently(compositeE);
            }
        } finally {
            uninstallSubsystemSilently(compositeE);
        }
    } finally {
        uninstallSubsystemSilently(applicationB);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 57 with Subsystem

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

the class Aries1435Test method testNoProviders.

@Test
public void testNoProviders() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        Bundle bundleA = getConstituentAsBundle(applicationB, BUNDLE_A, null, null);
        bundleA.loadClass("a.A");
        try {
            bundleA.loadClass("b.B");
            fail("Class should not have loaded");
        } catch (ClassNotFoundException e) {
        // Okay.
        }
        testSharingPolicy(applicationB, "b", false);
    } finally {
        uninstallSubsystemSilently(applicationB);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 58 with Subsystem

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

the class Aries1435Test method testWovenSubsystemParentContainsProvider.

@Test
public void testWovenSubsystemParentContainsProvider() throws Exception {
    registerWeavingHook("b");
    Subsystem compositeE = installSubsystemFromFile(COMPOSITE_E);
    try {
        assertNotConstituent(getRootSubsystem(), BUNDLE_B);
        assertConstituent(compositeE, BUNDLE_B);
        Subsystem applicationB = getChild(compositeE, APPLICATION_B);
        assertNotConstituent(applicationB, BUNDLE_B);
        testDynamicImport(applicationB, "b.B");
        testSharingPolicy(compositeE, "b", false);
        testSharingPolicy(applicationB, "b", true);
    } finally {
        uninstallSubsystemSilently(compositeE);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 59 with Subsystem

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

the class Aries1435Test method testDisconnectedEdgeWithParent.

@Test
public void testDisconnectedEdgeWithParent() throws Exception {
    registerWeavingHook("b");
    Bundle bundleB = getRootSubsystem().getBundleContext().installBundle(BUNDLE_B, new ByteArrayInputStream(createBundleBContent()));
    try {
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        try {
            Subsystem applicationB = getChild(applicationA, APPLICATION_B);
            uninstallSubsystem(applicationB);
            removeConnectionWithParent(applicationA);
            applicationB = installSubsystemFromFile(applicationA, APPLICATION_B);
            try {
                try {
                    testDynamicImport(applicationB, "b.B");
                    fail("Dynamic import should have failed");
                } catch (AssertionError e) {
                // Okay.
                }
                testSharingPolicy(applicationB, "b", true);
                testSharingPolicy(applicationA, "b", false);
                testSharingPolicy(getRootSubsystem(), "b", false);
            } finally {
                uninstallSubsystemSilently(applicationB);
            }
        } finally {
            uninstallSubsystemSilently(applicationA);
        }
    } finally {
        uninstallSilently(bundleB);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 60 with Subsystem

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

the class Aries1435Test method testWovenSubsystemContainsProvider.

@Test
public void testWovenSubsystemContainsProvider() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationE = installSubsystemFromFile(APPLICATION_E);
    try {
        assertConstituent(applicationE, BUNDLE_B);
        testDynamicImport(applicationE, "b.B");
        testSharingPolicy(applicationE, "b", false);
    } finally {
        uninstallSubsystemSilently(applicationE);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) 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