cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r679793 - in /cocoon/whiteboard/corona/trunk: corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ corona-sample/src/main/resources/COB-INF/ corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/ corona-sitemap/sr...
Date Fri, 25 Jul 2008 13:12:05 GMT
Author: reinhard
Date: Fri Jul 25 06:12:04 2008
New Revision: 679793

URL: http://svn.apache.org/viewvc?rev=679793&view=rev
Log:
. add an example with an empty <map:when> element
. add a regexp negative lookahead sample (regexp)
. check if there is a separating character between named parameters (otherwise ** matchers
would be generated)

Modified:
    cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
    cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
    cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcher.java
    cocoon/whiteboard/corona/trunk/corona-sitemap/src/test/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcherTest.java

Modified: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java?rev=679793&r1=679792&r2=679793&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
Fri Jul 25 06:12:04 2008
@@ -76,6 +76,8 @@
         this.assertXPath("/html/body/p[text() = '4']", "4");
         this.assertXPath("/html/body/p[text() = '5']", "");
         this.assertXPath("/html/body/p[text() = '6']", "6");
+        this.assertXPath("/html/body/p[text() = '7']", "7");
+        this.assertXPath("/html/body/p[text() = '8']", "");
     }
 
     public void testDeeplyNestedMatcherSelector2() throws Exception {
@@ -88,10 +90,12 @@
         this.assertXPath("/html/body/p[text() = '4']", "");
         this.assertXPath("/html/body/p[text() = '5']", "");
         this.assertXPath("/html/body/p[text() = '6']", "6");
+        this.assertXPath("/html/body/p[text() = '7']", "7");
+        this.assertXPath("/html/body/p[text() = '8']", "");
     }
 
     public void testDeeplyNestedMatcherSelector3() throws Exception {
-        this.loadXmlPage("advanced-matching-4?param_a=1&param_b=2&param_e=1");
+        this.loadXmlPage("advanced-matching-4?param_a=1&param_b=2&param_e=1&param_g=2");
         assertTrue(this.response.getStatusCode() == 200);
         assertEquals("text/xml", this.response.getContentType());
         this.assertXPath("/html/body/p[text() = '1']", "1");
@@ -100,6 +104,22 @@
         this.assertXPath("/html/body/p[text() = '4']", "");
         this.assertXPath("/html/body/p[text() = '5']", "5");
         this.assertXPath("/html/body/p[text() = '6']", "6");
+        this.assertXPath("/html/body/p[text() = '7']", "7");
+        this.assertXPath("/html/body/p[text() = '8']", "8");
+    }
+
+    public void testDeeplyNestedMatcherSelector4() throws Exception {
+        this.loadXmlPage("advanced-matching-4?param_g=1");
+        assertTrue(this.response.getStatusCode() == 200);
+        assertEquals("text/xml", this.response.getContentType());
+        this.assertXPath("/html/body/p[text() = '1']", "1");
+        this.assertXPath("/html/body/p[text() = '2']", "");
+        this.assertXPath("/html/body/p[text() = '3']", "");
+        this.assertXPath("/html/body/p[text() = '4']", "");
+        this.assertXPath("/html/body/p[text() = '5']", "");
+        this.assertXPath("/html/body/p[text() = '6']", "");
+        this.assertXPath("/html/body/p[text() = '7']", "7");
+        this.assertXPath("/html/body/p[text() = '8']", "");
     }
 
 }

Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html?rev=679793&r1=679792&r2=679793&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
(original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
Fri Jul 25 06:12:04 2008
@@ -18,7 +18,7 @@
 <html>
   <head>
     <title>Corona Samples and Integration Tests: Overview </title>
-  <base target="_blank"/>
+    <base target="_blank"/>
   </head>
   <body>
     <h1>Corona Samples and Integration Tests: Overview </h1>

Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap?rev=679793&r1=679792&r2=679793&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap Fri
Jul 25 06:12:04 2008
@@ -279,6 +279,21 @@
             <map:parameter name="text" value="6"/>
           </map:transform>
         </map:match>
+        <map:select value="{jexl:corona.request.param_f}">
+          <map:when equals="1" />
+          <map:otherwise>
+            <map:transform src="sax-pipeline/add-paragraph.xslt">
+              <map:parameter name="text" value="7"/>
+            </map:transform>               
+          </map:otherwise>
+        </map:select>
+        <map:select value="{jexl:corona.request.param_g}">
+          <map:when regexp="(?!1\b)\b.+\b">
+            <map:transform src="sax-pipeline/add-paragraph.xslt">
+              <map:parameter name="text" value="8"/>
+            </map:transform>             
+          </map:when>
+        </map:select>
         <map:serialize />
       </map:match>      
     </map:pipeline>    

Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcher.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcher.java?rev=679793&r1=679792&r2=679793&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcher.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcher.java
Fri Jul 25 06:12:04 2008
@@ -81,6 +81,7 @@
         public WildcardExpressionRewriter(String originalExpression) {
             super();
             this.originalExpression = originalExpression;
+            this.checkExpression();
 
             this.parameterAndWildcardMatcher = PARAMETER_WILDCARD_PATTERN.matcher(originalExpression);
             this.parameterMatcher = PARAMETER_PATTERN.matcher(originalExpression);
@@ -104,6 +105,13 @@
             return this.rewrittenExpression;
         }
 
+        private void checkExpression() {
+            if (this.originalExpression.contains("}{")) {
+                throw new UnsupportedNamedWildcardExpressionException("}{ is not allowed
(" + this.originalExpression
+                        + "). There must be a seperating character between two named wildcards.");
+            }
+        }
+
         private Map<String, String> findParameters() {
             Map<String, String> parameterNames = new HashMap<String, String>();
 
@@ -127,6 +135,12 @@
         private String rewriteExpression() {
             return this.parameterMatcher.replaceAll("*");
         }
+    }
+
+    public static class UnsupportedNamedWildcardExpressionException extends RuntimeException
{
 
+        public UnsupportedNamedWildcardExpressionException(String msg) {
+            super(msg);
+        }
     }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/test/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcherTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/test/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcherTest.java?rev=679793&r1=679792&r2=679793&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/test/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcherTest.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/test/java/org/apache/cocoon/corona/sitemap/matcher/WildcardMatcherTest.java
Fri Jul 25 06:12:04 2008
@@ -20,6 +20,7 @@
 
 import junit.framework.Assert;
 
+import org.apache.cocoon.corona.sitemap.matcher.WildcardMatcher.UnsupportedNamedWildcardExpressionException;
 import org.apache.cocoon.corona.sitemap.matcher.WildcardMatcher.WildcardExpressionRewriter;
 import org.junit.Test;
 
@@ -68,4 +69,16 @@
         WildcardExpressionRewriter rewriter = new WildcardExpressionRewriter("abc/{name}/*/{id}.html");
         Assert.assertEquals("abc/*/*/*.html", rewriter.getRewrittenExpression());
     }
+
+    @Test
+    public void testWrongNamedParameters() {
+        try {
+            new WildcardMatcher().match("*/{name}{id}", "abc/def/ghi");
+            Assert.fail("}{ is not allowed without some character in between "
+                    + "because this would be translated into a '**' which has a different
meaning");
+        } catch (UnsupportedNamedWildcardExpressionException e) {
+            // expected
+        }
+
+    }
 }



Mime
View raw message