[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...

Galder Zamarreno galder.zamarreno at jboss.com
Fri Jan 5 11:29:40 EST 2007


  User: gzamarreno
  Date: 07/01/05 11:29:40

  Modified:    tests/functional/org/jboss/cache/marshall 
                        RedeploymentEmulationTest.java
  Log:
  Modified so that it passes under CC
  
  Revision  Changes    Path
  1.5       +34 -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.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- RedeploymentEmulationTest.java	30 Dec 2006 17:49:57 -0000	1.4
  +++ RedeploymentEmulationTest.java	5 Jan 2007 16:29:40 -0000	1.5
  @@ -17,6 +17,7 @@
   import java.io.File;
   import java.net.URL;
   import java.net.URLClassLoader;
  +import java.net.MalformedURLException;
   
   /**
    * Unit test demonstrating usability of marshalling for application redeployment in application server.
  @@ -31,7 +32,9 @@
      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 = File.separator;//System.getProperty("file.separator");
  -   private static final String LIB_DIR = "lib";
  +   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
      {
  @@ -50,10 +53,7 @@
      {
         cache.start();
   
  -      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);
  @@ -75,10 +75,7 @@
      {
         cache.start();
   
  -      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);
   
         Region region = cache.getRegion(fqn("/"), true);
  @@ -109,6 +106,32 @@
         region.unregisterContextClassLoader();
      }
   
  +   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;
  +   }
  +
      private static Fqn fqn(String fqn)
      {
         return Fqn.fromString(fqn);
  
  
  



More information about the jboss-cvs-commits mailing list