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/08/07 00:17:02 UTC

svn commit: r683430 - in /cocoon/whiteboard/corona/trunk: corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/ corona-sample/src/main/resources/COB-INF/ corona-sample/sr...

Author: reinhard
Date: Wed Aug  6 15:17:01 2008
New Revision: 683430

URL: http://svn.apache.org/viewvc?rev=683430&view=rev
Log:
. add integration test for SpringRESTController and StringTemplate
. list sample in overview.html

Added:
    cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java   (with props)
Modified:
    cocoon/whiteboard/corona/trunk/corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/DemoRESTController.java
    cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/controller/demo.html
    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

Added: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java?rev=683430&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java Wed Aug  6 15:17:01 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.corona.it;
+
+/**
+ * Test a SpringRESTController and StringTemplate.
+ */
+public class ControllerTest extends CoronaHtmlUnitTestCase {
+
+    /**
+     * Test a pipeline that calls a SpringRESTController which delegates to a pipeline that uses a controller
+     * context-aware StringTemplate generator.
+     */
+    public void testControllerInvocation() throws Exception {
+        this.loadXmlPage("/controller/abc/foo?reqparam=1");
+        int statusCode = this.response.getStatusCode();
+        assertTrue(statusCode == 200);
+        assertEquals("text/xml", this.response.getContentType());
+        this.assertXPath("/html/body/p[1]", "name=foo");
+        this.assertXPath("/html/body/p[2]", "id=abc");
+        this.assertXPath("/html/body/p[3]", "reqparam=1");
+    }
+
+}

Propchange: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/ControllerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/DemoRESTController.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/DemoRESTController.java?rev=683430&r1=683429&r2=683430&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/DemoRESTController.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/java/org/apache/cocoon/corona/sample/controller/DemoRESTController.java Wed Aug  6 15:17:01 2008
@@ -20,6 +20,7 @@
 import java.util.Map;
 
 import org.apache.cocoon.corona.rest.controller.annotation.RESTController;
+import org.apache.cocoon.corona.rest.controller.annotation.RequestParameter;
 import org.apache.cocoon.corona.rest.controller.annotation.SitemapParameter;
 import org.apache.cocoon.corona.rest.controller.method.Get;
 import org.apache.cocoon.corona.rest.controller.response.Page;
@@ -34,10 +35,14 @@
     @SitemapParameter
     private String name;
 
+    @RequestParameter
+    private String reqparam;
+
     public RestResponse doGet() throws Exception {
         Map<String, Object> data = new HashMap<String, Object>();
         data.put("id", this.id);
         data.put("name", this.name);
+        data.put("reqparam", this.reqparam);
 
         return new Page("servlet:/controller/screen", data);
     }

Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/controller/demo.html
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/controller/demo.html?rev=683430&r1=683429&r2=683430&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/controller/demo.html (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/controller/demo.html Wed Aug  6 15:17:01 2008
@@ -23,11 +23,8 @@
   </head>
   <body>
     <h3>RESTController demo</h3>
-    <p>
-      name=$name$
-    </p>
-    <p>
-      id=$id$
-    </p>
+    <p>name=$name$</p>
+    <p>id=$id$</p>
+    <p>reqparam=$reqparam$</p>
   </body>
 </html>

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=683430&r1=683429&r2=683430&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 Wed Aug  6 15:17:01 2008
@@ -90,8 +90,7 @@
   </ul>
   <h2>Controller</h2>
   <ul>
-    <li><a href="controller/invoke">Invoke a controller</a>: Invoke a controller (the first time). (returns 201)</li>
-    <li><a href="controller/continue">Continue</a>: Continue a controller. (returns 202)</li>
+    <li><a href="controller/abc/foo?reqparam=1">Invoke a controller</a>: Invoke a controller and pass two parameters</li>
   </ul>
   </body>
 </html>

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=683430&r1=683429&r2=683430&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 Wed Aug  6 15:17:01 2008
@@ -360,7 +360,7 @@
       </map:match>
       <map:match pattern="controller/screen">
         <map:generate src="controller/demo.html" type="string-template" />
-        <map:serialize type="xhtml" />
+        <map:serialize type="xml" />
       </map:match>
     </map:pipeline>