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.git
The following commit(s) were added to refs/heads/master by this push:
new 211889b Added a test that checks that feature prototypes are not
included in the merge
211889b is described below
commit 211889b60eeed8629759894c48771773ac883851
Author: David Bosschaert <[email protected]>
AuthorDate: Fri Mar 22 16:16:59 2019 +0000
Added a test that checks that feature prototypes are not included in the
merge
---
.../sling/feature/builder/FeatureBuilderTest.java | 65 ++++++++++++++++------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git
a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
index 5de408b..b46d7f3 100644
--- a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
+++ b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
@@ -16,22 +16,6 @@
*/
package org.apache.sling.feature.builder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.felix.utils.resource.CapabilityImpl;
import org.apache.felix.utils.resource.RequirementImpl;
import org.apache.sling.feature.Artifact;
@@ -45,6 +29,22 @@ import org.junit.Test;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public class FeatureBuilderTest {
private static final Map<String, Feature> FEATURES = new HashMap<>();
@@ -468,6 +468,39 @@ public class FeatureBuilderTest {
assertEquals(idB, features[0].getId());
}
+ @Test public void testMergeIncludeDedup() throws Exception {
+ final ArtifactId idA = ArtifactId.fromMvnId("g:a:1.0.0");
+ final ArtifactId idB = ArtifactId.fromMvnId("g:b:1.0.0");
+
+ final Feature a = new Feature(idA);
+ ArtifactId b1ID = ArtifactId.fromMvnId("g:bundle1:1.2.3");
+ ArtifactId b2ID = ArtifactId.fromMvnId("g:bundle2:4.5.6");
+ Artifact b1 = new Artifact(b1ID);
+ Artifact b2 = new Artifact(b2ID);
+ a.getBundles().add(b1);
+ a.getBundles().add(b2);
+
+ final Feature b = new Feature(idB);
+ // feature b includes feature a and removes a bundle
+ final Prototype inc = new Prototype(idA);
+ b.setPrototype(inc);
+ inc.getBundleRemovals().add(b1ID);
+
+ // Merge all features together
+ ArtifactId c = ArtifactId.fromMvnId("g:c:1.0.0");
+ Feature fc = FeatureBuilder.assemble(c, new BuilderContext(new
FeatureProvider() {
+
+ @Override
+ public Feature provide(ArtifactId id) {
+ return null;
+ }
+ }), a, b);
+
+ // Test that the feature that acted as a prototype is not included in
the merge.
+ assertEquals(1, fc.getBundles().size());
+ assertEquals(b2, fc.getBundles().iterator().next());
+ }
+
@Test public void testBundleRemoveWithExactVersion() throws Exception {
final ArtifactId bundleA1 = ArtifactId.fromMvnId("g:a:1.0.0");
final ArtifactId bundleA2 = ArtifactId.fromMvnId("g:a:1.1.0");