[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...
Galder Zamarreno
galder.zamarreno at jboss.com
Fri Jan 5 11:45:40 EST 2007
User: gzamarreno
Date: 07/01/05 11:45:40
Modified: tests/functional/org/jboss/cache/marshall Tag:
Branch_JBossCache_1_4_0
RedeploymentEmulationTest.java
Log:
Modified so that it passes with CC
Revision Changes Path
No revision
No revision
1.1.2.2 +39 -11 JBossCache/tests/functional/org/jboss/cache/marshall/RedeploymentEmulationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RedeploymentEmulationTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/RedeploymentEmulationTest.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- RedeploymentEmulationTest.java 29 Nov 2006 18:39:16 -0000 1.1.2.1
+++ RedeploymentEmulationTest.java 5 Jan 2007 16:45:40 -0000 1.1.2.2
@@ -13,6 +13,7 @@
import java.net.URLClassLoader;
import java.net.URL;
+import java.net.MalformedURLException;
import java.io.File;
/**
@@ -26,9 +27,11 @@
private static final String INSTANCE_LIBRARY = "jgroups.jar";
private static final String INSTANCE_CLASS_NAME = "org.jgroups.Global";
- private static final String USER_DIR = System.getProperty("user.dir");
- private static final String FILE_SEPARATOR = System.getProperty("file.separator");
- private static final String LIB_DIR = "lib";
+ private static final String USER_DIR = ".";//System.getProperty("user.dir");
+ private static final String FILE_SEPARATOR = File.separator;//System.getProperty("file.separator");
+ private static final String LIB_DIR_NAME = "lib";
+ private static final String LIB_DIR = USER_DIR + FILE_SEPARATOR + LIB_DIR_NAME + FILE_SEPARATOR;
+ private static final String LIB_DIR_SP = System.getProperty("lib.dir");//"lib";
protected void setUp() throws Exception
{
@@ -38,14 +41,16 @@
tcmb = tc;
}
+ protected void tearDown()
+ {
+ tcmb.stop();
+ }
+
public void testClassCastException() throws Exception
{
tcmb.startService();
- File f = new File(USER_DIR + FILE_SEPARATOR + LIB_DIR + FILE_SEPARATOR);
- URL context = f.toURL();
- URL jar= new URL(context, INSTANCE_LIBRARY);
- URLClassLoader ucl1 = new URLClassLoader(new URL[]{jar}, null);
+ URLClassLoader ucl1 = createOrphanClassLoader();
Thread.currentThread().setContextClassLoader(ucl1);
Class clazz1 = ucl1.loadClass(INSTANCE_CLASS_NAME);
@@ -67,10 +72,7 @@
{
tcmb.startService();
- File f = new File(USER_DIR + FILE_SEPARATOR + LIB_DIR + FILE_SEPARATOR);
- URL context = f.toURL();
- URL jar= new URL(context, INSTANCE_LIBRARY);
- URLClassLoader ucl1 = new URLClassLoader(new URL[]{jar}, null);
+ URLClassLoader ucl1 = createOrphanClassLoader();
Thread.currentThread().setContextClassLoader(ucl1);
tcmb.registerClassLoader("/", Thread.currentThread().getContextClassLoader());
@@ -98,4 +100,30 @@
tcmb.inactivateRegion("/");
tcmb.unregisterClassLoader("/");
}
+
+ private URLClassLoader createOrphanClassLoader() throws MalformedURLException
+ {
+ File f;
+ if (LIB_DIR_SP == null)
+ {
+ /* lib.dir system property is null, so we assume this test is being run
+ * inside an IDE, where the user dir is the root of JBossCache. We know
+ * JGroups lib is located in lib/jgroups.jar */
+ f = new File(USER_DIR + FILE_SEPARATOR + LIB_DIR + FILE_SEPARATOR);
+ }
+ else
+ {
+ /* lib.dir is set, so we assume that you are running from the build.xml
+ * which means that the user dir might be a completely different one. lib.dir
+ * system property allows us to know where the lib directory is independently
+ * of the user dir*/
+ f = new File(LIB_DIR_SP);
+ }
+
+ URL context = f.toURL();
+ URL jar = new URL(context, INSTANCE_LIBRARY);
+ URLClassLoader ucl1 = new URLClassLoader(new URL[]{jar}, null);
+
+ return ucl1;
+ }
}
More information about the jboss-cvs-commits
mailing list