This is an automated email from the ASF dual-hosted git repository.

cziegeler 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 5ecbaf4  SLING-8064 : Support marking a feature as final - add test 
case
5ecbaf4 is described below

commit 5ecbaf46ac6c24de1cf9fe1aaa1c5be8a6000204
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Oct 31 14:40:41 2018 +0100

    SLING-8064 : Support marking a feature as final - add test case
---
 .../sling/feature/builder/FeatureBuilderTest.java  | 64 ++++++++++++++++------
 1 file changed, 47 insertions(+), 17 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 73c5f64..78133cf 100644
--- a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
+++ b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
@@ -16,6 +16,23 @@
  */
 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.AbstractMap;
+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;
@@ -31,23 +48,6 @@ import org.junit.Test;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 
-import java.util.AbstractMap;
-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<>();
@@ -685,4 +685,34 @@ public class FeatureBuilderTest {
 
     }
 
+    @Test
+    public void testFinalFlag() throws Exception {
+        // feature inclusion without final flag is already tested by other 
tests
+        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);
+        a.setFinal(true);
+        final Feature b = new Feature(idB);
+        // feature b includes feature a
+        final Include inc = new Include(idA);
+        b.setInclude(inc);
+
+        // assemble feature, this should throw an exception
+        try {
+            FeatureBuilder.assemble(b, new BuilderContext(new 
FeatureProvider() {
+
+                @Override
+                public Feature provide(ArtifactId id) {
+                    if (id.equals(idA)) {
+                        return a;
+                    }
+                    return null;
+                }
+            }, null));
+            fail();
+        } catch (final IllegalStateException ise) {
+            assertTrue(ise.getMessage().contains(" final "));
+        }
+    }
 }

Reply via email to