incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1606712 - 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 Mon, 30 Jun 2014 12:34:53 GMT
Author: asanso
Date: Mon Jun 30 12:34:52 2014
New Revision: 1606712

URL: http://svn.apache.org/r1606712
Log:
SLING-3712 - Increase code coverage for MapEntries

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=1606712&r1=1606711&r2=1606712&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
Mon Jun 30 12:34:52 2014
@@ -548,7 +548,6 @@ public class MapEntries implements Event
 
     // ---------- internal
 
-    //TODO add unit test
     private String getActualContentPath(String path){
         final String checkPath;
         if ( path.endsWith("/jcr:content") ) {
@@ -559,7 +558,6 @@ public class MapEntries implements Event
         return checkPath;
     }
 
-    //TODO add unit test
     private String getMapEntryRedirect(MapEntry mapEntry) {
         String[] redirect = mapEntry.getRedirect();
         if (redirect.length > 1) {

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=1606712&r1=1606711&r2=1606712&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
Mon Jun 30 12:34:52 2014
@@ -25,6 +25,7 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -293,4 +294,36 @@ public class MapEntriesTest {
             assertTrue(resultSet.remove(entry.getRedirect()[0]));
         }
     }
+    
+    @Test
+    public void test_getActualContentPath() throws Exception {
+
+        Method method = MapEntries.class.getDeclaredMethod("getActualContentPath", String.class);
+        method.setAccessible(true);
+        
+        String actualContent = (String) method.invoke(mapEntries, "/content");
+        assertEquals("/content", actualContent);
+        
+        actualContent = (String) method.invoke(mapEntries, "/content/jcr:content");
+        assertEquals("/content", actualContent);
+    }
+    
+    @Test
+    public void test_getMapEntryRedirect() throws Exception {
+
+        Method method = MapEntries.class.getDeclaredMethod("getMapEntryRedirect", MapEntry.class);
+        method.setAccessible(true);
+        
+        MapEntry mapEntry = new MapEntry("/content", -1, false, 0, "/content");     
+        String actualContent = (String) method.invoke(mapEntries, mapEntry);
+        assertEquals("/content", actualContent);
+        
+        mapEntry = new MapEntry("/content", -1, false, 0, "/content$1");     
+        actualContent = (String) method.invoke(mapEntries, mapEntry);
+        assertEquals("/content", actualContent);
+        
+        mapEntry = new MapEntry("/content", -1, false, 0, "/content.html");     
+        actualContent = (String) method.invoke(mapEntries, mapEntry);
+        assertEquals("/content", actualContent);
+    }
 }



Mime
View raw message