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/10/18 23:28:45 UTC

[sling-org-apache-sling-testing-caconfig-mock-plugin] branch master created (now fad9a49)

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

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git.


      at fad9a49  SLING-7167 Adjust READMEs

This branch includes the following new commits:

     new 5a8bc32  SLING-6427 Move Sling Context-Aware Config out of contrib - move in svn - update all SCM URLs - update jenkins build jobs
     new 9e0d27b  use Sling Parent 30
     new 1846e2d  SLING-6670 Support CAConfig Impl 1.3.0
     new 2cc1bb5  SLING-6670 Support CAConfig Impl 1.3.0
     new b254a86  SLING-6670 set dependencies to osgi-mock, sling-mock to "provided" - should be controlled by the main project
     new 12819ba  SLING-6670 Support CAConfig Impl 1.3.0
     new ce2e6b4  update dependencies
     new d327e93  [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.1.0
     new 1ef2f6b  [maven-release-plugin] prepare for next development iteration
     new 0f5f5b7  update dependencies
     new dcdcf51  SLING-6789 Support CAConfig Impl 1.4.0
     new 1b71f98  update dependency
     new 4ef00bc  [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.2.0
     new ec11bf4  [maven-release-plugin] prepare for next development iteration
     new 7b91b53  update to next development version until release version is available on maven central
     new abda57a  update dependency
     new 0d64470  SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations also drop support for 1.x versions of SPI/Impl
     new 4af96af  SLING-6881 CAConfig Mock Plugin: Register configuration classes via package name
     new 083991e  SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations
     new c37e161  [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.3.0
     new 55cadd9  [maven-release-plugin] prepare for next development iteration
     new 310b224  SLING-7167 Adjust READMEs
     new fad9a49  SLING-7167 Adjust READMEs

The 23 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 10/23: update dependencies

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 0f5f5b70d704e2f89a3d2124508b9ea032ec40c6
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Mar 23 15:13:09 2017 +0000

    update dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1788266 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a653853..14262c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,7 +80,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>2.2.0</version>
+            <version>2.2.4</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 16/23: update dependency

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit abda57a32becc69751099c7fcaa676b4a343a39c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri May 5 20:04:34 2017 +0000

    update dependency
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1794099 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 80cbcb6..d5bd7b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
-            <version>1.4.1-SNAPSHOT</version>
+            <version>1.4.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 17/23: SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations also drop support for 1.x versions of SPI/Impl

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 0d64470f5e9e31635478b85f40c2fa4541701e7c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed May 24 12:38:50 2017 +0000

    SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations
    also drop support for 1.x versions of SPI/Impl
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796051 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 22 +++---
 .../testing/mock/caconfig/ContextPlugins.java      |  8 +-
 .../mock/caconfig/MockContextAwareConfig.java      | 58 ++++++++++++++
 .../sling/testing/mock/caconfig/package-info.java  |  2 +-
 .../testing/mock/caconfig/CompatibilityUtil.java   | 68 ----------------
 .../testing/mock/caconfig/ContextPluginsTest.java  | 12 +--
 .../mock/caconfig/MockContextAwareConfigTest.java  | 90 ++++++++++++++++++++++
 .../example/{SimpleConfig.java => ListConfig.java} |  4 +-
 .../mock/caconfig/example/SimpleConfig.java        |  2 +-
 9 files changed, 172 insertions(+), 94 deletions(-)

diff --git a/pom.xml b/pom.xml
index d5bd7b2..e0ef829 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,34 +90,34 @@
     
     <profiles>
         
-        <!-- Test with Sling CAConfig Impl/SPI 1.1 -->
+        <!-- Test with Sling CAConfig Impl/SPI 1.2 -->
         <profile>
-            <id>caconfig-1.1</id>
+            <id>caconfig-1.2</id>
             <dependencies>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.api</artifactId>
-                    <version>1.0.0</version>
+                    <version>1.1.0</version>
                     <scope>compile</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.spi</artifactId>
-                    <version>1.1.0</version>
+                    <version>1.2.0</version>
                     <scope>compile</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.impl</artifactId>
-                    <version>1.1.0</version>
+                    <version>1.2.0</version>
                     <scope>compile</scope>
                 </dependency>
             </dependencies>
         </profile>
 
-        <!-- Test with Sling CAConfig Impl/SPI 1.2 -->
+        <!-- Test with Sling CAConfig Impl/SPI 1.3 -->
         <profile>
-            <id>caconfig-1.2</id>
+            <id>caconfig-1.3</id>
             <dependencies>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
@@ -128,13 +128,13 @@
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.spi</artifactId>
-                    <version>1.2.0</version>
+                    <version>1.3.0</version>
                     <scope>compile</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.impl</artifactId>
-                    <version>1.2.0</version>
+                    <version>1.3.0</version>
                     <scope>compile</scope>
                 </dependency>
             </dependencies>
@@ -142,7 +142,7 @@
 
         <!-- Test with Sling CAConfig Impl/SPI 1.3 -->
         <profile>
-            <id>caconfig-1.3</id>
+            <id>caconfig-1.4</id>
             <dependencies>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
@@ -159,7 +159,7 @@
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.impl</artifactId>
-                    <version>1.3.0</version>
+                    <version>1.4.0</version>
                     <scope>compile</scope>
                 </dependency>
             </dependencies>
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index 4197bff..03e124b 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -23,6 +23,7 @@ import org.apache.sling.caconfig.impl.ConfigurationResolverImpl;
 import org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrategy;
 import org.apache.sling.caconfig.impl.metadata.AnnotationClassConfigurationMetadataProvider;
 import org.apache.sling.caconfig.management.impl.ConfigurationManagerImpl;
+import org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolverImpl;
 import org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
 import org.apache.sling.caconfig.resource.impl.def.DefaultContextPathStrategy;
@@ -33,7 +34,7 @@ import org.osgi.annotation.versioning.ProviderType;
 
 /**
  * Mock context plugins.
- * The plugin supports all versions from 1.0 to the most recent versions of the Impl/SPI.
+ * The plugin supports all versions from 1.2 to the most recent versions of the Impl/SPI.
  */
 @ProviderType
 public final class ContextPlugins {
@@ -77,10 +78,7 @@ public final class ContextPlugins {
      */
     private static void registerConfigurationResourceResolver(SlingContextImpl context) {
         
-        if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl")) {
-            // fallback to impl 1.1
-            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer");
-        }
+        context.registerInjectActivateService(new ContextPathStrategyMultiplexerImpl());
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexerImpl")) {
             // fallback to impl 1.2
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
index 03b0212..d5a539b 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
@@ -18,6 +18,16 @@
  */
 package org.apache.sling.testing.mock.caconfig;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.management.ConfigurationManager;
+import org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData;
+import org.apache.sling.caconfig.spi.ConfigurationPersistData;
+import org.apache.sling.testing.mock.osgi.MapUtil;
 import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
 import org.osgi.annotation.versioning.ProviderType;
 
@@ -49,4 +59,52 @@ public final class MockContextAwareConfig {
         ConfigurationMetadataUtil.registerAnnotationClasses(context.bundleContext(), classes);
     }
 
+    /**
+     * Writes configuration parameters using the primary configured persistence
+     * provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
+     * @param configName Config name
+     * @param values Configuration values
+     */
+    public static void writeConfiguration(SlingContextImpl context, String contextPath, String configName,
+            Map<String, Object> values) {
+        ConfigurationManager configManager = context.getService(ConfigurationManager.class);
+        Resource contextResource = context.resourceResolver().getResource(contextPath);
+        configManager.persistConfiguration(contextResource, configName, new ConfigurationPersistData(values));
+    }
+
+    /**
+     * Writes configuration parameters using the primary configured persistence
+     * provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
+     * @param configName Config name
+     * @param values Configuration values
+     */
+    public static void writeConfiguration(SlingContextImpl context, String contextPath, String configName, Object... values) {
+        writeConfiguration(context, contextPath, configName, MapUtil.toMap(values));
+    }
+
+    /**
+     * Writes a collection of configuration parameters using the primary
+     * configured persistence provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
+     * @param configName Config name
+     * @param values Configuration values
+     */
+    public static void writeConfigurationCollection(SlingContextImpl context, String contextPath, String configName,
+            Collection<Map<String, Object>> values) {
+        ConfigurationManager configManager = context.getService(ConfigurationManager.class);
+        Resource contextResource = context.resourceResolver().getResource(contextPath);
+        List<ConfigurationPersistData> items = new ArrayList<>();
+        int index = 0;
+        for (Map<String, Object> map : values) {
+            items.add(new ConfigurationPersistData(map).collectionItemName("item" + (index++)));
+        }
+        configManager.persistConfigurationCollection(contextResource, configName,
+                new ConfigurationCollectionPersistData(items));
+    }
+
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java b/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java
index de6d18e..99d628c 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Apache Sling Context-Aware Configuration Mock Plugin
  */
-@org.osgi.annotation.versioning.Version("1.0.0")
+@org.osgi.annotation.versioning.Version("1.1.0")
 package org.apache.sling.testing.mock.caconfig;
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java b/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java
deleted file mode 100644
index 56a40bf..0000000
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.testing.mock.caconfig;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.caconfig.management.ConfigurationManager;
-import org.apache.sling.testing.mock.sling.junit.SlingContext;
-
-/**
- * Helper methods interacting with Context-Aware context supporting both version 1.1 and 2.0 of
- * the Management API via reflection.
- */
-public class CompatibilityUtil {
-
-    /**
-     * Write configuration for impl 1.2
-     */
-    public static void writeConfig(SlingContext context, Resource contextResource, String configName, Map<String,Object> props) {
-        try {
-            Class<?> configurationPersistDataClass;
-            try {
-                configurationPersistDataClass = Class.forName("org.apache.sling.caconfig.spi.ConfigurationPersistData");
-            }
-            catch (ClassNotFoundException e) {
-                // fallback to caconfig impl 1.1
-                writeConfigImpl11(context, contextResource, configName, props);
-                return;
-            }
-
-            Object persistData = configurationPersistDataClass.getConstructor(Map.class).newInstance(props);
-            ConfigurationManager configManager = context.getService(ConfigurationManager.class);
-            Method persistMethod = ConfigurationManager.class.getMethod("persistConfiguration", Resource.class, String.class, configurationPersistDataClass);
-            persistMethod.invoke(configManager, contextResource, configName, persistData);
-        }
-        catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    /**
-     * Fallback: Write configuration for impl 1.1
-     */
-    public static void writeConfigImpl11(SlingContext context, Resource contextResource, String configName, Map<String,Object> props) throws Exception {
-        ConfigurationManager configManager = context.getService(ConfigurationManager.class);
-        Method persistMethod = ConfigurationManager.class.getMethod("persist", Resource.class, String.class, Map.class);
-        persistMethod.invoke(configManager, contextResource, configName, props);
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
index bacb27d..1db5779 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
@@ -32,14 +32,14 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableMap;
-
 public class ContextPluginsTest {
     
-    private static final String CONFIG_NAME = "testConfig";
+    private static final String CONFIG_NAME = SimpleConfig.class.getName();
     
     @Rule
-    public SlingContext context = new SlingContextBuilder().plugin(CACONFIG).build();
+    public SlingContext context = new SlingContextBuilder()
+            .plugin(CACONFIG)
+            .build();
     
     private Resource contextResource;
 
@@ -52,10 +52,10 @@ public class ContextPluginsTest {
         MockContextAwareConfig.registerAnnotationClasses(context, SimpleConfig.class);
 
         // write config
-        CompatibilityUtil.writeConfig(context, contextResource, CONFIG_NAME, ImmutableMap.<String, Object>of(
+        MockContextAwareConfig.writeConfiguration(context, contextResource.getPath(), CONFIG_NAME, 
                         "stringParam", "value1",
                         "intParam", 123,
-                        "boolParam", true));
+                        "boolParam", true);
     }
     
     @Test
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
new file mode 100644
index 0000000..916b025
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.ConfigurationBuilder;
+import org.apache.sling.testing.mock.caconfig.example.ListConfig;
+import org.apache.sling.testing.mock.caconfig.example.SimpleConfig;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+public class MockContextAwareConfigTest {
+
+    @Rule
+    public SlingContext context = new SlingContextBuilder()
+            .plugin(CACONFIG)
+            .build();
+
+    @Before
+    public void setUp() {
+        MockContextAwareConfig.registerAnnotationClasses(context, SimpleConfig.class, ListConfig.class);
+
+        context.create().resource("/content/region/site", "sling:configRef", "/conf/region/site");
+
+        context.currentResource(context.create().resource("/content/region/site/en"));
+
+        MockContextAwareConfig.writeConfiguration(context, "/content/region/site", SimpleConfig.class.getName(),
+                "stringParam", "value1");
+
+        MockContextAwareConfig.writeConfigurationCollection(context, "/content/region/site", ListConfig.class.getName(),
+                ImmutableList.of((Map<String, Object>) ImmutableMap.<String, Object> of("stringParam", "value1"),
+                        (Map<String, Object>) ImmutableMap.<String, Object> of("stringParam", "value2")));
+    }
+
+    @Test
+    public void testSingletonConfig() {
+        Resource resource = context.request().getResource();
+        SimpleConfig config = resource.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
+        assertNotNull(config);
+        assertEquals("value1", config.stringParam());
+        assertEquals(5, config.intParam());
+    }
+
+    @Test
+    public void testConfigCollection() {
+        Resource resource = context.request().getResource();
+        Collection<ListConfig> config = resource.adaptTo(ConfigurationBuilder.class).asCollection(ListConfig.class);
+        assertEquals(2, config.size());
+        Iterator<ListConfig> items = config.iterator();
+
+        ListConfig item1 = items.next();
+        assertEquals("value1", item1.stringParam());
+        assertEquals(5, item1.intParam());
+
+        ListConfig item2 = items.next();
+        assertEquals("value2", item2.stringParam());
+        assertEquals(5, item2.intParam());
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java b/src/test/java/org/apache/sling/testing/mock/caconfig/example/ListConfig.java
similarity index 93%
copy from src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
copy to src/test/java/org/apache/sling/testing/mock/caconfig/example/ListConfig.java
index 821bd9e..85806a8 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/example/ListConfig.java
@@ -20,8 +20,8 @@ package org.apache.sling.testing.mock.caconfig.example;
 
 import org.apache.sling.caconfig.annotation.Configuration;
 
-@Configuration(name = "testConfig")
-public @interface SimpleConfig {
+@Configuration(collection = true)
+public @interface ListConfig {
 
     String stringParam();
     
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
index 821bd9e..b314fb3 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
@@ -20,7 +20,7 @@ package org.apache.sling.testing.mock.caconfig.example;
 
 import org.apache.sling.caconfig.annotation.Configuration;
 
-@Configuration(name = "testConfig")
+@Configuration
 public @interface SimpleConfig {
 
     String stringParam();

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 05/23: SLING-6670 set dependencies to osgi-mock, sling-mock to "provided" - should be controlled by the main project

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit b254a86d8243d3b711190615dc5d860fa0482f5a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 12:55:28 2017 +0000

    SLING-6670 set dependencies to osgi-mock, sling-mock to "provided" - should be controlled by the main project
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787758 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9164f43..4f18ef4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,13 +81,13 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
             <version>2.2.0</version>
-            <scope>compile</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.sling-mock</artifactId>
             <version>1.9.0</version>
-            <scope>compile</scope>
+            <scope>provided</scope>
         </dependency>
     </dependencies>
     

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 19/23: SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 083991eea0f613eff393a83312008754df2ba36f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed May 24 14:31:47 2017 +0000

    SLING-6880 CAConfig Mock Plugin: Add helper methods for writing configurations
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796067 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/caconfig/MockContextAwareConfig.java      | 47 ++++++++++++++++++++++
 .../testing/mock/caconfig/ContextPluginsTest.java  |  4 +-
 .../mock/caconfig/MockContextAwareConfigTest.java  |  4 +-
 .../mock/caconfig/example/SimpleConfig.java        |  2 +-
 4 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
index 46e4135..ac13366 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.annotation.Configuration;
 import org.apache.sling.caconfig.management.ConfigurationManager;
 import org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData;
 import org.apache.sling.caconfig.spi.ConfigurationPersistData;
@@ -75,6 +76,19 @@ public final class MockContextAwareConfig {
      * provider.
      * @param context Sling context
      * @param contextPath Configuration id
+     * @param configClass Configuration class
+     * @param values Configuration values
+     */
+    public static void writeConfiguration(SlingContextImpl context, String contextPath, Class<?> configClass,
+            Map<String, Object> values) {
+        writeConfiguration(context, contextPath, getConfigurationName(configClass), values);
+    }
+    
+    /**
+     * Writes configuration parameters using the primary configured persistence
+     * provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
      * @param configName Config name
      * @param values Configuration values
      */
@@ -90,6 +104,18 @@ public final class MockContextAwareConfig {
      * provider.
      * @param context Sling context
      * @param contextPath Configuration id
+     * @param configClass Configuration class
+     * @param values Configuration values
+     */
+    public static void writeConfiguration(SlingContextImpl context, String contextPath, Class<?> configClass, Object... values) {
+        writeConfiguration(context, contextPath, getConfigurationName(configClass), values);
+    }
+
+    /**
+     * Writes configuration parameters using the primary configured persistence
+     * provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
      * @param configName Config name
      * @param values Configuration values
      */
@@ -102,6 +128,19 @@ public final class MockContextAwareConfig {
      * configured persistence provider.
      * @param context Sling context
      * @param contextPath Configuration id
+     * @param configClass Configuration class
+     * @param values Configuration values
+     */
+    public static void writeConfigurationCollection(SlingContextImpl context, String contextPath,  Class<?> configClass,
+            Collection<Map<String, Object>> values) {
+        writeConfigurationCollection(context, contextPath, getConfigurationName(configClass), values);
+    }
+    
+    /**
+     * Writes a collection of configuration parameters using the primary
+     * configured persistence provider.
+     * @param context Sling context
+     * @param contextPath Configuration id
      * @param configName Config name
      * @param values Configuration values
      */
@@ -117,5 +156,13 @@ public final class MockContextAwareConfig {
         configManager.persistConfigurationCollection(contextResource, configName,
                 new ConfigurationCollectionPersistData(items));
     }
+    
+    private static String getConfigurationName(Class<?> configClass) {
+        Configuration annotation = configClass.getAnnotation(Configuration.class);
+        if (annotation != null && StringUtils.isNotBlank(annotation.name())) {
+            return annotation.name();
+        }
+        return configClass.getName();
+    }
 
 }
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
index 1db5779..d331e19 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
@@ -34,7 +34,7 @@ import org.junit.Test;
 
 public class ContextPluginsTest {
     
-    private static final String CONFIG_NAME = SimpleConfig.class.getName();
+    private static final String CONFIG_NAME = "testConfig";
     
     @Rule
     public SlingContext context = new SlingContextBuilder()
@@ -52,7 +52,7 @@ public class ContextPluginsTest {
         MockContextAwareConfig.registerAnnotationClasses(context, SimpleConfig.class);
 
         // write config
-        MockContextAwareConfig.writeConfiguration(context, contextResource.getPath(), CONFIG_NAME, 
+        MockContextAwareConfig.writeConfiguration(context, contextResource.getPath(), SimpleConfig.class, 
                         "stringParam", "value1",
                         "intParam", 123,
                         "boolParam", true);
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
index da190c2..4c71660 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
@@ -54,10 +54,10 @@ public class MockContextAwareConfigTest {
 
         context.currentResource(context.create().resource("/content/region/site/en"));
 
-        MockContextAwareConfig.writeConfiguration(context, "/content/region/site", SimpleConfig.class.getName(),
+        MockContextAwareConfig.writeConfiguration(context, "/content/region/site", SimpleConfig.class,
                 "stringParam", "value1");
 
-        MockContextAwareConfig.writeConfigurationCollection(context, "/content/region/site", ListConfig.class.getName(),
+        MockContextAwareConfig.writeConfigurationCollection(context, "/content/region/site", ListConfig.class,
                 ImmutableList.of((Map<String, Object>) ImmutableMap.<String, Object> of("stringParam", "value1"),
                         (Map<String, Object>) ImmutableMap.<String, Object> of("stringParam", "value2")));
     }
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
index b314fb3..821bd9e 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
@@ -20,7 +20,7 @@ package org.apache.sling.testing.mock.caconfig.example;
 
 import org.apache.sling.caconfig.annotation.Configuration;
 
-@Configuration
+@Configuration(name = "testConfig")
 public @interface SimpleConfig {
 
     String stringParam();

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 01/23: SLING-6427 Move Sling Context-Aware Config out of contrib - move in svn - update all SCM URLs - update jenkins build jobs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 5a8bc32e0e3f46d871958107680a072f8d2bcfa7
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Dec 22 09:52:16 2016 +0000

    SLING-6427 Move Sling Context-Aware Config out of contrib
    - move in svn
    - update all SCM URLs
    - update jenkins build jobs
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1775601 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt                                         |   6 +
 pom.xml                                            | 120 +++++++++
 .../mock/caconfig/ConfigurationMetadataUtil.java   | 269 +++++++++++++++++++++
 .../testing/mock/caconfig/ContextPlugins.java      | 153 ++++++++++++
 .../mock/caconfig/MockContextAwareConfig.java      |  52 ++++
 .../sling/testing/mock/caconfig/package-info.java  |  23 ++
 .../testing/mock/caconfig/CompatibilityUtil.java   |  68 ++++++
 .../testing/mock/caconfig/ContextPluginsTest.java  |  79 ++++++
 .../mock/caconfig/example/SimpleConfig.java        |  32 +++
 9 files changed, 802 insertions(+)

diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..1875af9
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,6 @@
+Apache Sling Context-Aware Configuration Mock Plugin
+
+Mock Context Plugin for Apache Sling Context-Aware Configuration
+
+Documentation:
+http://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..879ff2f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,120 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>29</version>
+        <relativePath />
+    </parent>
+    
+    <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.1-SNAPSHOT</version>
+    <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
+    <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
+    </scm>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.caconfig.api</artifactId>
+            <version>1.1.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.caconfig.spi</artifactId>
+            <version>1.2.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.caconfig.impl</artifactId>
+            <version>1.2.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.9.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
+            <version>2.2.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+            <version>1.9.0</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    
+    <profiles>
+        
+        <!-- Test with Sling CAConfig Impl/SPI 1.1 -->
+        <profile>
+            <id>caconfig-1.1</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.api</artifactId>
+                    <version>1.0.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.spi</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.impl</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+    </profiles>
+
+</project>
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java
new file mode 100644
index 0000000..a14bf81
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java
@@ -0,0 +1,269 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import static org.apache.sling.caconfig.impl.ConfigurationNameConstants.CONFIGURATION_CLASSES_HEADER;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.testing.mock.osgi.ManifestScanner;
+import org.apache.sling.testing.mock.osgi.MockOsgi;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+/**
+ * Helper methods for registering Configuration annotation classes from the classpath.
+ */
+final class ConfigurationMetadataUtil {
+    
+    private static final String[] CONFIGURATION_CLASSES_FROM_MANIFEST;
+    
+    static {
+        // scan classpath for configuration classes bundle header entries only once
+        CONFIGURATION_CLASSES_FROM_MANIFEST = toArray(ManifestScanner.getValues(CONFIGURATION_CLASSES_HEADER));
+    }
+    
+    private ConfigurationMetadataUtil() {
+        // static methods only
+    }
+
+    private static String[] toArray(Collection<String> values) {
+        return values.toArray(new String[values.size()]);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Configuration annotation.
+     * @param bundleContext Bundle context
+     * @param classNames Java class names
+     */
+    public static void registerAnnotationClasses(BundleContext bundleContext, String... classNames) {
+        Bundle bundle = new RegisterConfigurationMetadataBundle(bundleContext, Bundle.ACTIVE, classNames);
+        BundleEvent event = new BundleEvent(BundleEvent.STARTED, bundle);
+        MockOsgi.sendBundleEvent(bundleContext, event);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Configuration annotation.
+     * @param bundleContext Bundle context
+     * @param classNames Java class names
+     */
+    public static void registerAnnotationClasses(BundleContext bundleContext, Class... classes) {
+        String[] classNames = new String[classes.length];
+        for (int i = 0; i < classes.length; i++) {
+            classNames[i] = classes[i].getName();
+        }
+        registerAnnotationClasses(bundleContext, classNames);
+    }
+    
+    /**
+     * Scan MANIFEST.MF in the classpath and automatically register all Configuration annotation classes found.
+     * @param bundleContext Bundle context
+     */
+    public static void addAnnotationClassesForManifestEntries(BundleContext bundleContext) {
+        if (CONFIGURATION_CLASSES_FROM_MANIFEST.length > 0) {
+            registerAnnotationClasses(bundleContext, CONFIGURATION_CLASSES_FROM_MANIFEST);
+        }
+    }
+    
+
+    private static class RegisterConfigurationMetadataBundle implements Bundle {
+        
+        private final BundleContext bundleContext;
+        private final int state;
+        private final String classNames;
+
+        public RegisterConfigurationMetadataBundle(BundleContext bundleContext, int state, String[] classNames) {
+            this.bundleContext = bundleContext;
+            this.state = state;
+            this.classNames = normalizeValueList(classNames);
+        }
+        
+        private String normalizeValueList(String[] values) {
+            if (values == null || values.length == 0) {
+                return null;
+            }
+            return StringUtils.join(values, ",");
+        }
+
+        @Override
+        public int getState() {
+            return this.state;
+        }
+
+        @Override
+        public Dictionary<String,String> getHeaders() {
+            Dictionary<String, String> headers = new Hashtable<String, String>();
+            headers.put(CONFIGURATION_CLASSES_HEADER, classNames);
+            return headers;
+        }
+
+        @Override
+        public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
+            return new Vector<URL>().elements();
+        }
+        
+        @Override
+        public Class<?> loadClass(String name) throws ClassNotFoundException {
+            return getClass().getClassLoader().loadClass(name);
+        }
+
+        @Override
+        public BundleContext getBundleContext() {
+            return bundleContext;
+        }
+
+        @Override
+        public void start(int options) throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void start() throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void stop(int options) throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void stop() throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void update(InputStream input) throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void update() throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public void uninstall() throws BundleException {
+            // do nothing
+        }
+
+        @Override
+        public long getBundleId() {
+            return 0;
+        }
+
+        @Override
+        public String getLocation() {
+            return null;
+        }
+
+        @Override
+        public ServiceReference<?>[] getRegisteredServices() { // NOPMD
+            return null;
+        }
+
+        @Override
+        public ServiceReference<?>[] getServicesInUse() { // NOPMD
+            return null;
+        }
+
+        @Override
+        public boolean hasPermission(Object permission) {
+            return false;
+        }
+
+        @Override
+        public URL getResource(String name) {
+            return null;
+        }
+
+        @Override
+        public Dictionary<String,String> getHeaders(String locale) {
+            return null;
+        }
+
+        @Override
+        public String getSymbolicName() {
+            return null;
+        }
+
+        @Override
+        public Enumeration<URL> getResources(String name) throws IOException {
+            return null;
+        }
+
+        @Override
+        public Enumeration<String> getEntryPaths(String path) {
+            return null;
+        }
+
+        @Override
+        public URL getEntry(String path) {
+            return null;
+        }
+
+        @Override
+        public long getLastModified() {
+            return 0;
+        }
+
+        @Override
+        public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
+            return null;
+        }
+
+        @Override
+        public Version getVersion() {
+            return null;
+        }
+
+        @Override
+        public int compareTo(Bundle o) {
+            return 0;
+        }
+
+        @Override
+        public <A> A adapt(Class<A> type) {
+            return null;
+        }
+
+        @Override
+        public File getDataFile(String filename) {
+            return null;
+        }
+        
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
new file mode 100644
index 0000000..dc06a59
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -0,0 +1,153 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import org.apache.sling.caconfig.impl.ConfigurationBuilderAdapterFactory;
+import org.apache.sling.caconfig.impl.ConfigurationResolverImpl;
+import org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrategy;
+import org.apache.sling.caconfig.impl.metadata.AnnotationClassConfigurationMetadataProvider;
+import org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexer;
+import org.apache.sling.caconfig.management.impl.ConfigurationManagerImpl;
+import org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer;
+import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolverImpl;
+import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexer;
+import org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
+import org.apache.sling.caconfig.resource.impl.def.DefaultContextPathStrategy;
+import org.apache.sling.testing.mock.osgi.context.AbstractContextPlugin;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugin;
+import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
+import org.osgi.annotation.versioning.ProviderType;
+
+/**
+ * Mock context plugins.
+ * The plugin supports both 1.0/1.1 and 1.2+ version of the Impl/SPI.
+ */
+@ProviderType
+public final class ContextPlugins {
+
+    private ContextPlugins() {
+        // constants only
+    }
+
+    /**
+     * Context plugin for Sling Context-Aware Configuration.
+     */
+    public static final ContextPlugin<? extends SlingContextImpl> CACONFIG = new AbstractContextPlugin<SlingContextImpl>() {
+        @Override
+        public void afterSetUp(SlingContextImpl context) throws Exception {
+            registerConfigurationResourceResolver(context);
+            registerConfigurationResolver(context);
+            registerConfigurationManagement(context);
+            registerConfigurationResourceResolverDefaultImpl(context);
+            registerConfigurationResolverDefaultImpl(context);
+
+            // Scan MANIFEST.MF in the classpath and automatically register all Configuration annotation classes found.
+            ConfigurationMetadataUtil.addAnnotationClassesForManifestEntries(context.bundleContext());
+        }
+    };
+
+    /**
+     * Context plugin for Sling Context-Aware Configuration (without the default implementations).
+     */
+    public static final ContextPlugin<? extends SlingContextImpl> CACONFIG_NODEF = new AbstractContextPlugin<SlingContextImpl>() {
+        @Override
+        public void afterSetUp(SlingContextImpl context) throws Exception {
+            registerConfigurationResourceResolver(context);
+            registerConfigurationResolver(context);
+            registerConfigurationManagement(context);
+        }
+    };
+
+    /**
+     * Register all services for ConfigurationResourceResolver (without the default implementations).
+     * @param context Sling context
+     */
+    private static void registerConfigurationResourceResolver(SlingContextImpl context) {
+        
+        if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl")) {
+            // fallback to impl 1.1
+            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer");
+        }
+        
+        context.registerInjectActivateService(new ConfigurationResourceResolvingStrategyMultiplexer());
+        context.registerInjectActivateService(new ConfigurationResourceResolverImpl());
+    }
+
+    /**
+     * Register default implementations for for ConfigurationResourceResolver.
+     * @param context Sling context
+     */
+    private static void registerConfigurationResourceResolverDefaultImpl(SlingContextImpl context) {
+        context.registerInjectActivateService(new DefaultContextPathStrategy());
+        context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy());
+    }
+
+    /**
+     * Register all services for ConfigurationResolver (without the default implementations).
+     * @param context Sling context
+     */
+    private static void registerConfigurationResolver(SlingContextImpl context) {
+        context.registerInjectActivateService(new ConfigurationPersistenceStrategyMultiplexer());
+        context.registerInjectActivateService(new ConfigurationMetadataProviderMultiplexer());
+        
+        // only required for impl 1.2+
+        registerByClassName(context, "org.apache.sling.caconfig.impl.ConfigurationInheritanceStrategyMultiplexer");
+        
+        // only required for impl 1.2+
+        registerByClassName(context, "org.apache.sling.caconfig.impl.override.ConfigurationOverrideManager");
+
+        context.registerInjectActivateService(new ConfigurationResolverImpl());
+        context.registerInjectActivateService(new ConfigurationBuilderAdapterFactory());
+    }
+
+    /**
+     * Register default implementations for for ConfigurationResolver.
+     * @param context Sling context
+     */
+    private static void registerConfigurationResolverDefaultImpl(SlingContextImpl context) {
+        context.registerInjectActivateService(new DefaultConfigurationPersistenceStrategy());
+
+        // only required for impl 1.2+
+        registerByClassName(context,"org.apache.sling.caconfig.impl.def.DefaultConfigurationInheritanceStrategy");
+    }
+
+    private static void registerConfigurationManagement(SlingContextImpl context) {
+        context.registerInjectActivateService(new ConfigurationManagerImpl());
+        context.registerInjectActivateService(new AnnotationClassConfigurationMetadataProvider());
+    }
+
+    private static boolean registerByClassName(SlingContextImpl context, String className) {
+        try {
+            Class<?> clazz = Class.forName(className);
+            context.registerInjectActivateService(clazz.newInstance());
+            return true;
+        }
+        catch (ClassNotFoundException ex) {
+            return false;
+        }
+        catch (InstantiationException ex) {
+            throw new RuntimeException(ex);
+        }
+        catch (IllegalAccessException ex) {
+            throw new RuntimeException(ex);
+        }
+
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
new file mode 100644
index 0000000..03b0212
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
@@ -0,0 +1,52 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
+import org.osgi.annotation.versioning.ProviderType;
+
+/**
+ * Helps setting up a mock environment for Context-Aware Configuration.
+ */
+@ProviderType
+public final class MockContextAwareConfig {
+    
+    private MockContextAwareConfig() {
+        // static methods only
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Configuration annotation.
+     * @param context Sling context
+     * @param classNames Java class names
+     */
+    public static void registerAnnotationClasses(SlingContextImpl context, String... classNames) {
+        ConfigurationMetadataUtil.registerAnnotationClasses(context.bundleContext(), classNames);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Configuration annotation.
+     * @param context Sling context
+     * @param classes Java classes
+     */
+    public static void registerAnnotationClasses(SlingContextImpl context, Class... classes) {
+        ConfigurationMetadataUtil.registerAnnotationClasses(context.bundleContext(), classes);
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java b/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java
new file mode 100644
index 0000000..de6d18e
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/package-info.java
@@ -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.
+ */
+/**
+ * Apache Sling Context-Aware Configuration Mock Plugin
+ */
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.testing.mock.caconfig;
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java b/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java
new file mode 100644
index 0000000..56a40bf
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/CompatibilityUtil.java
@@ -0,0 +1,68 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.management.ConfigurationManager;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+
+/**
+ * Helper methods interacting with Context-Aware context supporting both version 1.1 and 2.0 of
+ * the Management API via reflection.
+ */
+public class CompatibilityUtil {
+
+    /**
+     * Write configuration for impl 1.2
+     */
+    public static void writeConfig(SlingContext context, Resource contextResource, String configName, Map<String,Object> props) {
+        try {
+            Class<?> configurationPersistDataClass;
+            try {
+                configurationPersistDataClass = Class.forName("org.apache.sling.caconfig.spi.ConfigurationPersistData");
+            }
+            catch (ClassNotFoundException e) {
+                // fallback to caconfig impl 1.1
+                writeConfigImpl11(context, contextResource, configName, props);
+                return;
+            }
+
+            Object persistData = configurationPersistDataClass.getConstructor(Map.class).newInstance(props);
+            ConfigurationManager configManager = context.getService(ConfigurationManager.class);
+            Method persistMethod = ConfigurationManager.class.getMethod("persistConfiguration", Resource.class, String.class, configurationPersistDataClass);
+            persistMethod.invoke(configManager, contextResource, configName, persistData);
+        }
+        catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Fallback: Write configuration for impl 1.1
+     */
+    public static void writeConfigImpl11(SlingContext context, Resource contextResource, String configName, Map<String,Object> props) throws Exception {
+        ConfigurationManager configManager = context.getService(ConfigurationManager.class);
+        Method persistMethod = ConfigurationManager.class.getMethod("persist", Resource.class, String.class, Map.class);
+        persistMethod.invoke(configManager, contextResource, configName, props);
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
new file mode 100644
index 0000000..bacb27d
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/ContextPluginsTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.testing.mock.caconfig;
+
+import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.caconfig.ConfigurationBuilder;
+import org.apache.sling.testing.mock.caconfig.example.SimpleConfig;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ContextPluginsTest {
+    
+    private static final String CONFIG_NAME = "testConfig";
+    
+    @Rule
+    public SlingContext context = new SlingContextBuilder().plugin(CACONFIG).build();
+    
+    private Resource contextResource;
+
+    @Before
+    public void setUp() {
+        context.create().resource("/content/site1", "sling:configRef", "/conf/site1");
+        contextResource = context.create().resource("/content/site1/page1");
+        
+        // register configuration annotation class
+        MockContextAwareConfig.registerAnnotationClasses(context, SimpleConfig.class);
+
+        // write config
+        CompatibilityUtil.writeConfig(context, contextResource, CONFIG_NAME, ImmutableMap.<String, Object>of(
+                        "stringParam", "value1",
+                        "intParam", 123,
+                        "boolParam", true));
+    }
+    
+    @Test
+    public void testValueMap() {
+        // read config
+        ValueMap props = contextResource.adaptTo(ConfigurationBuilder.class).name(CONFIG_NAME).asValueMap();
+        assertEquals("value1", props.get("stringParam", String.class));
+        assertEquals((Integer)123, props.get("intParam", Integer.class));
+        assertTrue(props.get("boolParam", Boolean.class));
+    }
+
+    @Test
+    public void testAnnotationClass() {
+        // read config
+        SimpleConfig config = contextResource.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
+        assertEquals("value1", config.stringParam());
+        assertEquals(123, config.intParam());
+        assertTrue(config.boolParam());
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
new file mode 100644
index 0000000..821bd9e
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/example/SimpleConfig.java
@@ -0,0 +1,32 @@
+/*
+ * 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.testing.mock.caconfig.example;
+
+import org.apache.sling.caconfig.annotation.Configuration;
+
+@Configuration(name = "testConfig")
+public @interface SimpleConfig {
+
+    String stringParam();
+    
+    int intParam() default 5;
+    
+    boolean boolParam();
+    
+}

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 07/23: update dependencies

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit ce2e6b4579def997d695bc7540965c996e4ccd79
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 22:40:24 2017 +0000

    update dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787866 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4f18ef4..a4efcd7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,13 +156,13 @@
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.spi</artifactId>
-                    <version>1.2.1-SNAPSHOT</version>
+                    <version>1.3.0</version>
                     <scope>compile</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.sling</groupId>
                     <artifactId>org.apache.sling.caconfig.impl</artifactId>
-                    <version>1.2.1-SNAPSHOT</version>
+                    <version>1.3.0</version>
                     <scope>compile</scope>
                 </dependency>
             </dependencies>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 08/23: [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit d327e93715e5b606917d93b8eb15f9c299293ac1
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 22:41:01 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787867 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index a4efcd7..16b1cd9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 02/23: use Sling Parent 30

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 9e0d27b6bb233b07f652fbef73688b78aba999a0
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Mar 6 10:22:30 2017 +0000

    use Sling Parent 30
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1785621 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 879ff2f..d8ada57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>29</version>
+        <version>30</version>
         <relativePath />
     </parent>
     

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 04/23: SLING-6670 Support CAConfig Impl 1.3.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 2cc1bb5468bd3aa6ae086ce486e74006587587df
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sun Mar 19 15:49:42 2017 +0000

    SLING-6670 Support CAConfig Impl 1.3.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787636 13f79535-47bb-0310-9956-ffa450edef68
---
 .../testing/mock/caconfig/ContextPlugins.java      | 40 +++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index 6a24e0a..85f2bb1 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -22,10 +22,8 @@ import org.apache.sling.caconfig.impl.ConfigurationBuilderAdapterFactory;
 import org.apache.sling.caconfig.impl.ConfigurationResolverImpl;
 import org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrategy;
 import org.apache.sling.caconfig.impl.metadata.AnnotationClassConfigurationMetadataProvider;
-import org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexer;
 import org.apache.sling.caconfig.management.impl.ConfigurationManagerImpl;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolverImpl;
-import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexer;
 import org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
 import org.apache.sling.caconfig.resource.impl.def.DefaultContextPathStrategy;
 import org.apache.sling.testing.mock.osgi.context.AbstractContextPlugin;
@@ -81,10 +79,14 @@ public final class ContextPlugins {
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl")) {
             // fallback to impl 1.1
-            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer", true);
+            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer");
+        }
+        
+        if (!registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexerImpl")) {
+            // fallback to impl 1.2
+            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexer");
         }
         
-        context.registerInjectActivateService(new ConfigurationResourceResolvingStrategyMultiplexer());
         context.registerInjectActivateService(new ConfigurationResourceResolverImpl());
     }
 
@@ -105,16 +107,23 @@ public final class ContextPlugins {
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexerImpl")) {
             // fallback to impl 1.2
-            registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer", true);
+            registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer");
         }
 
-        context.registerInjectActivateService(new ConfigurationMetadataProviderMultiplexer());
+        if (!registerByClassName(context, "org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexerImpl")) {
+            // fallback to impl 1.2
+            registerByClassName(context, "org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexer");
+        }
         
-        // only required for impl 1.2+
-        registerByClassName(context, "org.apache.sling.caconfig.impl.ConfigurationInheritanceStrategyMultiplexer");
+        if (!registerByClassName(context, "org.apache.sling.caconfig.impl.ConfigurationInheritanceStrategyMultiplexerImpl")) {
+            // fallback to impl 1.2 (not existing in 1.1 or below)
+            registerByClassName(context, "org.apache.sling.caconfig.impl.ConfigurationInheritanceStrategyMultiplexer");
+        }
         
-        // only required for impl 1.2+
-        registerByClassName(context, "org.apache.sling.caconfig.impl.override.ConfigurationOverrideManager");
+        if (!registerByClassName(context, "org.apache.sling.caconfig.impl.override.ConfigurationOverrideMultiplexerImpl")) {
+            // fallback to impl 1.2 (not existing in 1.1 or below)
+            registerByClassName(context, "org.apache.sling.caconfig.impl.override.ConfigurationOverrideManager");
+        }
 
         context.registerInjectActivateService(new ConfigurationResolverImpl());
         context.registerInjectActivateService(new ConfigurationBuilderAdapterFactory());
@@ -137,22 +146,13 @@ public final class ContextPlugins {
     }
 
     private static boolean registerByClassName(SlingContextImpl context, String className) {
-        return registerByClassName(context, className, false);
-    }
-
-    private static boolean registerByClassName(SlingContextImpl context, String className, boolean mandatory) {
         try {
             Class<?> clazz = Class.forName(className);
             context.registerInjectActivateService(clazz.newInstance());
             return true;
         }
         catch (ClassNotFoundException ex) {
-            if (mandatory) {
-                throw new RuntimeException(ex.getMessage(), ex);
-            }
-            else {
-                return false;
-            }
+            return false;
         }
         catch (InstantiationException ex) {
             throw new RuntimeException(ex);

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 11/23: SLING-6789 Support CAConfig Impl 1.4.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit dcdcf5175f53c5d9867f0051befc1e7721e8d478
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Apr 25 07:47:06 2017 +0000

    SLING-6789 Support CAConfig Impl 1.4.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1792579 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                            | 7 ++-----
 .../org/apache/sling/testing/mock/caconfig/ContextPlugins.java     | 1 +
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 14262c4..e16af18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,22 +53,19 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.api</artifactId>
-            <!-- Stick with dependency version 1.1.0 as it was released with caconfig-mock-plugin 1.0.0 -->
             <version>1.1.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.spi</artifactId>
-            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin 1.0.0 -->
-            <version>1.2.0</version>
+            <version>1.3.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
-            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin 1.0.0 -->
-            <version>1.2.0</version>
+            <version>1.3.3-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index 0f14346..4197bff 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -104,6 +104,7 @@ public final class ContextPlugins {
      * @param context Sling context
      */
     private static void registerConfigurationResolver(SlingContextImpl context) {
+        registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationManagementSettingsImpl");
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexerImpl")) {
             // fallback to impl 1.2

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 23/23: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit fad9a493021a6524f70674f5fea4b853d699f00f
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 10:11:07 2017 +0000

    SLING-7167 Adjust READMEs
    
    add uniform header linking to Sling project
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810950 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 1875af9..d135776 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-Apache Sling Context-Aware Configuration Mock Plugin
+# Apache Sling Context-Aware Configuration Mock Plugin
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
 
 Mock Context Plugin for Apache Sling Context-Aware Configuration
 

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 12/23: update dependency

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 1b71f986e41886f7028b6ed9ab3489005673d08a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue May 2 15:46:15 2017 +0000

    update dependency
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1793539 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e16af18..fa6f851 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
-            <version>1.3.3-SNAPSHOT</version>
+            <version>1.4.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 06/23: SLING-6670 Support CAConfig Impl 1.3.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 12819bac79c54a1786092cc4e8392e58c59ac52c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 16:17:06 2017 +0000

    SLING-6670 Support CAConfig Impl 1.3.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787807 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index 85f2bb1..0f14346 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -109,6 +109,9 @@ public final class ContextPlugins {
             // fallback to impl 1.2
             registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer");
         }
+        
+        // only required for impl 1.3+
+        registerByClassName(context, "org.apache.sling.caconfig.impl.ConfigurationPersistenceStrategyBridge");
 
         if (!registerByClassName(context, "org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexerImpl")) {
             // fallback to impl 1.2

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 22/23: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 310b2241566682837ea602a7c1a8d548d41fe0d1
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Oct 2 16:22:59 2017 +0000

    SLING-7167 Adjust READMEs
    
    switch from plain text to Markdown
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810535 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt => README.md | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/README.txt b/README.md
similarity index 100%
rename from README.txt
rename to README.md

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 14/23: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit ec11bf46588b8e7e39d190e3121139d33749ddb9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue May 2 15:47:00 2017 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1793542 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7cfde93..d5bd7b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.2.0</version>
+    <version>1.2.1-SNAPSHOT</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 15/23: update to next development version until release version is available on maven central

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 7b91b53fa53c324bce5f7dc18781005a0faf2f12
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue May 2 15:48:59 2017 +0000

    update to next development version until release version is available on maven central
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1793543 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index d5bd7b2..80cbcb6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
-            <version>1.4.0</version>
+            <version>1.4.1-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 20/23: [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.3.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit c37e161fa11ee3550356862736cf5d887a526310
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri May 26 07:31:48 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.3.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796248 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e0ef829..0eb5e5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.2.1-SNAPSHOT</version>
+    <version>1.3.0</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 09/23: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 1ef2f6b3d228523fa0d7cfbb41369fc26eaabca1
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 22:41:17 2017 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787869 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 16b1cd9..a653853 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.1.0</version>
+    <version>1.1.1-SNAPSHOT</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.1.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 18/23: SLING-6881 CAConfig Mock Plugin: Register configuration classes via package name

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 4af96afe75a33100f87ba4774bf96dabab2ee214
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed May 24 13:02:55 2017 +0000

    SLING-6881 CAConfig Mock Plugin: Register configuration classes via package name
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796055 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/caconfig/ConfigurationMetadataUtil.java   | 37 ++++++++++++++++++++--
 .../mock/caconfig/MockContextAwareConfig.java      | 11 +++++++
 .../mock/caconfig/MockContextAwareConfigTest.java  |  2 +-
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java
index a14bf81..d12d9e5 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ConfigurationMetadataUtil.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.security.cert.X509Certificate;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Enumeration;
@@ -32,8 +33,11 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Vector;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.caconfig.annotation.Configuration;
 import org.apache.sling.testing.mock.osgi.ManifestScanner;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.osgi.framework.Bundle;
@@ -42,6 +46,7 @@ import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
+import org.reflections.Reflections;
 
 /**
  * Helper methods for registering Configuration annotation classes from the classpath.
@@ -49,12 +54,16 @@ import org.osgi.framework.Version;
 final class ConfigurationMetadataUtil {
     
     private static final String[] CONFIGURATION_CLASSES_FROM_MANIFEST;
-    
+    private static final ConcurrentMap<String, List<Class>> CONFIGURATION_CLASSES_FOR_PACKAGES = new ConcurrentHashMap<String, List<Class>>();
+        
     static {
+        // suppress log entries from Reflections library
+        Reflections.log = null;
+        
         // scan classpath for configuration classes bundle header entries only once
         CONFIGURATION_CLASSES_FROM_MANIFEST = toArray(ManifestScanner.getValues(CONFIGURATION_CLASSES_HEADER));
     }
-    
+
     private ConfigurationMetadataUtil() {
         // static methods only
     }
@@ -97,7 +106,29 @@ final class ConfigurationMetadataUtil {
         }
     }
     
-
+    /**
+     * Get configuration classes in list of packages (and subpackages), and cache result in static map.
+     * @param packageNames Package names
+     * @return List of classes
+     */
+    public static Collection<Class> getConfigurationClassesForPackages(String packageNames) {
+        List<Class> classes = CONFIGURATION_CLASSES_FOR_PACKAGES.get(packageNames);
+        if (classes == null) {
+            classes = new ArrayList<Class>();
+            String[] packageNameArray = StringUtils.split(packageNames, ",");
+            // add "." to each package name because it's a prefix, not a package name
+            Object[] prefixArray = new Object[packageNameArray.length];
+            for (int i = 0; i < packageNameArray.length; i++) {
+                prefixArray[i] = packageNameArray[i] + ".";
+            }
+            Reflections reflections = new Reflections(prefixArray);
+            classes.addAll(reflections.getTypesAnnotatedWith(Configuration.class));
+            CONFIGURATION_CLASSES_FOR_PACKAGES.putIfAbsent(packageNames, classes);
+        }
+        return classes;
+    }
+    
+    
     private static class RegisterConfigurationMetadataBundle implements Bundle {
         
         private final BundleContext bundleContext;
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
index d5a539b..46e4135 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfig.java
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.caconfig.management.ConfigurationManager;
 import org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData;
@@ -60,6 +61,16 @@ public final class MockContextAwareConfig {
     }
 
     /**
+     * Search classpath for given class names to scan for and register all classes with @Configuration annotation.
+     * @param context Sling context
+     * @param packageNames Java package names
+     */
+    public static void registerAnnotationPackages(SlingContextImpl context, String... packageNames) {
+        Collection<Class> classes = ConfigurationMetadataUtil.getConfigurationClassesForPackages(StringUtils.join(packageNames, ","));
+        registerAnnotationClasses(context, classes.toArray(new Class[classes.size()]));
+    }
+
+    /**
      * Writes configuration parameters using the primary configured persistence
      * provider.
      * @param context Sling context
diff --git a/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
index 916b025..da190c2 100644
--- a/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/caconfig/MockContextAwareConfigTest.java
@@ -48,7 +48,7 @@ public class MockContextAwareConfigTest {
 
     @Before
     public void setUp() {
-        MockContextAwareConfig.registerAnnotationClasses(context, SimpleConfig.class, ListConfig.class);
+        MockContextAwareConfig.registerAnnotationPackages(context, "org.apache.sling.testing.mock.caconfig.example");
 
         context.create().resource("/content/region/site", "sling:configRef", "/conf/region/site");
 

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 13/23: [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.2.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 4ef00bcfb07dfb4062734e228e77754b6c4fde9e
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue May 2 15:46:46 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.testing.caconfig-mock-plugin-1.2.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1793540 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fa6f851..7cfde93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.2.0</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.2.0</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 21/23: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 55cadd9803693453c6a9cc3d7feb7ee5b8be501f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri May 26 07:32:03 2017 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796250 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0eb5e5b..008a51b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,14 +29,14 @@
     
     <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
     <packaging>bundle</packaging>
-    <version>1.3.0</version>
+    <version>1.3.1-SNAPSHOT</version>
     <name>Apache Sling Context-Aware Configuration Mock Plugin</name>
     <description>Mock Context Plugin for Apache Sling Context-Aware Configuration</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.caconfig-mock-plugin-1.3.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/caconfig-mock-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/caconfig-mock-plugin</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-testing-caconfig-mock-plugin] 03/23: SLING-6670 Support CAConfig Impl 1.3.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 1846e2d63808f6515d35636b01305aac4eff9d94
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sun Mar 19 14:59:51 2017 +0000

    SLING-6670 Support CAConfig Impl 1.3.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787628 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 53 ++++++++++++++++++++++
 .../testing/mock/caconfig/ContextPlugins.java      | 23 ++++++++--
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index d8ada57..9164f43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,18 +53,21 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.api</artifactId>
+            <!-- Stick with dependency version 1.1.0 as it was released with caconfig-mock-plugin 1.0.0 -->
             <version>1.1.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.spi</artifactId>
+            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin 1.0.0 -->
             <version>1.2.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
+            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin 1.0.0 -->
             <version>1.2.0</version>
             <scope>compile</scope>
         </dependency>
@@ -115,6 +118,56 @@
             </dependencies>
         </profile>
 
+        <!-- Test with Sling CAConfig Impl/SPI 1.2 -->
+        <profile>
+            <id>caconfig-1.2</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.api</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.spi</artifactId>
+                    <version>1.2.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.impl</artifactId>
+                    <version>1.2.0</version>
+                    <scope>compile</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <!-- Test with Sling CAConfig Impl/SPI 1.3 -->
+        <profile>
+            <id>caconfig-1.3</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.api</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.spi</artifactId>
+                    <version>1.2.1-SNAPSHOT</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.impl</artifactId>
+                    <version>1.2.1-SNAPSHOT</version>
+                    <scope>compile</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
     </profiles>
 
 </project>
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index dc06a59..6a24e0a 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -24,7 +24,6 @@ import org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrateg
 import org.apache.sling.caconfig.impl.metadata.AnnotationClassConfigurationMetadataProvider;
 import org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexer;
 import org.apache.sling.caconfig.management.impl.ConfigurationManagerImpl;
-import org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolverImpl;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexer;
 import org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
@@ -36,7 +35,7 @@ import org.osgi.annotation.versioning.ProviderType;
 
 /**
  * Mock context plugins.
- * The plugin supports both 1.0/1.1 and 1.2+ version of the Impl/SPI.
+ * The plugin supports all versions from 1.0 to the most recent versions of the Impl/SPI.
  */
 @ProviderType
 public final class ContextPlugins {
@@ -82,7 +81,7 @@ public final class ContextPlugins {
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl")) {
             // fallback to impl 1.1
-            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer");
+            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer", true);
         }
         
         context.registerInjectActivateService(new ConfigurationResourceResolvingStrategyMultiplexer());
@@ -103,7 +102,12 @@ public final class ContextPlugins {
      * @param context Sling context
      */
     private static void registerConfigurationResolver(SlingContextImpl context) {
-        context.registerInjectActivateService(new ConfigurationPersistenceStrategyMultiplexer());
+        
+        if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexerImpl")) {
+            // fallback to impl 1.2
+            registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer", true);
+        }
+
         context.registerInjectActivateService(new ConfigurationMetadataProviderMultiplexer());
         
         // only required for impl 1.2+
@@ -133,13 +137,22 @@ public final class ContextPlugins {
     }
 
     private static boolean registerByClassName(SlingContextImpl context, String className) {
+        return registerByClassName(context, className, false);
+    }
+
+    private static boolean registerByClassName(SlingContextImpl context, String className, boolean mandatory) {
         try {
             Class<?> clazz = Class.forName(className);
             context.registerInjectActivateService(clazz.newInstance());
             return true;
         }
         catch (ClassNotFoundException ex) {
-            return false;
+            if (mandatory) {
+                throw new RuntimeException(ex.getMessage(), ex);
+            }
+            else {
+                return false;
+            }
         }
         catch (InstantiationException ex) {
             throw new RuntimeException(ex);

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