You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/06 18:38:17 UTC

[2/6] git commit: [KARAF-2753] Fix potential parsing problem with overrides

[KARAF-2753] Fix potential parsing problem with overrides

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/a33fd100
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/a33fd100
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/a33fd100

Branch: refs/heads/master
Commit: a33fd100e7a27ddf6cc652f8e9414f7b98a7227d
Parents: cb7e77d
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Mar 6 12:03:14 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Mar 6 12:15:13 2014 +0100

----------------------------------------------------------------------
 .../karaf/features/internal/Overrides.java      |  9 ++++----
 .../karaf/features/internal/OverridesTest.java  | 21 ++++++++++++++++++
 .../features/internal/overrides.properties      | 23 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/a33fd100/features/core/src/main/java/org/apache/karaf/features/internal/Overrides.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/Overrides.java b/features/core/src/main/java/org/apache/karaf/features/internal/Overrides.java
index 8c7d468..dab988a 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/Overrides.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/Overrides.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,7 +48,7 @@ public class Overrides {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(Overrides.class);
 
-    private static final String OVERRIDE_RANGE = "range";
+    protected static final String OVERRIDE_RANGE = "range";
     private static final String VENDOR_WARNING = "Bundle Vendor has changed, please check if this is intentional. Bundle: ";
 
     /**
@@ -169,10 +170,8 @@ public class Overrides {
                     while ((line = reader.readLine()) != null) {
                         line = line.trim();
                         if (!line.isEmpty() && !line.startsWith("#")) {
-                            Clause[] cs = Parser.parseHeader(line);
-                            for (Clause c : cs) {
-                                overrides.add(c);
-                            }
+                            Clause[] cs = Parser.parseClauses(new String[]{line});
+                            Collections.addAll(overrides, cs);
                         }
                     }
                 } finally {

http://git-wip-us.apache.org/repos/asf/karaf/blob/a33fd100/features/core/src/test/java/org/apache/karaf/features/internal/OverridesTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/OverridesTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/OverridesTest.java
index 79e2015..99feb32 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/OverridesTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/OverridesTest.java
@@ -26,6 +26,7 @@ import java.io.Writer;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.felix.utils.manifest.Clause;
 import org.apache.karaf.features.BundleInfo;
 import org.apache.karaf.features.internal.model.Bundle;
 import org.junit.Before;
@@ -201,6 +202,26 @@ public class OverridesTest {
         assertEquals(b100.toURI().toString(), out.getLocation());
     }
 
+    @Test
+    public void testLoadOverrides() {
+        List<Clause> overrides = Overrides.loadOverrides(getClass().getResource("overrides.properties").toExternalForm());
+        assertEquals(2, overrides.size());
+
+        Clause karafAdminCommand = null;
+        Clause karafAdminCore = null;
+        for (Clause clause : overrides) {
+            if (clause.getName().equals("mvn:org.apache.karaf.admin/org.apache.karaf.admin.command/2.3.0.redhat-61033X")) {
+                karafAdminCommand = clause;
+            }
+            if (clause.getName().equals("mvn:org.apache.karaf.admin/org.apache.karaf.admin.core/2.3.0.redhat-61033X")) {
+                karafAdminCore = clause;
+            }
+        }
+        assertNotNull("Missing admin.command bundle override", karafAdminCommand);
+        assertNotNull("Missing admin.core bundle override", karafAdminCore);
+        assertNotNull("Missing range on admin.core override", karafAdminCore.getAttribute(Overrides.OVERRIDE_RANGE));
+    }
+
     /**
      * Copies the content of {@link java.io.InputStream} to {@link java.io.OutputStream}.
      *

http://git-wip-us.apache.org/repos/asf/karaf/blob/a33fd100/features/core/src/test/resources/org/apache/karaf/features/internal/overrides.properties
----------------------------------------------------------------------
diff --git a/features/core/src/test/resources/org/apache/karaf/features/internal/overrides.properties b/features/core/src/test/resources/org/apache/karaf/features/internal/overrides.properties
new file mode 100644
index 0000000..d34fa7e
--- /dev/null
+++ b/features/core/src/test/resources/org/apache/karaf/features/internal/overrides.properties
@@ -0,0 +1,23 @@
+
+################################################################################
+#
+#    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.
+#
+################################################################################
+
+# Sample etc/overrides.properties file for testing purposes
+mvn:org.apache.karaf.admin/org.apache.karaf.admin.command/2.3.0.redhat-61033X
+mvn:org.apache.karaf.admin/org.apache.karaf.admin.core/2.3.0.redhat-61033X;range=[2.3.0,2.5)