You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/07/29 16:03:18 UTC
svn commit: r680699 - in
/cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache:
./ EventAwareCacheTest.java
Author: reinhard
Date: Tue Jul 29 07:03:17 2008
New Revision: 680699
URL: http://svn.apache.org/viewvc?rev=680699&view=rev
Log:
COCOON-2224
add IT for eventcache
Added:
cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/
cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java (with props)
Added: cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java?rev=680699&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java (added)
+++ cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java Tue Jul 29 07:03:17 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.it.blocks.eventcache;
+
+import org.apache.cocoon.tools.it.HtmlUnitTestCase;
+
+/**
+ * Runs various tests on the eventcache block.
+ */
+public class EventAwareCacheTest extends HtmlUnitTestCase {
+
+ /**
+ * Verifies a key to be cached.
+ *
+ * @throws Exception In case of environmental errors.
+ */
+ public void testGetCachedSite() throws Exception {
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=one");
+ assertEquals(200, this.response.getStatusCode());
+ assertXPath("/eventcache/key", "one");
+ String firstLoaded = this.response.getContentAsString();
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=one");
+ assertEquals(200, this.response.getStatusCode());
+ assertEquals(this.response.getContentAsString(), firstLoaded);
+ }
+
+ /**
+ * Verifies a key to be invalidated by invoking an action.
+ *
+ * @throws Exception In case of environmental errors.
+ */
+ public void testUncacheWithAction() throws Exception {
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=two");
+ assertEquals(200, this.response.getStatusCode());
+ assertXPath("/eventcache/key", "two");
+ String firstLoaded = this.response.getContentAsString();
+ this.loadResponse("cocoon-eventcache-sample/it/action?event=two&pageKey=two");
+ // Check for correct redirect
+ assertEquals(302, this.response.getStatusCode());
+ // Check, whether the response has changed
+ assertNotSame(this.response.getContentAsString(), firstLoaded);
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=two");
+ assertXPath("/eventcache/key", "two");
+ }
+
+ /**
+ * Verifies a key to be invalidated by invoking a flow script.
+ *
+ * @throws Exception In case of environmental errors.
+ */
+ public void testUncacheWithFlow() throws Exception {
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=two");
+ assertEquals(200, this.response.getStatusCode());
+ assertXPath("/eventcache/key", "two");
+ String firstLoaded = this.response.getContentAsString();
+ this.loadResponse("cocoon-eventcache-sample/it/flow?event=two&pageKey=two");
+ // Check for correct redirect
+ assertEquals(302, this.response.getStatusCode());
+ // Check, whether the response has changed
+ assertNotSame(this.response.getContentAsString(), firstLoaded);
+ this.loadXmlPage("cocoon-eventcache-sample/it/demo?pageKey=two");
+ assertXPath("/eventcache/key", "two");
+ }
+}
\ No newline at end of file
Propchange: cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/core/cocoon-webapp/src/test/java/org/apache/cocoon/it/blocks/eventcache/EventAwareCacheTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain