You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/03/13 12:50:18 UTC

[sling-whiteboard] branch master updated: [cp2fm] testing empty OSGi configurations don't generate any Feature configuration

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

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new dfc7cb0  [cp2fm] testing empty OSGi configurations don't generate any Feature configuration
dfc7cb0 is described below

commit dfc7cb0ccf528721f394146139fd843c0e7baa88
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Wed Mar 13 13:50:01 2019 +0100

    [cp2fm] testing empty OSGi configurations don't generate any Feature
    configuration
---
 .../handlers/ConfigurationEntryHandlerTest.java    | 45 ++++++++++++++--------
 ...sermapping.impl.ServiceUserMapperImpl.empty.cfg | 14 +++++++
 ...pping.impl.ServiceUserMapperImpl.empty.cfg.json |  3 ++
 ...mapping.impl.ServiceUserMapperImpl.empty.config | 14 +++++++
 ...sermapping.impl.ServiceUserMapperImpl.empty.xml | 19 +++++++++
 ...apping.impl.ServiceUserMapperImpl.empty.xml.cfg | 19 +++++++++
 6 files changed, 97 insertions(+), 17 deletions(-)

diff --git a/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java b/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
index f852eaf..3c329d1 100644
--- a/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
+++ b/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
@@ -32,11 +32,6 @@ import java.util.Collection;
 import org.apache.jackrabbit.vault.fs.io.Archive;
 import org.apache.jackrabbit.vault.fs.io.Archive.Entry;
 import org.apache.sling.cp2fm.ContentPackage2FeatureModelConverter;
-import org.apache.sling.cp2fm.handlers.AbstractConfigurationEntryHandler;
-import org.apache.sling.cp2fm.handlers.ConfigurationEntryHandler;
-import org.apache.sling.cp2fm.handlers.JsonConfigurationEntryHandler;
-import org.apache.sling.cp2fm.handlers.PropertiesConfigurationEntryHandler;
-import org.apache.sling.cp2fm.handlers.XmlConfigurationEntryHandler;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Configuration;
 import org.apache.sling.feature.Configurations;
@@ -53,11 +48,15 @@ public class ConfigurationEntryHandlerTest {
 
     private final String resourceConfiguration;
 
+    private final int expectedConfigurationsSize;
+
     private final AbstractConfigurationEntryHandler configurationEntryHandler;
 
     public ConfigurationEntryHandlerTest(String resourceConfiguration,
+                                         int expectedConfigurationsSize,
                                          AbstractConfigurationEntryHandler configurationEntryHandler) {
         this.resourceConfiguration = resourceConfiguration;
+        this.expectedConfigurationsSize = expectedConfigurationsSize;
         this.configurationEntryHandler = configurationEntryHandler;
     }
 
@@ -88,13 +87,15 @@ public class ConfigurationEntryHandlerTest {
         configurationEntryHandler.handle(resourceConfiguration, archive, entry, converter);
 
         Configurations configurations = converter.getTargetFeature().getConfigurations();
-        assertFalse(configurations.isEmpty());
-        assertEquals(1, configurations.size());
 
-        Configuration configuration = configurations.get(0);
+        assertEquals(expectedConfigurationsSize, configurations.size());
+
+        if (expectedConfigurationsSize > 0) {
+            Configuration configuration = configurations.get(0);
 
-        assertTrue(configuration.getPid(), configuration.getPid().startsWith(EXPECTED_PID));
-        assertEquals("Unmatching size: " + configuration.getProperties().size(), 2, configuration.getProperties().size());
+            assertTrue(configuration.getPid(), configuration.getPid().startsWith(EXPECTED_PID));
+            assertEquals("Unmatching size: " + configuration.getProperties().size(), 2, configuration.getProperties().size());
+        }
     }
 
     @Parameters
@@ -102,14 +103,24 @@ public class ConfigurationEntryHandlerTest {
         String path = "jcr_root/apps/asd/config/";
 
         return Arrays.asList(new Object[][] {
-            { path + EXPECTED_PID + ".cfg", new PropertiesConfigurationEntryHandler() },
-            { path + EXPECTED_PID + ".cfg.json", new JsonConfigurationEntryHandler() },
-            { path + EXPECTED_PID + ".config", new ConfigurationEntryHandler() },
-            { path + EXPECTED_PID + ".xml", new XmlConfigurationEntryHandler() },
-            { path + EXPECTED_PID + ".xml.cfg", new PropertiesConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".empty.cfg", 0, new PropertiesConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".cfg", 1, new PropertiesConfigurationEntryHandler() },
+
+            { path + EXPECTED_PID + ".empty.cfg.json", 0, new JsonConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".cfg.json", 1, new JsonConfigurationEntryHandler() },
+
+            { path + EXPECTED_PID + ".empty.config", 0, new ConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".config", 1, new ConfigurationEntryHandler() },
+
+            { path + EXPECTED_PID + ".empty.xml", 0, new XmlConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".xml", 1, new XmlConfigurationEntryHandler() },
+
+            { path + EXPECTED_PID + ".empty.xml.cfg", 0, new PropertiesConfigurationEntryHandler() },
+            { path + EXPECTED_PID + ".xml.cfg", 1, new PropertiesConfigurationEntryHandler() },
+
             // runmode aware folders
-            { "jcr_root/apps/asd/config.author/" + EXPECTED_PID + ".config", new ConfigurationEntryHandler() },
-            { "jcr_root/apps/asd/config.publish/" + EXPECTED_PID + ".config", new ConfigurationEntryHandler() },
+            { "jcr_root/apps/asd/config.author/" + EXPECTED_PID + ".config", 1, new ConfigurationEntryHandler() },
+            { "jcr_root/apps/asd/config.publish/" + EXPECTED_PID + ".config", 1, new ConfigurationEntryHandler() },
         });
     }
 
diff --git a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg
new file mode 100644
index 0000000..5db1a19
--- /dev/null
+++ b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to You under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
diff --git a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg.json b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg.json
new file mode 100644
index 0000000..49d1a20
--- /dev/null
+++ b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.cfg.json
@@ -0,0 +1,3 @@
+{
+    
+}
diff --git a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.config b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.config
new file mode 100644
index 0000000..5db1a19
--- /dev/null
+++ b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.config
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to You under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
diff --git a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml
new file mode 100644
index 0000000..6211b85
--- /dev/null
+++ b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with this
+ work for additional information regarding copyright ownership. The ASF
+ licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations under
+ the License.
+-->
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+    jcr:primaryType="sling:OsgiConfig"/>
diff --git a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml.cfg b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml.cfg
new file mode 100644
index 0000000..87a44e8
--- /dev/null
+++ b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/jcr_root/apps/asd/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.empty.xml.cfg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with this
+ work for additional information regarding copyright ownership. The ASF
+ licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations under
+ the License.
+-->
+<properties />