Search in sources :

Example 16 with RegionDigraph

use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.

the class Aries1435Test method testConnectedNonSubsystemRegions.

@Test
public void testConnectedNonSubsystemRegions() throws Exception {
    registerWeavingHook("b");
    Bundle bundleB = getRootSubsystem().getBundleContext().installBundle(BUNDLE_B, new ByteArrayInputStream(createBundleBContent()));
    uninstallableBundles.add(bundleB);
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    uninstallableSubsystems.add(applicationA);
    Subsystem applicationB = getChild(applicationA, APPLICATION_B);
    uninstallSubsystem(applicationB);
    removeConnectionWithParent(applicationA);
    Region region = getRegion(applicationA);
    RegionDigraph digraph = region.getRegionDigraph();
    Region r1 = digraph.createRegion("R1");
    deletableRegions.add(r1);
    region.connectRegion(r1, digraph.createRegionFilterBuilder().allow("y", "(y=x)").build());
    Region r2a = digraph.createRegion("R2A");
    deletableRegions.add(r2a);
    Bundle bundleB1 = r2a.installBundleAtLocation(BUNDLE_B + '1', new ByteArrayInputStream(createBundleBContent()));
    uninstallableBundles.add(bundleB1);
    Region r2b = digraph.createRegion("R2B");
    deletableRegions.add(r2b);
    r2b.connectRegion(r2a, digraph.createRegionFilterBuilder().allow("osgi.wiring.package", "(&(osgi.wiring.package=b)(version=0))").build());
    region.connectRegion(r2b, digraph.createRegionFilterBuilder().allow("osgi.wiring.package", "(&(osgi.wiring.package=b)(version=0))").build());
    applicationB = installSubsystemFromFile(applicationA, APPLICATION_B);
    uninstallableSubsystems.add(applicationB);
    try {
        testDynamicImport(applicationB, "b.B");
    } catch (AssertionError e) {
        fail("Dynamic import should have succeeded");
    }
    testSharingPolicy(applicationB, "b", true);
    testSharingPolicy(applicationA, "b", true);
    testSharingPolicy(getRootSubsystem(), "b", false);
}
Also used : RegionDigraph(org.eclipse.equinox.region.RegionDigraph) ByteArrayInputStream(java.io.ByteArrayInputStream) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) Region(org.eclipse.equinox.region.Region) FilteredRegion(org.eclipse.equinox.region.RegionDigraph.FilteredRegion) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

RegionDigraph (org.eclipse.equinox.region.RegionDigraph)16 Region (org.eclipse.equinox.region.Region)14 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Set (java.util.Set)4 Bundle (org.osgi.framework.Bundle)4 Subsystem (org.osgi.service.subsystem.Subsystem)4 MapUtils.addToMapSet (org.apache.karaf.features.internal.util.MapUtils.addToMapSet)3 StandardRegionDigraph (org.eclipse.equinox.internal.region.StandardRegionDigraph)3 RegionFilterBuilder (org.eclipse.equinox.region.RegionFilterBuilder)3 BundleException (org.osgi.framework.BundleException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)2 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)2 Feature (org.apache.karaf.features.Feature)2 Test (org.junit.Test)2