You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/09/29 15:09:57 UTC

svn commit: r1810119 - in /sling/whiteboard/cziegeler/feature/src: main/java/org/apache/sling/feature/process/ test/java/org/apache/sling/feature/ test/java/org/apache/sling/feature/process/

Author: cziegeler
Date: Fri Sep 29 15:09:56 2017
New Revision: 1810119

URL: http://svn.apache.org/viewvc?rev=1810119&view=rev
Log:
Support maven coordinates

Modified:
    sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/process/ApplicationBuilder.java
    sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/BundlesTest.java
    sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/BuilderUtilTest.java
    sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/FeatureBuilderTest.java

Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/process/ApplicationBuilder.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/process/ApplicationBuilder.java?rev=1810119&r1=1810118&r2=1810119&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/process/ApplicationBuilder.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/process/ApplicationBuilder.java Fri Sep 29 15:09:56 2017
@@ -55,7 +55,7 @@ public class ApplicationBuilder {
         final Feature[] features = new Feature[featureIds.length];
         int index = 0;
         for(final String id : featureIds) {
-            features[index] = context.getFeatureProvider().provide(ArtifactId.fromMvnId(id));
+            features[index] = context.getFeatureProvider().provide(ArtifactId.parse(id));
             if ( features[index] == null ) {
                 throw new IllegalStateException("Unable to find included feature " + id);
             }

Modified: sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/BundlesTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/BundlesTest.java?rev=1810119&r1=1810118&r2=1810119&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/BundlesTest.java (original)
+++ sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/BundlesTest.java Fri Sep 29 15:09:56 2017
@@ -16,23 +16,23 @@
  */
 package org.apache.sling.feature;
 
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
 
 public class BundlesTest {
 
     @Test
     public void testIterator() {
         final Bundles bundles = new Bundles();
-        bundles.add(1, new Artifact(ArtifactId.fromMvnId("1/a/1")));
-        bundles.add(5, new Artifact(ArtifactId.fromMvnId("5/a/5")));
-        bundles.add(5, new Artifact(ArtifactId.fromMvnId("5/b/6")));
-        bundles.add(2, new Artifact(ArtifactId.fromMvnId("2/b/2")));
-        bundles.add(2, new Artifact(ArtifactId.fromMvnId("2/a/3")));
-        bundles.add(4, new Artifact(ArtifactId.fromMvnId("4/x/4")));
+        bundles.add(1, new Artifact(ArtifactId.parse("1/a/1")));
+        bundles.add(5, new Artifact(ArtifactId.parse("5/a/5")));
+        bundles.add(5, new Artifact(ArtifactId.parse("5/b/6")));
+        bundles.add(2, new Artifact(ArtifactId.parse("2/b/2")));
+        bundles.add(2, new Artifact(ArtifactId.parse("2/a/3")));
+        bundles.add(4, new Artifact(ArtifactId.parse("4/x/4")));
 
         int index = 1;
         for(final Map.Entry<Integer, Artifact> entry : bundles) {

Modified: sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/BuilderUtilTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/BuilderUtilTest.java?rev=1810119&r1=1810118&r2=1810119&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/BuilderUtilTest.java (original)
+++ sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/BuilderUtilTest.java Fri Sep 29 15:09:56 2017
@@ -16,18 +16,18 @@
  */
 package org.apache.sling.feature.process;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Bundles;
-import org.apache.sling.feature.process.BuilderUtil.ArtifactMerge;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Bundles;
+import org.apache.sling.feature.process.BuilderUtil.ArtifactMerge;
+import org.junit.Test;
 
 public class BuilderUtilTest {
 
@@ -53,81 +53,81 @@ public class BuilderUtilTest {
     @Test public void testMergeBundlesWithAlgHighest() {
         final Bundles target = new Bundles();
 
-        target.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.0")));
-        target.add(2, new Artifact(ArtifactId.fromMvnId("g/b/2.0")));
-        target.add(3, new Artifact(ArtifactId.fromMvnId("g/c/2.5")));
+        target.add(1, new Artifact(ArtifactId.parse("g/a/1.0")));
+        target.add(2, new Artifact(ArtifactId.parse("g/b/2.0")));
+        target.add(3, new Artifact(ArtifactId.parse("g/c/2.5")));
 
         final Bundles source = new Bundles();
-        source.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.1")));
-        source.add(2, new Artifact(ArtifactId.fromMvnId("g/b/1.9")));
-        source.add(3, new Artifact(ArtifactId.fromMvnId("g/c/2.5")));
+        source.add(1, new Artifact(ArtifactId.parse("g/a/1.1")));
+        source.add(2, new Artifact(ArtifactId.parse("g/b/1.9")));
+        source.add(3, new Artifact(ArtifactId.parse("g/c/2.5")));
 
         BuilderUtil.mergeBundles(target, source, ArtifactMerge.HIGHEST);
 
         final List<Map.Entry<Integer, Artifact>> result = getBundles(target);
         assertEquals(3, result.size());
-        assertContains(result, 1, ArtifactId.fromMvnId("g/a/1.1"));
-        assertContains(result, 2, ArtifactId.fromMvnId("g/b/2.0"));
-        assertContains(result, 3, ArtifactId.fromMvnId("g/c/2.5"));
+        assertContains(result, 1, ArtifactId.parse("g/a/1.1"));
+        assertContains(result, 2, ArtifactId.parse("g/b/2.0"));
+        assertContains(result, 3, ArtifactId.parse("g/c/2.5"));
     }
 
     @Test public void testMergeBundlesWithAlgLatest() {
         final Bundles target = new Bundles();
 
-        target.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.0")));
-        target.add(2, new Artifact(ArtifactId.fromMvnId("g/b/2.0")));
-        target.add(3, new Artifact(ArtifactId.fromMvnId("g/c/2.5")));
+        target.add(1, new Artifact(ArtifactId.parse("g/a/1.0")));
+        target.add(2, new Artifact(ArtifactId.parse("g/b/2.0")));
+        target.add(3, new Artifact(ArtifactId.parse("g/c/2.5")));
 
         final Bundles source = new Bundles();
-        source.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.1")));
-        source.add(2, new Artifact(ArtifactId.fromMvnId("g/b/1.9")));
-        source.add(3, new Artifact(ArtifactId.fromMvnId("g/c/2.5")));
+        source.add(1, new Artifact(ArtifactId.parse("g/a/1.1")));
+        source.add(2, new Artifact(ArtifactId.parse("g/b/1.9")));
+        source.add(3, new Artifact(ArtifactId.parse("g/c/2.5")));
 
         BuilderUtil.mergeBundles(target, source, ArtifactMerge.LATEST);
 
         final List<Map.Entry<Integer, Artifact>> result = getBundles(target);
         assertEquals(3, result.size());
-        assertContains(result, 1, ArtifactId.fromMvnId("g/a/1.1"));
-        assertContains(result, 2, ArtifactId.fromMvnId("g/b/1.9"));
-        assertContains(result, 3, ArtifactId.fromMvnId("g/c/2.5"));
+        assertContains(result, 1, ArtifactId.parse("g/a/1.1"));
+        assertContains(result, 2, ArtifactId.parse("g/b/1.9"));
+        assertContains(result, 3, ArtifactId.parse("g/c/2.5"));
     }
 
     @Test public void testMergeBundlesDifferentStartlevel() {
         final Bundles target = new Bundles();
 
-        target.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.0")));
+        target.add(1, new Artifact(ArtifactId.parse("g/a/1.0")));
 
         final Bundles source = new Bundles();
-        source.add(2, new Artifact(ArtifactId.fromMvnId("g/a/1.1")));
+        source.add(2, new Artifact(ArtifactId.parse("g/a/1.1")));
 
         BuilderUtil.mergeBundles(target, source, ArtifactMerge.LATEST);
 
         final List<Map.Entry<Integer, Artifact>> result = getBundles(target);
         assertEquals(1, result.size());
-        assertContains(result, 2, ArtifactId.fromMvnId("g/a/1.1"));
+        assertContains(result, 2, ArtifactId.parse("g/a/1.1"));
     }
 
     @Test public void testMergeBundles() {
         final Bundles target = new Bundles();
 
-        target.add(1, new Artifact(ArtifactId.fromMvnId("g/a/1.0")));
-        target.add(2, new Artifact(ArtifactId.fromMvnId("g/b/2.0")));
-        target.add(3, new Artifact(ArtifactId.fromMvnId("g/c/2.5")));
+        target.add(1, new Artifact(ArtifactId.parse("g/a/1.0")));
+        target.add(2, new Artifact(ArtifactId.parse("g/b/2.0")));
+        target.add(3, new Artifact(ArtifactId.parse("g/c/2.5")));
 
         final Bundles source = new Bundles();
-        source.add(1, new Artifact(ArtifactId.fromMvnId("g/d/1.1")));
-        source.add(2, new Artifact(ArtifactId.fromMvnId("g/e/1.9")));
-        source.add(3, new Artifact(ArtifactId.fromMvnId("g/f/2.5")));
+        source.add(1, new Artifact(ArtifactId.parse("g/d/1.1")));
+        source.add(2, new Artifact(ArtifactId.parse("g/e/1.9")));
+        source.add(3, new Artifact(ArtifactId.parse("g/f/2.5")));
 
         BuilderUtil.mergeBundles(target, source, ArtifactMerge.LATEST);
 
         final List<Map.Entry<Integer, Artifact>> result = getBundles(target);
         assertEquals(6, result.size());
-        assertContains(result, 1, ArtifactId.fromMvnId("g/a/1.0"));
-        assertContains(result, 2, ArtifactId.fromMvnId("g/b/2.0"));
-        assertContains(result, 3, ArtifactId.fromMvnId("g/c/2.5"));
-        assertContains(result, 1, ArtifactId.fromMvnId("g/d/1.1"));
-        assertContains(result, 2, ArtifactId.fromMvnId("g/e/1.9"));
-        assertContains(result, 3, ArtifactId.fromMvnId("g/f/2.5"));
+        assertContains(result, 1, ArtifactId.parse("g/a/1.0"));
+        assertContains(result, 2, ArtifactId.parse("g/b/2.0"));
+        assertContains(result, 3, ArtifactId.parse("g/c/2.5"));
+        assertContains(result, 1, ArtifactId.parse("g/d/1.1"));
+        assertContains(result, 2, ArtifactId.parse("g/e/1.9"));
+        assertContains(result, 3, ArtifactId.parse("g/f/2.5"));
     }
 }

Modified: sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/FeatureBuilderTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/FeatureBuilderTest.java?rev=1810119&r1=1810118&r2=1810119&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/FeatureBuilderTest.java (original)
+++ sling/whiteboard/cziegeler/feature/src/test/java/org/apache/sling/feature/process/FeatureBuilderTest.java Fri Sep 29 15:09:56 2017
@@ -41,16 +41,16 @@ public class FeatureBuilderTest {
     private static final Map<String, Feature> FEATURES = new HashMap<>();
 
     static {
-        final Feature f1 = new Feature(ArtifactId.fromMvnId("g/a/1"));
+        final Feature f1 = new Feature(ArtifactId.parse("g/a/1"));
 
         f1.getFrameworkProperties().put("foo", "2");
         f1.getFrameworkProperties().put("bar", "X");
 
-        f1.getBundles().add(3, new Artifact(ArtifactId.fromMvnId("org.apache.sling/foo-bar/4.5.6")));
-        f1.getBundles().add(5, new Artifact(ArtifactId.fromMvnId("group/testnewversion_low/2")));
-        f1.getBundles().add(5, new Artifact(ArtifactId.fromMvnId("group/testnewversion_high/2")));
-        f1.getBundles().add(5, new Artifact(ArtifactId.fromMvnId("group/testnewstartlevel/1")));
-        f1.getBundles().add(5, new Artifact(ArtifactId.fromMvnId("group/testnewstartlevelandversion/1")));
+        f1.getBundles().add(3, new Artifact(ArtifactId.parse("org.apache.sling/foo-bar/4.5.6")));
+        f1.getBundles().add(5, new Artifact(ArtifactId.parse("group/testnewversion_low/2")));
+        f1.getBundles().add(5, new Artifact(ArtifactId.parse("group/testnewversion_high/2")));
+        f1.getBundles().add(5, new Artifact(ArtifactId.parse("group/testnewstartlevel/1")));
+        f1.getBundles().add(5, new Artifact(ArtifactId.parse("group/testnewstartlevelandversion/1")));
 
         final Configuration c1 = new Configuration("org.apache.sling.foo");
         c1.getProperties().put("prop", "value");
@@ -63,7 +63,7 @@ public class FeatureBuilderTest {
 
         @Override
         public Feature provide(final ArtifactId id) {
-            return FEATURES.get(id.getGroupId() + "/" + id.getArtifactId() + "/" + id.getVersion());
+            return FEATURES.get(id.getGroupId() + ":" + id.getArtifactId() + ":" + id.getVersion());
         }
     };
 
@@ -173,7 +173,7 @@ public class FeatureBuilderTest {
     }
 
     @Test public void testNoIncludesNoUpgrade() throws Exception {
-        final Feature base = new Feature(ArtifactId.fromMvnId("org.apache.sling/test-feature/1.1"));
+        final Feature base = new Feature(ArtifactId.parse("org.apache.sling/test-feature/1.1"));
 
         final Requirement r1 = new Requirement("osgi.contract");
         r1.getDirectives().put("filter", "(&(osgi.contract=JavaServlet)(version=3.1))");
@@ -193,12 +193,12 @@ public class FeatureBuilderTest {
         base.getFrameworkProperties().put("brave", "something");
         base.getFrameworkProperties().put("org.apache.felix.scr.directory", "launchpad/scr");
 
-        final Artifact a1 = new Artifact(ArtifactId.fromMvnId("org.apache.sling/oak-server/1.0.0"));
+        final Artifact a1 = new Artifact(ArtifactId.parse("org.apache.sling/oak-server/1.0.0"));
         a1.getMetadata().put("hash", "4632463464363646436");
         base.getBundles().add(1, a1);
-        base.getBundles().add(1,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/application-bundle/2.0.0")));
-        base.getBundles().add(1,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/another-bundle/2.1.0")));
-        base.getBundles().add(2,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/foo-xyz/1.2.3")));
+        base.getBundles().add(1,  new Artifact(ArtifactId.parse("org.apache.sling/application-bundle/2.0.0")));
+        base.getBundles().add(1,  new Artifact(ArtifactId.parse("org.apache.sling/another-bundle/2.1.0")));
+        base.getBundles().add(2,  new Artifact(ArtifactId.parse("org.apache.sling/foo-xyz/1.2.3")));
 
         final Configuration co1 = new Configuration("my.pid");
         co1.getProperties().put("foo", 5L);
@@ -218,8 +218,8 @@ public class FeatureBuilderTest {
     }
 
     @Test public void testSingleInclude() throws Exception {
-        final Feature base = new Feature(ArtifactId.fromMvnId("org.apache.sling/test-feature/1.1"));
-        final Include i1 = new Include(ArtifactId.fromMvnId("g/a/1"));
+        final Feature base = new Feature(ArtifactId.parse("org.apache.sling/test-feature/1.1"));
+        final Include i1 = new Include(ArtifactId.parse("g/a/1"));
         base.getIncludes().add(i1);
 
         final Requirement r1 = new Requirement("osgi.contract");
@@ -236,16 +236,16 @@ public class FeatureBuilderTest {
         base.getFrameworkProperties().put("brave", "something");
         base.getFrameworkProperties().put("org.apache.felix.scr.directory", "launchpad/scr");
 
-        final Artifact a1 = new Artifact(ArtifactId.fromMvnId("org.apache.sling/oak-server/1.0.0"));
+        final Artifact a1 = new Artifact(ArtifactId.parse("org.apache.sling/oak-server/1.0.0"));
         a1.getMetadata().put("hash", "4632463464363646436");
         base.getBundles().add(1, a1);
-        base.getBundles().add(1,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/application-bundle/2.0.0")));
-        base.getBundles().add(1,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/another-bundle/2.1.0")));
-        base.getBundles().add(2,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/foo-xyz/1.2.3")));
-        base.getBundles().add(5,  new Artifact(ArtifactId.fromMvnId("group/testnewversion_low/1")));
-        base.getBundles().add(5,  new Artifact(ArtifactId.fromMvnId("group/testnewversion_high/5")));
-        base.getBundles().add(10,  new Artifact(ArtifactId.fromMvnId("group/testnewstartlevel/1")));
-        base.getBundles().add(10,  new Artifact(ArtifactId.fromMvnId("group/testnewstartlevelandversion/2")));
+        base.getBundles().add(1,  new Artifact(ArtifactId.parse("org.apache.sling/application-bundle/2.0.0")));
+        base.getBundles().add(1,  new Artifact(ArtifactId.parse("org.apache.sling/another-bundle/2.1.0")));
+        base.getBundles().add(2,  new Artifact(ArtifactId.parse("org.apache.sling/foo-xyz/1.2.3")));
+        base.getBundles().add(5,  new Artifact(ArtifactId.parse("group/testnewversion_low/1")));
+        base.getBundles().add(5,  new Artifact(ArtifactId.parse("group/testnewversion_high/5")));
+        base.getBundles().add(10,  new Artifact(ArtifactId.parse("group/testnewstartlevel/1")));
+        base.getBundles().add(10,  new Artifact(ArtifactId.parse("group/testnewstartlevelandversion/2")));
 
         final Configuration co1 = new Configuration("my.pid");
         co1.getProperties().put("foo", 5L);
@@ -263,7 +263,7 @@ public class FeatureBuilderTest {
         final Feature result = base.copy();
         result.getIncludes().remove(0);
         result.getFrameworkProperties().put("bar", "X");
-        result.getBundles().add(3,  new Artifact(ArtifactId.fromMvnId("org.apache.sling/foo-bar/4.5.6")));
+        result.getBundles().add(3,  new Artifact(ArtifactId.parse("org.apache.sling/foo-bar/4.5.6")));
         final Configuration co3 = new Configuration("org.apache.sling.foo");
         co3.getProperties().put("prop", "value");
         result.getConfigurations().add(co3);