[jboss-cvs] JBossAS SVN: r75863 - in trunk/testsuite: src/main/org/jboss/test/classloader and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 16 00:13:59 EDT 2008
Author: scott.stark at jboss.org
Date: 2008-07-16 00:13:59 -0400 (Wed, 16 Jul 2008)
New Revision: 75863
Added:
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.java
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener1.java
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener2.java
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Sequencer.java
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/SequencerMBean.java
trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/package.html
trunk/testsuite/src/resources/classloader/sharing/
trunk/testsuite/src/resources/classloader/sharing/staticarray/
trunk/testsuite/src/resources/classloader/sharing/staticarray/jboss-service.xml
trunk/testsuite/src/resources/classloader/sharing/staticarray/validate.jsp
trunk/testsuite/src/resources/classloader/sharing/staticarray/web1.xml
trunk/testsuite/src/resources/classloader/sharing/staticarray/web2.xml
Modified:
trunk/testsuite/imports/sections/classloader.xml
trunk/testsuite/src/main/org/jboss/test/classloader/test/ScopingUnitTestCase.java
Log:
JBAS-5773, add a test which illustrates nested war with manifest classpath class sharing issues
Modified: trunk/testsuite/imports/sections/classloader.xml
===================================================================
--- trunk/testsuite/imports/sections/classloader.xml 2008-07-16 02:37:10 UTC (rev 75862)
+++ trunk/testsuite/imports/sections/classloader.xml 2008-07-16 04:13:59 UTC (rev 75863)
@@ -556,6 +556,55 @@
<include name="simple.jsp"/>
</fileset>
</war>
-
- </target>
+
+ <!-- ScopingUnitTestCase.testNestedWarManifest staticarray.sar -->
+ <jar destfile="${build.lib}/staticarray-web1.war">
+ <manifest>
+ <attribute name="Class-Path" value="staticarray1.jar"/>
+ </manifest>
+ <zipfileset dir="${build.resources}/classloader/sharing/staticarray"
+ fullpath="WEB-INF/web.xml" >
+ <include name="web1.xml" />
+ </zipfileset>
+ <fileset dir="${build.resources}/classloader/sharing/staticarray">
+ <include name="validate.jsp"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/staticarray-web2.war">
+ <manifest>
+ <attribute name="Class-Path" value="staticarray1.jar staticarray2.jar"/>
+ </manifest>
+ <zipfileset dir="${build.resources}/classloader/sharing/staticarray"
+ fullpath="WEB-INF/web.xml">
+ <include name="web2.xml" />
+ </zipfileset>
+ <fileset dir="${build.resources}/classloader/sharing/staticarray">
+ <include name="validate.jsp"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/staticarray1.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/classloader/sharing/staticarray/common/Sequencer*.class" />
+ <include name="org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.class" />
+ <include name="org/jboss/test/classloader/sharing/staticarray/common/Listener1.class" />
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/staticarray2.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.class" />
+ <include name="org/jboss/test/classloader/sharing/staticarray/common/Listener2.class" />
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/staticarray.sar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/util/Debug.class" />
+ </fileset>
+ <fileset dir="${build.lib}">
+ <include name="staticarray1.jar" />
+ <include name="staticarray2.jar" />
+ <include name="staticarray-web1.war" />
+ <include name="staticarray-web2.war" />
+ </fileset>
+ </jar>
+ </target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/AbstractServletRequestListener.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.classloader.sharing.staticarray.common;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+
+import org.jboss.test.classloader.sharing.staticarray.common.Sequencer;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public abstract class AbstractServletRequestListener implements
+ ServletRequestListener
+{
+
+ public void requestDestroyed(ServletRequestEvent sre)
+ {
+ }
+
+ public void requestInitialized(ServletRequestEvent sre)
+ {
+ ServletRequest sr = sre.getServletRequest();
+ String op = sr.getParameter("op");
+ if(op != null)
+ {
+ if(op.equalsIgnoreCase("set"))
+ {
+ String value = sr.getParameter("array");
+ if(value == null)
+ throw new IllegalStateException("op=set requires an array=x,y,z... value");
+ String[] values = value.split(",");
+ int[] array = new int[values.length];
+ for(int n = 0; n < values.length; n ++)
+ array[n] = Integer.parseInt(values[n]);
+ setArray(array);
+ }
+ }
+ // Copy the current info array to the Sequencer.info attribute
+ Integer[] info = Sequencer.info;
+ sr.setAttribute("Sequencer.info", info);
+ }
+
+ protected void setArray(int[] array)
+ {
+ Sequencer.setInfo(array);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener1.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener1.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener1.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.classloader.sharing.staticarray.common;
+
+/**
+ * A ServletRequestListener found in the sar
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Listener1
+ extends AbstractServletRequestListener
+{
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener2.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener2.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Listener2.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.classloader.sharing.staticarray.common;
+
+/**
+ * A ServletRequestListener found in the sar
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Listener2
+ extends AbstractServletRequestListener
+{
+}
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Sequencer.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Sequencer.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/Sequencer.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.classloader.sharing.staticarray.common;
+
+import java.util.Arrays;
+
+/**
+ * Class with a static public int array
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Sequencer
+ implements SequencerMBean
+{
+ public static Integer[] info = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+ public synchronized static void setInfo(int[] array)
+ {
+ info = new Integer[array.length];
+ for(int n = 0; n < array.length; n ++)
+ info[n] = array[n];
+ }
+
+ public synchronized void randomize()
+ {
+ }
+
+ public synchronized void reverse()
+ {
+ Integer[] tmp = new Integer[info.length];
+ for(int n = 0; n < info.length; n ++)
+ tmp[n] = info[n];
+ info = tmp;
+ }
+
+ public synchronized void set(int[] array)
+ {
+ setInfo(array);
+ }
+
+ public synchronized void sort()
+ {
+ Arrays.sort(info);
+ }
+
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/SequencerMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/SequencerMBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/common/SequencerMBean.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.classloader.sharing.staticarray.common;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface SequencerMBean
+{
+ /**
+ * Randomize the int array
+ */
+ public void randomize();
+ /**
+ * sort the int array
+ */
+ public void sort();
+ /**
+ * Reverse the int array
+ */
+ public void reverse();
+ /**
+ * Set the int array value
+ * @param array
+ */
+ public void set(int[] array);
+}
Added: trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/package.html
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/package.html (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/sharing/staticarray/package.html 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<a href='http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163225'></a>
+</body>
+</html>
Modified: trunk/testsuite/src/main/org/jboss/test/classloader/test/ScopingUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/test/ScopingUnitTestCase.java 2008-07-16 02:37:10 UTC (rev 75862)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/test/ScopingUnitTestCase.java 2008-07-16 04:13:59 UTC (rev 75863)
@@ -27,9 +27,12 @@
import javax.management.ObjectName;
import javax.naming.InitialContext;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethodBase;
import org.jboss.test.JBossTestCase;
import org.jboss.test.classloader.scoping.override.ejb.log4j113.StatelessSession;
import org.jboss.test.classloader.scoping.override.ejb.log4j113.StatelessSessionHome;
+import org.jboss.test.util.web.HttpUtils;
import org.jboss.system.ServiceMBean;
import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
import org.jboss.mx.loading.RepositoryClassLoader;
@@ -212,6 +215,47 @@
}
}
+ /**
+ * Deploy a sar with nested wars that reference jars in
+ * the sar through the war manifest classpath.
+ */
+ public void testNestedWarManifest()
+ throws Exception
+ {
+ getLog().debug("+++ testNestedWarManifest");
+ String baseURL = HttpUtils.getBaseURL();
+ URL url = new URL(baseURL+"staticarray-web1/validate.jsp"
+ + "?Sequencer.info.expected=1,2,3,4,5,6,7,8,9,10"
+ + "&op=set"
+ + "&array=1,2,3,4,5,6,7,8,9,10");
+ try
+ {
+ deploy("staticarray.sar");
+ // Set the static array value to a non-default from war1
+ HttpMethodBase request = HttpUtils.accessURL(url);
+ Header errors = request.getResponseHeader("X-Error");
+ log.info("war1 X-Error: "+errors);
+ assertTrue("war1 X-Error("+errors+") is null", errors == null);
+ // Validate that war2 sees the changed values
+ url = new URL(baseURL+"staticarray-web2/validate.jsp"
+ + "?Sequencer.info.expected=1,2,3,4,5,6,7,8,9,10");
+ request = HttpUtils.accessURL(url);
+ errors = request.getResponseHeader("X-Error");
+ log.info("war2 X-Error: "+errors);
+ assertTrue("war2 X-Error("+errors+") is null", errors == null);
+
+ }
+ catch(Exception e)
+ {
+ getLog().info("Failed to access: "+url, e);
+ throw e;
+ }
+ finally
+ {
+ undeploy("staticarray2.sar");
+ }
+ }
+
/** Tests for accessing java system classes from scoped
* repositories.
*
Added: trunk/testsuite/src/resources/classloader/sharing/staticarray/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/classloader/sharing/staticarray/jboss-service.xml (rev 0)
+++ trunk/testsuite/src/resources/classloader/sharing/staticarray/jboss-service.xml 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,5 @@
+<server>
+ <mbean code="org.jboss.test.classloader.sharing.staticarray.common.Sequencer"
+ name="jboss.test:name=Sequencer">
+ </mbean>
+</server>
Added: trunk/testsuite/src/resources/classloader/sharing/staticarray/validate.jsp
===================================================================
--- trunk/testsuite/src/resources/classloader/sharing/staticarray/validate.jsp (rev 0)
+++ trunk/testsuite/src/resources/classloader/sharing/staticarray/validate.jsp 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,40 @@
+<%@page contentType="text/html"%>
+<%@page import="java.util.Arrays"%>
+<%@page import="org.jboss.test.util.Debug"%>
+
+<%
+ Integer[] array = (Integer[]) request.getAttribute("Sequencer.info");
+ if(array == null)
+ throw new IllegalStateException("No Sequencer.info attribute found");
+ String expectedString = request.getParameter("Sequencer.info.expected");
+ if(expectedString == null)
+ throw new IllegalStateException("No Sequencer.info.expected parameter found");
+ String[] expectedValues = expectedString.split(",");
+ int[] expected = new int[array.length];
+ StringBuffer check = new StringBuffer("Array mismatches: ");
+ boolean matches = true;
+ for(int n = 0; n < array.length; n ++)
+ {
+ expected[n] = Integer.parseInt(expectedValues[n]);
+ if(array[n] != expected[n])
+ {
+ check.append("["+n+"] "+array[n]+"!="+expected[n]);
+ check.append('\n');
+ matches = false;
+ }
+ }
+ if(matches == false)
+ {
+ StringBuffer classInfo = new StringBuffer();
+ Debug.displayClassInfo(org.jboss.test.classloader.sharing.staticarray.common.Sequencer.class, classInfo);
+ System.err.println(classInfo.toString());
+ response.addHeader("X-Error", check.toString());
+ response.sendError(HttpServletResponse.SC_EXPECTATION_FAILED, check.toString());
+ }
+%>
+<h1>Sequencer.info Comparision</h1>
+Sequencer.info = <%= Arrays.asList(array) %><br>
+Sequencer.info.expected = <%= Arrays.asList(expected) %><br>
+<pre>
+<%= check %>
+</pre>
Added: trunk/testsuite/src/resources/classloader/sharing/staticarray/web1.xml
===================================================================
--- trunk/testsuite/src/resources/classloader/sharing/staticarray/web1.xml (rev 0)
+++ trunk/testsuite/src/resources/classloader/sharing/staticarray/web1.xml 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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>
+ <description>First staticarray.sar war</description>
+ <listener>
+ <listener-class>org.jboss.test.classloader.sharing.staticarray.common.Listener1</listener-class>
+ </listener>
+
+</web-app>
Added: trunk/testsuite/src/resources/classloader/sharing/staticarray/web2.xml
===================================================================
--- trunk/testsuite/src/resources/classloader/sharing/staticarray/web2.xml (rev 0)
+++ trunk/testsuite/src/resources/classloader/sharing/staticarray/web2.xml 2008-07-16 04:13:59 UTC (rev 75863)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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>
+ <description>Second staticarray.sar war</description>
+ <listener>
+ <listener-class>org.jboss.test.classloader.sharing.staticarray.common.Listener2</listener-class>
+ </listener>
+
+
+</web-app>
More information about the jboss-cvs-commits
mailing list