cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r721814 - in /cocoon/cocoon3/trunk: cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ cocoon-sample/ cocoon-sample/src/main/resources/COB-INF/
Date Sun, 30 Nov 2008 14:05:45 GMT
Author: reinhard
Date: Sun Nov 30 06:05:44 2008
New Revision: 721814

URL: http://svn.apache.org/viewvc?rev=721814&view=rev
Log:
. add integration tests for caching
. tidy up samples page

Modified:
    cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CachingOfPipelinesTest.java
    cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ReaderTest.java
    cocoon/cocoon3/trunk/cocoon-sample/pom.xml
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html

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=721814&r1=721813&r2=721814&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
Sun Nov 30 06:05:44 2008
@@ -16,8 +16,12 @@
  */
 package org.apache.cocoon.it;
 
+import org.apache.cocoon.sample.generation.CachingTimestampGenerator;
+import org.apache.cocoon.sample.generation.TimestampGenerator;
+
 /**
- * Test pipeline caching
+ * Test pipeline caching. The tests use the {@link TimestampGenerator} which always takes
more 0.5 seconds to produce a
+ * result.
  */
 public class CachingOfPipelinesTest extends CocoonHtmlUnitTestCase {
 
@@ -28,6 +32,7 @@
         this.loadResponse("caching-pipeline/off");
         String content1 = this.response.getContentAsString();
         assertNotNull(content1);
+
         this.loadResponse("caching-pipeline/off");
         String content2 = this.response.getContentAsString();
         assertNotNull(content2);
@@ -35,16 +40,62 @@
     }
 
     /**
-     * This caching pipeline always returns the same.
+     * This caching pipeline uses the {@link CachingTimestampGenerator} that produces results
valid for 1.5 seconds.
+     * This means that the second request has to return the same result but the third a different
one because the cache
+     * key produced by the first result has become invalid in the meantime.
      */
     public void testCachingPipeline() throws Exception {
         this.loadResponse("caching-pipeline/on");
         String content1 = this.response.getContentAsString();
-        assertNotNull(content1);
+
         this.loadResponse("caching-pipeline/on");
         String content2 = this.response.getContentAsString();
-        assertNotNull(content2);
         assertTrue("The response has to be always the same.", content1.equals(content2));
+
+        Thread.sleep(1000);
+        this.loadResponse("caching-pipeline/on");
+        String content3 = this.response.getContentAsString();
+        assertFalse("The response has to change because the caching period has expired.",
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()}
+     */
+    public void testExpiresCachingPipeline() throws Exception {
+        Thread.sleep(2000);
+        this.loadResponse("/expires/caching-pipeline/on");
+        String content1 = this.response.getContentAsString();
+
+        Thread.sleep(2100);
+        this.loadResponse("/expires/caching-pipeline/on");
+        String content2 = this.response.getContentAsString();
+        assertFalse("The response has to be the same as before.", content1.equals(content2));
     }
 
+    /**
+     * 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));
+
+    }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ReaderTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ReaderTest.java?rev=721814&r1=721813&r2=721814&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ReaderTest.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ReaderTest.java
Sun Nov 30 06:05:44 2008
@@ -40,7 +40,7 @@
     }
 
     /**
-     * Call a pipeline that uses an unkown file extentions.
+     * Call a pipeline that uses an unknown file extensions.
      */
     public void testReadingResourceWithUnknownMimeType() throws Exception {
         this.loadResponse("read/javascript-resource-implicit.abc");
@@ -55,7 +55,8 @@
         this.loadResponse("read/javascript-resource-implicit.js");
         String lastModified = this.response.getResponseHeaderValue("Last-Modified");
         assertNotNull("Last-Modified has to be set at this point!", lastModified);
-        assertFalse("Last-Modified hast to be set at this point!", "".equals(lastModified));
+        assertFalse("Last-Modified has to be set at this point!", "".equals(lastModified));
+
         this.webClient.addRequestHeader("If-Modified-Since", lastModified);
         this.loadResponse("read/javascript-resource-implicit.js");
         assertEquals(304, this.response.getStatusCode());

Modified: cocoon/cocoon3/trunk/cocoon-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/pom.xml?rev=721814&r1=721813&r2=721814&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/pom.xml Sun Nov 30 06:05:44 2008
@@ -80,9 +80,9 @@
     <plugins>
       <plugin>
         <artifactId>maven-eclipse-plugin</artifactId>
-        <configuration>
+        <!-- configuration>
           <useProjectReferences>false</useProjectReferences>
-        </configuration>
+        </configuration-->
       </plugin>
       <plugin>
         <groupId>org.apache.cocoon</groupId>

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=721814&r1=721813&r2=721814&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Sun Nov 30
06:05:44 2008
@@ -37,17 +37,24 @@
   </ul>
   <h2>Caching</h2>
   <ul>
-  	<li><a href="caching-pipeline/on">Caching pipeline</a>: The result of
the pipeline is cached forever.</li>
   	<li><a href="caching-pipeline/off">Non-Caching pipeline</a>: The pipeline
doesn't cache (although it's components support it)</li>
-  	<li><a href="async-caching-pipeline/on">Async-Caching pipeline</a>:
</li>
-  	<li><a href="expires-caching-pipeline/on">Expires-Caching pipeline</a>:
The pipeline returns a cached result for defined period.</li>
+  	<li><a href="caching-pipeline/on">Caching pipeline</a>: The result of
the pipeline is cached for 1.5 seconds. The next request that occurs 
+	  after the cached response has expires, triggers a reexecution of the pipeline in the same
thread.</li>
+  	<li><a href="async-caching-pipeline/on">Async-Caching pipeline</a>:
The result of the pipeline is cached for 1.5 seconds. The next request that occurs 
+	  after the cached response has expires, triggers a reexecution of the pipeline in a separate
thread.</li>
+  	<li><a href="/expires/caching-pipeline/on">Expires-Caching pipeline</a>:
The pipeline returns a cached result for defined period, 
+	  independently from whether components used in the pipeline support caching or not. The
pipeline result is cached for 2 seconds. The
+	  recreation of the pipeline result is done in the same thread as the servlet request.</li>
+  	<li><a href="/expires/async-caching-pipeline/on">Expires-Async-Caching pipeline</a>:
The pipeline returns a cached result for defined period, 
+	  independently from whether components used in the pipeline support caching or not. The
pipeline result is cached for 2 seconds. The recreation of the
+	  pipeline result is done in a separate thread than the servlet request.</li>
   </ul>
   <h2>Error handling</h2>
   <ul>
     <li><a href="123456789123456789">ResourceNotFound</a>: The error handler
catches all exceptions, in this case no matcher matches.</li>
     <li><a href="error-handling/custom-error">Custom error - Sitemap</a>:
Catch a custom error in the sitemap.</li>
     <li><a href="error-handling/custom-error-per-pipeline-error-handling">
-      Custom error - Pipeline</a>: Catch a custom error using a per-pipeline error
handler. <b>*** doesn't work ***</b></li>
+      Custom error - Pipeline</a>: Catch a custom error using a per-pipeline error
handler.</li>
   </ul>
   <h2>Servlet-Service-Components and servlet: protocol</h2>
   <ul>
@@ -58,7 +65,6 @@
   <h2>Expression language</h2>
   <ul>
     <li><a href="expression-language/jexl?fileName=simple">request attribute
(jexl)</a>: Accessing a request attribute using Jexl.</li>
-    <li><a href="expression-language/jxpath?fileName=simple">request attribute
(jxpath)</a>: Accessing a request attribute using JXPath.</li>
     <li><a href="expression-language/map-numbers/simple">sitemap parameter</a>:
Accessing a sitemap parameter.</li>
     <li><a href="expression-language/map-named-parameters/simple">sitemap parameter</a>:
Accessing a sitemap parameter using named parameters in the pattern.</li>
     <li><a href="expression-language/nested/simple">nested matchers</a>:
Accessing a parameter from one level above.</li>
@@ -66,7 +72,7 @@
   <h2>Redirects</h2>
   <ul>
     <li><a href="redirect/www.orf.at">Temporary (302)</a>: Temporary redirect
to orf.at.</li>
-    <li><a href="redirect/sax-pipeline/simple-xml">servlet:</a>: Redirect
to a servlet: URL.</li>
+    <li><a href="redirect/sax-pipeline/simple-xml">servlet</a>: Redirect
to a servlet: URL.</li>
   </ul>
   <h2>Object Model</h2>
   <ul>
@@ -91,11 +97,6 @@
   <ul>
     <li><a href="xslt/main">XSLT Transformation</a>: An XSLT transformation
that includes stylesheets via file and servlet protocol.</li>
   </ul>
-  <h2>Parameter passing</h2>
-  <ul>
-    <li><a href="parameter-passing/working">Matching Matcher</a>: Passing
a named parameter from a matcher to the sitemap.</li>
-    <li><a href="parameter-passing/failing">Not-Matching Matcher</a>: Passing
null from a matcher to the sitemap.</li>
-  </ul>
   <h2>Controller</h2>
   <ul>
     <li><a href="controller/abc/foo?reqparam=1">Invoke a controller</a>:
Invoke a controller and pass two parameters</li>



Mime
View raw message