Author: craigmcc
Date: Wed Oct 18 10:40:30 2006
New Revision: 465311

URL: http://svn.apache.org/viewvc?view=rev&rev=465311
Log:
Add an integration test case to investigate SHALE-307, which reports
that prerender() is not getting called on the second page when
navigating from one view controller to another.  At the moment, the test
case passes (indicating prerender() was indeed called as expected), so
further investigation is necessary to see where a failure case might
still exist.

SHALE-307


Added:
    
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle1.java
    
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle2.java
    
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Recorder.java
    
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle1.jsp
    
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle2.jsp
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/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/Lifecycle1.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle1.java?view=auto&rev=465311
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle1.java
 (added)
+++ 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle1.java
 Wed Oct 18 10:40:30 2006
@@ -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.
+ *
+ * $Id: Standard.java 464373 2006-10-16 04:21:54Z rahul $
+ */
+
+package org.apache.shale.examples.test.view;
+
+import org.apache.shale.view.AbstractViewController;
+
+/**
+ * <p>First page for lifecycle event tests.</p>
+ */
+public class Lifecycle1 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("init1");
+    }
+
+
+    /**
+     * <p>Record a preprocess event.</p>
+     */
+    public void preprocess() {
+        getRecorder().record("preprocess1");
+    }
+
+
+    /**
+     * <p>Record a prerender event.</p>
+     */
+    public void prerender() {
+        getRecorder().record("prerender1");
+    }
+
+
+    /**
+     * <p>Record a destroy event.</p>
+     */
+    public void destroy() {
+        getRecorder().record("destroy1");
+    }
+
+
+}

Added: 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle2.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle2.java?view=auto&rev=465311
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle2.java
 (added)
+++ 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Lifecycle2.java
 Wed Oct 18 10:40:30 2006
@@ -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.
+ *
+ * $Id: Standard.java 464373 2006-10-16 04:21:54Z rahul $
+ */
+
+package org.apache.shale.examples.test.view;
+
+import org.apache.shale.view.AbstractViewController;
+
+/**
+ * <p>Second page for lifecycle event tests.</p>
+ */
+public class Lifecycle2 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");
+    }
+
+
+    /**
+     * <p>Record a preprocess event.</p>
+     */
+    public void preprocess() {
+        getRecorder().record("preprocess2");
+    }
+
+
+    /**
+     * <p>Record a prerender event.</p>
+     */
+    public void prerender() {
+        getRecorder().record("prerender2");
+    }
+
+
+    /**
+     * <p>Record a destroy event.</p>
+     */
+    public void destroy() {
+        getRecorder().record("destroy2");
+    }
+
+
+}

Added: 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Recorder.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Recorder.java?view=auto&rev=465311
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Recorder.java
 (added)
+++ 
shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Recorder.java
 Wed Oct 18 10:40:30 2006
@@ -0,0 +1,72 @@
+/*
+ * 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: Standard.java 464373 2006-10-16 04:21:54Z rahul $
+ */
+
+package org.apache.shale.examples.test.view;
+
+/**
+ * <p>Simple bean to record and play back event messages.</p>
+ */
+public class Recorder {
+    
+
+    // ------------------------------------------------------ Instance 
Variables
+
+
+    /**
+     * <p>The logged events as a concatenated string.</p>
+     */
+    private StringBuffer events = new StringBuffer();
+
+
+    // -------------------------------------------------------------- 
Properties
+
+
+    /**
+     * <p>Return the complete set of events that has occurred since
+     * we were last erased.</p>
+     */
+    public String getEvents() {
+        return events.toString();
+    }
+
+
+
+    // ---------------------------------------------------------- Public 
Methods
+
+
+    /**
+     * <p>Clear all previously recorded events.</p>
+     */
+    public void clear() {
+        events.setLength(0);
+    }
+
+
+    /**
+     * <p>Record the specified event.</p>
+     *
+     * @param event Event to be recorded
+     */
+    public void record(String event) {
+        events.append(event);
+        events.append("/");
+    }
+
+
+}

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=465311&r1=465310&r2=465311
==============================================================================
--- 
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 10:40:30 2006
@@ -32,6 +32,10 @@
     <navigation-rule>
         <from-view-id>*</from-view-id>
         <navigation-case>
+            <from-outcome>lifecycle2</from-outcome>
+            <to-view-id>/lifecycle2.jsp</to-view-id>
+        </navigation-case>
+        <navigation-case>
             <from-outcome>menu</from-outcome>
             <to-view-id>/menu.jsp</to-view-id>
         </navigation-case>
@@ -48,6 +52,30 @@
     <!-- ========== View Controller Beans ========== -->
 
     <managed-bean>
+        <managed-bean-name>lifecycle1</managed-bean-name>
+        <managed-bean-class>
+            org.apache.shale.examples.test.view.Lifecycle1
+        </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>lifecycle2</managed-bean-name>
+        <managed-bean-class>
+            org.apache.shale.examples.test.view.Lifecycle2
+        </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>standard</managed-bean-name>
         <managed-bean-class>
             org.apache.shale.examples.test.view.Standard
@@ -64,5 +92,13 @@
     </managed-bean>
 
     <!-- ========== Other Managed Beans ========== -->
+
+    <managed-bean>
+        <managed-bean-name>recorder</managed-bean-name>
+        <managed-bean-class>
+            org.apache.shale.examples.test.view.Recorder
+        </managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
 
 </faces-config>

Added: 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle1.jsp
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle1.jsp?view=auto&rev=465311
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle1.jsp 
(added)
+++ 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle1.jsp 
Wed Oct 18 10:40:30 2006
@@ -0,0 +1,65 @@
+<%--
+
+ 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: standard.jsp 464719 2006-10-16 23:18:31Z rahul $
+
+--%>
+
+<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
+<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>
+
+<f:view>
+<html>
+<head>
+    <title>Lifecycle Navigation Test (Page 1)</title>
+</head>
+<body>
+
+    <h3>Lifecycle Navigation Test (Page 1)</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="navigate" value="Navigate" action="lifecycle2"/>
+    </h:form>
+
+    <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 Navigate button, you
+    should advance to page 2, where the event listing should be
+    "init1/preprocess1/init2/prerender2/".</p>
+
+    <p>NOTE:  Destroy events do not get listed, because rendering
+    is completed before that method gets called.</p>
+
+    <p><a href="menu.faces">Back</a> to main menu</p>
+
+</body>
+</html>
+</f:view>

Added: 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle2.jsp
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle2.jsp?view=auto&rev=465311
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle2.jsp 
(added)
+++ 
shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/lifecycle2.jsp 
Wed Oct 18 10:40:30 2006
@@ -0,0 +1,61 @@
+<%--
+
+ 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: standard.jsp 464719 2006-10-16 23:18:31Z rahul $
+
+--%>
+
+<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
+<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>
+
+<f:view>
+<html>
+<head>
+    <title>Lifecycle Navigation Test (Page 2)</title>
+</head>
+<body>
+
+    <h3>Lifecycle Navigation Test (Page 2)</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>
+
+    <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 Navigate button, you
+    should advance to page 2, where the event listing should be
+    "init1/preprocess1/init2/prerender2/".</p>
+
+    <p>NOTE:  Destroy events do not get listed, because rendering
+    is completed before that method gets called.</p>
+
+    <p><a href="menu.faces">Back</a> to main menu</p>
+
+</body>
+</html>
+</f:view>

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=465311&r1=465310&r2=465311
==============================================================================
--- 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 10:40:30 2006
@@ -32,6 +32,7 @@
     <h3>Shale Test App (Core Library)</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>
     </ul>

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=465311&r1=465310&r2=465311
==============================================================================
--- 
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 10:40:30 2006
@@ -85,6 +85,36 @@
     // ------------------------------------------------- Individual Test 
Methods
 
 
+    // Test /lifecycle1.jsp and /lifecycle2.jsp
+    public void testLifecycle() throws Exception {
+
+        HtmlElement element;
+        page("/lifecycle1.faces");
+        assertEquals("Lifecycle Navigation Test (Page 1)", title());
+
+        // Validate values for initial non-postback call
+        
+        element = element("recorderEvents");
+        assertNotNull(element);
+        assertEquals("init1/prerender1/", element.asText());
+
+        // Click the navigate hyperlink
+
+        HtmlAnchor anchor = (HtmlAnchor) element("form:navigate");
+        assertNotNull(anchor);
+        link(anchor);
+
+        // Validate values for subsequent postback call
+        
+        assertEquals("Lifecycle Navigation Test (Page 2)", title());
+
+        element = element("recorderEvents");
+        assertNotNull(element);
+        assertEquals("init1/preprocess1/init2/prerender2/", element.asText());
+
+    }
+
+
     // Test /menu.jsp
     public void testMenu() throws Exception {
 


Reply via email to