[jboss-cvs] JBossAS SVN: r62576 - in trunk: 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 22:26:16 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-04-25 22:26:16 -0400 (Wed, 25 Apr 2007)
New Revision: 62576

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

Modified: trunk/testsuite/imports/sections/web.xml
===================================================================
--- trunk/testsuite/imports/sections/web.xml	2007-04-26 01:45:26 UTC (rev 62575)
+++ trunk/testsuite/imports/sections/web.xml	2007-04-26 02:26:16 UTC (rev 62576)
@@ -606,5 +606,24 @@
          </fileset>
       </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>

Added: trunk/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java	2007-04-26 02:26:16 UTC (rev 62576)
@@ -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: trunk/testsuite/src/main/org/jboss/test/web/servlets/ClasspathServlet2.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: trunk/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java	2007-04-26 01:45:26 UTC (rev 62575)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java	2007-04-26 02:26:16 UTC (rev 62576)
@@ -443,6 +443,36 @@
    }
 
    /**
+    * 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");
+      }
+   }
+
+   /**
     * Setup the test suite.
     */
    public static Test suite() throws Exception

Added: trunk/testsuite/src/resources/web/class-loading/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/web/class-loading/jboss-web.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/class-loading/jboss-web.xml	2007-04-26 02:26:16 UTC (rev 62576)
@@ -0,0 +1,10 @@
+<?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>
+    
\ No newline at end of file


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

Added: trunk/testsuite/src/resources/web/class-loading/web.xml
===================================================================
--- trunk/testsuite/src/resources/web/class-loading/web.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/class-loading/web.xml	2007-04-26 02:26:16 UTC (rev 62576)
@@ -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: trunk/testsuite/src/resources/web/class-loading/web.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2007-04-26 01:45:26 UTC (rev 62575)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2007-04-26 02:26:16 UTC (rev 62576)
@@ -166,7 +166,7 @@
 
       Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
       if (webLoader == null)
-         webLoader = getWebLoader(webApp.getDeploymentUnit(), loader, url);
+         webLoader = getWebLoader(webApp.getDeploymentUnit(), metaData, loader, url);
 
       webApp.setName(url.getPath());
       webApp.setClassLoader(loader);
@@ -509,7 +509,8 @@
 
    }
 
-   public Loader getWebLoader(DeploymentUnit unit, ClassLoader loader, URL url) throws MalformedURLException
+   public Loader getWebLoader(DeploymentUnit unit, WebMetaData metaData, ClassLoader loader, URL url)
+      throws MalformedURLException
    {
       Loader webLoader = null;
 
@@ -539,7 +540,7 @@
          }
       }
 
-      if (config.isUseJBossWebLoader())
+      if (metaData.getJava2ClassLoadingCompliance())
       {
          WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
          if (classpath != null)




More information about the jboss-cvs-commits mailing list