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 2021/03/02 05:56:14 UTC
[sling-org-apache-sling-feature-cpconverter] branch master updated:
SLING-10157 : Converter fails with duplicate configuration PIDs
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-cpconverter.git
The following commit(s) were added to refs/heads/master by this push:
new 28a78d2 SLING-10157 : Converter fails with duplicate configuration PIDs
28a78d2 is described below
commit 28a78d2a8f2cee923402cf1be39be9cac62baa6c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Mar 2 06:56:03 2021 +0100
SLING-10157 : Converter fails with duplicate configuration PIDs
---
.../features/DefaultFeaturesManager.java | 1 +
.../ContentPackage2FeatureModelConverterTest.java | 26 +++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
index 4d6f4f2..9896f4b 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
@@ -230,6 +230,7 @@ public class DefaultFeaturesManager implements FeaturesManager {
if (configuration == null) {
configuration = new Configuration(pid);
feature.getConfigurations().add(configuration);
+ this.pidToPathMapping.put(pid, path);
} else {
switch ( this.configurationHandling ) {
case STRICT : throw new IllegalStateException("Configuration '"
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java b/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
index 7aa1798..4fa6911 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
@@ -510,7 +510,31 @@ public class ContentPackage2FeatureModelConverterTest {
}
@Test
- public void testSameConfigurationPidDifferentPaths() throws Exception {
+ public void testSameConfigurationPidTwoDifferentPaths() throws Exception {
+ File outputDirectory = new File(System.getProperty("java.io.tmpdir"), getClass().getName() + '_' + System.currentTimeMillis());
+ try {
+ URL packageUrl = getClass().getResource("test-content-package.zip");
+ File packageFile = FileUtils.toFile(packageUrl);
+
+ converter.setBundlesDeployer(new DefaultArtifactsDeployer(outputDirectory))
+ .setFeaturesManager(new DefaultFeaturesManager(false, 5, outputDirectory, null, null, null))
+ .setEmitter(DefaultPackagesEventsEmitter.open(outputDirectory))
+ .convert(packageFile);
+
+ String pid = "this.is.just.a.pid";
+ converter.getFeaturesManager().addConfiguration(null, pid, "/apps/a/config/pid.json", new Hashtable<String, Object>(){{put("foo", "a");}});
+ converter.getFeaturesManager().addConfiguration(null, pid, "/apps/b/config/pid.json", new Hashtable<String, Object>(){{put("foo", "b");}});
+
+ Configuration c = converter.getFeaturesManager().getTargetFeature().getConfigurations().getConfiguration(pid);
+ assertNotNull(c);
+ assertEquals("a", c.getConfigurationProperties().get("foo"));
+ } finally {
+ deleteDirTree(outputDirectory);
+ }
+ }
+
+ @Test
+ public void testSameConfigurationPidThreeDifferentPaths() throws Exception {
File outputDirectory = new File(System.getProperty("java.io.tmpdir"), getClass().getName() + '_' + System.currentTimeMillis());
try {
URL packageUrl = getClass().getResource("test-content-package.zip");