Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,103 @@
+/*
+ * 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.contextaware.config.management.impl;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.ModifiableValueMap;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+import 
org.apache.sling.contextaware.config.spi.ConfigurationPersistenceException;
+import 
org.apache.sling.contextaware.config.spi.ConfigurationPersistenceStrategy;
+
+/**
+ * This is a variant of {@link 
org.apache.sling.contextaware.config.impl.def.DefaultConfigurationPersistenceStrategy}
+ * which reads and stores data from a sub-resources named "jcr:content".
+ */
+public class CustomConfigurationPersistenceStrategy implements 
ConfigurationPersistenceStrategy {
+    
+    private static final String DEFAULT_RESOURCE_TYPE = 
JcrConstants.NT_UNSTRUCTURED;
+    
+    @Override
+    public Resource getResource(Resource resource) {
+        return resource.getChild("jcr:content");
+    }
+
+    @Override
+    public boolean persist(ResourceResolver resourceResolver, String 
configResourcePath, Map<String,Object> properties) {
+        getOrCreateResource(resourceResolver, configResourcePath + 
"/jcr:content", properties);
+        return true;
+    }
+
+    @Override
+    public boolean persistCollection(ResourceResolver resourceResolver, String 
configResourceCollectionParentPath,
+            Collection<Map<String,Object>> propertiesCollection) {
+        Resource configResourceParent = getOrCreateResource(resourceResolver, 
configResourceCollectionParentPath, ValueMap.EMPTY);
+        deleteChildren(configResourceParent);
+        int index = 0;
+        for (Map<String,Object> properties : propertiesCollection) {
+            String path = configResourceParent.getPath() + "/" + (index++) + 
"/jcr:content";
+            getOrCreateResource(resourceResolver, path, properties);
+        }
+        return true;
+    }
+    
+    private Resource getOrCreateResource(ResourceResolver resourceResolver, 
String path, Map<String,Object> properties) {
+        try {
+            Resource resource = 
ResourceUtil.getOrCreateResource(resourceResolver, path, DEFAULT_RESOURCE_TYPE, 
DEFAULT_RESOURCE_TYPE, false);
+            replaceProperties(resource, properties);
+            return resource;
+        }
+        catch (PersistenceException ex) {
+            throw new ConfigurationPersistenceException("Unable to persist 
configuration to " + path, ex);
+        }
+    }
+
+    private void deleteChildren(Resource resource) {
+        ResourceResolver resourceResolver = resource.getResourceResolver();
+        try {
+            for (Resource child : resource.getChildren()) {
+                resourceResolver.delete(child);
+            }
+        }
+        catch (PersistenceException ex) {
+            throw new ConfigurationPersistenceException("Unable to remove 
children from " + resource.getPath(), ex);
+        }
+    }
+    
+    private void replaceProperties(Resource resource, Map<String,Object> 
properties) {
+        ModifiableValueMap modValueMap = 
resource.adaptTo(ModifiableValueMap.class);
+        // remove all existing properties that do not have jcr: or sling: 
namespace
+        for (String propertyName : new HashSet<>(modValueMap.keySet())) {
+            if (StringUtils.startsWith(propertyName, "jcr:") || 
StringUtils.startsWith(propertyName, "sling:")) {
+                continue;
+            }
+            modValueMap.remove(propertyName);
+        }
+        modValueMap.putAll(properties);
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/CustomConfigurationPersistenceStrategy.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,74 @@
+/*
+ * 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.contextaware.config.management.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.sling.contextaware.config.management.ValueInfo;
+import org.apache.sling.contextaware.config.spi.metadata.PropertyMetadata;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ValueInfoImplTest {
+    
+    private PropertyMetadata<String> propertyMetadata;
+
+    @Before
+    public void setUp() {
+        propertyMetadata = new PropertyMetadata<String>("prop1", "defValue");
+    }
+    
+    @Test
+    public void testValueMetadata() {
+        ValueInfo<String> underTest = new ValueInfoImpl<>("value", 
"/conf/test", propertyMetadata);
+        
+        assertSame(propertyMetadata, underTest.getPropertyMetadata());
+        assertEquals("value", underTest.getValue());
+        assertEquals("value", underTest.getEffectiveValue());
+        assertEquals("/conf/test", underTest.getConfigSourcePath());
+        assertFalse(underTest.isDefault());
+    }
+
+    @Test
+    public void testNoValueMetadata() {
+        ValueInfo<String> underTest = new ValueInfoImpl<>(null, "/conf/test", 
propertyMetadata);
+        
+        assertSame(propertyMetadata, underTest.getPropertyMetadata());
+        assertNull(underTest.getValue());
+        assertEquals("defValue", underTest.getEffectiveValue());
+        assertEquals("/conf/test", underTest.getConfigSourcePath());
+        assertTrue(underTest.isDefault());
+    }
+
+    @Test
+    public void testValueNoMetadata() {
+        ValueInfo<String> underTest = new ValueInfoImpl<>("value", 
"/conf/test", null);
+        
+        assertNull(underTest.getPropertyMetadata());
+        assertEquals("value", underTest.getValue());
+        assertEquals("value", underTest.getEffectiveValue());
+        assertEquals("/conf/test", underTest.getConfigSourcePath());
+        assertFalse(underTest.isDefault());
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/management/impl/ValueInfoImplTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolverImplTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolverImplTest.java?rev=1761468&r1=1761467&r2=1761468&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolverImplTest.java
 (original)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolverImplTest.java
 Mon Sep 19 15:39:17 2016
@@ -18,7 +18,7 @@
  */
 package org.apache.sling.contextaware.config.resource.impl;
 
-import static 
org.apache.sling.contextaware.config.resource.impl.TestUtils.assetResourcePaths;
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
 import static org.junit.Assert.assertEquals;
 
 import java.util.Collection;
@@ -46,7 +46,7 @@ public class ConfigurationResourceResolv
 
     @Before
     public void setUp() {
-        underTest = context.registerInjectActivateService(new 
ConfigurationResourceResolverImpl());
+        underTest = 
ConfigurationResourceTestUtils.registerConfigurationResourceResolver(context);
 
         // content resources
         context.build()

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,158 @@
+/*
+ * 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.contextaware.config.resource.impl;
+
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.apache.sling.api.resource.Resource;
+import 
org.apache.sling.contextaware.config.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
+import 
org.apache.sling.contextaware.config.resource.impl.def.DefaultContextPathStrategy;
+import 
org.apache.sling.contextaware.config.resource.spi.ConfigurationResourceResolvingStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+
+import com.google.common.collect.ImmutableList;
+
+public class ConfigurationResourceResolvingStrategyMultiplexerTest {
+
+    private static final String BUCKET = "sling:test";
+    
+    @Rule
+    public SlingContext context = new SlingContext();
+    
+    private ConfigurationResourceResolvingStrategyMultiplexer underTest;
+    
+    private Resource site1Page1;
+
+    @Before
+    public void setUp() {
+        context.registerInjectActivateService(new 
DefaultContextPathStrategy());
+        context.registerInjectActivateService(new 
ContextPathStrategyMultiplexer());
+        underTest = context.registerInjectActivateService(new 
ConfigurationResourceResolvingStrategyMultiplexer());
+
+        // content resources
+        context.build()
+            .resource("/content/site1", "sling:config-ref", "/conf/site1")
+            .resource("/content/site2", "sling:config-ref", "/conf/site2");
+        site1Page1 = context.create().resource("/content/site1/page1");
+        
+        // configuration
+        context.build()
+            .resource("/conf/site1/sling:test/test")
+            .resource("/conf/site1/sling:test/feature/c")
+            .resource("/conf/site2/sling:test/feature/c")
+            .resource("/conf/site2/sling:test/feature/d")
+            .resource("/apps/conf/sling:test/feature/a")
+            .resource("/libs/conf/sling:test/test")
+            .resource("/libs/conf/sling:test/feature/b");
+    }
+    
+    @Test
+    public void testWithNoStrategies() {
+        assertNull(underTest.getResource(site1Page1, BUCKET, "test"));
+        
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "feature");
+        assertTrue(col1.isEmpty());
+
+        assertNull(underTest.getResourcePath(site1Page1, BUCKET, "test"));
+        assertNull(underTest.getResourceCollectionParentPath(site1Page1, 
BUCKET, "feature"));
+    }
+
+    @Test
+    public void testWithDefaultStrategy() {
+        context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResource(site1Page1, BUCKET, "test").getPath());
+
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "feature");
+        assetResourcePaths(new String[] {
+                "/conf/site1/sling:test/feature/c",
+                "/apps/conf/sling:test/feature/a", 
+                "/libs/conf/sling:test/feature/b" },
+                col1);
+
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResourcePath(site1Page1, BUCKET, "test"));
+        assertEquals("/conf/site1/sling:test/feature", 
underTest.getResourceCollectionParentPath(site1Page1, BUCKET, "feature"));
+    }
+    
+    @Test
+    public void testMultipleStrategies() {
+        
+        // strategy 1
+        context.registerService(ConfigurationResourceResolvingStrategy.class, 
new ConfigurationResourceResolvingStrategy() {
+            @Override
+            public Resource getResource(Resource resource, String bucketName, 
String configName) {
+                return 
context.resourceResolver().getResource("/conf/site1/sling:test/test");
+            }
+            @Override
+            public Collection<Resource> getResourceCollection(Resource 
resource, String bucketName, String configName) {
+                return 
ImmutableList.copyOf(context.resourceResolver().getResource("/conf/site1/sling:test/feature").listChildren());
+            }
+            @Override
+            public String getResourcePath(Resource resource, String 
bucketName, String configName) {
+                return "/conf/site1/sling:test/test";
+            }
+            @Override
+            public String getResourceCollectionParentPath(Resource resource, 
String bucketName, String configName) {
+                return "/conf/site1/sling:test/feature";
+            }
+        }, Constants.SERVICE_RANKING, 2000);
+        
+        // strategy 2
+        context.registerService(ConfigurationResourceResolvingStrategy.class, 
new ConfigurationResourceResolvingStrategy() {
+            @Override
+            public Resource getResource(Resource resource, String bucketName, 
String configName) {
+                return 
context.resourceResolver().getResource("/libs/conf/sling:test/test");
+            }
+            @Override
+            public Collection<Resource> getResourceCollection(Resource 
resource, String bucketName, String configName) {
+                return 
ImmutableList.copyOf(context.resourceResolver().getResource("/libs/conf/sling:test/feature").listChildren());
+            }
+            @Override
+            public String getResourcePath(Resource resource, String 
bucketName, String configName) {
+                return null;
+            }
+            @Override
+            public String getResourceCollectionParentPath(Resource resource, 
String bucketName, String configName) {
+                return null;
+            }
+        }, Constants.SERVICE_RANKING, 1000);
+        
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResource(site1Page1, BUCKET, "test").getPath());
+
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "feature");
+        assetResourcePaths(new String[] {
+                "/conf/site1/sling:test/feature/c",
+                "/libs/conf/sling:test/feature/b" },
+                col1);
+        
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResourcePath(site1Page1, BUCKET, "test"));
+        assertEquals("/conf/site1/sling:test/feature", 
underTest.getResourceCollectionParentPath(site1Page1, BUCKET, "feature"));
+    }
+    
+    
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceResolvingStrategyMultiplexerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,75 @@
+/*
+ * 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.contextaware.config.resource.impl;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.sling.api.resource.Resource;
+import 
org.apache.sling.contextaware.config.resource.ConfigurationResourceResolver;
+import 
org.apache.sling.contextaware.config.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
+import 
org.apache.sling.contextaware.config.resource.impl.def.DefaultContextPathStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+
+import com.google.common.collect.ImmutableList;
+
+public final class ConfigurationResourceTestUtils {
+    
+    private ConfigurationResourceTestUtils() {
+        // static methods only
+    }
+
+    /**
+     * Assert that resources with the given path exist in the given order in 
the given collection.
+     * @param expectedPaths Expected path
+     * @param actualResources Actual resources
+     */
+    public static void assetResourcePaths(String[] expectedPaths, 
Collection<Resource> actualResources) {
+        String[] actualPaths = new String[actualResources.size()];
+        int i = 0;
+        for (Iterator<Resource> it=actualResources.iterator(); it.hasNext(); 
i++) {
+            actualPaths[i] = it.next().getPath();
+        }
+        assertArrayEquals(expectedPaths, actualPaths);
+    }
+    
+    /**
+     * Assert that resources with the given path exist in the given order in 
the given collection.
+     * @param expectedPaths Expected path
+     * @param actualResources Actual resources
+     */
+    public static void assetResourcePaths(String[] expectedPaths, 
Iterator<Resource> actualResources) {
+        assetResourcePaths(expectedPaths, 
ImmutableList.copyOf(actualResources));
+    }
+    
+    /**
+     * Register all services for {@link ConfigurationResourceResolver}.
+     * @param context Sling context
+     */
+    public static ConfigurationResourceResolver 
registerConfigurationResourceResolver(SlingContext context) {
+        context.registerInjectActivateService(new 
DefaultContextPathStrategy());
+        context.registerInjectActivateService(new 
ContextPathStrategyMultiplexer());
+        context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+        context.registerInjectActivateService(new 
ConfigurationResourceResolvingStrategyMultiplexer());
+        return context.registerInjectActivateService(new 
ConfigurationResourceResolverImpl());
+    }
+    
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ConfigurationResourceTestUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,123 @@
+/*
+ * 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.contextaware.config.resource.impl;
+
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
+import static org.junit.Assert.assertFalse;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.sling.api.resource.Resource;
+import 
org.apache.sling.contextaware.config.resource.impl.def.DefaultContextPathStrategy;
+import org.apache.sling.contextaware.config.resource.spi.ContextPathStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class ContextPathStrategyMultiplexerTest {
+
+    @Rule
+    public SlingContext context = new SlingContext();
+    
+    private ContextPathStrategyMultiplexer underTest;
+    
+    private Resource site1Page1;
+    private Resource site2Page1;
+
+    @Before
+    public void setUp() {
+        underTest = context.registerInjectActivateService(new 
ContextPathStrategyMultiplexer());
+
+        // content resources that form a deeper hierarchy
+        context.build()
+            .resource("/content/tenant1", "sling:config-ref", "/conf/tenant1")
+            .resource("/content/tenant1/region1", "sling:config-ref", 
"/conf/tenant1/region1")
+            .resource("/content/tenant1/region1/site1", "sling:config-ref", 
"/conf/tenant1/region1/site1")
+            .resource("/content/tenant1/region1/site2", "sling:config-ref", 
"/conf/tenant1/region1/site2");
+        site1Page1 = 
context.create().resource("/content/tenant1/region1/site1/page1");
+        site2Page1 = 
context.create().resource("/content/tenant1/region1/site2/page1");
+    }
+    
+    @Test
+    public void testWithNoStrategies() {
+        Iterator<Resource> resources = 
underTest.findContextResources(site1Page1);
+        assertFalse(resources.hasNext());
+    }
+
+    @Test
+    public void testWithDefaultStrategy() {
+        context.registerInjectActivateService(new 
DefaultContextPathStrategy());
+
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site1",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site1Page1));
+
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site2",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site2Page1));
+    }
+    
+    @Test
+    public void testWithNonoverlappingStrategies() {
+        registerContextPathStrategy("/content/tenant1");
+        registerContextPathStrategy("/content/tenant1/region1/site1", 
"/content/tenant1/region1");
+        
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site1",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site1Page1));
+    }
+    
+    @Test
+    public void testWithOverlappingStrategies() {
+        registerContextPathStrategy("/content/tenant1", 
"/content/tenant1/region1");
+        registerContextPathStrategy("/content/tenant1/region1/site1", 
"/content/tenant1/region1");
+        
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site1",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site1Page1));
+    }
+    
+    private void registerContextPathStrategy(String... paths) {
+        final List<Resource> resources = new ArrayList<>();
+        for (String path : paths) {
+            Resource resource = context.resourceResolver().getResource(path);
+            if (resource != null) {
+                resources.add(resource);
+            }
+        }
+        context.registerService(ContextPathStrategy.class, new 
ContextPathStrategy() {
+            @Override
+            public Iterator<Resource> findContextResources(Resource resource) {
+                return resources.iterator();
+            }
+        });
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/ContextPathStrategyMultiplexerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,129 @@
+/*
+ * 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.contextaware.config.resource.impl.def;
+
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collection;
+
+import org.apache.sling.api.resource.Resource;
+import 
org.apache.sling.contextaware.config.resource.impl.ContextPathStrategyMultiplexer;
+import 
org.apache.sling.contextaware.config.resource.spi.ConfigurationResourceResolvingStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Tests with content and configurations that form a deeper nested hierarchy.
+ */
+public class DefaultConfigurationResourceResolvingStrategyHierarchyTest {
+    
+    private static final String BUCKET = "sling:test";
+
+    @Rule
+    public SlingContext context = new SlingContext();
+
+    private ConfigurationResourceResolvingStrategy underTest;
+
+    private Resource site1Page1;
+    private Resource site2Page1;
+
+    @Before
+    public void setUp() {
+        context.registerInjectActivateService(new 
DefaultContextPathStrategy());
+        context.registerInjectActivateService(new 
ContextPathStrategyMultiplexer());
+        underTest = context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+
+        // content resources that form a deeper hierarchy
+        context.build()
+            .resource("/content/tenant1", "sling:config-ref", "/conf/tenant1")
+            .resource("/content/tenant1/region1", "sling:config-ref", 
"/conf/tenant1/region1")
+            .resource("/content/tenant1/region1/site1", "sling:config-ref", 
"/conf/tenant1/region1/site1")
+            .resource("/content/tenant1/region1/site2", "sling:config-ref", 
"/conf/tenant1/region1/site2");
+        site1Page1 = 
context.create().resource("/content/tenant1/region1/site1/page1");
+        site2Page1 = 
context.create().resource("/content/tenant1/region1/site2/page1");
+
+        // configuration
+        context.build()
+            .resource("/conf/tenant1/region1/site1/sling:test/cfgSite1")
+            .resource("/conf/tenant1/region1/site1/sling:test/cfgCol/site1")
+            .resource("/conf/tenant1/region1/sling:test/cfgRegion1")
+            .resource("/conf/tenant1/region1/sling:test/cfgCol/region1")
+            .resource("/conf/tenant1/sling:test/cfgTenant1")
+            .resource("/conf/tenant1/sling:test/cfgCol/tenant1")
+            .resource("/conf/tenant1/sling:test/test")
+            .resource("/conf/global/sling:test/cfgGlobal")
+            .resource("/conf/global/sling:test/cfgCol/confGlobal")
+            .resource("/conf/global/sling:test/test")
+            .resource("/apps/conf/sling:test/cfgAppsGlobal")
+            .resource("/apps/conf/sling:test/cfgCol/appsGlobal")
+            .resource("/apps/conf/sling:test/test")
+            .resource("/libs/conf/sling:test/cfgLibsGlobal")
+            .resource("/libs/conf/sling:test/cfgCol/libsGlobal1")
+            .resource("/libs/conf/sling:test/cfgCol/libsGlobal2")
+            .resource("/libs/conf/sling:test/test");
+    }
+
+    @Test
+    public void testGetResource() {
+        assertEquals("/conf/tenant1/region1/site1/sling:test/cfgSite1", 
underTest.getResource(site1Page1, BUCKET, "cfgSite1").getPath());
+        assertEquals("/conf/tenant1/region1/sling:test/cfgRegion1", 
underTest.getResource(site1Page1, BUCKET, "cfgRegion1").getPath());
+        assertEquals("/conf/tenant1/sling:test/cfgTenant1", 
underTest.getResource(site1Page1, BUCKET, "cfgTenant1").getPath());
+        assertEquals("/conf/global/sling:test/cfgGlobal", 
underTest.getResource(site1Page1, BUCKET, "cfgGlobal").getPath());
+        assertEquals("/apps/conf/sling:test/cfgAppsGlobal", 
underTest.getResource(site1Page1, BUCKET, "cfgAppsGlobal").getPath());
+        assertEquals("/libs/conf/sling:test/cfgLibsGlobal", 
underTest.getResource(site1Page1, BUCKET, "cfgLibsGlobal").getPath());
+        assertEquals("/conf/tenant1/sling:test/test", 
underTest.getResource(site1Page1, BUCKET, "test").getPath());
+
+        assertNull(underTest.getResource(site2Page1, BUCKET, "cfgSite1"));
+        assertEquals("/conf/tenant1/region1/sling:test/cfgRegion1", 
underTest.getResource(site2Page1, BUCKET, "cfgRegion1").getPath());
+        assertEquals("/conf/tenant1/sling:test/cfgTenant1", 
underTest.getResource(site2Page1, BUCKET, "cfgTenant1").getPath());
+        assertEquals("/conf/global/sling:test/cfgGlobal", 
underTest.getResource(site2Page1, BUCKET, "cfgGlobal").getPath());
+        assertEquals("/apps/conf/sling:test/cfgAppsGlobal", 
underTest.getResource(site2Page1, BUCKET, "cfgAppsGlobal").getPath());
+        assertEquals("/libs/conf/sling:test/cfgLibsGlobal", 
underTest.getResource(site2Page1, BUCKET, "cfgLibsGlobal").getPath());
+        assertEquals("/conf/tenant1/sling:test/test", 
underTest.getResource(site2Page1, BUCKET, "test").getPath());
+    }
+
+    @Test
+    public void testGetResourceCollection() {
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "cfgCol");
+        assetResourcePaths(new String[] {
+                "/conf/tenant1/region1/site1/sling:test/cfgCol/site1",
+                "/conf/tenant1/region1/sling:test/cfgCol/region1", 
+                "/conf/tenant1/sling:test/cfgCol/tenant1", 
+                "/conf/global/sling:test/cfgCol/confGlobal", 
+                "/apps/conf/sling:test/cfgCol/appsGlobal", 
+                "/libs/conf/sling:test/cfgCol/libsGlobal1", 
+                "/libs/conf/sling:test/cfgCol/libsGlobal2" },
+                col1);
+
+        Collection<Resource> col2 = 
underTest.getResourceCollection(site2Page1, BUCKET, "cfgCol");
+        assetResourcePaths(new String[] {
+                "/conf/tenant1/region1/sling:test/cfgCol/region1", 
+                "/conf/tenant1/sling:test/cfgCol/tenant1", 
+                "/conf/global/sling:test/cfgCol/confGlobal", 
+                "/apps/conf/sling:test/cfgCol/appsGlobal", 
+                "/libs/conf/sling:test/cfgCol/libsGlobal1", 
+                "/libs/conf/sling:test/cfgCol/libsGlobal2" },
+                col2);
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyHierarchyTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,121 @@
+/*
+ * 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.contextaware.config.resource.impl.def;
+
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.apache.sling.api.resource.Resource;
+import 
org.apache.sling.contextaware.config.resource.impl.ContextPathStrategyMultiplexer;
+import 
org.apache.sling.contextaware.config.resource.spi.ConfigurationResourceResolvingStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class DefaultConfigurationResourceResolvingStrategyTest {
+    
+    private static final String BUCKET = "sling:test";
+
+    @Rule
+    public SlingContext context = new SlingContext();
+
+    private Resource site1Page1;
+    private Resource site2Page1;
+
+    @Before
+    public void setUp() {
+        context.registerInjectActivateService(new 
DefaultContextPathStrategy());
+        context.registerInjectActivateService(new 
ContextPathStrategyMultiplexer());
+
+        // content resources
+        context.build()
+            .resource("/content/site1", "sling:config-ref", "/conf/site1")
+            .resource("/content/site2", "sling:config-ref", "/conf/site2");
+        site1Page1 = context.create().resource("/content/site1/page1");
+        site2Page1 = context.create().resource("/content/site2/page1");
+        
+        // configuration
+        context.build()
+            .resource("/conf/site1/sling:test/test")
+            .resource("/conf/site1/sling:test/feature/c")
+            .resource("/conf/site2/sling:test/feature/c")
+            .resource("/conf/site2/sling:test/feature/d")
+            .resource("/apps/conf/sling:test/feature/a")
+            .resource("/libs/conf/sling:test/test")
+            .resource("/libs/conf/sling:test/feature/b");
+    }
+
+    @Test
+    public void testGetResource() {
+        ConfigurationResourceResolvingStrategy underTest = 
context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResource(site1Page1, BUCKET, "test").getPath());
+        assertEquals("/libs/conf/sling:test/test", 
underTest.getResource(site2Page1, BUCKET, "test").getPath());
+    }
+
+    @Test
+    public void testGetResourceCollection() {
+        ConfigurationResourceResolvingStrategy underTest = 
context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "feature");
+        assetResourcePaths(new String[] {
+                "/conf/site1/sling:test/feature/c",
+                "/apps/conf/sling:test/feature/a", 
+                "/libs/conf/sling:test/feature/b" },
+                col1);
+
+        Collection<Resource> col2 = 
underTest.getResourceCollection(site2Page1, BUCKET, "feature");
+        assetResourcePaths(new String[] {
+                "/conf/site2/sling:test/feature/c",
+                "/conf/site2/sling:test/feature/d",
+                "/apps/conf/sling:test/feature/a",
+                "/libs/conf/sling:test/feature/b" },
+                col2);
+    }
+
+    @Test
+    public void testGetResourcePath() throws Exception {
+        ConfigurationResourceResolvingStrategy underTest = 
context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+        assertEquals("/conf/site1/sling:test/test", 
underTest.getResourcePath(site1Page1, BUCKET, "test"));
+    }
+
+    @Test
+    public void testGetResourceCollectionParentPath() throws Exception {
+        ConfigurationResourceResolvingStrategy underTest = 
context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy());
+        assertEquals("/conf/site1/sling:test/feature", 
underTest.getResourceCollectionParentPath(site1Page1, BUCKET, "feature"));
+    }
+
+    @Test
+    public void testDisabled() {
+        ConfigurationResourceResolvingStrategy underTest = 
context.registerInjectActivateService(new 
DefaultConfigurationResourceResolvingStrategy(),
+                "enabled", false);
+
+        assertNull(underTest.getResource(site1Page1, BUCKET, "test"));
+        Collection<Resource> col1 = 
underTest.getResourceCollection(site1Page1, BUCKET, "feature");
+        assertTrue(col1.isEmpty());
+        assertNull(underTest.getResourcePath(site1Page1, BUCKET, "test"));
+        assertNull(underTest.getResourceCollectionParentPath(site1Page1, 
BUCKET, "feature"));
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,76 @@
+/*
+ * 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.contextaware.config.resource.impl.def;
+
+import static 
org.apache.sling.contextaware.config.resource.impl.ConfigurationResourceTestUtils.assetResourcePaths;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.contextaware.config.resource.spi.ContextPathStrategy;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class DefaultContextPathStrategyTest {
+    
+    @Rule
+    public SlingContext context = new SlingContext();
+    
+    private Resource site1Page1;
+    private Resource site2Page1;
+
+    @Before
+    public void setUp() {
+        // content resources that form a deeper hierarchy
+        context.build()
+            .resource("/content/tenant1", "sling:config-ref", "/conf/tenant1")
+            .resource("/content/tenant1/region1", "sling:config-ref", 
"/conf/tenant1/region1")
+            .resource("/content/tenant1/region1/site1", "sling:config-ref", 
"/conf/tenant1/region1/site1")
+            .resource("/content/tenant1/region1/site2", "sling:config-ref", 
"/conf/tenant1/region1/site2");
+        site1Page1 = 
context.create().resource("/content/tenant1/region1/site1/page1");
+        site2Page1 = 
context.create().resource("/content/tenant1/region1/site2/page1");
+    }
+
+    @Test
+    public void testFindContextPaths() {
+        ContextPathStrategy underTest = 
context.registerInjectActivateService(new DefaultContextPathStrategy());
+
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site1",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site1Page1));
+
+        assetResourcePaths(new String[] {
+                "/content/tenant1/region1/site2",
+                "/content/tenant1/region1",
+                "/content/tenant1"
+        }, underTest.findContextResources(site2Page1));
+    }
+
+    @Test
+    public void testDisabled() {
+        ContextPathStrategy underTest = 
context.registerInjectActivateService(new DefaultContextPathStrategy(),
+                "enabled", false);
+
+        assetResourcePaths(new String[0], 
underTest.findContextResources(site1Page1));
+        assetResourcePaths(new String[0], 
underTest.findContextResources(site2Page1));
+    }
+
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/contextaware/config/resource/impl/def/DefaultContextPathStrategyTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/AdaptToConfigClassIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/AdaptToConfigClassIT.java?rev=1761468&r1=1761467&r2=1761468&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/AdaptToConfigClassIT.java
 (original)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/AdaptToConfigClassIT.java
 Mon Sep 19 15:39:17 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.sling.contextaware.config.it;
 
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONFIG_ROOT_PATH;
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONTENT_ROOT_PATH;
+import static org.apache.sling.contextaware.config.it.TestUtils.cleanUp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -41,6 +44,9 @@ public class AdaptToConfigClassIT {
     private ResourceResolver resourceResolver;
     private ResourceBuilder resourceBuilder;
     
+    private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
+    private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
+    
     @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
@@ -50,12 +56,13 @@ public class AdaptToConfigClassIT {
     
     @After
     public void tearDown() {
+        cleanUp(resourceResolver);
         resourceResolver.close();
     }
     
     @Test
     public void testNonExistingConfig() throws Exception {
-        Resource resourcePage1 = 
resourceBuilder.resource("/content/page1").getCurrentParent();
+        Resource resourcePage1 = 
resourceBuilder.resource(PAGE_PATH).getCurrentParent();
         
         SimpleConfig config = 
resourcePage1.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
         assertNotNull(config);
@@ -67,13 +74,13 @@ public class AdaptToConfigClassIT {
     
     @Test
     public void testExistingConfig() throws Exception {
-        
resourceBuilder.resource("/conf/content/page1/sling:configs/org.apache.sling.contextaware.config.it.example.SimpleConfig",
+        resourceBuilder.resource(CONFIG_PATH + 
"/sling:configs/org.apache.sling.contextaware.config.it.example.SimpleConfig",
                 "stringParam", "value1",
                 "intParam", 123,
                 "boolParam", true)
-            .resource("/content/page1", "sling:config-ref", 
"/conf/content/page1");
+            .resource(PAGE_PATH, "sling:config-ref", CONFIG_PATH);
 
-        Resource resourcePage1 = 
resourceResolver.getResource("/content/page1");
+        Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
         
         SimpleConfig config = 
resourcePage1.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
         assertNotNull(config);

Added: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,161 @@
+/*
+ * 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.contextaware.config.it;
+
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONFIG_ROOT_PATH;
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONTENT_ROOT_PATH;
+import static org.apache.sling.contextaware.config.it.TestUtils.cleanUp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.contextaware.config.ConfigurationResolver;
+import org.apache.sling.contextaware.config.it.example.SimpleConfig;
+import org.apache.sling.contextaware.config.management.ConfigurationData;
+import org.apache.sling.contextaware.config.management.ConfigurationManager;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+import org.apache.sling.resourcebuilder.api.ResourceBuilderFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class ConfigurationManagerIT {
+    
+    @Rule
+    public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), 
"IT");
+    
+    private ResourceResolver resourceResolver;
+    private ResourceBuilder resourceBuilder;
+    private ConfigurationManager configManager;
+    private ConfigurationResolver configResolver;
+    
+    private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
+    private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
+    private static final String CONFIG_NAME = SimpleConfig.class.getName();
+    
+    private Resource resourcePage1;
+    
+    @SuppressWarnings("deprecation")
+    @Before
+    public void setUp() throws Exception {
+        resourceResolver = 
teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+        resourceBuilder = 
teleporter.getService(ResourceBuilderFactory.class).forResolver(resourceResolver);
+        configManager = teleporter.getService(ConfigurationManager.class);
+        configResolver = teleporter.getService(ConfigurationResolver.class);
+        
+        resourcePage1 = resourceBuilder.resource(PAGE_PATH, 
"sling:config-ref", CONFIG_PATH).getCurrentParent();
+    }
+    
+    @After
+    public void tearDown() {
+        cleanUp(resourceResolver);
+        resourceResolver.close();
+    }
+    
+    @Test
+    public void testNonExistingConfig() throws Exception {
+        ConfigurationData config = configManager.get(resourcePage1, 
CONFIG_NAME);
+        assertNotNull(config);
+
+        ValueMap props = config.getEffectiveValues();
+        assertNull(props.get("stringParam", String.class));
+        assertEquals("defValue", props.get("stringParamDefault", 
String.class));
+        assertEquals(0, (int)props.get("intParam", 0));
+        assertEquals(false, props.get("boolParam", false));
+    }
+    
+    @Test
+    public void testExistingConfig() throws Exception {
+        resourceBuilder.resource(CONFIG_PATH + "/sling:configs/" + CONFIG_NAME,
+                "stringParam", "value1",
+                "intParam", 123,
+                "boolParam", true);
+        
+        ConfigurationData config = configManager.get(resourcePage1, 
CONFIG_NAME);
+        assertNotNull(config);
+        
+        ValueMap props = config.getEffectiveValues();
+        assertEquals("value1", props.get("stringParam", String.class));
+        assertEquals("defValue", props.get("stringParamDefault", 
String.class));
+        assertEquals(123, (int)props.get("intParam", 0));
+        assertEquals(true, props.get("boolParam", false));
+    }
+    
+    @Test
+    public void testWriteConfig() throws Exception {
+        // write configuration data via configuration manager
+        Map<String,Object> values = new HashMap<>();
+        values.put("stringParam", "valueA");
+        values.put("stringParamDefault", "valueB");
+        values.put("intParam", 55);
+        values.put("boolParam", true);
+        configManager.persist(resourcePage1, CONFIG_NAME, values);
+        resourceResolver.commit();
+        
+        // read config via configuration resolver
+        SimpleConfig config = 
configResolver.get(resourcePage1).as(SimpleConfig.class);
+        assertNotNull(config);
+        
+        assertEquals("valueA", config.stringParam());
+        assertEquals("valueB", config.stringParamDefault());
+        assertEquals(55, (int)config.intParam());
+        assertEquals(true, config.boolParam());
+    }
+    
+    @Test
+    public void testWriteConfigCollection() throws Exception {
+        // write configuration data via configuration manager
+        Map<String,Object> values1 = new HashMap<>();
+        values1.put("stringParam", "valueA");
+        values1.put("stringParamDefault", "valueB");
+        Map<String,Object> values2 = new HashMap<>();
+        values2.put("intParam", 55);
+        values2.put("boolParam", true);
+        List<Map<String,Object>> values = new ArrayList<>();
+        values.add(values1);
+        values.add(values2);
+        configManager.persistCollection(resourcePage1, CONFIG_NAME, values);
+        resourceResolver.commit();
+        
+        // read config via configuration resolver
+        Collection<SimpleConfig> config = 
configResolver.get(resourcePage1).asCollection(SimpleConfig.class);
+        assertEquals(2, config.size());
+        
+        Iterator<SimpleConfig> configIterator = config.iterator();
+        SimpleConfig config1 = configIterator.next();
+        SimpleConfig config2 = configIterator.next();
+        
+        assertEquals("valueA", config1.stringParam());
+        assertEquals("valueB", config1.stringParamDefault());
+        assertEquals(55, (int)config2.intParam());
+        assertEquals(true, config2.boolParam());
+    }
+    
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationManagerIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverConfigClassIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverConfigClassIT.java?rev=1761468&r1=1761467&r2=1761468&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverConfigClassIT.java
 (original)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverConfigClassIT.java
 Mon Sep 19 15:39:17 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.sling.contextaware.config.it;
 
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONFIG_ROOT_PATH;
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONTENT_ROOT_PATH;
+import static org.apache.sling.contextaware.config.it.TestUtils.cleanUp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -41,6 +44,9 @@ public class ConfigurationResolverConfig
     private ResourceResolver resourceResolver;
     private ResourceBuilder resourceBuilder;
     
+    private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
+    private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
+    
     @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
@@ -50,37 +56,40 @@ public class ConfigurationResolverConfig
     
     @After
     public void tearDown() {
+        cleanUp(resourceResolver);
         resourceResolver.close();
     }
     
     @Test
     public void testNonExistingConfig() throws Exception {
-        Resource resourcePage1 = 
resourceBuilder.resource("/content/page1").getCurrentParent();
+        Resource resourcePage1 = 
resourceBuilder.resource(PAGE_PATH).getCurrentParent();
         
         ConfigurationResolver configResolver = 
teleporter.getService(ConfigurationResolver.class);
         SimpleConfig config = 
configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
         assertNotNull(config);
 
         assertNull(config.stringParam());
+        assertEquals("defValue", config.stringParamDefault());
         assertEquals(0, config.intParam());
         assertEquals(false, config.boolParam());
     }
     
     @Test
     public void testExistingConfig() throws Exception {
-        resourceBuilder.resource("/conf/content/page1/sling:configs/test",
+        resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test",
                 "stringParam", "value1",
                 "intParam", 123,
                 "boolParam", true)
-            .resource("/content/page1", "sling:config-ref", 
"/conf/content/page1");
+            .resource(PAGE_PATH, "sling:config-ref", CONFIG_PATH);
         
-        Resource resourcePage1 = 
resourceResolver.getResource("/content/page1");
+        Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
         
         ConfigurationResolver configResolver = 
teleporter.getService(ConfigurationResolver.class);
         SimpleConfig config = 
configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
         assertNotNull(config);
         
         assertEquals("value1", config.stringParam());
+        assertEquals("defValue", config.stringParamDefault());
         assertEquals(123, (int)config.intParam());
         assertEquals(true, config.boolParam());
     }

Modified: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverValueMapIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverValueMapIT.java?rev=1761468&r1=1761467&r2=1761468&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverValueMapIT.java
 (original)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/ConfigurationResolverValueMapIT.java
 Mon Sep 19 15:39:17 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.sling.contextaware.config.it;
 
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONFIG_ROOT_PATH;
+import static 
org.apache.sling.contextaware.config.it.TestUtils.CONTENT_ROOT_PATH;
+import static org.apache.sling.contextaware.config.it.TestUtils.cleanUp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -41,6 +44,9 @@ public class ConfigurationResolverValueM
     private ResourceResolver resourceResolver;
     private ResourceBuilder resourceBuilder;
     
+    private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
+    private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
+    
     @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
@@ -50,12 +56,13 @@ public class ConfigurationResolverValueM
     
     @After
     public void tearDown() {
+        cleanUp(resourceResolver);
         resourceResolver.close();
     }
     
     @Test
     public void testNonExistingConfig() throws Exception {
-        Resource resourcePage1 = 
resourceBuilder.resource("/content/page1").getCurrentParent();
+        Resource resourcePage1 = 
resourceBuilder.resource(PAGE_PATH).getCurrentParent();
         
         ConfigurationResolver configResolver = 
teleporter.getService(ConfigurationResolver.class);
         ValueMap props = 
configResolver.get(resourcePage1).name("test").asValueMap();
@@ -68,13 +75,13 @@ public class ConfigurationResolverValueM
     
     @Test
     public void testExistingConfig() throws Exception {
-        resourceBuilder.resource("/conf/content/page1/sling:configs/test",
+        resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test",
                 "stringParam", "value1",
                 "intParam", 123,
                 "boolParam", true)
-            .resource("/content/page1", "sling:config-ref", 
"/conf/content/page1");
+            .resource(PAGE_PATH, "sling:config-ref", CONFIG_PATH);
         
-        Resource resourcePage1 = 
resourceResolver.getResource("/content/page1");
+        Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
         
         ConfigurationResolver configResolver = 
teleporter.getService(ConfigurationResolver.class);
         ValueMap props = 
configResolver.get(resourcePage1).name("test").asValueMap();

Added: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java?rev=1761468&view=auto
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
 (added)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
 Mon Sep 19 15:39:17 2016
@@ -0,0 +1,67 @@
+/*
+ * 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.contextaware.config.it;
+
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class TestUtils {
+    
+    /**
+     * Root path for test content
+     */
+    public static final String CONTENT_ROOT_PATH = "/content/test";
+    
+    /**
+     * Root path for config content
+     */
+    public static final String CONFIG_ROOT_PATH = "/conf/test";
+    
+    private static final Logger log = LoggerFactory.getLogger(TestUtils.class);
+    
+    private TestUtils() {
+        // static methods only
+    }
+    
+    public static void cleanUp(ResourceResolver resourceResolver) {
+        deletePath(resourceResolver, CONTENT_ROOT_PATH);
+        deletePath(resourceResolver, CONFIG_ROOT_PATH);
+        try {
+            resourceResolver.commit();
+        }
+        catch (PersistenceException ex) {
+            log.error("Unable clean up resources.", ex);
+        }
+    }
+
+    public static void deletePath(ResourceResolver resourceResolver, String 
path) {
+        Resource resource = resourceResolver.getResource(path);
+        if (resource != null) {
+            try {
+                resourceResolver.delete(resource);
+            }
+            catch (PersistenceException ex) {
+                log.error("Unable to delete resource " + path, ex);
+            }
+        }
+    }
+}

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Sep 19 15:39:17 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/TestUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/example/SimpleConfig.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/example/SimpleConfig.java?rev=1761468&r1=1761467&r2=1761468&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/example/SimpleConfig.java
 (original)
+++ 
sling/trunk/contrib/extensions/contextaware-config/integration-tests/src/test/java/org/apache/sling/contextaware/config/it/example/SimpleConfig.java
 Mon Sep 19 15:39:17 2016
@@ -25,6 +25,8 @@ public @interface SimpleConfig {
 
     String stringParam();
     
+    String stringParamDefault() default "defValue";
+    
     int intParam();
     
     boolean boolParam();


Reply via email to