SLING-8133 Feature IO doesn't allow for bundles with same ID and different versions.
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 @@
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.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 @@
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