You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:57:50 UTC

[sling-org-apache-sling-provisioning-model] 12/19: SLING-4782 : Update to latest format from Apache Felix config admin

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.2.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 1f2cf687a2528289528ca0741d312d086dd10fd4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jun 8 11:37:27 2015 +0000

    SLING-4782 : Update to latest format from Apache Felix config admin
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1684163 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  2 +-
 .../apache/sling/provisioning/model/io/IOTest.java | 46 ++++++++++++++++++++--
 src/test/resources/configadmin.txt                 | 44 +++++++++++++++++++++
 3 files changed, 87 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 03c881f..f22cf8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.configadmin</artifactId>
-            <version>1.2.8</version>
+            <version>1.8.6</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java b/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
index 47b80cc..9abf82d 100644
--- a/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
+++ b/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
@@ -16,14 +16,21 @@
  */
 package org.apache.sling.provisioning.model.io;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.sling.provisioning.model.Configuration;
 import org.apache.sling.provisioning.model.Model;
 import org.apache.sling.provisioning.model.ModelUtility;
-import org.apache.sling.provisioning.model.U;
 import org.apache.sling.provisioning.model.Traceable;
+import org.apache.sling.provisioning.model.U;
 import org.junit.Test;
 
 /** Read and merge our test models, write and read them again
@@ -33,7 +40,7 @@ public class IOTest {
 
     @Test public void testReadWrite() throws Exception {
         final Model result = U.readCompleteTestModel();
-        
+
         U.verifyTestModel(result, false);
 
         // Write the merged model
@@ -52,12 +59,43 @@ public class IOTest {
         if (readErrors != null ) {
             throw new Exception("Invalid read model : " + readErrors);
         }
-        
+
         // and verify the result
         U.verifyTestModel(readModel, false);
-        
+
         // Resolve variables and verify the result
         final Model effective = ModelUtility.getEffectiveModel(readModel, null);
         U.verifyTestModel(effective, true);
     }
+
+    @Test public void testMultilineConfiguration() throws Exception {
+        final Model m = ModelUtility.getEffectiveModel(U.readCompleteTestModel(new String[] {"configadmin.txt"}), null);
+
+        final List<Configuration> configs = new ArrayList<Configuration>();
+        for(final Configuration c :  m.getFeature("configadmin").getRunMode().getConfigurations()) {
+            configs.add(c);
+        }
+
+        assertEquals(3, configs.size());
+
+        final Configuration cfgA = configs.get(0);
+        assertEquals("org.apache.test.A", cfgA.getPid());
+        assertNull(cfgA.getFactoryPid());
+        assertEquals(1, cfgA.getProperties().size());
+        assertEquals("A", cfgA.getProperties().get("name"));
+
+        final Configuration cfgB = configs.get(1);
+        assertEquals("org.apache.test.B", cfgB.getPid());
+        assertNull(cfgB.getFactoryPid());
+        assertEquals(2, cfgB.getProperties().size());
+        assertEquals("B", cfgB.getProperties().get("name"));
+        assertArrayEquals(new String[] {"one", "two", "three"}, (String[])cfgB.getProperties().get("array"));
+
+        final Configuration cfgC = configs.get(2);
+        assertEquals("org.apache.test.C", cfgC.getPid());
+        assertNull(cfgC.getFactoryPid());
+        assertEquals(2, cfgC.getProperties().size());
+        assertEquals("C", cfgC.getProperties().get("name"));
+        assertArrayEquals(new Integer[] {1,2,3}, (Integer[])cfgC.getProperties().get("array"));
+    }
 }
diff --git a/src/test/resources/configadmin.txt b/src/test/resources/configadmin.txt
new file mode 100644
index 0000000..e5c0451
--- /dev/null
+++ b/src/test/resources/configadmin.txt
@@ -0,0 +1,44 @@
+#
+#  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.
+#
+# This is a feature description
+#
+# A feature consists of variables and run mode dependent artifacts.
+#
+[feature name=configadmin]
+
+[configurations]
+org.apache.test.A
+    name="A"    
+
+org.apache.test.B
+    array=[
+      "one",
+      "two",
+      "three"
+    ]
+    name="B"    
+
+org.apache.test.C
+    array=I[
+      "1",
+      "2",
+      "3"
+    ]
+    name="C"    
+    
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.