sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1767918 - in /sling/trunk/contrib/extensions/contextaware-config/impl/src: main/java/org/apache/sling/caconfig/resource/impl/def/ test/java/org/apache/sling/caconfig/resource/impl/def/
Date Thu, 03 Nov 2016 16:05:32 GMT
Author: cziegeler
Date: Thu Nov  3 16:05:32 2016
New Revision: 1767918

URL: http://svn.apache.org/viewvc?rev=1767918&view=rev
Log:
SLING-6239 : Support relative references in DefaultConfigurationResourceResolvingStrategy.
Fix impl and add test case

Modified:
    sling/trunk/contrib/extensions/contextaware-config/impl/src/main/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategy.java
    sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java

Modified: sling/trunk/contrib/extensions/contextaware-config/impl/src/main/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategy.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/main/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategy.java?rev=1767918&r1=1767917&r2=1767918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/contextaware-config/impl/src/main/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategy.java
(original)
+++ sling/trunk/contrib/extensions/contextaware-config/impl/src/main/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategy.java
Thu Nov  3 16:05:32 2016
@@ -180,9 +180,8 @@ public class DefaultConfigurationResourc
                             if ( isAbsolute && !relativePaths.isEmpty() ) {
                                 useFromRelativePathsWith = val;
                                 val = null;
-                                val = null;
                             } else if ( !isAbsolute ) {
-                                relativePaths.add(contextResource);
+                                relativePaths.add(0, contextResource);
                                 val = null;
                             }
                         }

Modified: sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java?rev=1767918&r1=1767917&r2=1767918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
(original)
+++ sling/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/def/DefaultConfigurationResourceResolvingStrategyTest.java
Thu Nov  3 16:05:32 2016
@@ -35,7 +35,7 @@ import org.junit.Rule;
 import org.junit.Test;
 
 public class DefaultConfigurationResourceResolvingStrategyTest {
-    
+
     private static final String BUCKET = "sling:test";
 
     @Rule
@@ -44,6 +44,9 @@ public class DefaultConfigurationResourc
     private Resource site1Page1;
     private Resource site2Page1;
 
+    private Resource subPage;
+    private Resource deepPage;
+
     @Before
     public void setUp() {
         context.registerInjectActivateService(new DefaultContextPathStrategy());
@@ -52,10 +55,14 @@ public class DefaultConfigurationResourc
         // content resources
         context.build()
             .resource("/content/site1", PROPERTY_CONFIG_REF, "/conf/site1")
-            .resource("/content/site2", PROPERTY_CONFIG_REF, "/conf/site2");
+            .resource("/content/site2", PROPERTY_CONFIG_REF, "/conf/site2")
+            .resource("/content/mainsite", PROPERTY_CONFIG_REF, "/conf/main")
+            .resource("/content/mainsite/sub", PROPERTY_CONFIG_REF, "sub")
+            .resource("/content/mainsite/sub/some/where/deep", PROPERTY_CONFIG_REF, "deep");
         site1Page1 = context.create().resource("/content/site1/page1");
         site2Page1 = context.create().resource("/content/site2/page1");
-        
+        subPage = context.create().resource("/content/mainsite/sub/page1");
+        deepPage = context.create().resource("/content/mainsite/sub/some/where/deep/page1");
     }
 
     @Test
@@ -71,6 +78,19 @@ public class DefaultConfigurationResourc
         assertEquals("/libs/conf/sling:test/test", underTest.getResource(site2Page1, BUCKET,
"test").getPath());
     }
 
+    @Test
+    public void testRelativeConfPropery() {
+        ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new
DefaultConfigurationResourceResolvingStrategy());
+
+        // build config resources
+        context.build()
+            .resource("/conf/main/sub/sling:test/test")
+            .resource("/conf/main/sub/deep/sling:test/test");
+
+        assertEquals("/conf/main/sub/sling:test/test", underTest.getResource(subPage, BUCKET,
"test").getPath());
+        assertEquals("/conf/main/sub/deep/sling:test/test", underTest.getResource(deepPage,
BUCKET, "test").getPath());
+    }
+
     /**
      * Default resource inheritance without customizing inheritance.
      * => no resource list merging.
@@ -90,7 +110,7 @@ public class DefaultConfigurationResourc
         assertThat(underTest.getResourceCollection(site1Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site1/sling:test/feature/c"));
 
-        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(

+        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site2/sling:test/feature/c",
                 "/conf/site2/sling:test/feature/d"));
     }
@@ -112,7 +132,7 @@ public class DefaultConfigurationResourc
         assertThat(underTest.getResourceCollection(site1Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/apps/conf/sling:test/feature/a"));
 
-        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(

+        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/apps/conf/sling:test/feature/a"));
     }
 
@@ -138,7 +158,7 @@ public class DefaultConfigurationResourc
                 "/conf/site1/sling:test/feature/c",
                 "/apps/conf/sling:test/feature/a"));
 
-        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(

+        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site2/sling:test/feature/c",
                 "/conf/site2/sling:test/feature/d",
                 "/apps/conf/sling:test/feature/a"));
@@ -167,10 +187,10 @@ public class DefaultConfigurationResourc
 
         assertThat(underTest.getResourceCollection(site1Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site1/sling:test/feature/c",
-                "/apps/conf/sling:test/feature/a", 
+                "/apps/conf/sling:test/feature/a",
                 "/libs/conf/sling:test/feature/b"));
 
-        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(

+        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site2/sling:test/feature/c",
                 "/conf/site2/sling:test/feature/d",
                 "/apps/conf/sling:test/feature/a",
@@ -196,7 +216,7 @@ public class DefaultConfigurationResourc
         assertThat(underTest.getResourceCollection(site1Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site1/sling:test/feature/c"));
 
-        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(

+        assertThat(underTest.getResourceCollection(site2Page1, BUCKET, "feature"), ResourceCollectionMatchers.paths(
                 "/conf/site2/sling:test/feature/c",
                 "/conf/site2/sling:test/feature/d"));
     }



Mime
View raw message