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/08/15 00:34:01 UTC

svn commit: r431450 - in /shale/framework/trunk/shale-apps/shale-test-tiger: ./ src/main/java/org/apache/shale/examples/test/tiger/ src/main/webapp/ src/main/webapp/WEB-INF/

Author: craigmcc
Date: Mon Aug 14 15:34:00 2006
New Revision: 431450

URL: http://svn.apache.org/viewvc?rev=431450&view=rev
Log:
Add the beginnings of an integration test for annotated managed beans.
It is not complete yet.

SHALE-254

Added:
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/ApplicationBean.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Managed.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/RequestBean.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/SessionBean.java   (with props)
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/managed.jsp   (with props)
Modified:
    shale/framework/trunk/shale-apps/shale-test-tiger/SESSIONS.ser
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml
    shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp

Modified: shale/framework/trunk/shale-apps/shale-test-tiger/SESSIONS.ser
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/SESSIONS.ser?rev=431450&r1=431449&r2=431450&view=diff
==============================================================================
Binary files - no diff available.

Added: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/ApplicationBean.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/ApplicationBean.java?rev=431450&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/ApplicationBean.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/ApplicationBean.java Mon Aug 14 15:34:00 2006
@@ -0,0 +1,63 @@
+/*
+ * ApplicationBean.java
+ *
+ * Created on August 13, 2006, 10:04 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.apache.shale.examples.test.tiger;
+
+import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Scope;
+import org.apache.shale.tiger.view.Application;
+import org.apache.shale.tiger.view.Destroy;
+import org.apache.shale.tiger.view.Init;
+
+/**
+ * <p>Application scope managed bean declared with annotations.</p>
+ */
+@Application
+@Bean(name="applicationBean", scope=Scope.APPLICATION)
+public class ApplicationBean {
+    
+
+    // ------------------------------------------------------- Public Properties
+
+
+    /**
+     * <p>Render a stringified version of this instance.</p>
+     */
+    public String getDisplay() {
+        return toString();
+    }
+
+
+    /**
+     * <p>Return the events that have occurred so far.</p>
+     */
+    private StringBuffer events = new StringBuffer();
+
+    public String getEvents() {
+        return events.toString();
+    }
+
+
+
+    // -------------------------------------------------------- Lifecycle Events
+
+
+    @Init
+    public void myInit() {
+        events.append("init/");
+    }
+
+
+    @Destroy
+    public void myDestroy() {
+        events.append("destroy/");
+    }
+
+
+}

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

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

Added: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Managed.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Managed.java?rev=431450&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Managed.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Managed.java Mon Aug 14 15:34:00 2006
@@ -0,0 +1,118 @@
+/*
+ * ApplicationBean.java
+ *
+ * Created on August 13, 2006, 10:04 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.apache.shale.examples.test.tiger;
+
+import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Property;
+import org.apache.shale.tiger.managed.Scope;
+import org.apache.shale.tiger.view.Destroy;
+import org.apache.shale.tiger.view.Init;
+import org.apache.shale.tiger.view.Preprocess;
+import org.apache.shale.tiger.view.Prerender;
+import org.apache.shale.tiger.view.View;
+
+/**
+ * <p>View controller for the <code>/managed.jsp</code> view,
+ * completely configured via annotations.</p>
+ */
+@View
+@Bean(name="managed", scope=Scope.REQUEST)
+public class Managed {
+    
+
+    // ------------------------------------------------------- Public Properties
+
+
+    /**
+     * <p>Injected application bean instance.</p>
+     */
+    @Property(value="#{applicationBean}")
+    private ApplicationBean applicationBean;
+
+    public ApplicationBean getApplicationBean() {
+        return this.applicationBean;
+    }
+
+    public void setApplicationBean(ApplicationBean applicationBean) {
+        this.applicationBean = applicationBean;
+    }
+
+
+    /**
+     * <p>Render a stringified version of this instance.</p>
+     */
+    public String getDisplay() {
+        return toString();
+    }
+
+
+    /**
+     * <p>Return the events that have occurred so far.</p>
+     */
+    private StringBuffer events = new StringBuffer();
+
+    public String getEvents() {
+        return events.toString();
+    }
+
+
+
+    /**
+     * <p>Injected session bean instance.</p>
+     */
+    @Property(value="#{sessionBean}")
+    private SessionBean sessionBean;
+
+    public SessionBean getSessionBean() {
+        return this.sessionBean;
+    }
+
+    public void setSessionBean(SessionBean sessionBean) {
+        this.sessionBean = sessionBean;
+    }
+
+
+    // -------------------------------------------------------- Lifecycle Events
+
+
+    @Init
+    public void myInit() {
+        events.append("init/");
+    }
+
+
+    @Preprocess
+    public void myPreprocess() {
+        events.append("preprocess/");
+    }
+
+
+    @Prerender
+    public void myPrerender() {
+        events.append("prerender/");
+    }
+
+
+    @Destroy
+    public void myDestroy() {
+        events.append("destroy/");
+    }
+
+
+    // ------------------------------------------------------------- View Events
+
+
+    // Process a click on the resubmit link
+    public String resubmit() {
+        return null;
+    }
+
+
+}

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

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

Added: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/RequestBean.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/RequestBean.java?rev=431450&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/RequestBean.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/RequestBean.java Mon Aug 14 15:34:00 2006
@@ -0,0 +1,94 @@
+/*
+ * ApplicationBean.java
+ *
+ * Created on August 13, 2006, 10:04 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.apache.shale.examples.test.tiger;
+
+import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Property;
+import org.apache.shale.tiger.managed.Scope;
+import org.apache.shale.tiger.view.Destroy;
+import org.apache.shale.tiger.view.Init;
+import org.apache.shale.tiger.view.Request;
+
+/**
+ * <p>Request scope managed bean declared with annotations.</p>
+ */
+@Request
+@Bean(name="requestBean", scope=Scope.REQUEST)
+public class RequestBean {
+    
+
+    // ------------------------------------------------------- Public Properties
+
+
+    /**
+     * <p>Injected application bean instance.</p>
+     */
+    @Property(value="#{applicationBean}")
+    private ApplicationBean applicationBean;
+
+    public ApplicationBean getApplicationBean() {
+        return this.applicationBean;
+    }
+
+    public void setApplicationBean(ApplicationBean applicationBean) {
+        this.applicationBean = applicationBean;
+    }
+
+
+    /**
+     * <p>Render a stringified version of this instance.</p>
+     */
+    public String getDisplay() {
+        return toString();
+    }
+
+
+    /**
+     * <p>Return the events that have occurred so far.</p>
+     */
+    private StringBuffer events = new StringBuffer();
+
+    public String getEvents() {
+        return events.toString();
+    }
+
+
+
+    /**
+     * <p>Injected session bean instance.</p>
+     */
+    @Property(value="#{sessionBean}")
+    private SessionBean sessionBean;
+
+    public SessionBean getSessionBean() {
+        return this.sessionBean;
+    }
+
+    public void setSessionBean(SessionBean sessionBean) {
+        this.sessionBean = sessionBean;
+    }
+
+
+    // -------------------------------------------------------- Lifecycle Events
+
+
+    @Init
+    public void myInit() {
+        events.append("init/");
+    }
+
+
+    @Destroy
+    public void myDestroy() {
+        events.append("destroy/");
+    }
+
+
+}

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

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

Added: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/SessionBean.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/SessionBean.java?rev=431450&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/SessionBean.java (added)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/SessionBean.java Mon Aug 14 15:34:00 2006
@@ -0,0 +1,93 @@
+/*
+ * ApplicationBean.java
+ *
+ * Created on August 13, 2006, 10:04 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.apache.shale.examples.test.tiger;
+
+import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Property;
+import org.apache.shale.tiger.managed.Scope;
+import org.apache.shale.tiger.view.Activate;
+import org.apache.shale.tiger.view.Destroy;
+import org.apache.shale.tiger.view.Init;
+import org.apache.shale.tiger.view.Passivate;
+import org.apache.shale.tiger.view.Session;
+
+/**
+ * <p>Session scope managed bean declared with annotations.</p>
+ */
+@Session
+@Bean(name="sessionBean", scope=Scope.SESSION)
+public class SessionBean {
+    
+
+    // ------------------------------------------------------- Public Properties
+
+
+    /**
+     * <p>Injected application bean instance.</p>
+     */
+    @Property(value="#{applicationBean}")
+    private ApplicationBean applicationBean;
+
+    public ApplicationBean getApplicationBean() {
+        return this.applicationBean;
+    }
+
+    public void setApplicationBean(ApplicationBean applicationBean) {
+        this.applicationBean = applicationBean;
+    }
+
+
+    /**
+     * <p>Render a stringified version of this instance.</p>
+     */
+    public String getDisplay() {
+        return toString();
+    }
+
+
+    /**
+     * <p>Return the events that have occurred so far.</p>
+     */
+    private StringBuffer events = new StringBuffer();
+
+    public String getEvents() {
+        return events.toString();
+    }
+
+
+
+    // -------------------------------------------------------- Lifecycle Events
+
+
+    @Init
+    public void myInit() {
+        events.append("init/");
+    }
+
+
+    @Destroy
+    public void myDestroy() {
+        events.append("destroy/");
+    }
+
+
+    @Activate
+    public void myActivate() {
+        events.append("activate/");
+    }
+
+
+    @Passivate
+    public void myPassivate() {
+        events.append("passivate/");
+    }
+
+
+}

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

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

Modified: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml?rev=431450&r1=431449&r2=431450&view=diff
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml Mon Aug 14 15:34:00 2006
@@ -35,6 +35,10 @@
             <to-view-id>/annotated.jsp</to-view-id>
         </navigation-case>
         <navigation-case>
+            <from-outcome>managed</from-outcome>
+            <to-view-id>/managed.jsp</to-view-id>
+        </navigation-case>
+        <navigation-case>
             <from-outcome>menu</from-outcome>
             <to-view-id>/menu.jsp</to-view-id>
         </navigation-case>
@@ -50,6 +54,8 @@
 
     <!-- ========== View Controller Beans ========== -->
 
+    <!-- Bean "applicationBean" is declared with annotations -->
+
     <managed-bean>
         <managed-bean-name>annotated</managed-bean-name>
         <managed-bean-class>
@@ -58,6 +64,8 @@
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
 
+    <!-- Bean "managed" is declared with annotations -->
+
     <managed-bean>
         <managed-bean-name>standard</managed-bean-name>
         <managed-bean-class>
@@ -65,6 +73,10 @@
         </managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
+
+    <!-- Bean "requestBean" is declared with annotations -->
+
+    <!-- Bean "sessionBean" is declared with annotations -->
 
     <managed-bean>
         <managed-bean-name>status</managed-bean-name>

Added: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/managed.jsp
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/managed.jsp?rev=431450&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/managed.jsp (added)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/managed.jsp Mon Aug 14 15:34:00 2006
@@ -0,0 +1,109 @@
+<%--
+
+ Copyright 2006 The Apache Software Foundation.
+ 
+ Licensed 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" %>
+
+<f:view>
+<html>
+<head>
+    <title>Annotated ViewController and Managed Beans</title>
+</head>
+<body>
+
+    <h3>Annotated ViewController and Managed Beans</h3>
+
+    <table cellspacing="5">
+        <tr>
+            <th align="center">Category</th>
+            <th align="center">Value</th>
+            <th align="center">Events</th>
+        </tr>
+        <tr>
+            <th align="right">managed</th>
+            <td><h:outputText id="managedValue"
+                           value="#{managed.display}"/></td>
+            <td><h:outputText id="managedEvents"
+                            value="#{managed.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">managed.applicationBean</th>
+            <td><h:outputText id="managedApplicationValue"
+                           value="#{managed.applicationBean.display}"/></td>
+            <td><h:outputText id="managedApplicationEvents"
+                            value="#{managed.applicationBean.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">managed.requestBean</th>
+            <td><h:outputText id="managedRequestValue"
+                           value="#{managed.requestBean.display}"/></td>
+            <td><h:outputText id="managedRequestEvents"
+                            value="#{managed.requestBean.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">managed.sessionBean</th>
+            <td><h:outputText id="managedSessionValue"
+                           value="#{managed.sessionBean.display}"/></td>
+            <td><h:outputText id="managedSessionEvents"
+                            value="#{managed.sessionBean.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">applicationBean</th>
+            <td><h:outputText id="applicationValue"
+                           value="#{applicationBean.display}"/></td>
+            <td><h:outputText id="applicationEvents"
+                            value="#{applicationBean.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">requestBean</th>
+            <td><h:outputText id="requestValue"
+                           value="#{requestBean.display}"/></td>
+            <td><h:outputText id="requestEvents"
+                            value="#{requestBean.events}"/></td>
+        </tr>
+        <tr>
+            <th align="right">sessionBean</th>
+            <td><h:outputText id="sessionValue"
+                           value="#{sessionBean.display}"/></td>
+            <td><h:outputText id="applicationEvents"
+                            value="#{sessionBean.events}"/></td>
+        </tr>
+    </table>
+
+    <h:form id="form">
+      <h:commandLink id="resubmit" value="Resubmit" action="#{managed.resubmit}"/>
+    </h:form>
+
+    <h3>Test Description</h3>
+
+    <p>Describes the static state after multiple dependency injections
+    have occurred based on annotated managed beans.  The values for
+    <code>managed.application</code>, <code>managed.request</code>,
+    and <code>managed.session</code> should be equal to those for
+    accessing the beans directly, and the events should include only
+    <code>init/</code> for all beans except <code>managed</code>,
+    which should be <code>init/prerender/</code> on the initial execution
+    and <code>init/preprocess/prerender/</code> on a resubmit.</p>
+
+    <p><a href="menu.faces">Back</a> to main menu</p>
+
+</body>
+</html>
+</f:view>

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

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

Modified: shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp?rev=431450&r1=431449&r2=431450&view=diff
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp (original)
+++ shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp Mon Aug 14 15:34:00 2006
@@ -31,6 +31,7 @@
     <h3>Shale Test App (Tiger Extensions)</h3>
 
     <ul>
+        <li><a href="managed.faces">Annotated ViewController and Managed Beans</a></li>
         <li><a href="annotated.faces">Annotated ViewController Lifecycle Events</a></li>
         <li><a href="standard.faces">Standard ViewController Lifecycle Events</a></li>
         <li><a href="status.faces">Static Status Information</a></li>