You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2006/10/19 00:41:30 UTC

svn commit: r465405 - in /shale/framework/trunk/shale-apps/shale-test-view/src: main/java/org/apache/shale/examples/test/view/ main/webapp/ main/webapp/WEB-INF/ test/java/org/apache/shale/examples/test/core/systest/

Author: craigmcc
Date: Wed Oct 18 15:41:29 2006
New Revision: 465405

URL: http://svn.apache.org/viewvc?view=rev&rev=465405
Log:
Add a test scenario to validate lifecycle events for subviews.  The
current implementation fires events correctly, and this will help us
catch future regressions.

SHALE-220

Added:
    shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp   (with props)
Modified:
    shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml
    shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml
    shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp
    shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java

Added: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java?view=auto&rev=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java Wed Oct 18 15:41:29 2006
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.examples.test.view;
+
+import org.apache.shale.view.AbstractViewController;
+
+/**
+ * <p>First page for subview lifecycle event tests.</p>
+ */
+public class Subview1 extends AbstractViewController {
+    
+
+    // -------------------------------------------------------------- Properties
+
+
+    // The "Recorder" object for this request
+    private Recorder recorder = null;
+    public Recorder getRecorder() {
+        return this.recorder;
+    }
+    public void setRecorder(Recorder recorder) {
+        this.recorder = recorder;
+    }
+
+
+    // ========================================================== Event Handlers
+
+
+    /**
+     * <p>Return null to stay on the same page.</p>
+     */
+    public String resubmit() {
+        return null;
+    }
+
+
+    // ------------------------------------------------------- Lifecycle Methods
+
+
+    /**
+     * <p>Record an init event.</p>
+     */
+    public void init() {
+        getRecorder().record("init1");
+        System.out.println("Subview1.init()");
+    }
+
+
+    /**
+     * <p>Record a preprocess event.</p>
+     */
+    public void preprocess() {
+        getRecorder().record("preprocess1");
+        System.out.println("Subview1.preprocess()");
+    }
+
+
+    /**
+     * <p>Record a prerender event.</p>
+     */
+    public void prerender() {
+        getRecorder().record("prerender1");
+        System.out.println("Subview1.prerender()");
+    }
+
+
+    /**
+     * <p>Record a destroy event.</p>
+     */
+    public void destroy() {
+        getRecorder().record("destroy1");
+        System.out.println("Subview1.destroy()");
+    }
+
+
+}

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java?view=auto&rev=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java Wed Oct 18 15:41:29 2006
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.examples.test.view;
+
+import org.apache.shale.view.AbstractViewController;
+
+/**
+ * <p>Second page for subview lifecycle event tests.</p>
+ */
+public class Subview2 extends AbstractViewController {
+    
+
+    // -------------------------------------------------------------- Properties
+
+
+    // The "Recorder" object for this request
+    private Recorder recorder = null;
+    public Recorder getRecorder() {
+        return this.recorder;
+    }
+    public void setRecorder(Recorder recorder) {
+        this.recorder = recorder;
+    }
+
+
+    // ------------------------------------------------------- Lifecycle Methods
+
+
+    /**
+     * <p>Record an init event.</p>
+     */
+    public void init() {
+        getRecorder().record("init2");
+        System.out.println("Subview2.init()");
+    }
+
+
+    /**
+     * <p>Record a preprocess event.</p>
+     */
+    public void preprocess() {
+        getRecorder().record("preprocess2");
+        System.out.println("Subview2.preprocess()");
+    }
+
+
+    /**
+     * <p>Record a prerender event.</p>
+     */
+    public void prerender() {
+        getRecorder().record("prerender2");
+        System.out.println("Subview2.prerender()");
+    }
+
+
+    /**
+     * <p>Record a destroy event.</p>
+     */
+    public void destroy() {
+        getRecorder().record("destroy2");
+        System.out.println("Subview2.destroy()");
+    }
+
+
+}

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=465405&r1=465404&r2=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml Wed Oct 18 15:41:29 2006
@@ -91,6 +91,30 @@
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
 
+    <managed-bean>
+        <managed-bean-name>subview1</managed-bean-name>
+        <managed-bean-class>
+            org.apache.shale.examples.test.view.Subview1
+        </managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+        <managed-property>
+            <property-name>recorder</property-name>
+            <value>#{recorder}</value>
+        </managed-property>
+    </managed-bean>
+
+    <managed-bean>
+        <managed-bean-name>subview2</managed-bean-name>
+        <managed-bean-class>
+            org.apache.shale.examples.test.view.Subview2
+        </managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+        <managed-property>
+            <property-name>recorder</property-name>
+            <value>#{recorder}</value>
+        </managed-property>
+    </managed-bean>
+
     <!-- ========== Other Managed Beans ========== -->
 
     <managed-bean>

Modified: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml?view=diff&rev=465405&r1=465404&r2=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml (original)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml Wed Oct 18 15:41:29 2006
@@ -26,7 +26,7 @@
                       version="2.4">
 
   <!-- Display name for this application -->
-  <display-name>Shale Test App (Tiger Extensions)</display-name>
+  <display-name>Shale Test App (View Controller)</display-name>
 
   <!-- Select JSF State Saving Mode -->
   <context-param>

Modified: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp?view=diff&rev=465405&r1=465404&r2=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp (original)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp Wed Oct 18 15:41:29 2006
@@ -25,16 +25,17 @@
 <f:view>
 <html>
 <head>
-    <title>Shale Test App (Core Library)</title>
+    <title>Shale Test App (View Controller)</title>
 </head>
 <body>
 
-    <h3>Shale Test App (Core Library)</h3>
+    <h3>Shale Test App (View Controller)</h3>
 
     <ul>
         <li><a href="lifecycle1.faces">Lifecyle Navigation Events</a></li>
         <li><a href="standard.faces">Standard ViewController Lifecycle Events</a></li>
         <li><a href="status.faces">Static Status Information</a></li>
+        <li><a href="subview1.faces">Subview Lifecycle Events</a></li>
     </ul>
 
 

Added: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp?view=auto&rev=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp (added)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp Wed Oct 18 15:41:29 2006
@@ -0,0 +1,74 @@
+<%--
+
+ 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.
+
+ $Id$
+
+--%>
+
+<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
+<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
+<%@ taglib prefix="s" uri="http://shale.apache.org/view" %>
+
+<f:view>
+<html>
+<head>
+    <title>Subview Lifecycle Events</title>
+</head>
+<body>
+
+    <h3>Subview Lifecycle Events</h3>
+
+    <table cellspacing="5">
+        <tr>
+            <th align="center">Name</th>
+            <th align="center">Value</th>
+        </tr>
+        <tr>
+            <th align="right">recorder.events</th>
+            <td><h:outputText id="recorderEvents"
+                           value="#{recorder.events}"/></td>
+        </tr>
+    </table>
+
+    <h:form id="form">
+      <h:commandLink id="resubmit" value="Resubmit" action="#{subview1.resubmit}"/>
+    </h:form>
+
+    <s:subview id="subview2">
+      <h:outputText value="This text is from a subview"/>
+    </s:subview>
+
+    <h3>Test Description</h3>
+
+    <p>Displays the lifecycle events that have been recorded so far.
+    When this page is initially navigated to, it should be
+    "init1/prerender1/".  When you press the Resubmit button, you
+    should see "init1/preprocess1/init2/preprocess2/prerender1".</p>
+
+    <p>NOTE:  The display does not show all of the events that are
+    actually fired, because of the way JSF 1.1 builds the component
+    tree on the fly.  If you check the System.out log of your servlet
+    container, you will see that the actual stream of events for the
+    initial page is "init1/prerender1/init2/prerender2/destroy2/destroy1"
+    and the stream of events for the resubmit is actually
+    "init1/preprocess1/init2/preprocess2/prerender1/prerender2/destroy2/destroy1".</p>
+
+    <p><a href="menu.faces">Back</a> to main menu</p>
+
+</body>
+</html>
+</f:view>

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java?view=diff&rev=465405&r1=465404&r2=465405
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java (original)
+++ shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java Wed Oct 18 15:41:29 2006
@@ -118,7 +118,7 @@
     // Test /menu.jsp
     public void testMenu() throws Exception {
 
-        assertEquals("Shale Test App (Core Library)", title());
+        assertEquals("Shale Test App (View Controller)", title());
 
     }
 
@@ -204,6 +204,36 @@
         assertNotNull(element);
         assertEquals("org.apache.shale.view.impl.DefaultViewControllerMapper",
                      element.asText());
+
+    }
+
+
+    // Test /subview1.jsp
+    public void testSubview() throws Exception {
+
+        HtmlElement element;
+        page("/subview1.faces");
+        assertEquals("Subview Lifecycle Events", title());
+
+        // Validate values for initial non-postback call
+        
+        element = element("recorderEvents");
+        assertNotNull(element);
+        assertEquals("init1/prerender1/", element.asText());
+
+        // Click the resubmit hyperlink
+
+        HtmlAnchor anchor = (HtmlAnchor) element("form:resubmit");
+        assertNotNull(anchor);
+        link(anchor);
+
+        // Validate values for subsequent postback call
+        
+        assertEquals("Subview Lifecycle Events", title());
+
+        element = element("recorderEvents");
+        assertNotNull(element);
+        assertEquals("init1/preprocess1/init2/preprocess2/prerender1/", element.asText());
 
     }