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 2019/01/29 11:15:42 UTC

[sling-org-apache-sling-feature-analyser] branch master updated: SLING-8213 Not possible to specify wildcard handler property in Maven plugin

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-analyser.git


The following commit(s) were added to refs/heads/master by this push:
     new 70274a1  SLING-8213 Not possible to specify wildcard handler property in Maven plugin
70274a1 is described below

commit 70274a1a15cfe1308add630ea3334c49cf01d7f6
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Tue Jan 29 11:15:02 2019 +0000

    SLING-8213 Not possible to specify wildcard handler property in Maven plugin
    
    Change wildcard from '*' to 'all'.
---
 .../apache/sling/feature/analyser/Analyser.java    |  8 +++-
 .../sling/feature/analyser/AnalyserTest.java       | 54 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/analyser/Analyser.java b/src/main/java/org/apache/sling/feature/analyser/Analyser.java
index 1ad2e24..0243e78 100644
--- a/src/main/java/org/apache/sling/feature/analyser/Analyser.java
+++ b/src/main/java/org/apache/sling/feature/analyser/Analyser.java
@@ -40,6 +40,10 @@ import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTas
 import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasksByIds;
 
 public class Analyser {
+    /**
+     * Configurration key for configuration that applies to all tasks.
+     */
+    static final String ALL_TASKS_KEY = "all";
 
     private final AnalyserTask[] tasks;
 
@@ -171,10 +175,10 @@ public class Analyser {
         };
     }
 
-    private Map<String,String> getConfiguration(final String id) {
+    Map<String,String> getConfiguration(final String id) {
         final Map<String,String> result = new HashMap<>();
 
-        Map<String, String> globalCfg = this.configurations.get("*");
+        Map<String, String> globalCfg = this.configurations.get(ALL_TASKS_KEY);
         if (globalCfg != null)
             result.putAll(globalCfg);
 
diff --git a/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java b/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java
new file mode 100644
index 0000000..c62b382
--- /dev/null
+++ b/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package org.apache.sling.feature.analyser;
+
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class AnalyserTest {
+    @Test
+    public void testConfiguration() throws Exception {
+        Map<String, Map<String,String>> cfgs = new HashMap<String, Map<String,String>>();
+        cfgs.put("all", Collections.singletonMap("aa", "bb"));
+        cfgs.put("an-analyser", Collections.singletonMap("cc", "dd"));
+        cfgs.put("another-analyser", Collections.singletonMap("ee", "ff"));
+
+        Analyser a = new Analyser(null, cfgs, new String [] {});
+
+        Map<String, String> cfg = a.getConfiguration("an-analyser");
+        assertEquals(2, cfg.size());
+        assertEquals("bb", cfg.get("aa"));
+        assertEquals("dd", cfg.get("cc"));
+    }
+
+    @Test
+    public void testConfiguration1() throws Exception {
+        Map<String, Map<String,String>> cfgs = new HashMap<String, Map<String,String>>();
+        cfgs.put("another-analyser", Collections.singletonMap("ee", "ff"));
+
+        Analyser a = new Analyser(null, cfgs, new AnalyserTask [] {});
+
+        Map<String, String> cfg = a.getConfiguration("an-analyser");
+        assertEquals(0, cfg.size());
+    }
+}