[jboss-cvs] JBossAS SVN: r60007 - in branches/Branch_4_2/testsuite: imports/sections and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 25 15:45:08 EST 2007


Author: stan.silvert at jboss.com
Date: 2007-01-25 15:45:08 -0500 (Thu, 25 Jan 2007)
New Revision: 60007

Added:
   branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/
   branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/
   branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/InjectionBean.java
   branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/JBossColor.java
   branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/MySessionBean.java
Removed:
   branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/WEB-INF/lib/
Modified:
   branches/Branch_4_2/testsuite/build.xml
   branches/Branch_4_2/testsuite/imports/sections/jsf.xml
   branches/Branch_4_2/testsuite/src/resources/web/WEB-INF/jsftest-web.xml
   branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/WEB-INF/faces-config.xml
   branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/index.jsp
Log:
http://jira.jboss.com/jira/browse/JBAS-4026


Modified: branches/Branch_4_2/testsuite/build.xml
===================================================================
--- branches/Branch_4_2/testsuite/build.xml	2007-01-25 20:13:54 UTC (rev 60006)
+++ branches/Branch_4_2/testsuite/build.xml	2007-01-25 20:45:08 UTC (rev 60007)
@@ -118,6 +118,7 @@
     <path refid="oswego.concurrent.classpath"/>
     <path refid="sun.jaxb.classpath"/>
     <path refid="sun.jaf.classpath"/>
+    <path refid="sun.jsf.classpath"/>
     <path refid="sun.javamail.classpath"/>
     <path refid="sun.servlet.classpath"/>
     <path refid="trove.classpath"/>

Modified: branches/Branch_4_2/testsuite/imports/sections/jsf.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/jsf.xml	2007-01-25 20:13:54 UTC (rev 60006)
+++ branches/Branch_4_2/testsuite/imports/sections/jsf.xml	2007-01-25 20:45:08 UTC (rev 60007)
@@ -1,17 +1,22 @@
 <project name="tests-jsf-jars">
    <!-- jsf test -->
    <target name="_jars-jsf">
-      <mkdir dir="${build.lib}"/>
-      <!-- build jbosstest-jsf.war -->
-      <war warfile="${build.lib}/jbosstest-jsf.war"
-         webxml="${build.resources}/web/WEB-INF/jsftest-web.xml">
-         <fileset dir="${build.resources}/web/html/jsftest">
-            <include name="**/*.jsp"/>
-         </fileset>
-         
-         <webinf dir="${build.resources}/web/html/jsftest/WEB-INF">
-            <include name="**/*"/>
-         </webinf>
-      </war>
+     <mkdir dir="${build.lib}"/>
+     <!-- build jbosstest-jsf.war -->
+     <war destfile="${build.lib}/jbosstest-jsf.war"
+       webxml="${build.resources}/web/WEB-INF/jsftest-web.xml">
+       <fileset dir="${build.resources}/web/html/jsftest">
+         <include name="**/*.jsp"/>
+       </fileset>
+
+       <classes dir="${build.classes}">
+          <include name="org/jboss/test/jsf/webapp/**"/>
+       </classes>
+
+       <webinf dir="${build.resources}/web/html/jsftest/WEB-INF">
+         <include name="**/*"/>
+       </webinf>
+     </war>
    </target>
+
 </project>

Added: branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/InjectionBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/InjectionBean.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/InjectionBean.java	2007-01-25 20:45:08 UTC (rev 60007)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.jsf.webapp;
+
+import java.util.Map;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+/**
+ * Tests resource injection and lifecycle annotations for JSF managed bean.
+ *
+ * @author Stan Silvert
+ */
+public class InjectionBean {
+    
+    private DataSource defaultDS;
+    
+    private boolean postConstructCalled = false;
+    private boolean datasourceInjected = false;
+    
+    // This bean lives in the HttpSession.  Save a reference here.
+    private MySessionBean mySessionBean = null;
+    
+    /** Creates a new instance of InjectionBean */
+    public InjectionBean() {
+    }
+    
+    public String getName() {
+        return "InjectionBean";
+    }
+    
+    public boolean getPostConstructCalled() {
+        return this.postConstructCalled;
+    }
+    
+    public boolean getDatasourceInjected() {
+        return this.datasourceInjected;
+    }
+
+    // TODO: test this annotation on a private method
+    @PostConstruct
+    private void testPostConstruct() {
+        this.postConstructCalled = true;
+        
+        Object dataSourceFromLookup = null;
+        try {
+            dataSourceFromLookup = new InitialContext().lookup("java:/DefaultDS");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        if (defaultDS == dataSourceFromLookup) {
+            this.datasourceInjected = true;
+        } 
+        
+        // doing this puts an instance of MySesisonBean into the session
+        ValueExpression preDestroyVe = expressionFactory().createValueExpression(elContext(), "#{mySessionBean}", MySessionBean.class);
+        this.mySessionBean = (MySessionBean)preDestroyVe.getValue(elContext());
+        
+    }
+    
+    private ELContext elContext() {
+        return FacesContext.getCurrentInstance().getELContext();
+    }
+    
+    private ExpressionFactory expressionFactory() {
+        return FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
+    }
+    
+    @PreDestroy
+    public void testPreDestroy() {
+        this.mySessionBean.setPreDestroyCalled(true);
+    }
+    
+    @Resource(name="java:/DefaultDS")
+    public void setDefaultDS(DataSource dataSource) {
+        this.defaultDS = dataSource;
+    }
+    
+}

Added: branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/JBossColor.java
===================================================================
--- branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/JBossColor.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/JBossColor.java	2007-01-25 20:45:08 UTC (rev 60007)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.jsf.webapp;
+
+/**
+ * Simple enumeration of colors.
+ *
+ * @author Stan Silvert
+ */
+public enum JBossColor {
+  RED, BLUE, ORANGE, GREEN, PURPLE, YELLOW, TEAL
+}

Added: branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/MySessionBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/MySessionBean.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/jdk15/org/jboss/test/jsf/webapp/MySessionBean.java	2007-01-25 20:45:08 UTC (rev 60007)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.jsf.webapp;
+
+/**
+ * Session bean used to tell if @PreDestroy was called on the InjectionBean.
+ *
+ * Also allows you to get the numList for testing JSTL/JSF integration.
+ *
+ * @author Stan Silvert
+ */
+public class MySessionBean {
+    
+    private String[] numList = {"number one", "number two", "number three"};
+    
+    private boolean preDestroyCalled = false;
+
+    private JBossColor color = JBossColor.PURPLE;
+    
+    public boolean isPreDestroyCalled() {
+        return this.preDestroyCalled;
+    }
+    
+    public void setPreDestroyCalled(boolean preDestroyCalled) {
+        this.preDestroyCalled = preDestroyCalled;
+    }
+
+    public JBossColor getColor() {
+        return this.color;
+    }
+
+    public void setColor(JBossColor color) {
+        this.color = color;
+    }
+    
+    public String[] getNumList() {
+        return this.numList;
+    }
+    
+    public void setNumList(String[] numList) {
+        this.numList = numList;
+    }
+}

Modified: branches/Branch_4_2/testsuite/src/resources/web/WEB-INF/jsftest-web.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/web/WEB-INF/jsftest-web.xml	2007-01-25 20:13:54 UTC (rev 60006)
+++ branches/Branch_4_2/testsuite/src/resources/web/WEB-INF/jsftest-web.xml	2007-01-25 20:45:08 UTC (rev 60007)
@@ -1,27 +1,20 @@
-<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
-   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-   "http://java.sun.com/dtd/web-app_2_3.dtd">
+<?xml version="1.0" encoding="UTF-8"?>
 
-<web-app> 
-   <!-- Listener, that does all the startup work (configuration, init). -->
-    <listener>
-        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
-    </listener>
-
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+	 version="2.4">
+    <!-- The JavaServer Faces Servlet -->
    <servlet>
-      <servlet-name>Faces Servlet</servlet-name>
-      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
-      <load-on-startup>1</load-on-startup>
+      <servlet-name>javax.faces.FacesServlet</servlet-name>
+      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>             
+
+      <load-on-startup>6</load-on-startup>
    </servlet>   
    
+   <!-- Mappings for JavaServer Faces Servlet -->
    <servlet-mapping>
-      <servlet-name>Faces Servlet</servlet-name>
-      <url-pattern>*.faces</url-pattern>
+      <servlet-name>javax.faces.FacesServlet</servlet-name>
+      <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>  
-
-   <welcome-file-list>
-      <welcome-file>index.jsp</welcome-file>
-   </welcome-file-list>
-   
 </web-app>

Modified: branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/WEB-INF/faces-config.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/WEB-INF/faces-config.xml	2007-01-25 20:13:54 UTC (rev 60006)
+++ branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/WEB-INF/faces-config.xml	2007-01-25 20:45:08 UTC (rev 60007)
@@ -1,10 +1,22 @@
-<?xml version="1.0"?>
+<?xml version='1.0' encoding='UTF-8'?>
 
-<!DOCTYPE faces-config PUBLIC
-  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
-  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+              version="1.2">
 
-<faces-config>
+   <managed-bean> 
+      <description>Injection Test</description>
+      <managed-bean-name>injectionBean</managed-bean-name>
+      <managed-bean-class>org.jboss.test.jsf.webapp.InjectionBean</managed-bean-class> 
+      <managed-bean-scope>request</managed-bean-scope> 
+   </managed-bean>
    
-
+   <managed-bean> 
+      <description>Session Scope Bean</description>
+      <managed-bean-name>mySessionBean</managed-bean-name>
+      <managed-bean-class>org.jboss.test.jsf.webapp.MySessionBean</managed-bean-class> 
+      <managed-bean-scope>session</managed-bean-scope> 
+   </managed-bean>
+   
 </faces-config>

Modified: branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/index.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/index.jsp	2007-01-25 20:13:54 UTC (rev 60006)
+++ branches/Branch_4_2/testsuite/src/resources/web/html/jsftest/index.jsp	2007-01-25 20:45:08 UTC (rev 60007)
@@ -1,22 +1,42 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+
 <html>
-   <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-   <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
-   <%@ taglib uri="http://java.sun.com/jsf/demo/components" prefix="d" %>
-   
-   <f:view>
-      <head>          
-         <title><h:outputText value="Hello from JSF"/></title>
-      </head>
-      <body>
-         <h:outputText value="Hello from JSF"/>
-         <br><br>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>JBoss JSF Integration Test</title>
+    </head>
+    <body>
+
+     <f:view>
+         <font color="red"><h1><h:outputText value="#{injectionBean.name}: hit this page twice to complete the test."/></h1></font>
+         <h3><h:outputText rendered="#{injectionBean.postConstructCalled}" value="@PostConstruct was called."/></h3>
+         <h3><h:outputText rendered="#{mySessionBean.preDestroyCalled}" value="@PreDestroy was called."/></h3>
+         <h3><h:outputText rendered="#{injectionBean.datasourceInjected}" value="Datasource was injected."/></h3>
          
-<!-- Generate the HTML for the custom JSF component, but don't try to render the chart -->
-<!-- This tests that TLD's can be read from WEB-INF/lib/*.jar                          -->
-         <d:chart width="10" height="10" type="PieChart">
-             <d:chartItem itemColor="blue" itemLabel="foo" itemValue="10" />
-         </d:chart>  
+         <%
+               // I think that the fact I need to do this constitutes a bug in JSTL
+               if (session.getAttribute("mySessionBean") == null) {
+                    session.setAttribute("mySessionBean", new org.jboss.test.jsf.webapp.MySessionBean()); 
+               }
+          %>
+          
+         <font color="red"><h1>Classic test of JSTL 1.2/JSF 1.2 with deferred expressions:</h1></font>
+         <c:forEach var="item" items="#{mySessionBean.numList}">
+             <h3><h:outputText value="#{item}"/></h3>
+         </c:forEach>
 
-      </body>
-   </f:view>
-</html>
\ No newline at end of file
+         <font color="red"><h1>ServletContext Minor Version Test (should return 5)</h1></font>
+         <h3><h:outputText value="ServletContext.getMinorVersion() = #{application.minorVersion}"/></h3>
+
+         <font color="red"><h1>Enum Test</h1></font>
+         <h3><h:outputText rendered="#{mySessionBean.color == 'PURPLE'}" 
+                           value="JBoss Color selection is #{mySessionBean.color}"
+                           /></h3>
+     </f:view>
+ 
+    </body>
+</html>




More information about the jboss-cvs-commits mailing list