[jboss-cvs] JBoss Messaging SVN: r4409 - trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 6 11:16:23 EDT 2008


Author: jmesnil
Date: 2008-06-06 11:16:23 -0400 (Fri, 06 Jun 2008)
New Revision: 4409

Modified:
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
Log:
reverted last commit

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java	2008-06-06 14:59:16 UTC (rev 4408)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java	2008-06-06 15:16:23 UTC (rev 4409)
@@ -21,13 +21,17 @@
   */
 package org.jboss.test.messaging.jms.message;
 
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
 import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.ObjectMessage;
 
-import org.jboss.messaging.tests.unit.core.util.ObjectInputStreamWithClassLoaderTest;
-
 /**
  * A test that sends/receives object messages to the JMS provider and verifies their integrity.
  *
@@ -79,7 +83,7 @@
 
          SomeObject testObject = new SomeObject(3, 7);
 
-         ClassLoader testClassLoader = ObjectInputStreamWithClassLoaderTest.newClassLoader(testObject.getClass());
+         ClassLoader testClassLoader = newClassLoader(testObject.getClass());
 
          om.setObject(testObject);
 
@@ -142,4 +146,39 @@
       ObjectMessage om = (ObjectMessage)m;
       assertEquals("this is the serializable object", om.getObject());
    }
+
+   protected static ClassLoader newClassLoader(Class anyUserClass) throws Exception
+   {
+      URL classLocation = anyUserClass.getProtectionDomain().getCodeSource().getLocation();
+      StringTokenizer tokenString = new StringTokenizer(System.getProperty("java.class.path"),
+         File.pathSeparator);
+      String pathIgnore = System.getProperty("java.home");
+      if (pathIgnore == null)
+      {
+         pathIgnore = classLocation.toString();
+      }
+
+      ArrayList urls = new ArrayList();
+      while (tokenString.hasMoreElements())
+      {
+         String value = tokenString.nextToken();
+         URL itemLocation = new File(value).toURL();
+         if (!itemLocation.equals(classLocation) &&
+                      itemLocation.toString().indexOf(pathIgnore) >= 0)
+         {
+            urls.add(itemLocation);
+         }
+      }
+
+      URL[] urlArray = (URL[]) urls.toArray(new URL[urls.size()]);
+
+      ClassLoader masterClassLoader = URLClassLoader.newInstance(urlArray, null);
+
+
+      ClassLoader appClassLoader = URLClassLoader.newInstance(new URL[]{classLocation},
+                                      masterClassLoader);
+
+      return appClassLoader;
+   }
+
 }




More information about the jboss-cvs-commits mailing list