You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/11/27 11:50:45 UTC
[sling-org-apache-sling-feature-io] branch master updated:
SLING-8133 Feature IO doesn't allow for bundles with same ID and different
versions.
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-io.git
The following commit(s) were added to refs/heads/master by this push:
new ded139b SLING-8133 Feature IO doesn't allow for bundles with same ID and different versions.
ded139b is described below
commit ded139b9ec1434e6f0e7f59c8c628ddfbf982ba3
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Tue Nov 27 11:50:02 2018 +0000
SLING-8133 Feature IO doesn't allow for bundles with same ID and different versions.
---
.../sling/feature/io/json/JSONReaderBase.java | 5 ++--
.../feature/io/json/FeatureJSONReaderTest.java | 28 +++++++++++++++-------
src/test/resources/features/test3.json | 7 ++++++
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
index e4051f0..95ba21d 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
@@ -196,9 +196,8 @@ abstract class JSONReaderBase {
readArtifacts(JSONConstants.FEATURE_BUNDLES, "bundle", list, bundlesObj, configContainer);
for(final Artifact a : list) {
- Artifact sameFound = container.getSame(a.getId());
- if ( sameFound != null) {
- throw new IOException(exceptionPrefix + "Duplicate bundle " + a.getId().toMvnId());
+ if ( container.containsExact(a.getId())) {
+ throw new IOException(exceptionPrefix + "Duplicate identical bundle " + a.getId().toMvnId());
}
try {
// check start order
diff --git a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONReaderTest.java b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONReaderTest.java
index ab30274..a51a62e 100644
--- a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONReaderTest.java
+++ b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONReaderTest.java
@@ -16,14 +16,8 @@
*/
package org.apache.sling.feature.io.json;
-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 java.util.Arrays;
-
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Bundles;
import org.apache.sling.feature.Configuration;
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.Extensions;
@@ -31,6 +25,14 @@ import org.apache.sling.feature.Feature;
import org.junit.Test;
import org.osgi.resource.Capability;
+import java.util.Arrays;
+
+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;
+
public class FeatureJSONReaderTest {
@Test public void testRead() throws Exception {
@@ -86,4 +88,14 @@ public class FeatureJSONReaderTest {
final Feature featureB = U.readFeature("final");
assertTrue(featureB.isFinal());
}
+
+ @Test
+ public void testReadMultiBSNVer() throws Exception {
+ final Feature f = U.readFeature("test3");
+ Bundles fb = f.getBundles();
+ assertEquals(2, fb.size());
+ assertTrue(fb.containsExact(ArtifactId.fromMvnId("org.apache.sling:foo:1.2.3")));
+ assertTrue(fb.containsExact(ArtifactId.fromMvnId("org.apache.sling:foo:4.5.6")));
+ assertFalse(fb.containsExact(ArtifactId.fromMvnId("org.apache.sling:foo:7.8.9")));
+ }
}
diff --git a/src/test/resources/features/test3.json b/src/test/resources/features/test3.json
new file mode 100644
index 0000000..de143cc
--- /dev/null
+++ b/src/test/resources/features/test3.json
@@ -0,0 +1,7 @@
+{
+ "id" : "org.apache.sling/test-feature3/2",
+ "bundles": [
+ "org.apache.sling/foo/1.2.3",
+ "org.apache.sling/foo/4.5.6"
+ ]
+}
\ No newline at end of file