cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/3] cxf-fediz git commit: Consolidate Tomcat shutdown code + avoid a NPE
Date Thu, 07 Apr 2016 16:03:06 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master 4c20cefb8 -> a2e10b873


Consolidate Tomcat shutdown code + avoid a NPE


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

Branch: refs/heads/master
Commit: 953282b320e5342020fe8b77e62715b617877479
Parents: 4c20cef
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Apr 7 12:03:49 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Apr 7 12:03:49 2016 +0100

----------------------------------------------------------------------
 .../federation/FederationTest.java              | 28 +++++++------------
 .../cxf/fediz/integrationtests/OIDCTest.java    | 27 +++++++-----------
 .../integrationtests/SAMLSSOFedizTest.java      | 27 +++++++-----------
 .../cxf/fediz/integrationtests/SAMLSSOTest.java | 27 +++++++-----------
 .../cxf/fediz/integrationtests/WSFedTest.java   | 27 +++++++-----------
 .../apache/cxf/fediz/systests/idp/IdpTest.java  | 14 ++++++----
 .../fediz/integrationtests/KerberosTest.java    | 27 +++++++-----------
 .../cxf/fediz/systests/oidc/OIDCTest.java       | 27 ++++++------------
 .../apache/cxf/fediz/systests/idp/IdpTest.java  | 14 ++++++----
 .../cxf/fediz/integrationtests/Spring2Test.java | 28 ++++++++-----------
 .../cxf/fediz/integrationtests/SpringTest.java  | 27 +++++++-----------
 .../integrationtests/ClientCertificateTest.java | 27 +++++++-----------
 .../fediz/integrationtests/HolderOfKeyTest.java | 29 ++++++++------------
 .../cxf/fediz/integrationtests/TomcatTest.java  | 27 +++++++-----------
 .../cxf/fediz/integrationtests/WReqTest.java    | 27 +++++++-----------
 .../integrationtests/ClientCertificateTest.java | 27 +++++++-----------
 .../fediz/integrationtests/HolderOfKeyTest.java | 27 +++++++-----------
 .../cxf/fediz/integrationtests/TomcatTest.java  | 27 +++++++-----------
 .../cxf/fediz/integrationtests/WReqTest.java    | 29 ++++++++------------
 19 files changed, 189 insertions(+), 304 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
----------------------------------------------------------------------
diff --git a/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
b/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
index 5404e49..937d5af 100644
--- a/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
+++ b/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
@@ -134,30 +134,22 @@ public class FederationTest extends AbstractTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        
     }
     
     public String getIdpHttpsPort() {

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/federation/oidc/src/test/java/org/apache/cxf/fediz/integrationtests/OIDCTest.java
----------------------------------------------------------------------
diff --git a/systests/federation/oidc/src/test/java/org/apache/cxf/fediz/integrationtests/OIDCTest.java
b/systests/federation/oidc/src/test/java/org/apache/cxf/fediz/integrationtests/OIDCTest.java
index 0a7e83a..d1ba012 100644
--- a/systests/federation/oidc/src/test/java/org/apache/cxf/fediz/integrationtests/OIDCTest.java
+++ b/systests/federation/oidc/src/test/java/org/apache/cxf/fediz/integrationtests/OIDCTest.java
@@ -200,25 +200,18 @@ public class OIDCTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOFedizTest.java
----------------------------------------------------------------------
diff --git a/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOFedizTest.java
b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOFedizTest.java
index 42518f3..bd7d7f1 100644
--- a/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOFedizTest.java
+++ b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOFedizTest.java
@@ -195,25 +195,18 @@ public class SAMLSSOFedizTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java
----------------------------------------------------------------------
diff --git a/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java
b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java
index af47527..7aeac6e 100644
--- a/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java
+++ b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java
@@ -206,25 +206,18 @@ public class SAMLSSOTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/federation/wsfed/src/test/java/org/apache/cxf/fediz/integrationtests/WSFedTest.java
----------------------------------------------------------------------
diff --git a/systests/federation/wsfed/src/test/java/org/apache/cxf/fediz/integrationtests/WSFedTest.java
b/systests/federation/wsfed/src/test/java/org/apache/cxf/fediz/integrationtests/WSFedTest.java
index dae44a6..f5cc0e6 100644
--- a/systests/federation/wsfed/src/test/java/org/apache/cxf/fediz/integrationtests/WSFedTest.java
+++ b/systests/federation/wsfed/src/test/java/org/apache/cxf/fediz/integrationtests/WSFedTest.java
@@ -198,25 +198,18 @@ public class WSFedTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
----------------------------------------------------------------------
diff --git a/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java b/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
index 1116759..58ed81c 100644
--- a/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
+++ b/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
@@ -117,13 +117,17 @@ public class IdpTest {
 
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                idpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/kerberos/src/test/java/org/apache/cxf/fediz/integrationtests/KerberosTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/fediz/integrationtests/KerberosTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/fediz/integrationtests/KerberosTest.java
index 564731a..74106e4 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/fediz/integrationtests/KerberosTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/fediz/integrationtests/KerberosTest.java
@@ -241,25 +241,18 @@ public class KerberosTest extends AbstractLdapTestUnit {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
----------------------------------------------------------------------
diff --git a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
index f4ea3a4..f57aa1a 100644
--- a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
+++ b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
@@ -186,30 +186,19 @@ public class OIDCTest {
         try {
             loginToClientsPageAndDeleteClient(rpHttpsPort, idpHttpsPort);
         } finally {
-            shutdownServers();
+            shutdownServer(idpServer);
+            shutdownServer(rpServer);
         }
     }
     
-    private static void shutdownServers() {
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
-                }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
----------------------------------------------------------------------
diff --git a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
index 2af63be..fa75b9d 100644
--- a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
+++ b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
@@ -137,13 +137,17 @@ public class IdpTest {
 
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                idpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
----------------------------------------------------------------------
diff --git a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
index 86a928f..f20a45f 100644
--- a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
+++ b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
@@ -72,25 +72,18 @@ public class Spring2Test extends AbstractTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -259,6 +252,7 @@ public class Spring2Test extends AbstractTests {
             //                  || ex.getMessage().contains("403 Forbidden"));
         }
 
+        webClient.close();
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
----------------------------------------------------------------------
diff --git a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
index 5e100c8..4da2edc 100644
--- a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
+++ b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
@@ -58,25 +58,18 @@ public class SpringTest extends AbstractTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
index f6022ed..406e4b5 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
@@ -139,25 +139,18 @@ public class ClientCertificateTest extends AbstractClientCertTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
index 872dd3c..9b996cf 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
@@ -149,31 +149,24 @@ public class HolderOfKeyTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
-
+    
     public String getIdpHttpsPort() {
         return idpHttpsPort;
     }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
index a375e75..f41f03b 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
@@ -138,25 +138,18 @@ public class TomcatTest extends AbstractTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
index 0af94dd..0bf7691 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
@@ -152,25 +152,18 @@ public class WReqTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
index daa661b..7a1e24e 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
@@ -139,25 +139,18 @@ public class ClientCertificateTest extends AbstractClientCertTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
index 1a2dc0a..650b610 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
@@ -149,25 +149,18 @@ public class HolderOfKeyTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
index 857301e..646c9ed 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
@@ -138,25 +138,18 @@ public class TomcatTest extends AbstractTests {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/953282b3/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
index 2a2626c..48e5851 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
@@ -152,31 +152,24 @@ public class WReqTest {
     
     @AfterClass
     public static void cleanup() {
+        shutdownServer(idpServer);
+        shutdownServer(rpServer);
+    }
+    
+    private static void shutdownServer(Tomcat server) {
         try {
-            if (idpServer.getServer() != null
-                && idpServer.getServer().getState() != LifecycleState.DESTROYED)
{
-                if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    idpServer.stop();
-                }
-                idpServer.destroy();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (rpServer.getServer() != null
-                && rpServer.getServer().getState() != LifecycleState.DESTROYED) {
-                if (rpServer.getServer().getState() != LifecycleState.STOPPED) {
-                    rpServer.stop();
+            if (server != null && server.getServer() != null
+                && server.getServer().getState() != LifecycleState.DESTROYED) {
+                if (server.getServer().getState() != LifecycleState.STOPPED) {
+                    server.stop();
                 }
-                rpServer.destroy();
+                server.destroy();
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
-
+    
     public String getIdpHttpsPort() {
         return idpHttpsPort;
     }


Mime
View raw message