cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1304424 - /cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
Date Fri, 23 Mar 2012 15:16:04 GMT
Author: dkulp
Date: Fri Mar 23 15:16:04 2012
New Revision: 1304424

URL: http://svn.apache.org/viewvc?rev=1304424&view=rev
Log:
Merged revisions 1303999 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1303999 | dkulp | 2012-03-22 15:30:56 -0400 (Thu, 22 Mar 2012) | 3 lines

  Use full classname when checking for test ports so multiple "Server"
  classes can have different ports.  Also log the ports in use.

........

Modified:
    cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java

Modified: cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java?rev=1304424&r1=1304423&r2=1304424&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
(original)
+++ cxf/branches/2.5.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
Fri Mar 23 15:16:04 2012
@@ -28,9 +28,13 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Properties;
 import java.util.Random;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
 
 
 public final class TestUtil {
+    private static final Logger LOG = LogUtils.getL7dLogger(TestUtil.class);
     private static int portNum = -1;
     private static Properties ports = new Properties();
     
@@ -107,18 +111,24 @@ public final class TestUtil {
     public static Properties getAllPorts() {
         return ports;
     }
+    
     public static String getPortNumber(Class<?> cls) {
-        return getPortNumber(cls.getSimpleName());
+        return getPortNumber(cls.getName(), cls.getSimpleName());
     }
     public static String getPortNumber(Class<?> cls, int count) {
-        return getPortNumber(cls.getSimpleName() + "." + count);
+        return getPortNumber(cls.getName() + "." + count,
+                             cls.getSimpleName() + "." + count);
     }
     public static String getPortNumber(String name) {
-        String p = ports.getProperty("testutil.ports." + name);
+        return getPortNumber(name, name);
+    }
+    public static String getPortNumber(String fullName, String simpleName) {
+        String p = ports.getProperty("testutil.ports." + fullName);
         if (p == null) {
-            p = System.getProperty("testutil.ports." + name);
+            p = System.getProperty("testutil.ports." + fullName);
             if (p != null) {
-                ports.setProperty("testutil.ports." + name, p);
+                ports.setProperty("testutil.ports." + fullName, p);
+                ports.setProperty("testutil.ports." + simpleName, p);
             }
         }
         while (p == null) {
@@ -128,12 +138,15 @@ public final class TestUtil {
                 ServerSocket sock = new ServerSocket(pn);
                 sock.close();
                 p = Integer.toString(pn);
+                LOG.fine("Setting port for " + fullName + " to " + p);
             } catch (IOException ex) {
                 //
             }
         }
-        ports.put("testutil.ports." + name, p);
-        System.setProperty("testutil.ports." + name, p);
+        ports.put("testutil.ports." + fullName, p);
+        ports.put("testutil.ports." + simpleName, p);
+        System.setProperty("testutil.ports." + fullName, p);
+        System.setProperty("testutil.ports." + simpleName, p);
         return p;
     }
 }



Mime
View raw message