[jboss-cvs] JBossAS SVN: r62575 - in branches/Branch_4_2: testsuite/src/main/org/jboss/test/web/servlets and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 25 21:45:26 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-04-25 21:45:26 -0400 (Wed, 25 Apr 2007)
New Revision: 62575

Added:
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java
   branches/Branch_4_2/testsuite/src/resources/web/class-loading/
   branches/Branch_4_2/testsuite/src/resources/web/class-loading/jboss-web.xml
   branches/Branch_4_2/testsuite/src/resources/web/class-loading/web.xml
Modified:
   branches/Branch_4_2/testsuite/imports/sections/naming.xml
   branches/Branch_4_2/testsuite/imports/sections/web.xml
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java
Log:
JBAS-3047, pickup the java2ClassLoadingCompliance from the war jboss-web.xml

Modified: branches/Branch_4_2/testsuite/imports/sections/naming.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/naming.xml	2007-04-25 22:46:42 UTC (rev 62574)
+++ branches/Branch_4_2/testsuite/imports/sections/naming.xml	2007-04-26 01:45:26 UTC (rev 62575)
@@ -103,7 +103,21 @@
             <include name="org/jboss/test/naming/interceptors/*"/>
          </fileset>
       </jar>
-      
+
+      <!-- A unified invoker test sar -->
+      <jar destfile="${build.lib}/naming-unified.sar">
+         <zipfileset dir="${build.resources}/naming/services"
+            fullpath="META-INF/jboss-service.xml">
+            <include name="unified-service.xml"/>
+         </zipfileset>
+         <fileset dir="${build.resources}/naming/services">
+            <include name="naming-xmbean.xml"/>
+         </fileset>
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/naming/interceptors/*"/>
+         </fileset>
+      </jar>
+
       <!-- ExternalContext sar -->
       <jar destfile="${build.lib}/extcontext.sar">
          <zipfileset dir="${build.resources}/naming/services"

Modified: branches/Branch_4_2/testsuite/imports/sections/web.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/web.xml	2007-04-25 22:46:42 UTC (rev 62574)
+++ branches/Branch_4_2/testsuite/imports/sections/web.xml	2007-04-26 01:45:26 UTC (rev 62575)
@@ -546,5 +546,25 @@
 
       </war>
 
+      <!-- War java2ClassLoadingCompliance=true test  -->
+      <war destfile="${build.lib}/class-loading.war"
+         webxml="${build.resources}/web/class-loading/web.xml">
+         <webinf dir="${build.resources}/web/class-loading">
+            <include name="jboss-web.xml"/>
+         </webinf>
+         <lib dir="${apache.log4j.lib}">
+            <include name="log4j.jar" />
+         </lib>
+         <lib dir="${build.lib}">
+            <include name="jbosstest-web-util.jar"/>
+            <include name="resources.jar"/>
+         </lib>
+         
+         <classes dir="${build.classes}">
+            <include name="org/jboss/test/web/servlets/ClasspathServlet2.class"/>
+            <include name="org/jboss/test/util/Debug.class"/>
+         </classes>
+      </war>
+
    </target>
 </project>

Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet.java	2007-04-25 22:46:42 UTC (rev 62574)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet.java	2007-04-26 01:45:26 UTC (rev 62575)
@@ -36,8 +36,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.log4j.Logger;
-
+import org.jboss.logging.Logger;
 import org.jboss.test.web.util.EJBManifestClass;
 import org.jboss.test.web.util.EarLibUser;
 import org.jboss.test.util.Debug;

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java	2007-04-26 01:45:26 UTC (rev 62575)
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+package org.jboss.test.web.servlets;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.util.Debug;
+
+/** A servlet that loads classes requested via the class request param.
+ *
+ * @author  Scott.Scott at jboss.org
+ * @version $Revision$
+ */
+public class ClasspathServlet2 extends HttpServlet
+{
+   private static final long serialVersionUID = 1;
+   private static Logger log = Logger.getLogger(ClasspathServlet2.class);
+
+   protected void doGet(HttpServletRequest request, HttpServletResponse response)
+      throws ServletException, IOException
+   {
+      processRequest(request, response);
+   }
+   
+   protected void doPost(HttpServletRequest request, HttpServletResponse response)
+      throws ServletException, IOException
+   {
+      processRequest(request, response);
+   }
+
+   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+      throws ServletException, IOException
+   {
+      String className = request.getParameter("class");
+
+      response.setContentType("text/html");
+      PrintWriter out = response.getWriter();
+      out.println("<html>");
+      out.println("<head><title>"+getServletName()+"</title></head>");
+      out.println("<body><h1>Class Info</h1>");
+      try
+      {
+         Class clazz = Class.forName(className);
+         ProtectionDomain pd = clazz.getProtectionDomain();
+         CodeSource cs = pd.getCodeSource();
+         response.addHeader("X-CodeSource", cs.getLocation().toString());
+         out.println("<pre>\n");
+         StringBuffer results = new StringBuffer();
+         Debug.displayClassInfo(clazz, results);
+         out.println(results.toString());
+         out.println("</pre>");
+      }
+      catch(Exception e)
+      {
+         log.debug("Failed to load "+className, e);
+         throw new ServletException("Failed to load "+className, e);
+      }
+
+      out.println("</html>");
+      out.close();
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java	2007-04-25 22:46:42 UTC (rev 62574)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java	2007-04-26 01:45:26 UTC (rev 62575)
@@ -433,7 +433,37 @@
       } // end of try-finally
       
    } 
-   
+
+   /**
+    * Validate a war level override of the 
+    * java2ClassLoadingComplianceOverride flag to true.
+    * 
+    * @throws Exception
+    */
+   public void testJava2ClassLoadingComplianceOverride() throws Exception
+   {
+      getLog().info("+++ Begin testJava2ClassLoadingComplianceOverride");
+      deploy("class-loading.war");
+      try
+      {
+         String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+         // Load a log4j class
+         URL url = new URL(baseURL+"class-loading/ClasspathServlet2?class=org.apache.log4j.net.SocketAppender");
+         HttpMethodBase request = HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
+         Header cs = request.getResponseHeader("X-CodeSource");
+         log.info(cs);
+         // Validate it has not come from the war
+         assertTrue("X-CodeSource("+cs+") does not contain war",
+               cs.getValue().indexOf(".war") < 0 );
+         getLog().debug(url+" OK");
+      }
+      finally
+      {
+         undeploy("class-loading.war");
+         getLog().info("+++ End testJava2ClassLoadingComplianceOverride");
+      }
+   }
+
    /** 
     * JBAS-3279: Authenticated user can bypass declarative role checks for servlets
     */

Added: branches/Branch_4_2/testsuite/src/resources/web/class-loading/jboss-web.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/web/class-loading/jboss-web.xml	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/web/class-loading/jboss-web.xml	2007-04-26 01:45:26 UTC (rev 62575)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-web PUBLIC
+    "-//JBoss//DTD Web Application 4.2//EN"
+    "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
+
+<jboss-web>
+    <!-- Use parent first class loading model -->
+    <class-loading java2ClassLoadingCompliance="true" />
+</jboss-web>


Property changes on: branches/Branch_4_2/testsuite/src/resources/web/class-loading/jboss-web.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/resources/web/class-loading/web.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/web/class-loading/web.xml	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/web/class-loading/web.xml	2007-04-26 01:45:26 UTC (rev 62575)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
+   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">
+
+   <description>Test of overriding class loading model at war level</description>
+
+   <!-- The Welcome File List -->
+   <welcome-file-list>
+      <welcome-file>index.html</welcome-file>
+   </welcome-file-list>
+
+   <servlet>
+      <servlet-name>ClasspathServlet2</servlet-name>
+      <servlet-class>org.jboss.test.web.servlets.ClasspathServlet2</servlet-class>
+   </servlet>
+
+   <servlet-mapping>
+      <servlet-name>ClasspathServlet2</servlet-name>
+      <url-pattern>/ClasspathServlet2</url-pattern>
+   </servlet-mapping>
+</web-app>


Property changes on: branches/Branch_4_2/testsuite/src/resources/web/class-loading/web.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java	2007-04-25 22:46:42 UTC (rev 62574)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java	2007-04-26 01:45:26 UTC (rev 62575)
@@ -135,7 +135,8 @@
       paths to the deployment UCL.
       */
       Loader webLoader = null;
-      if (config.isUseJBossWebLoader())
+      boolean isUseJBossWebLoader = metaData.getJava2ClassLoadingCompliance();
+      if (isUseJBossWebLoader)
       {
          WebCtxLoader jbossLoader = new WebCtxLoader(loader);
          jbossLoader.setWarURL(url);




More information about the jboss-cvs-commits mailing list