sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1607312 - in /sling/trunk/bundles/resourceresolver/src: main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
Date Wed, 02 Jul 2014 11:23:35 GMT
Author: asanso
Date: Wed Jul  2 11:23:35 2014
New Revision: 1607312

URL: http://svn.apache.org/r1607312
Log:
SLING-3727 - MapEntries should not update the aliasMap is enableOptimizeAliasResolution is
disabled

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java?rev=1607312&r1=1607311&r2=1607312&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
Wed Jul  2 11:23:35 2014
@@ -215,7 +215,9 @@ public class MapEntries implements Event
                 } else if ("sling:vanityOrder".equals(changedAttribute)) {
                     doUpdateVanityOrder(path, false);
                 } else if ("sling:alias".equals(changedAttribute)) {
-                    doAddAlias(path);
+                    if (enableOptimizeAliasResolution) {
+                       doAddAlias(path);
+                    }
                 } else {
                     configurationUpdate = true;
                 }
@@ -245,7 +247,9 @@ public class MapEntries implements Event
                 } else if ("sling:vanityOrder".equals(changedAttribute)) {
                     doUpdateVanityOrder(path, false);
                 } else if ("sling:alias".equals(changedAttribute)) {
-                    doUpdateAlias(path);
+                    if (enableOptimizeAliasResolution) {
+                        doUpdateAlias(path);
+                     }                    
                 } else {
                     configurationUpdate = true;
                 }
@@ -275,7 +279,9 @@ public class MapEntries implements Event
                 } else if ("sling:vanityOrder".equals(changedAttribute)) {
                     doUpdateVanityOrder(path, true);
                 } else if ("sling:alias".equals(changedAttribute)) {
-                    doRemoveAlias(path, nodeDeletion);
+                    if (enableOptimizeAliasResolution) {
+                        doRemoveAlias(path, nodeDeletion);
+                    }
                 } else {
                     configurationUpdate = true;
                 }

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java?rev=1607312&r1=1607311&r2=1607312&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
Wed Jul  2 11:23:35 2014
@@ -609,4 +609,62 @@ public class MapEntriesTest {
         assertFalse(iterator.hasNext());
     }
     
+    //SLING-3727
+    @Test
+    public void test_doAddAliasAttributesWithDisableAliasOptimization() throws Exception
{
+        Method method = MapEntries.class.getDeclaredMethod("doAddAttributes", String.class,
String[].class, boolean.class);
+        method.setAccessible(true);
+        
+        when(resourceResolverFactory.isOptimizeAliasResolutionEnabled()).thenReturn(false);
+        mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin);
+        
+        Resource parent = mock(Resource.class);
+        when(parent.getPath()).thenReturn("/parent");
+
+        final Resource result = mock(Resource.class);
+        when(resourceResolver.getResource("/parent/child")).thenReturn(result);
+        when(result.getParent()).thenReturn(parent);
+        when(result.getPath()).thenReturn("/parent/child");
+        when(result.getName()).thenReturn("child");
+        when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias"));
+        
+        method.invoke(mapEntries, "/parent/child",
+                new String[] { "sling:alias" }, false);
+        
+        Map<String, String> aliasMap = mapEntries.getAliasMap("/parent");
+        assertNull(aliasMap);
+    }
+    
+    //SLING-3727
+    @Test
+    public void test_doRemoveAttributessWithDisableAliasOptimization() throws Exception {
+        Method method = MapEntries.class.getDeclaredMethod("doRemoveAttributes", String.class,
String[].class, boolean.class, boolean.class);
+        method.setAccessible(true);
+        
+        when(resourceResolverFactory.isOptimizeAliasResolutionEnabled()).thenReturn(false);
+        mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin);
+        
+        Resource parent = mock(Resource.class);
+        when(parent.getPath()).thenReturn("/parent");
+
+        final Resource result = mock(Resource.class);
+        when(resourceResolver.getResource("/parent/child")).thenReturn(result);
+        when(result.getParent()).thenReturn(parent);
+        when(result.getPath()).thenReturn("/parent/child");
+        when(result.getName()).thenReturn("child");
+        when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias"));
+        
+        method.invoke(mapEntries, "/parent/child",
+                new String[] { "sling:alias" }, false, false);
+        
+        Map<String, String> aliasMap = mapEntries.getAliasMap("/parent");
+        assertNull(aliasMap);
+    }
+    
+    //SLING-3727
+    @Test
+    public void test_doUpdateAttributesWithDisableAliasOptimization() throws Exception {
+        
+    }
+    
 }



Mime
View raw message