This is an automated email from the ASF dual-hosted git repository.
davidb pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-apiregions.git
The following commit(s) were added to refs/heads/master by this push:
new 92b8194 SLING-8970 Remove handling of region order-inheritance
92b8194 is described below
commit 92b8194689dc8d98f2a373a17487c61d99525259
Author: David Bosschaert <[email protected]>
AuthorDate: Mon Jan 20 14:49:31 2020 +0000
SLING-8970 Remove handling of region order-inheritance
Since this is now handled by the merge extension
---
.../feature/apiregions/impl/ResolverHookImpl.java | 17 ---------
.../apiregions/impl/ResolverHookImplTest.java | 42 ----------------------
2 files changed, 59 deletions(-)
diff --git
a/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
b/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
index 208a0cf..a8f3b67 100644
---
a/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
+++
b/src/main/java/org/apache/sling/feature/apiregions/impl/ResolverHookImpl.java
@@ -161,23 +161,6 @@ class ResolverHookImpl implements ResolverHook {
List<String> sharedRegions = new ArrayList<>(reqRegions);
sharedRegions.retainAll(capRegions);
- // Add any regions before the sharedRegions back in, as later
regions inherit from earlier ones
- List<String> capRegionList = new ArrayList<>(capRegions);
- for (String region : new ArrayList<>(sharedRegions)) {
- boolean foundRegion = false;
- for (int i = capRegionList.size() - 1; i >= 0; i--) {
- String capRegion = capRegionList.get(i);
- if (region.equals(capRegion)) {
- foundRegion = true;
- continue;
- }
- if (foundRegion) {
- // Add the found region to the front of the list
of shared regions
- sharedRegions.add(0, capRegion);
- }
- }
- }
-
Object pkg =
bc.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
if (pkg instanceof String) {
packageName = (String) pkg;
diff --git
a/src/test/java/org/apache/sling/feature/apiregions/impl/ResolverHookImplTest.java
b/src/test/java/org/apache/sling/feature/apiregions/impl/ResolverHookImplTest.java
index 2910492..cde362f 100644
---
a/src/test/java/org/apache/sling/feature/apiregions/impl/ResolverHookImplTest.java
+++
b/src/test/java/org/apache/sling/feature/apiregions/impl/ResolverHookImplTest.java
@@ -34,7 +34,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -72,47 +71,6 @@ public class ResolverHookImplTest {
}
@Test
- public void testRegionInheritance() {
- Map<Entry<String, Version>, List<String>> bsnvermap = new HashMap<>();
- bsnvermap.put(new AbstractMap.SimpleEntry<String,Version>(
- "providing.bundle", new Version(9,9,9)),
Collections.singletonList("b1"));
- bsnvermap.put(new AbstractMap.SimpleEntry<String,Version>(
- "requiring.bundle", new Version(123,456,789)),
Collections.singletonList("b2"));
-
- Map<String, Set<String>> bfmap = new HashMap<>();
- bfmap.put("b1", Collections.singleton("f1"));
- bfmap.put("b2", Collections.singleton("f2"));
-
- Map<String, Set<String>> frmap = new HashMap<>();
- frmap.put("f1", new LinkedHashSet<>(Arrays.asList("r0", "r1", "r2",
"r3")));
- frmap.put("f2", Collections.singleton("r2"));
-
- Map<String, Set<String>> rpmap = new HashMap<>();
- rpmap.put("r0", Collections.<String>emptySet());
- rpmap.put("r1", Collections.singleton("org.apache.sling.test"));
- rpmap.put("r3", Collections.singleton("org.apache.sling.toast"));
-
- ResolverHookImpl rh = new ResolverHookImpl(bsnvermap, bfmap, frmap,
rpmap, Collections.singleton(""));
-
- // b2 is in r2, it requires a capability that is provided by b1 in r1.
However since b1 is also
- // in r2, r2 inherits all the capabilities provided by regions before
r2, which includes r2. So
- // b2, which is in r2 should resolve.
- BundleRequirement req1 = mockRequirement("b2", bsnvermap);
- BundleCapability cap1 = mockCapability("org.apache.sling.test", "b1",
bsnvermap);
- List<BundleCapability> candidates1 = new
ArrayList<>(Arrays.asList(cap1));
- rh.filterMatches(req1, candidates1);
- assertEquals(Collections.singletonList(cap1), candidates1);
-
- // b2 is in r2, it requires a capability that is provided by b1 in r3.
r3 is listed after r2 in
- // b1 so it is not inherited by r2. The requirement should not resolve.
- BundleRequirement req2 = mockRequirement("b2", bsnvermap);
- BundleCapability cap2 = mockCapability("org.apache.sling.toast", "b1",
bsnvermap);
- List<BundleCapability> candidates2 = new
ArrayList<>(Arrays.asList(cap2));
- rh.filterMatches(req2, candidates2);
- assertEquals(Collections.emptyList(), candidates2);
- }
-
- @Test
public void testFilterMatches() {
Map<Entry<String, Version>, List<String>> bsnvermap = new HashMap<>();
bsnvermap.put(new
AbstractMap.SimpleEntry<String,Version>("system.bundle", new Version(3,2,1)),