cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [05/20] cxf git commit: Surefire 2.18 allocates and initializes the statics for ALL the test classes up front. Thus, the "Server" and similar ports get overwridden and tests fail. Update TestUtil to record the port on the various package names walkingu
Date Fri, 22 May 2015 19:19:33 GMT
Surefire 2.18 allocates and initializes the statics for ALL the test classes up front.  Thus,
the "Server" and similar ports get overwridden and tests fail.  Update TestUtil to record
the port on the various package names walkingup the class so we can start fixing tests.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/94337b7a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/94337b7a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/94337b7a

Branch: refs/heads/3.0.x-fixes
Commit: 94337b7a052c9f926667b0b5d07a4d6dcc635fbb
Parents: 9b9bc69
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed May 20 13:37:06 2015 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri May 22 14:36:28 2015 -0400

----------------------------------------------------------------------
 .../apache/cxf/testutil/common/TestUtil.java    | 38 ++++++++++++++++----
 1 file changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/94337b7a/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
----------------------------------------------------------------------
diff --git a/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java b/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
index 2cb3703..b72e5c6 100644
--- a/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
+++ b/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java
@@ -142,13 +142,42 @@ public final class TestUtil {
     public static String getNewPortNumber(String name) {
         return getNewPortNumber(name, name);
     }
-    public static String getNewPortNumber(String fullName, String simpleName) {
+    
+    private static void applyNames(String fullName, String simpleName, String p) {
+        ports.setProperty("testutil.ports." + fullName, p);
+        ports.setProperty("testutil.ports." + simpleName, p);
+        System.setProperty("testutil.ports." + fullName, p);
+        System.setProperty("testutil.ports." + simpleName, p);
+        if (fullName.endsWith("." + simpleName)) {
+            int idx = fullName.lastIndexOf('.', fullName.lastIndexOf('.'));
+            while (idx != -1) {
+                String name = fullName.substring(idx + 1);
+                ports.setProperty("testutil.ports." + name, p);
+                System.setProperty("testutil.ports." + name, p);
+                idx = fullName.lastIndexOf('.', idx - 1);
+            }
+        }
+    }
+    private static void removeNames(String fullName, String simpleName) {
         ports.remove("testutil.ports." + fullName);
         ports.remove("testutil.ports." + simpleName);
         System.clearProperty("testutil.ports." + fullName);
         System.clearProperty("testutil.ports." + simpleName);        
+        if (fullName.endsWith("." + simpleName)) {
+            int idx = fullName.lastIndexOf('.', fullName.lastIndexOf('.'));
+            while (idx != -1) {
+                String name = fullName.substring(idx + 1);
+                ports.remove("testutil.ports." + name);
+                System.clearProperty("testutil.ports." + name);
+                idx = fullName.lastIndexOf('.', idx - 1);
+            }
+        }
+    }
+    
+    public static String getNewPortNumber(String fullName, String simpleName) {
+        removeNames(fullName, simpleName);
         return getPortNumber(fullName, simpleName);
-    }    
+    } 
     public static String getPortNumber(String fullName, String simpleName) {
         String p = ports.getProperty("testutil.ports." + fullName);
         if (p == null) {
@@ -170,10 +199,7 @@ public final class TestUtil {
                 //
             }
         }
-        ports.put("testutil.ports." + fullName, p);
-        ports.put("testutil.ports." + simpleName, p);
-        System.setProperty("testutil.ports." + fullName, p);
-        System.setProperty("testutil.ports." + simpleName, p);
+        applyNames(fullName, simpleName, p);
         return p;
     }
     


Mime
View raw message