incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r881785 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/request/ api/src/test/java/org/apache/sling/api/request/ engine/src/test/java/org/apache/sling/engine/impl/request/
Date Wed, 18 Nov 2009 14:18:18 GMT
Author: cziegeler
Date: Wed Nov 18 14:18:17 2009
New Revision: 881785

URL: http://svn.apache.org/viewvc?rev=881785&view=rev
Log:
SLING-633 : RequestDispatcherOptions.setReplaceSelectors("") doesn't work

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
    sling/trunk/bundles/api/src/test/java/org/apache/sling/api/request/RequestDispatcherOptionsTest.java
    sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java?rev=881785&r1=881784&r2=881785&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
Wed Nov 18 14:18:17 2009
@@ -48,7 +48,8 @@
 
     /**
      * When dispatching, replace {@link RequestPathInfo} selectors by the value
-     * provided by this option.
+     * provided by this option. If this value contains an empty string, all
+     * original selectors are removed.
      */
     public static final String OPT_REPLACE_SELECTORS = "replaceSelectors";
 
@@ -146,6 +147,8 @@
     /**
      * Sets the {@link #OPT_REPLACE_SELECTORS} option to the given
      * <code>replaceSelectors</code> if not <code>null</code>.
+     * If this value contains an empty string, all
+     * original selectors are removed.
      */
     public void setReplaceSelectors(String replaceSelectors) {
         if (replaceSelectors != null) {

Modified: sling/trunk/bundles/api/src/test/java/org/apache/sling/api/request/RequestDispatcherOptionsTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/request/RequestDispatcherOptionsTest.java?rev=881785&r1=881784&r2=881785&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/test/java/org/apache/sling/api/request/RequestDispatcherOptionsTest.java
(original)
+++ sling/trunk/bundles/api/src/test/java/org/apache/sling/api/request/RequestDispatcherOptionsTest.java
Wed Nov 18 14:18:17 2009
@@ -81,5 +81,4 @@
         assertEquals("Expected option found (" + result + ")", "xyz",
             result.getReplaceSelectors());
     }
-
 }

Modified: sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java?rev=881785&r1=881784&r2=881785&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
(original)
+++ sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
Wed Nov 18 14:18:17 2009
@@ -18,11 +18,11 @@
 
 import junit.framework.TestCase;
 
+import org.apache.sling.api.request.RequestDispatcherOptions;
 import org.apache.sling.api.request.RequestPathInfo;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.engine.impl.request.SlingRequestPathInfo;
 
 /** Test the SlingRequestPathInfo class */
 public class SlingRequestPathInfoTest extends TestCase {
@@ -250,6 +250,39 @@
         assertNull("Selectors are null",p.getSelectorString());
     }
 
+
+    public void testMerge() {
+        SlingRequestPathInfo p = new SlingRequestPathInfo(new MockResource(
+                "/some/path", ".s1.s2.ext"));
+        assertEquals("s1.s2", p.getSelectorString());
+        assertEquals("ext", p.getExtension());
+
+        // test to replace selectors with a new one
+        RequestDispatcherOptions o = new RequestDispatcherOptions();
+        o.setReplaceSelectors("a");
+        RequestPathInfo result = p.merge(o);
+        assertEquals("a", result.getSelectorString());
+        assertEquals("ext", result.getExtension());
+
+        // test to replace selector with the empty string
+        o.setReplaceSelectors("");
+        result = p.merge(o);
+        assertEquals(null, result.getSelectorString());
+        assertEquals("ext", result.getExtension());
+
+        // now add a selector
+        o.setAddSelectors("b");
+        result = p.merge(o);
+        assertEquals("b", result.getSelectorString());
+        assertEquals("ext", result.getExtension());
+
+        // replace ext
+        o.setReplaceSuffix("html");
+        result = p.merge(o);
+        assertEquals("b", result.getSelectorString());
+        assertEquals("html", result.getSuffix());
+    }
+
     static class MockResource implements Resource {
 
         private final ResourceMetadata metadata;



Mime
View raw message