cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r920425 - in /cocoon/cocoon3/trunk: cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ cocoon-sample/src/main/resources/COB-INF/ cocoon-sample/src/main/resources/COB-INF/sax-pipeline/
Date Mon, 08 Mar 2010 18:05:47 GMT
Author: reinhard
Date: Mon Mar  8 18:05:47 2010
New Revision: 920425

URL: http://svn.apache.org/viewvc?rev=920425&view=rev
Log:
COCOON3-53
provide a test case for the caching problem (however, the testcase doesn't fail)

Added:
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
  (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
  (with props)
Modified:
    cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap

Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java?rev=920425&r1=920424&r2=920425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java
Mon Mar  8 18:05:47 2010
@@ -26,17 +26,18 @@
 public class CachingOfPipelinesTest extends CocoonHtmlUnitTestCase {
 
     /**
-     * A non-caching pipeline mustn't produce the same result twice.
+     * Test if different matches in the same <map:pipeline>, produce different
results.
      */
-    public void testNonCachingPipeline() throws Exception {
-        this.loadResponse("caching-pipeline/off");
+    public void testCachingOfDifferentPipelines() throws Exception {
+        this.loadResponse("sax-pipeline/simple-1");
         String content1 = this.response.getContentAsString();
         assertNotNull(content1);
 
-        this.loadResponse("caching-pipeline/off");
+        this.loadResponse("sax-pipeline/simple-2");
         String content2 = this.response.getContentAsString();
         assertNotNull(content2);
-        assertFalse("The response has to change with every request.", content1.equals(content2));
+
+        assertFalse(content1.equals(content2));
     }
 
     /**
@@ -59,9 +60,33 @@
     }
 
     /**
-     * This caching pipeline returns the same result for 2 seconds (see the 'expires' parameter
in the sitemap). After
-     * 2.1 it produces a different result because the first result generated has become invalid
in the meantime and the
-     * refresh is being performed in the same thread.
+     * This async-caching pipeline returns the same result for 2 seconds (see the 'expires'
+     * parameter in the sitemap). After 2.1 seconds it still produces the same result but
because
+     * the cache key of this pipeline has changed, a separate thread is started that refreshs
the
+     * cache.
+     * 
+     * After waiting for another second, a fresh result is returned.
+     */
+    public void testExpiresAsyncCaching() throws Exception {
+        this.loadResponse("/expires/async-caching-pipeline/on");
+        String content1 = this.response.getContentAsString();
+
+        Thread.sleep(2100);
+        this.loadResponse("/expires/async-caching-pipeline/on");
+        String content2 = this.response.getContentAsString();
+        assertEquals("The response has to be the same as before.", content1, content2);
+
+        Thread.sleep(500);
+        this.loadResponse("/expires/async-caching-pipeline/on");
+        String content3 = this.response.getContentAsString();
+        assertFalse("The response mustn't be the same as before.", content3.equals(content2));
+
+    }
+
+    /**
+     * This caching pipeline returns the same result for 2 seconds (see the 'expires' parameter
in
+     * the sitemap). After 2.1 it produces a different result because the first result generated
has
+     * become invalid in the meantime and the refresh is being performed in the same thread.
      * 
      * @see {@link #testExpiresAsyncCaching()}
      */
@@ -84,25 +109,16 @@
     }
 
     /**
-     * This async-caching pipeline returns the same result for 2 seconds (see the 'expires'
parameter in the sitemap).
-     * After 2.1 seconds it still produces the same result but because the cache key of this
pipeline has changed, a
-     * separate thread is started that refreshs the cache.
-     * 
-     * After waiting for another second, a fresh result is returned.
+     * A non-caching pipeline mustn't produce the same result twice.
      */
-    public void testExpiresAsyncCaching() throws Exception {
-        this.loadResponse("/expires/async-caching-pipeline/on");
+    public void testNonCachingPipeline() throws Exception {
+        this.loadResponse("caching-pipeline/off");
         String content1 = this.response.getContentAsString();
+        assertNotNull(content1);
 
-        Thread.sleep(2100);
-        this.loadResponse("/expires/async-caching-pipeline/on");
+        this.loadResponse("caching-pipeline/off");
         String content2 = this.response.getContentAsString();
-        assertEquals("The response has to be the same as before.", content1, content2);
-
-        Thread.sleep(500);
-        this.loadResponse("/expires/async-caching-pipeline/on");
-        String content3 = this.response.getContentAsString();
-        assertFalse("The response mustn't be the same as before.", content3.equals(content2));
-
+        assertNotNull(content2);
+        assertFalse("The response has to change with every request.", content1.equals(content2));
     }
 }

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml?rev=920425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
(added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
Mon Mar  8 18:05:47 2010
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<simple>simple-text-1</simple>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml?rev=920425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
(added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
Mon Mar  8 18:05:47 2010
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<simple>simple-text-2</simple>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sax-pipeline/simple-2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=920425&r1=920424&r2=920425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Mon Mar  8
18:05:47 2010
@@ -47,6 +47,14 @@
         </map:transform>
         <map:serialize />
       </map:match>
+      <map:match equals="sax-pipeline/simple-1">
+        <map:generate src="sax-pipeline/simple-1.xml" />
+        <map:serialize />
+      </map:match>
+      <map:match equals="sax-pipeline/simple-2">
+        <map:generate src="sax-pipeline/simple-2.xml" />
+        <map:serialize />
+      </map:match>
       <map:match pattern="sax-pipeline/simple-xhtml">
         <map:generate src="sax-pipeline/simple.xml" />
         <map:transform src="sax-pipeline/simple.xslt">
@@ -79,7 +87,7 @@
         <map:serialize type="xml" />
       </map:match>
     </map:pipeline>
-    
+
     <map:pipeline type="async-caching" jmx-group-name="async-caching">
       <map:match pattern="async-caching-pipeline/on">
         <map:generate type="timestamp-caching" />
@@ -93,27 +101,27 @@
         <map:serialize type="xml" />
       </map:match>
     </map:pipeline>
-    
+
     <map:pipeline expires="2" expires-cache-key="some-key">
       <map:match pattern="expires/caching-pipeline/on">
         <map:generate type="timestamp-noncaching" />
         <map:serialize type="xml" />
       </map:match>
-    </map:pipeline>    
-    
+    </map:pipeline>
+
     <map:pipeline expires="2">
       <map:match pattern="expires/caching-pipeline/invalid">
         <map:generate type="timestamp-noncaching" />
         <map:serialize type="xml" />
       </map:match>
-    </map:pipeline>    
-    
+    </map:pipeline>
+
     <map:pipeline type="async-caching" expires="2" expires-cache-key="some-other-key">
       <map:match pattern="expires/async-caching-pipeline/on">
         <map:generate type="timestamp-noncaching" />
         <map:serialize type="xml" />
       </map:match>
-    </map:pipeline>    
+    </map:pipeline>
 
     <!-- ~~~~~~~~~~~~~~~~ servlet service framework ~~~~~~~~~~~~~~~ -->
     <map:pipeline jmx-group-name="servlet-service">
@@ -126,14 +134,14 @@
       </map:match>
       <map:match pattern="ssf/service-consumer">
         <map:generate type="service-consumer" />
-        <map:serialize type="xml" />      
+        <map:serialize type="xml" />
       </map:match>
       <map:match pattern="ssf/transformer-pipeline">
         <map:generate type="service-consumer" />
         <map:transform src="sax-pipeline/simple.xslt">
           <map:parameter name="myParam" value="transformer-pipeline" />
         </map:transform>
-        <map:serialize type="xml" />      
+        <map:serialize type="xml" />
       </map:match>
       <map:match pattern="ssf/serializer-pipeline">
         <map:generate type="service-consumer" />
@@ -190,8 +198,8 @@
         </map:match>
       </map:match>
     </map:pipeline>
-    
-    <!-- ~~~~~~~~~~~~~~~~ advanced matching (when/otherwise) ~~~~~~~~~~~~~~~ -->  
 
+
+    <!-- ~~~~~~~~~~~~~~~~ advanced matching (when/otherwise) ~~~~~~~~~~~~~~~ -->
     <map:pipeline>
       <map:match pattern="advanced-matching">
         <map:select value="{jexl:cocoon.request.myparam}">
@@ -221,7 +229,7 @@
             <map:transform src="sax-pipeline/simple.xslt">
               <map:parameter name="myParam" value="otherwise" />
             </map:transform>
-            <map:serialize />          
+            <map:serialize />
           </map:otherwise>
         </map:select>
       </map:match>
@@ -236,17 +244,17 @@
           <map:otherwise>
             <map:transform src="sax-pipeline/simple.xslt">
               <map:parameter name="myParam" value="otherwise" />
-            </map:transform>          
+            </map:transform>
           </map:otherwise>
         </map:select>
         <map:serialize />
-      </map:match>      
+      </map:match>
       <map:match wildcard="advanced-matching-3">
         <map:generate src="sax-pipeline/simple.xml" />
         <map:match value="{jexl:cocoon.request.myparam}" equals="1">
           <map:transform src="sax-pipeline/simple.xslt">
             <map:parameter name="myParam" value="1" />
-          </map:transform>        
+          </map:transform>
         </map:match>
         <map:match value="{jexl:cocoon.request.yourparam}" equals="2">
           <map:transform src="sax-pipeline/add-paragraph.xslt">
@@ -254,12 +262,12 @@
           </map:transform>
         </map:match>
         <map:serialize />
-      </map:match>      
+      </map:match>
       <map:match wildcard="advanced-matching-4">
         <map:generate src="sax-pipeline/simple.xml" />
         <map:transform src="sax-pipeline/simple.xslt">
           <map:parameter name="myParam" value="1" />
-        </map:transform>            
+        </map:transform>
         <map:match value="{jexl:cocoon.request.param_a}" equals="1">
           <map:select value="{jexl:cocoon.request.param_b}">
             <map:when equals="1">
@@ -270,21 +278,21 @@
                 <map:transform src="sax-pipeline/add-paragraph.xslt">
                   <map:parameter name="text" value="3"/>
                 </map:transform>
-                <map:select value="{jexl:cocoon.request.param_d}">   
-                  <map:when equals="1">                
+                <map:select value="{jexl:cocoon.request.param_d}">
+                  <map:when equals="1">
                     <map:transform src="sax-pipeline/add-paragraph.xslt">
                       <map:parameter name="text" value="4"/>
-                    </map:transform>                
+                    </map:transform>
                   </map:when>
-                </map:select>             
+                </map:select>
               </map:match>
             </map:when>
             <map:otherwise>
               <map:transform src="sax-pipeline/add-paragraph.xslt">
                 <map:parameter name="text" value="5"/>
-              </map:transform>               
+              </map:transform>
             </map:otherwise>
-          </map:select>    
+          </map:select>
         </map:match>
         <map:match value="{jexl:cocoon.request.param_e}" equals="1">
           <map:transform src="sax-pipeline/add-paragraph.xslt">
@@ -296,19 +304,19 @@
           <map:otherwise>
             <map:transform src="sax-pipeline/add-paragraph.xslt">
               <map:parameter name="text" value="7"/>
-            </map:transform>               
+            </map:transform>
           </map:otherwise>
         </map:select>
         <map:select value="{jexl:cocoon.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:transform>
           </map:when>
         </map:select>
         <map:serialize />
-      </map:match>     
-      
+      </map:match>
+
       <!-- named matcher -->
       <map:match wildcard="named-matcher/{a}" name="m1">
         <map:match value="{jexl:cocoon.request.param_a}" equals="1">
@@ -318,11 +326,11 @@
               <map:parameter name="myParam" value="{map:m1/a}" />
             </map:transform>
             <map:serialize />
-          </map:match>        
+          </map:match>
         </map:match>
       </map:match>
-      
-      <!-- deep relative matcher --> 
+
+      <!-- deep relative matcher -->
       <map:match wildcard="deep-relative-matcher/{a}">
         <map:match value="{jexl:cocoon.request.param_a}" equals="1">
           <map:match value="{jexl:cocoon.request.param_b}" equals="1">
@@ -331,10 +339,10 @@
               <map:parameter name="myParam" value="{map:../../a}" />
             </map:transform>
             <map:serialize />
-          </map:match>        
+          </map:match>
         </map:match>
-      </map:match>      
-    </map:pipeline>    
+      </map:match>
+    </map:pipeline>
 
     <!-- ~~~~~~~~~~~~~~~~ aggregation ~~~~~~~~~~~~~~~ -->
     <map:pipeline>
@@ -363,7 +371,7 @@
     </map:pipeline>
 
     <!-- ~~~~~~~~~~~~~~~~ matcher: parameter passing ~~~~~~~~~~~~~~~ -->
-    <!--  
+    <!--
     <map:pipeline>
       <map:match pattern="parameter-passing/failing">
         <map:match type="parameter-passing">
@@ -441,7 +449,7 @@
         <map:serialize type="xhtml" status-code="501" />
       </map:handle-errors>
     </map:pipeline>
-    
+
     <!-- FOP -->
     <map:pipeline>
       <map:match equals="fop/test.pdf">
@@ -466,37 +474,37 @@
           <map:parameter name="myParam" value="2" />
         </map:transform>
         <map:serialize type="exhtml" doctype-default="strict" />
-      </map:match>    
+      </map:match>
       <map:match equals="serializers/ehtml">
         <map:generate src="sax-pipeline/simple.xml" />
         <map:transform src="sax-pipeline/simple.xslt">
           <map:parameter name="myParam" value="2" />
         </map:transform>
         <map:serialize type="ehtml" encoding="iso-8859-1"/>
-      </map:match>    
+      </map:match>
     </map:pipeline>
-    
+
     <!-- Cocoon Wicket integration -->
     <map:pipeline type="noncaching">
       <map:match wildcard="wicket/**">
         <map:read type="wicket" base-path="/wicket" />
       </map:match>
     </map:pipeline>
- 
+
     <!-- Global error handling -->
     <map:handle-errors>
       <map:select value="{jexl:cocoon.exception.class.name}">
         <map:when contains="NoMatchingPipelineException">
           <map:generate src="error-handling/404.xml" />
-          <map:serialize type="xhtml" status-code="404" />        
+          <map:serialize type="xhtml" status-code="404" />
         </map:when>
         <map:when ends-with="CustomException">
           <map:generate src="error-handling/500.xml" />
           <map:serialize type="xhtml" status-code="500" />
-        </map:when>        
+        </map:when>
         <map:otherwise>
           <map:generate type="exception" />
-          <map:serialize type="xml" status-code="500" />        
+          <map:serialize type="xml" status-code="500" />
         </map:otherwise>
       </map:select>
       <!--



Mime
View raw message