JBoss Remoting SVN: r5206 - remoting2/branches/2.2/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-13 00:05:31 -0400 (Wed, 13 May 2009)
New Revision: 5206
Modified:
remoting2/branches/2.2/docs/guide/en/chap-classloaders.xml
Log:
JBREM-1127: Added discussion of parameter "useCurrentThreadClassLoader".
Modified: remoting2/branches/2.2/docs/guide/en/chap-classloaders.xml
===================================================================
--- remoting2/branches/2.2/docs/guide/en/chap-classloaders.xml 2009-05-12 06:45:00 UTC (rev 5205)
+++ remoting2/branches/2.2/docs/guide/en/chap-classloaders.xml 2009-05-13 04:05:31 UTC (rev 5206)
@@ -88,6 +88,17 @@
the implication that this discussion about classloading in client invokers
applies not only to clients in the ordinary client server sense, but also to
clients running inside the server.</para>
+
+ <para><emphasis role="bold">Note.</emphasis> Prior to Remoting release 2.2.3, a
+ bug in the implementation of the classloading behavior caused the reference
+ to the thread context classloader to be, in fact, to the context classloader
+ of the thread in which the unmarshaller was originally created. A subsequent
+ invocation in a different thread would ignore the current thread context
+ classloader. To get the correct behavior, it is necessary to set the
+ parameter <code>org.jboss.remoting.Remoting.USE_CURRENT_THREAD_CLASS_LOADER</code>
+ (actual value "useCurrentThreadClassLoader") to "true".
+
+ </para>
</section>
<section id="section-server-classloading"
14 years, 12 months
JBoss Remoting SVN: r5205 - remoting2/branches/2.2.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:45:00 -0400 (Tue, 12 May 2009)
New Revision: 5205
Modified:
remoting2/branches/2.2/build.xml
Log:
(1) JBREM-1079: Added servlet tests; (2) JBREM-1129, JBREM-1130: added lease versioning tests; (3) JBREM-1131: Updated version to 2.2.2.SP12.
Modified: remoting2/branches/2.2/build.xml
===================================================================
--- remoting2/branches/2.2/build.xml 2009-05-12 06:39:15 UTC (rev 5204)
+++ remoting2/branches/2.2/build.xml 2009-05-12 06:45:00 UTC (rev 5205)
@@ -38,9 +38,9 @@
<!-- Module name(s) & version -->
<property name="module.name" value="remoting"/>
<property name="module.Name" value="JBoss Remoting"/>
- <property name="module.version" value="2.2.2.SP11"/>
+ <property name="module.version" value="2.2.2.SP12"/>
<!-- extension is for the file suffix to use for distribution build -->
- <property name="module.version.extension" value="2_2_2_SP11"/>
+ <property name="module.version.extension" value="2_2_2_SP12"/>
<property name="implementation.url" value="http://www.jboss.org/products/remoting"/>
<property name="root.dir" value="${basedir}"/>
@@ -930,8 +930,8 @@
<copy file="${jboss.deploy.dir}/jboss-web.deployer/server.xml" todir="${basedir}/Save" overwrite="true"/>
<copy file="${output.lib.dir}/jboss-remoting.jar" todir="${jboss.lib.dir}" overwrite="true"/>
<copy file="${output.lib.dir}/jboss-remoting-tests.jar" todir="${jboss.lib.dir}" overwrite="true"/>
- <copy file="${servlet.tests.dir}/server.xml" todir="${jboss.deploy.dir}/jboss-web.deployer"/>
- <copy file="${servlet.tests.dir}/ssl/keystore" tofile="${jboss.conf.dir}/keystore"/>
+ <copy file="${servlet.tests.dir}/server.xml" todir="${jboss.deploy.dir}/jboss-web.deployer" overwrite="true"/>
+ <copy file="${servlet.tests.dir}/ssl/keystore" tofile="${jboss.conf.dir}/keystore" overwrite="true"/>
</target>
<target name="tests.servlet.teardown" depends="tests.servlet.clean">
@@ -990,6 +990,8 @@
<antcall target="tests.servlet" inheritrefs="true"/>
<antcall target="tests.servlet.callback" inheritrefs="true"/>
<antcall target="tests.servlet.marshal" inheritrefs="true"/>
+ <antcall target="tests.servlet.nopreservelines" inheritrefs="true"/>
+ <antcall target="tests.servlet.preservelines" inheritrefs="true"/>
<antcall target="tests.servlet.ssl" inheritrefs="true"/>
<antcall target="AS.shutdown"/>
</target>
@@ -1016,7 +1018,7 @@
extension="-java_serialization.xml"/>
<batchtest fork="yes" todir="${output.tests.results}" haltonfailure="no">
<fileset dir="${tests.compile.dir}">
- <include name="**/remoting/transport/servlet/**TestClient.class"/>
+ <include name="**/remoting/transport/servlet/*TestClient.class"/>
</fileset>
</batchtest>
</junit>
@@ -1026,15 +1028,15 @@
<target name="tests.servlet.callback">
<copy file="${servlet.tests.dir}/callback/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
- <sleep seconds="2"/>
- <copy todir="${jboss.deploy.dir}">
+ <sleep seconds="4"/>
+ <copy todir="${jboss.deploy.dir}" overwrite="true">
<fileset dir="${output.lib.dir}">
<include name="servlet-invoker.war/**"/>
</fileset>
</copy>
<copy file="${servlet.tests.dir}/callback/WEB-INF/web.xml"
todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
- <sleep seconds="2"/>
+ <sleep seconds="4"/>
<junit printsummary="true" fork="yes" includeantruntime="true">
<jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
<jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
@@ -1056,7 +1058,7 @@
<target name="tests.servlet.marshal">
<copy file="${servlet.tests.dir}/marshal/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
- <sleep seconds="2"/>
+ <sleep seconds="4"/>
<copy todir="${jboss.deploy.dir}">
<fileset dir="${output.lib.dir}">
<include name="servlet-invoker.war/**"/>
@@ -1064,7 +1066,7 @@
</copy>
<copy file="${servlet.tests.dir}/marshal/WEB-INF/web.xml"
todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
- <sleep seconds="2"/>
+ <sleep seconds="4"/>
<junit printsummary="true" fork="yes" includeantruntime="true">
<jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
<jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
@@ -1084,6 +1086,66 @@
<delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
</target>
+ <target name="tests.servlet.nopreservelines">
+ <copy file="${servlet.tests.dir}/nopreservelines/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <sleep seconds="4"/>
+ <copy todir="${jboss.deploy.dir}">
+ <fileset dir="${output.lib.dir}">
+ <include name="servlet-invoker.war/**"/>
+ </fileset>
+ </copy>
+ <copy file="${servlet.tests.dir}/nopreservelines/WEB-INF/web.xml"
+ todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
+ <sleep seconds="4"/>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
+ <jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
+ <classpath>
+ <path refid="tests.classpath"/>
+ <pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
+ </classpath>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ extension="-java_serialization.xml"/>
+ <batchtest fork="yes" todir="${output.tests.results}" haltonfailure="no">
+ <fileset dir="${tests.compile.dir}">
+ <include name="**/remoting/transport/servlet/nopreservelines/*TestClient.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <delete dir="${jboss.deploy.dir}/servlet-invoker.war"/>
+ <delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
+ </target>
+
+ <target name="tests.servlet.preservelines">
+ <copy file="${servlet.tests.dir}/preservelines/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <sleep seconds="4"/>
+ <copy todir="${jboss.deploy.dir}" overwrite="true">
+ <fileset dir="${output.lib.dir}">
+ <include name="servlet-invoker.war/**"/>
+ </fileset>
+ </copy>
+ <copy file="${servlet.tests.dir}/preservelines/WEB-INF/web.xml"
+ todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
+ <sleep seconds="4"/>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
+ <jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
+ <classpath>
+ <path refid="tests.classpath"/>
+ <pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
+ </classpath>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ extension="-java_serialization.xml"/>
+ <batchtest fork="yes" todir="${output.tests.results}" haltonfailure="no">
+ <fileset dir="${tests.compile.dir}">
+ <include name="**/remoting/transport/servlet/preservelines/*TestClient.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <delete dir="${jboss.deploy.dir}/servlet-invoker.war"/>
+ <delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
+ </target>
+
<target name="tests.servlet.ssl">
<copy file="${servlet.tests.dir}/ssl/remoting-sslservlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
<sleep seconds="4"/>
@@ -1094,7 +1156,7 @@
</copy>
<copy file="${servlet.tests.dir}/ssl/WEB-INF/web.xml"
todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
- <sleep seconds="2"/>
+ <sleep seconds="5"/>
<junit printsummary="true" fork="yes" includeantruntime="true">
<jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
<jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
@@ -1176,7 +1238,7 @@
<target name="tests.versioning.all"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
-
+
<!-- ******************************************************************************** -->
<!-- Current <- -> Current -->
<antcall target="tests.versioning.all_transports" inheritrefs="true">
@@ -1184,8 +1246,31 @@
<param name="client.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
<param name="server.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
</antcall>
-
+
<!-- ******************************************************************************** -->
+ <!-- Current <- -> 2.2.2.SP11 -->
+ <antcall target="tests.versioning.all_transports" inheritrefs="true">
+ <param name="jboss-junit-configuration" value="2_2_2_SP11-client"/>
+ <param name="client.classpath" value="${etc.dir}/lib/remoting_2_2_2_SP11/jboss-remoting.jar"/>
+ <param name="server.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
+ <param name="client.pre_2_0_compatible" value=""/>
+ <param name="server.pre_2_0_compatible" value=""/>
+ <param name="client.version" value=""/>
+ <param name="server.version" value="2"/>
+ <param name="check_connection" value="false"/>
+ </antcall>
+ <antcall target="tests.versioning.all_transports" inheritrefs="true">
+ <param name="jboss-junit-configuration" value="2_2_2_SP11-server"/>
+ <param name="server.classpath" value="${etc.dir}/lib/remoting_2_2_2_SP11/jboss-remoting.jar"/>
+ <param name="client.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
+ <param name="client.pre_2_0_compatible" value=""/>
+ <param name="server.pre_2_0_compatible" value=""/>
+ <param name="client.version" value="2"/>
+ <param name="server.version" value=""/>
+ <param name="check_connection" value="false"/>
+ </antcall>
+
+ <!-- ******************************************************************************** -->
<!-- Current <- -> 2.2.2.SP10 -->
<antcall target="tests.versioning.all_transports" inheritrefs="true">
<param name="jboss-junit-configuration" value="2_2_2_SP10-client"/>
@@ -1207,7 +1292,7 @@
<param name="server.version" value=""/>
<param name="check_connection" value="false"/>
</antcall>
-
+
<!-- ******************************************************************************** -->
<!-- Current <- -> 2.2.2.SP9 -->
<antcall target="tests.versioning.all_transports" inheritrefs="true">
@@ -1469,7 +1554,7 @@
<antcall target="tests.versioning.socket" inheritrefs="true">
<param name="version" value="1_4_3_GA"/>
</antcall>
-
+
<!-- ******************************************************************************** -->
<!-- Current <- -> 1.4.0.final -->
<antcall target="tests.versioning.all_but_socket_and_bisocket" inheritrefs="true">
@@ -1481,7 +1566,7 @@
<param name="client.version" value=""/>
<param name="server.version" value=""/>
</antcall>
-
+
<antcall target="tests.versioning.all_but_socket_and_bisocket" inheritrefs="true">
<param name="jboss-junit-configuration" value="1_4_0_final-server"/>
<param name="server.classpath" value="${etc.dir}/lib/remoting_1_4_0_final/jboss-remoting.jar"/>
@@ -1491,16 +1576,16 @@
<param name="client.version" value=""/>
<param name="server.version" value=""/>
</antcall>
-
- <!-- 1.4.0.final does not allow turning off socket connection check -->
+
+ <!-- 1.4.0.final does not allow turning off socket connection check -->
<antcall target="tests.versioning.socket.1.4.0" inheritrefs="true">
- <param name="version" value="1_4_0_final"/>
+ <param name="version" value="1_4_0_final"/>
</antcall>
-
+
<!-- ******************************************************************************** -->
<!-- Current <- -> 1.2.1.final -->
<!-- Compatibility is not guaranteed with 1.2.1.final
-
+
<antcall target="tests.versioning.all_but_socket" inheritrefs="true">
<param name="jboss-junit-configuration" value="1_2_1_final-client"/>
<param name="client.classpath" value="${etc.dir}/lib/remoting_1_2_1_final/jboss-remoting.jar"/>
@@ -1510,7 +1595,7 @@
<param name="client.version" value=""/>
<param name="server.version" value=""/>
</antcall>
-
+
<antcall target="tests.versioning.all_but_socket" inheritrefs="true">
<param name="jboss-junit-configuration" value="1_2_1_final-server"/>
<param name="server.classpath" value="${etc.dir}/lib/remoting_1_2_1_final/jboss-remoting.jar"/>
@@ -1520,9 +1605,9 @@
<param name="client.version" value=""/>
<param name="server.version" value=""/>
</antcall>
-
+
<antcall target="tests.versioning.socket.1.4.0" inheritrefs="true">
- <param name="version" value="1_2_1_final"/>
+ <param name="version" value="1_2_1_final"/>
</antcall>
-->
</target>
@@ -1597,12 +1682,13 @@
haltonfailure="no">
<fileset dir="${tests.compile.dir}">
<include name="**/remoting/versioning/transport/**/*TestCase.class"/>
- <exclude name="**/remoting/**/multiplex/**/*.class"/>
+ <include name="**/remoting/versioning/lease/**/*TestCase.class"/>
+ <exclude name="**/remoting/**/multiplex/**/*.class"/>
</fileset>
</batchtest>
</junit>
</target>
-
+
<target name="tests.versioning.all_transports_but_bisocket"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
@@ -1627,13 +1713,13 @@
haltonfailure="no">
<fileset dir="${tests.compile.dir}">
<include name="**/remoting/versioning/transport/**/*TestCase.class"/>
- <exclude name="**/remoting/**/bisocket/**/*.class"/>
- <exclude name="**/remoting/**/multiplex/**/*.class"/>
+ <exclude name="**/remoting/**/bisocket/**/*.class"/>
+ <exclude name="**/remoting/**/multiplex/**/*.class"/>
</fileset>
</batchtest>
</junit>
</target>
-
+
<target name="tests.versioning.all_but_socket_and_bisocket"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
@@ -1657,20 +1743,20 @@
haltonfailure="no">
<fileset dir="${tests.compile.dir}">
<include name="**/remoting/versioning/transport/**/*TestCase.class"/>
- <exclude name="**/bisocket/**"/>
- <exclude name="**/socket/**"/>
- <exclude name="**/multiplex/**"/>
+ <exclude name="**/bisocket/**"/>
+ <exclude name="**/socket/**"/>
+ <exclude name="**/multiplex/**"/>
</fileset>
</batchtest>
</junit>
</target>
-
+
<target name="tests.versioning.socket"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
-
+
<antcall target="tests.versioning.socket.1.4.0" inheritrefs="true"/>
-
+
<antcall target="tests.versioning.socket.sub" inheritrefs="true">
<param name="jboss-junit-configuration" value="${version}-client_nocheck"/>
<param name="client.classpath" value="${etc.dir}/lib/remoting_${version}/jboss-remoting.jar"/>
@@ -1682,7 +1768,7 @@
<param name="client.check_connection" value="false"/>
<param name="server.check_connection" value="false"/>
</antcall>
-
+
<antcall target="tests.versioning.socket.sub" inheritrefs="true">
<param name="jboss-junit-configuration" value="${version}-server_nocheck"/>
<param name="server.classpath" value="${etc.dir}/lib/remoting_${version}/jboss-remoting.jar"/>
@@ -1695,7 +1781,7 @@
<param name="server.check_connection" value="false"/>
</antcall>
</target>
-
+
<target name="tests.versioning.socket.1.4.0"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
@@ -1710,7 +1796,7 @@
<param name="client.check_connection" value="true"/>
<param name="server.check_connection" value="true"/>
</antcall>
-
+
<antcall target="tests.versioning.socket.sub" inheritrefs="true">
<param name="jboss-junit-configuration" value="${version}-client_default"/>
<param name="client.classpath" value="${etc.dir}/lib/remoting_${version}/jboss-remoting.jar"/>
@@ -1732,9 +1818,9 @@
<param name="client.version" value=""/>
<param name="server.version" value=""/>
<param name="client.check_connection" value="true"/>
- <param name="server.check_connection" value="true"/>
+ <param name="server.check_connection" value="true"/>
</antcall>
-
+
<antcall target="tests.versioning.socket.sub" inheritrefs="true">
<param name="jboss-junit-configuration" value="${version}-server_default"/>
<param name="server.classpath" value="${etc.dir}/lib/remoting_${version}/jboss-remoting.jar"/>
@@ -1747,7 +1833,7 @@
<param name="server.check_connection" value=""/>
</antcall>
</target>
-
+
<target name="tests.versioning.socket.sub"
description="Runs remoting fuctional tests with different remoting versions for client and server."
depends="jars, tests.jars">
@@ -1830,8 +1916,42 @@
</batchtest>
</junit>
</target>
-
-
+ <target name="tests.versioning.lease" depends="configure">
+ <antcall target="tests.versioning.lease.sub" inheritrefs="true">
+ <param name="jboss-junit-configuration" value="${module.version.extension}"/>
+ <param name="client.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
+ <param name="server.classpath" value="${output.lib.dir}/jboss-remoting.jar"/>
+ </antcall>
+ </target>
+
+ <target name="tests.versioning.lease.sub"
+ description="Runs remoting fuctional tests with different remoting versions for client and server."
+ depends="jars, tests.jars">
+ <mkdir dir="${output.tests.results}"/>
+ <echo>Running: ${jboss-junit-configuration}</echo>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <classpath>
+ <path refid="third_party.classpath"/>
+ <path refid="tests.version.classpath"/>
+ </classpath>
+ <jvmarg value="-Dclient.path=${client.classpath}"/>
+ <jvmarg value="-Dserver.path=${server.classpath}"/>
+ <jvmarg value="-Dclient.version=2.2"/>
+ <jvmarg value="-Dserver.version=2.2"/>
+ <jvmarg value="-Dclient.pre_2_0_compatible=false"/>
+ <jvmarg value="-Dserver.pre_2_0_compatible=false"/>
+ <jvmarg value="-Dremoting.metadata=check_connection=false"/>
+ <sysproperty key="jboss-junit-configuration" value="${jboss-junit-configuration}"/>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ extension="-${jboss-junit-configuration}.xml"/>
+ <batchtest fork="yes" todir="${output.tests.results}"
+ haltonfailure="no">
+ <fileset dir="${tests.compile.dir}">
+ <include name="**/remoting/versioning/lease/*TestCase.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
<!-- Tests only the multiplex transport -->
<target name="tests.multiplex" depends="tests.jars">
<mkdir dir="${output.tests.results}"/>
@@ -3020,13 +3140,13 @@
<include name="**"/>
</fileset>
</copy>
-
+
<copy todir="${dist.dir}/docs/guide/html_single">
<fileset dir="${basedir}/docs/guide/build/en/html_single">
<include name="**"/>
</fileset>
</copy>
-
+
<copy todir="${dist.dir}" filtering="no">
<fileset dir="${basedir}/docs">
<include name="README.txt"/>
14 years, 12 months
JBoss Remoting SVN: r5204 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:39:15 -0400 (Tue, 12 May 2009)
New Revision: 5204
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Version.java
Log:
JBREM-1131: Updated version to 2.2.2.SP12.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Version.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Version.java 2009-05-12 06:38:05 UTC (rev 5203)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Version.java 2009-05-12 06:39:15 UTC (rev 5204)
@@ -32,14 +32,14 @@
public static final byte VERSION_2 = 2;
public static final byte VERSION_2_2 = 22;
- public static final String VERSION = "2.2.2.SP11";
+ public static final String VERSION = "2.2.2.SP12";
private static final byte byteVersion = VERSION_2_2;
private static byte defaultByteVersion = byteVersion;
private static boolean performVersioning = true;
// static
// {
-// System.out.println("Remoting version: " + VERSION);
+// System.out.println("Remoting version: " + VERSION + ": 5/08/09-15:22");
// }
@@ -57,6 +57,7 @@
if(precompatible != null && precompatible.length() > 0)
{
precompatibleFlag = Boolean.valueOf(precompatible).booleanValue();
+ System.out.println("precompatibleFlag: " + precompatibleFlag);
}
// if is precompatible, no need to look for custom version, as there is only 1 precompatible version
if(precompatibleFlag)
14 years, 12 months
JBoss Remoting SVN: r5203 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning: lease and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:38:05 -0400 (Tue, 12 May 2009)
New Revision: 5203
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestClient.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestServer.java
Log:
JBREM-1129, JBREM-1130: Added lease test to versioning test suite.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestCase.java 2009-05-12 06:38:05 UTC (rev 5203)
@@ -0,0 +1,133 @@
+package org.jboss.test.remoting.versioning.lease;
+
+import org.apache.log4j.Level;
+import org.jboss.test.remoting.transport.InvokerTestDriver;
+
+/**
+ * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
+ */
+public class LeaseVersionTestCase extends InvokerTestDriver
+{
+ public void declareTestClasses()
+ {
+ addTestClasses("org.jboss.test.remoting.versioning.lease.LeaseVersionTestClient",
+ 1,
+ "org.jboss.test.remoting.versioning.lease.LeaseVersionTestServer");
+ }
+
+ /**
+ * Returns the classpath to be added to the classpath used to start the client tests.
+ * Default return is null, which means no extra classpath will be added.
+ *
+ * @return
+ */
+ protected String getExtendedServerClasspath()
+ {
+ return System.getProperty("server.path");
+ }
+
+ /**
+ * Returns the classpath to be added to the classpath used to start the client tests.
+ * Default return is null, which means no extra classpath will be added.
+ *
+ * @return
+ */
+ protected String getExtendedClientClasspath()
+ {
+ return System.getProperty("client.path");
+ }
+
+ protected String getClientJVMArguments()
+ {
+ String prop = System.getProperty("client.pre_2_0_compatible");
+ String args = "";
+ if (prop != null && !"".equals(prop))
+ {
+ args = "-Djboss.remoting.pre_2_0_compatible=" + prop;
+ }
+ else
+ {
+ prop = System.getProperty("client.version");
+ if (prop != null && !"".equals(prop))
+ args = "-Djboss.remoting.version=" + prop;
+ }
+ prop = System.getProperty("client.check_connection");
+ if (prop != null && !"".equals(prop))
+ {
+ args += " -Dremoting.metadata=socket.check_connection=" + prop;
+ }
+ System.out.println("client arg: " + args);
+ return args;
+ }
+
+
+ protected String getServerJVMArguments()
+ {
+ String prop = System.getProperty("server.pre_2_0_compatible");
+ String args = "";
+ if (prop != null && !"".equals(prop))
+ {
+ args = "-Djboss.remoting.pre_2_0_compatible=" + prop;
+ }
+ else
+ {
+ prop = System.getProperty("server.version");
+ if (prop != null && !"".equals(prop))
+ args = "-Djboss.remoting.version=" + prop;
+ }
+ prop = System.getProperty("server.check_connection");
+ if (prop != null && !"".equals(prop))
+ {
+ args += " -Dremoting.metadata=socket.check_connection=" + prop;
+ }
+ System.out.println("server arg: " + args);
+ return args;
+ }
+
+
+ protected Level getTestHarnessLogLevel()
+ {
+ return Level.INFO;
+ }
+
+ protected Level getTestLogLevel()
+ {
+ return Level.INFO;
+ }
+
+ /**
+ * How long to wait for test results to be returned from the client(s). If goes longer than the
+ * specified limit, will throw an exception and kill the running test cases. Default value is
+ * RESULTS_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getResultsTimeout()
+ {
+ return 60000;
+ }
+
+ /**
+ * How long for the server test case to wait for tear down message. If exceeds timeout,
+ * will throw exception. The default value is TEARDOWN_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getTearDownTimeout()
+ {
+ return 60000;
+ }
+
+ /**
+ * How long to allow each of the test cases to run their tests. If exceeds this timeout
+ * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getRunTestTimeout()
+ {
+ return 60000;
+ }
+
+
+}
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestClient.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestClient.java 2009-05-12 06:38:05 UTC (rev 5203)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.remoting.versioning.lease;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ClientDisconnectedException;
+import org.jboss.remoting.InvokerLocator;
+
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright May 08, 2009
+ * </p>
+ */
+public class LeaseVersionTestClient extends TestCase
+{
+ private static Logger log = Logger.getLogger(LeaseVersionTestClient.class);
+
+ protected static long LEASE_PERIOD = 2000;
+ protected static String LEASE_PERIOD_STRING = "2000";
+
+ private static boolean firstTime = true;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testLease() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(createLocatorURI());
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Test lease behavior.
+ client.disconnect();
+ client.connect();
+ Map info = (Map) client.invoke(LeaseVersionTestServer.GET_LISTENER_INFO);
+ log.info("listener info: " + info);
+ assertEquals(1, ((Integer)info.get(LeaseVersionTestServer.LISTENER_COUNT)).intValue());
+ assertTrue(info.get(LeaseVersionTestServer.THROWABLE) instanceof ClientDisconnectedException);
+ client.disconnect();
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+
+
+ protected String createLocatorURI() throws UnknownHostException
+ {
+ String locatorURI = getTransport() + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + LeaseVersionTestServer.PORT;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ return locatorURI;
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestServer.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestServer.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestServer.java 2009-05-12 06:38:05 UTC (rev 5203)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.remoting.versioning.lease;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.jrunit.extensions.ServerTestCase;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright May 08, 2009
+ * </p>
+ */
+public class LeaseVersionTestServer extends ServerTestCase
+{
+ public static final String REMOTING_METADATA = "remoting.metadata";
+ public static final String JVM_MAX_HEAP_SIZE = "jvm.mx";
+ public static final String GET_LISTENER_INFO = "getListenerCount";
+ public static final String LISTENER_COUNT = "listenerCount";
+ public static final String THROWABLE = "throwable";
+ public static final String PORT = "9091";
+
+ private static Logger log = Logger.getLogger(LeaseVersionTestServer.class);
+
+ protected static long LEASE_PERIOD = 2000;
+ protected static String LEASE_PERIOD_STRING = "2000";
+
+ protected Connector connector;
+ protected TestConnectionListener listener;
+
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ LeaseVersionTestServer p = new LeaseVersionTestServer();
+ p.setUp();
+ Thread.sleep(3000000);
+ p.tearDown();
+ }
+ catch (Exception e)
+ {
+ log.error("Error", e);
+ }
+ }
+
+
+ public void setUp() throws Exception
+ {
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ setupServer();
+ }
+
+
+ public void tearDown()
+ {
+ if(connector != null)
+ {
+ connector.stop();
+ connector.destroy();
+ }
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ String locatorURI = createLocatorURI();
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ InvokerLocator serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put("leasePeriod", LEASE_PERIOD_STRING);
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ ServerInvocationHandler invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ listener = new TestConnectionListener();
+ connector.addConnectionListener(listener);
+ }
+
+
+ protected String createLocatorURI() throws UnknownHostException
+ {
+ String locatorURI = getTransport() + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + PORT;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ return locatorURI;
+ }
+
+
+ class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Object o = invocation.getParameter();
+ if (GET_LISTENER_INFO.equals(o))
+ {
+ HashMap map = new HashMap();
+ map.put(LISTENER_COUNT, new Integer(listener.counter));
+ map.put(THROWABLE, listener.throwable);
+ listener.counter = 0;
+ listener.throwable = null;
+ return map;
+ }
+ return o;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestConnectionListener implements ConnectionListener
+ {
+ public int counter;
+ public Throwable throwable;
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ counter++;
+ this.throwable = throwable;
+ log.info("called: throwable = " + throwable);
+ }
+ }
+}
\ No newline at end of file
14 years, 12 months
JBoss Remoting SVN: r5202 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/web.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:37:04 -0400 (Tue, 12 May 2009)
New Revision: 5202
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTestClient.java
Log:
JBREM-1079: Added test for transport to support servlet and sslservlet transports.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTestClient.java 2009-05-12 06:35:42 UTC (rev 5201)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTestClient.java 2009-05-12 06:37:04 UTC (rev 5202)
@@ -99,8 +99,8 @@
String locatorURI = getLocatorURI();
int index = locatorURI.indexOf(':');
String transport = locatorURI.substring(0, index);
- String params = ("servlet".equals(transport) ? ",createUniqueObjectName=true" : "");
- String port = ("servlet".equals(transport) ? "8080" : "8888");
+ String params = (isServlet(transport) ? ",createUniqueObjectName=true" : "");
+ String port = "servlet".equals(transport) ? "8080" : ("sslservlet".equals(transport) ? "8443" : "8888");
assertEquals("jboss.remoting:service=invoker,transport= " + transport + ",host=localhost,port=" + port + params, response);
checkUserAgent(remotingClient, metadata);
@@ -205,6 +205,7 @@
Object response = null;
// test with null return expected
+ System.out.println("calling Client.invoke()");
response = remotingClient.invoke((Object) null, metadata);
System.out.println("Response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response);
assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response);
@@ -215,6 +216,7 @@
}
catch (Throwable throwable)
{
+ System.out.println("invoke() failed");
throw new Exception(throwable);
}
finally
@@ -228,6 +230,11 @@
}
+ protected boolean isServlet(String transport)
+ {
+ return transport.indexOf("servlet") >= 0;
+ }
+
protected void addHeaders(Properties headerProps)
{
//NO OP - for overriding by sub-classes.
14 years, 12 months
JBoss Remoting SVN: r5201 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:35:42 -0400 (Tue, 12 May 2009)
New Revision: 5201
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerExceptionTestClient.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerTestClient.java
Log:
JBREM-1079: Added
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerExceptionTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerExceptionTestClient.java 2009-05-12 06:34:31 UTC (rev 5200)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerExceptionTestClient.java 2009-05-12 06:35:42 UTC (rev 5201)
@@ -45,7 +45,7 @@
String trustStoreFilePath = this.getClass().getResource("truststore").getFile();
System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
- return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet";
+ return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true";
//return "http://localhost:8080/servlet-invoker/ServerInvokerServlet";
}
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerTestClient.java 2009-05-12 06:34:31 UTC (rev 5200)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerTestClient.java 2009-05-12 06:35:42 UTC (rev 5201)
@@ -17,7 +17,7 @@
System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
- return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet";
+ return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true";
//return "http://localhost:8080/servlet-invoker/ServerInvokerServlet";
}
14 years, 12 months
JBoss Remoting SVN: r5200 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader: currentthread and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:34:31 -0400 (Tue, 12 May 2009)
New Revision: 5200
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/CurrentThreadContextClassLoaderTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass1.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass2.java
Log:
JBREM-1127: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/CurrentThreadContextClassLoaderTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/CurrentThreadContextClassLoaderTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/CurrentThreadContextClassLoaderTestCase.java 2009-05-12 06:34:31 UTC (rev 5200)
@@ -0,0 +1,374 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.remoting.classloader.currentthread;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit tests for JBREM-1127
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright May 10, 2009
+ * </p>
+ */
+public class CurrentThreadContextClassLoaderTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(CurrentThreadContextClassLoaderTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+ protected String currentPackage;
+ protected ClassLoader mainContextClassLoader;
+ protected TestClassLoader testClassLoader1;
+ protected TestClassLoader testClassLoader2;
+ protected TestCallingThread testCallingThread;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+
+ String className = getClass().getName();
+ int index = className.lastIndexOf('.');
+ currentPackage = className.substring(0, index);
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ mainContextClassLoader = Thread.currentThread().getContextClassLoader();
+
+ // Create testClassLoader1 for testCallingThread.
+ testClassLoader1 = new TestClassLoader("testClassLoader1");
+
+ // Create testClassLoader2 for main thread.
+ testClassLoader2 = new TestClassLoader("testClassLoader2");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
+ TestCallingThread t = new TestCallingThread(client);
+ t.run();
+ synchronized (t)
+ {
+ if (!t.done)
+ {
+ t.wait();
+ }
+ }
+
+ // Make invocation in main thread with context classloader testClassLoader2.
+ testClassLoader2.setClassLoader(mainContextClassLoader);
+ Thread.currentThread().setContextClassLoader(testClassLoader2);
+ log.info("main thread result: " + client.invoke("2"));
+ assertTrue(testClassLoader1.counter > 0);
+ assertTrue(testClassLoader2.counter == 0);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseCurrentThreadClassLoaderFalse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ mainContextClassLoader = Thread.currentThread().getContextClassLoader();
+
+ // Create testClassLoader1 for testCallingThread.
+ testClassLoader1 = new TestClassLoader("testClassLoader1");
+
+ // Create testClassLoader2 for main thread.
+ testClassLoader2 = new TestClassLoader("testClassLoader2");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.USE_CURRENT_THREAD_CLASS_LOADER, "false");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
+ TestCallingThread t = new TestCallingThread(client);
+ t.run();
+ synchronized (t)
+ {
+ if (!t.done)
+ {
+ t.wait();
+ }
+ }
+
+ // Make invocation in main thread with context classloader testClassLoader2.
+ testClassLoader2.setClassLoader(mainContextClassLoader);
+ Thread.currentThread().setContextClassLoader(testClassLoader2);
+ log.info("main thread result: " + client.invoke("2"));
+ assertTrue(testClassLoader1.counter > 0);
+ assertTrue(testClassLoader2.counter == 0);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseCurrentThreadClassLoaderTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ mainContextClassLoader = Thread.currentThread().getContextClassLoader();
+
+ // Create testClassLoader1 for testCallingThread.
+ testClassLoader1 = new TestClassLoader("testClassLoader1");
+
+ // Create testClassLoader2 for main thread.
+ testClassLoader2 = new TestClassLoader("testClassLoader2");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.USE_CURRENT_THREAD_CLASS_LOADER, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
+ TestCallingThread t = new TestCallingThread(client);
+ t.run();
+ synchronized (t)
+ {
+ if (!t.done)
+ {
+ t.wait();
+ }
+ }
+
+ // Make invocation in main thread with context classloader testClassLoader2.
+ testClassLoader2.setClassLoader(mainContextClassLoader);
+ Thread.currentThread().setContextClassLoader(testClassLoader2);
+ log.info("main thread result: " + client.invoke("2"));
+ assertTrue(testClassLoader1.counter > 0);
+ assertTrue(testClassLoader2.counter > 0);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION + "=false";
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Object o = invocation.getParameter();
+ if ("1".equals(o))
+ {
+ return Class.forName(currentPackage + ".TestClass1").newInstance();
+ }
+ else if ("2".equals(o))
+ {
+ return Class.forName(currentPackage + ".TestClass2").newInstance();
+ }
+ else
+ {
+ throw new Exception("unexpected request: " + o);
+ }
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ class TestCallingThread extends Thread
+ {
+ Client client;
+ boolean done;
+
+ public TestCallingThread(Client client)
+ {
+ this.client = client;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // Make testClassloader1 the context classloader for this TestCallingThread.
+ testClassLoader1.setClassLoader(mainContextClassLoader);
+ Thread.currentThread().setContextClassLoader(testClassLoader1);
+ log.info("TestCallingThread result: " + client.invoke("1"));
+ synchronized (this)
+ {
+ done = true;
+ notifyAll();
+ }
+ }
+ catch (Throwable e)
+ {
+ log.error("Error", e);
+ }
+ }
+ }
+
+
+ static class TestClassLoader extends ClassLoader
+ {
+ ClassLoader cl;
+ String name;
+ int counter;
+
+ public TestClassLoader(String name)
+ {
+ this.name = name;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ counter++;
+ log.info(this + " called: " + name);
+// log.info(this + " called: " + name, new Exception());
+ return cl.loadClass(name);
+ }
+
+ public void setClassLoader(ClassLoader cl)
+ {
+ this.cl = cl;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass1.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass1.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass1.java 2009-05-12 06:34:31 UTC (rev 5200)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.remoting.classloader.currentthread;
+
+import java.io.Serializable;
+
+public class TestClass1 implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass2.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass2.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/currentthread/TestClass2.java 2009-05-12 06:34:31 UTC (rev 5200)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.remoting.classloader.currentthread;
+
+import java.io.Serializable;
+
+public class TestClass2 implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+}
+
14 years, 12 months
JBoss Remoting SVN: r5199 - remoting2/branches/2.2/src/main/org/jboss/remoting/loading.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 02:00:58 -0400 (Tue, 12 May 2009)
New Revision: 5199
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/loading/RemotingClassLoader.java
Log:
JBREM-1127: If loadClass() gets a null primaryClassLoader, it will get the thread context classloader.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/loading/RemotingClassLoader.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/loading/RemotingClassLoader.java 2009-05-12 05:59:39 UTC (rev 5198)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/loading/RemotingClassLoader.java 2009-05-12 06:00:58 UTC (rev 5199)
@@ -47,7 +47,12 @@
try
{
- loadedClass = Class.forName(name, false, getParent());
+ ClassLoader primaryClassLoader = getParent();
+ if (primaryClassLoader == null)
+ {
+ primaryClassLoader = Thread.currentThread().getContextClassLoader();
+ }
+ loadedClass = Class.forName(name, false, primaryClassLoader);
if (isTrace) log.trace("loaded from primary classloader: " + name);
}
catch(ClassNotFoundException e)
14 years, 12 months
JBoss Remoting SVN: r5198 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 01:59:39 -0400 (Tue, 12 May 2009)
New Revision: 5198
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
Log:
JBREM-1127: Added "useCurrentThreadClassLoader: constant.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2009-05-12 05:59:04 UTC (rev 5197)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2009-05-12 05:59:39 UTC (rev 5198)
@@ -90,4 +90,13 @@
*/
public static final String USE_CLIENT_CONNECTION_IDENTITY = "useClientConnectionIdentity";
// public static final String USE_SERVER_CONNECTION_IDENTITY = "useServerConnectionIdentity";
+
+ /**
+ * A flag for indicating that when a client side Remoting unmarshaller uses the Thread
+ * contect classloader, it should use the context classloader for the currently executing
+ * thread, rather than the context classloader for the thread in which the unmarshaller
+ * was created. Note that this behavior is generally desirable and was introduced to
+ * fix a source of ClassCastExceptions.
+ */
+ public static final String USE_CURRENT_THREAD_CLASS_LOADER = "useCurrentThreadClassLoader";
}
14 years, 12 months
JBoss Remoting SVN: r5197 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-12 01:59:04 -0400 (Tue, 12 May 2009)
New Revision: 5197
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
JBREM-1127: Introduced useCurrentThreadClassLoader variable and related behavior.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-12 05:56:17 UTC (rev 5196)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-12 05:59:04 UTC (rev 5197)
@@ -43,6 +43,7 @@
private String invokerSessionID = new GUID().toString();
private boolean parentFirstClassLoading = true;
private boolean changeInvalidStateToCannotConnect = false;
+ private boolean useCurrentThreadClassLoader;
public MicroRemoteClientInvoker(InvokerLocator locator)
{
@@ -93,13 +94,27 @@
// and the current thread's class loader. This allows to load remoting classes as well as
// user's classes.
ClassLoader remotingClassLoader = null;
- if (parentFirstClassLoading)
+ if (useCurrentThreadClassLoader)
{
- remotingClassLoader = new RemotingClassLoader(getClassLoader(), Thread.currentThread().getContextClassLoader());
+ if (parentFirstClassLoading)
+ {
+ remotingClassLoader = new RemotingClassLoader(getClassLoader(), null);
+ }
+ else
+ {
+ remotingClassLoader = new RemotingClassLoader(null, getClassLoader());
+ }
}
else
{
- remotingClassLoader = new RemotingClassLoader(Thread.currentThread().getContextClassLoader(), getClassLoader());
+ if (parentFirstClassLoading)
+ {
+ remotingClassLoader = new RemotingClassLoader(getClassLoader(), Thread.currentThread().getContextClassLoader());
+ }
+ else
+ {
+ remotingClassLoader = new RemotingClassLoader(Thread.currentThread().getContextClassLoader(), getClassLoader());
+ }
}
// try by locator (in case unmarshaller class name specified)
@@ -566,6 +581,13 @@
String sflag = flag.toString();
changeInvalidStateToCannotConnect = Boolean.valueOf(sflag).booleanValue();
}
+
+ flag = configuration.get(Remoting.USE_CURRENT_THREAD_CLASS_LOADER);
+ if (flag != null)
+ {
+ String sflag = flag.toString();
+ useCurrentThreadClassLoader = Boolean.valueOf(sflag).booleanValue();
+ }
}
/**
14 years, 12 months