[jboss-cvs] JBossAS SVN: r62660 - in trunk: testsuite and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 30 16:14:14 EDT 2007


Author: stan.silvert at jboss.com
Date: 2007-04-30 16:14:14 -0400 (Mon, 30 Apr 2007)
New Revision: 62660

Added:
   trunk/testsuite/src/resources/web/WEB-INF/bundled-myfaces-jsf.xml
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/WEB-INF/
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/WEB-INF/faces-config.xml
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/finalgreeting.jsp
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.html
   trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.jsp
Modified:
   trunk/build/build-thirdparty.xml
   trunk/testsuite/build.xml
   trunk/testsuite/imports/sections/jsf.xml
   trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/jasper/JspServletOptions.java
Log:
JBAS-4383


Modified: trunk/build/build-thirdparty.xml
===================================================================
--- trunk/build/build-thirdparty.xml	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/build/build-thirdparty.xml	2007-04-30 20:14:14 UTC (rev 62660)
@@ -71,6 +71,7 @@
       <componentref name="asm" version="1.5.3"/>
       <componentref name="beanshell" version="1.3.0"/>
       <componentref name="cglib" version="2.1.3.nodep"/>
+      <componentref name="commons-el" version="1.0"/>
       <componentref name="dom4j" version="1.6.1jboss"/>
       <componentref name="easymock" version="1.1"/>
       <componentref name="ehcache" version="1.2.0.GA"/>
@@ -80,6 +81,7 @@
       <componentref name="hibernate-annotations" version="3.2.0.GA"/>
       <componentref name="hibernate-entitymanager" version="3.2.0.GA"/>
       <componentref name="hsqldb" version="1.8.0.2"/>
+      <componentref name="httpunit" version="1.6"/>
       <componentref name="jacorb" version="2.2.4jboss.patch1"/>
       <componentref name="javassist" version="3.5.0.CR1"/>
       <componentref name="jaxen" version="1.1-beta-10"/>
@@ -113,6 +115,7 @@
       <componentref name="joesnmp" version="0.3.4"/>
       <componentref name="juddi" version="0.9RC4"/>
       <componentref name="junit" version="3.8.1"/>
+      <componentref name="nekohtml" version="0.9.1"/>
       <componentref name="objectweb-joramtests" version="1.3"/>
       <componentref name="odmg" version="3.0"/>
       <componentref name="opensaml" version="1.1b"/>

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/testsuite/build.xml	2007-04-30 20:14:14 UTC (rev 62660)
@@ -100,6 +100,7 @@
       <path refid="apache.xerces.classpath"/>
       <path refid="apache.xmlsec.classpath"/>
       <path refid="dom4j.dom4j.classpath"/>
+      <path refid="httpunit.httpunit.classpath"/>
       <path refid="ibm.wsdl4j.classpath"/>
       <path refid="jacorb.jacorb.classpath"/>
       <path refid="jgroups.jgroups.classpath"/>
@@ -107,6 +108,7 @@
       <path refid="junit.junit.classpath"/>
       <path refid="javassist.classpath"/>
       <path refid="juddi.juddi.classpath"/>
+      <path refid="nekohtml.nekohtml.classpath"/>
       <path refid="objectweb.joramtests.classpath"/>
       <path refid="opensaml.opensaml.classpath"/>
       <path refid="oswego.concurrent.classpath"/>

Modified: trunk/testsuite/imports/sections/jsf.xml
===================================================================
--- trunk/testsuite/imports/sections/jsf.xml	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/testsuite/imports/sections/jsf.xml	2007-04-30 20:14:14 UTC (rev 62660)
@@ -17,6 +17,46 @@
          <include name="**/*"/>
        </webinf>
      </war>
+
+     <!-- make WAR for testing legacy WARs that bundle MyFaces -->
+     <war destfile="${build.lib}/bundled-myfaces-hellojsf.war"
+       webxml="${build.resources}/web/WEB-INF/bundled-myfaces-jsf.xml">
+       <lib dir="${apache.myfaces.lib}">
+            <include name="myfaces-api-1.1.3.jar"/>
+            <include name="myfaces-impl-1.1.3.jar"/>
+            <include name="jstl-1.1.0.jar"/>
+       </lib>
+       <lib dir="${apache.beanutils.lib}">
+            <include name="commons-beanutils.jar"/>
+       </lib>
+       <lib dir="${apache.codec.lib}">
+            <include name="commons-codec.jar"/>
+       </lib>
+       <lib dir="${apache.collections.lib}">
+            <include name="commons-collections.jar"/>
+       </lib>
+       <lib dir="${apache.digester.lib}">
+            <include name="commons-digester.jar"/>
+       </lib>
+       <lib dir="${apache.lang.lib}">
+            <include name="commons-lang.jar"/>
+       </lib>
+       <lib dir="${commons.el.lib}">
+            <include name="commons-el.jar"/>
+       </lib>
+
+
+       <fileset dir="${build.resources}/web/html/bundledmyfacesjsftest">
+         <include name="**/*.jsp"/>
+         <include name="**/*.html"/>
+       </fileset>
+
+       <webinf dir="${build.resources}/web/html/bundledmyfacesjsftest/WEB-INF">
+         <include name="**/*"/>
+       </webinf>
+  
+     </war>
+
    </target>
 
 </project>

Modified: trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java	2007-04-30 20:14:14 UTC (rev 62660)
@@ -34,6 +34,12 @@
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.methods.GetMethod;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.SubmitButton;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebForm;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
 
 /** Tests of JSF integration into the JBoss server. This test
  requires than a web container and JSF implementation be integrated 
@@ -85,6 +91,23 @@
       assertTrue(contains(responseBody, "JBoss Color selection is PURPLE"));
    }   
 
+   public void testJSFAppWithBundledMyFaces() throws Exception
+   {
+      WebConversation webConversation = new WebConversation();
+      
+      // Initial JSF request
+      WebRequest req = new GetMethodWebRequest(baseURL + "bundled-myfaces-hellojsf/index.faces");
+      WebResponse webResponse = webConversation.getResponse(req);
+      assertTrue(contains(webResponse.getText(), "Enter your name"));
+
+      // submit data
+      WebForm form = webResponse.getFormWithID("form1");
+      form.setParameter("form1:input_foo_text", "Stan");
+      SubmitButton submitButton = form.getSubmitButtonWithID("form1:submit_button");
+      webResponse = form.submit(submitButton);
+      assertTrue(contains(webResponse.getText(), "Hello Stan"));
+   }
+
    private boolean contains(String base, String target) {
       return base.indexOf(target) != -1;
    }
@@ -105,10 +128,12 @@
          {
             super.setUp();
             deploy("jbosstest-jsf.war");           
+            deploy("bundled-myfaces-hellojsf.war");
          }
          protected void tearDown() throws Exception
          {
             undeploy("jbosstest-jsf.war");
+            undeploy("bundled-myfaces-hellojsf.war");
             super.tearDown();            
          }
       };

Added: trunk/testsuite/src/resources/web/WEB-INF/bundled-myfaces-jsf.xml
===================================================================
--- trunk/testsuite/src/resources/web/WEB-INF/bundled-myfaces-jsf.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/WEB-INF/bundled-myfaces-jsf.xml	2007-04-30 20:14:14 UTC (rev 62660)
@@ -0,0 +1,31 @@
+<?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">
+
+<web-app>    
+
+   <context-param>
+     <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
+     <param-value>true</param-value>
+   </context-param>
+
+   <listener>
+     <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+   </listener>
+
+   <servlet>
+      <servlet-name>Faces Servlet</servlet-name>
+      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+      <load-on-startup>1</load-on-startup>
+   </servlet>      
+
+   <servlet-mapping>
+      <servlet-name>Faces Servlet</servlet-name>
+      <url-pattern>*.faces</url-pattern>
+   </servlet-mapping>  
+   
+   <welcome-file-list>
+      <welcome-file>index.html</welcome-file>
+   </welcome-file-list>
+</web-app>

Added: trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/WEB-INF/faces-config.xml
===================================================================
--- trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/WEB-INF/faces-config.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/WEB-INF/faces-config.xml	2007-04-30 20:14:14 UTC (rev 62660)
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+
+<!DOCTYPE faces-config PUBLIC
+  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+
+  <navigation-rule>
+    <from-view-id>/index.jsp</from-view-id>
+    <navigation-case>
+      <from-outcome>/finalgreeting.jsp</from-outcome>
+      <to-view-id>/finalgreeting.jsp</to-view-id>
+    </navigation-case>
+  </navigation-rule>
+
+  <managed-bean>
+    <description>Use a swing Button as a simple javabean</description>
+    <managed-bean-name>foo</managed-bean-name>
+    <managed-bean-class>javax.swing.JButton</managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+
+</faces-config>

Added: trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/finalgreeting.jsp
===================================================================
--- trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/finalgreeting.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/finalgreeting.jsp	2007-04-30 20:14:14 UTC (rev 62660)
@@ -0,0 +1,36 @@
+<%--
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<HTML>
+
+<f:view>  
+   
+      <h:outputText value="Bye #{foo.text}. I enjoyed our chat." id="finalgreeting"/><br/>
+
+</f:view>
+
+</HTML>

Added: trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.html
===================================================================
--- trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.html	                        (rev 0)
+++ trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.html	2007-04-30 20:14:14 UTC (rev 62660)
@@ -0,0 +1,9 @@
+<html> 
+   <head>
+      <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
+      <title>Start Web Application</title>
+   </head>
+   <body>
+      <p>Please wait for the web application to start.</p>   
+   </body> 
+</html>

Added: trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.jsp
===================================================================
--- trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/web/html/bundledmyfacesjsftest/index.jsp	2007-04-30 20:14:14 UTC (rev 62660)
@@ -0,0 +1,47 @@
+<%--
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<HTML>
+
+<f:view>  
+   <h:form id="form1">    
+      
+      <h:outputText value="Enter your name:" rendered="#{empty foo.text}" id="prompt"/>
+      <h:outputText value="Hello #{foo.text}" rendered="#{!empty foo.text}" id="greeting"/><br/>
+      
+      <h:inputText value="#{foo.text}" id="input_foo_text">          
+        <f:validateLength minimum="2"/>
+      </h:inputText>
+      <h:message for="input_foo_text" styleClass="errorMessage"/>
+      <br/>
+      <h:commandButton value="Submit" action="/index.jsp" id="submit_button"/>
+      <h:commandButton value="Goodbye" action="/finalgreeting.jsp" id="goodbye_button"/>
+
+   </h:form>
+</f:view>
+
+</HTML>

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2007-04-30 20:14:14 UTC (rev 62660)
@@ -37,17 +37,25 @@
  */
 public class JBossJSFConfigureListener extends ConfigureListener 
 {
-    
+    private static final String WAR_BUNDLES_JSF_IMPL = "org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL";
+   
     private static Logger LOG = Logger.getLogger(JBossJSFConfigureListener.class);
     
     public static final String SHOULD_LOG_CONFIG_MESSAGES = "com.sun.faces.displayConfiguration";
     
     private ServletContext servletContext;
     
+    public static boolean warBundlesJSFImpl(ServletContext servletContext)
+    {
+       String bundledJSFImpl = servletContext.getInitParameter(WAR_BUNDLES_JSF_IMPL);
+       return (bundledJSFImpl != null) && bundledJSFImpl.equalsIgnoreCase("true");
+    }
+
     @Override
     public void contextInitialized(ServletContextEvent event) 
     {
         this.servletContext = event.getServletContext();
+        if (warBundlesJSFImpl(this.servletContext)) return;
         
         // If the pluginClass is not set, assume Log4J
         if (System.getProperty("org.jboss.logging.Logger.pluginClass") == null) 
@@ -84,7 +92,7 @@
             Thread.currentThread()
                   .getContextClassLoader()
                   .loadClass("org.apache.myfaces.webapp.StartupServletContextListener");
-            LOG.warn("MyFaces JSF implementation found!  This version of JBoss AS ships with the java.net implementation of JSF.  There are known issues when mixing JSF implementations.  This warning does not apply to MyFaces component libraries such as Tomahawk.  However, myfaces-impl.jar and myfaces-api.jar should not be used without surgical removal of the java.net JSF implementation.  See the JBoss wiki for more details.");
+            LOG.warn("MyFaces JSF implementation found!  This version of JBoss AS ships with the java.net implementation of JSF.  There are known issues when mixing JSF implementations.  This warning does not apply to MyFaces component libraries such as Tomahawk.  However, myfaces-impl.jar and myfaces-api.jar should not be used without disabling the built-in JSF implementation.  See the JBoss wiki for more details.");
         }
         catch (ClassNotFoundException e)
         {

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/jasper/JspServletOptions.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/jasper/JspServletOptions.java	2007-04-30 20:08:27 UTC (rev 62659)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/jasper/JspServletOptions.java	2007-04-30 20:14:14 UTC (rev 62660)
@@ -32,6 +32,7 @@
 import org.apache.jasper.compiler.TagPluginManager;
 import org.apache.jasper.compiler.Localizer;
 import org.jboss.logging.Logger;
+import org.jboss.web.jsf.integration.config.JBossJSFConfigureListener;
 
 /**
  * Override the default JspServletOptions to externalize the jsp layer
@@ -804,7 +805,7 @@
       {
          String name = base + count;
          jarPath = config.getInitParameter(name);
-         if( jarPath != null )
+         if( (jarPath != null) && okToAddTagsFromJSFLibs(jarPath, context) )
             tldJars.add(jarPath);
          count ++;
       } while( jarPath != null );
@@ -818,4 +819,12 @@
       tagPluginManager = new TagPluginManager(context);
    }
 
+   private boolean okToAddTagsFromJSFLibs(String jarPath, ServletContext context)
+   {
+      // if it's not coming from jsf-libs you can always add it
+      if (!jarPath.startsWith("jsf-libs")) return true;
+
+      return !JBossJSFConfigureListener.warBundlesJSFImpl(context);
+   }
+
 }




More information about the jboss-cvs-commits mailing list