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/01/22 00:00:03 UTC
svn commit: r614037 - in
/cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro:
./ it/ it/ReaderTest.java it/SaxPipelineTest.java
Author: reinhard
Date: Mon Jan 21 15:00:02 2008
New Revision: 614037
URL: http://svn.apache.org/viewvc?rev=614037&view=rev
Log:
add integration tests:
- sax pipelines
- readers
- error handling
Added:
cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/
cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/
cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java (with props)
cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java (with props)
Added: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java?rev=614037&view=auto
==============================================================================
--- cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java (added)
+++ cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java Mon Jan 21 15:00:02 2008
@@ -0,0 +1,58 @@
+package org.apache.cocoon.micro.it;
+
+/*
+ * 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.
+ */
+
+import org.apache.cocoon.tools.it.HtmlUnitTestCase;
+
+/**
+ * Test readers
+ */
+public class ReaderTest extends HtmlUnitTestCase {
+
+ /**
+ * Call a pipeline that explicitly sets the mime-type of the resource.
+ */
+ public void testReadingResourceWithExplicitMimeType() throws Exception {
+ this.loadResponse("read/javascript-resource-explicit");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/javascript", this.response.getContentType());
+ assertEquals("853", this.response.getResponseHeaderValue("Content-Length"));
+ }
+
+ /**
+ * Call a pipeline that automatically sets the mime-type of the resource.
+ */
+ public void testReadingResourceWithImplicitMimeType() throws Exception {
+ this.loadResponse("read/javascript-resource-implicit");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("application/x-javascript", this.response.getContentType());
+ assertEquals("853", this.response.getResponseHeaderValue("Content-Length"));
+ }
+
+ /**
+ * A resource reader supports conditional gets.
+ */
+ public void testConditionalGet() throws Exception {
+ this.loadResponse("read/javascript-resource-implicit");
+ String lastModified = this.response.getResponseHeaderValue("Last-Modified");
+ this.webClient.addRequestHeader("If-Modified-Since", lastModified);
+ this.loadResponse("read/javascript-resource-implicit");
+ assertEquals(304, this.response.getStatusCode());
+ }
+
+}
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/ReaderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java?rev=614037&view=auto
==============================================================================
--- cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java (added)
+++ cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java Mon Jan 21 15:00:02 2008
@@ -0,0 +1,76 @@
+package org.apache.cocoon.micro.it;
+
+/*
+ * 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.
+ */
+
+import org.apache.cocoon.tools.it.HtmlUnitTestCase;
+
+/**
+ * Test SAX Pipelines
+ */
+public class SaxPipelineTest extends HtmlUnitTestCase {
+
+ /**
+ * A simple pipeline that produces an HTML document.
+ */
+ public void testSimplePipeline() throws Exception {
+ this.loadResponse("sax-pipeline/simple");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/html", this.response.getContentType());
+ assertTrue(!this.response.getContentAsString().contains("-//W3C//DTD XHTML 1.0 Strict//EN"));
+ }
+
+ /**
+ * A simple pipeline that produces an XHTML 1.0 document. This implicitly
+ * tests if the configuration of serializers works properly.
+ */
+ public void testSimplePipelineXhtml() throws Exception {
+ this.loadResponse("sax-pipeline/simple-xhtml");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/html", this.response.getContentType());
+ assertTrue(this.response.getContentAsString().contains("-//W3C//DTD XHTML 1.0 Strict//EN"));
+ }
+
+ /**
+ * A parameter is passed to an XSLT transformer.
+ */
+ public void testSimplePipelineParameterPassingToTransformer() throws Exception {
+ this.loadXmlPage("sax-pipeline/simple-xml");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/xml", this.response.getContentType());
+ assertXPath("/html/body/p", "3");
+ }
+
+ /**
+ * A status code is set explicitly at a serializer.
+ */
+ public void testSettingStatusCode() throws Exception {
+ this.loadResponse("sax-pipeline/unauthorized");
+ assertTrue(this.response.getStatusCode() == 401);
+ assertEquals("1030", this.response.getResponseHeaderValue("Content-Length"));
+ String lastModified = this.response.getResponseHeaderValue("Last-Modified");
+ assertNotNull(lastModified);
+ assertFalse(lastModified.equals(""));
+ }
+
+ public void testErrorHandling() throws Exception {
+ this.loadResponse("12345678901234567890");
+ assertTrue(this.response.getStatusCode() == 404);
+ assertTrue(this.response.getContentAsString().contains("404 Resource Not Available (Integration Tests)"));
+ }
+
+}
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SaxPipelineTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain