You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/04/07 18:03:06 UTC
[1/3] cxf-fediz git commit: Consolidate Tomcat shutdown code + avoid
a NPE
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 <co...@apache.org>
Authored: Thu Apr 7 12:03:49 2016 +0100
Committer: Colm O hEigeartaigh <co...@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;
}
[3/3] cxf-fediz git commit: Consolidate test launch code and avoid
stacktraces when launching Tomcat servers
Posted by co...@apache.org.
Consolidate test launch code and avoid stacktraces when launching Tomcat servers
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/a2e10b87
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/a2e10b87
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/a2e10b87
Branch: refs/heads/master
Commit: a2e10b8734db855026a2154ac5aaace7ec4959d3
Parents: 953282b
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Apr 7 17:02:40 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Apr 7 17:02:40 2016 +0100
----------------------------------------------------------------------
.../cxf/fediz/integrationtests/OIDCTest.java | 157 +++++++-----------
.../integrationtests/SAMLSSOFedizTest.java | 164 +++++++-----------
.../cxf/fediz/integrationtests/SAMLSSOTest.java | 165 +++++++------------
.../cxf/fediz/integrationtests/WSFedTest.java | 162 +++++++-----------
.../fediz/integrationtests/KerberosTest.java | 119 ++++++-------
systests/oidc/pom.xml | 20 +++
.../cxf/fediz/systests/oidc/OIDCTest.java | 116 ++++++-------
.../apache/cxf/fediz/systests/idp/IdpTest.java | 78 +++++----
.../cxf/fediz/integrationtests/Spring2Test.java | 121 ++++++--------
.../cxf/fediz/integrationtests/SpringTest.java | 120 ++++++--------
.../integrationtests/ClientCertificateTest.java | 116 ++++++-------
.../fediz/integrationtests/HolderOfKeyTest.java | 118 ++++++-------
.../cxf/fediz/integrationtests/TomcatTest.java | 120 ++++++--------
.../cxf/fediz/integrationtests/WReqTest.java | 119 ++++++-------
.../integrationtests/ClientCertificateTest.java | 116 ++++++-------
.../fediz/integrationtests/HolderOfKeyTest.java | 118 ++++++-------
.../cxf/fediz/integrationtests/TomcatTest.java | 120 ++++++--------
.../cxf/fediz/integrationtests/WReqTest.java | 119 ++++++-------
.../src/main/webapp/META-INF/context.xml | 22 ---
.../src/main/webapp/META-INF/context.xml | 22 ---
20 files changed, 886 insertions(+), 1326 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 d1ba012..4110355 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
@@ -24,6 +24,9 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+
import org.w3c.dom.Element;
import com.gargoylesoftware.htmlunit.CookieManager;
@@ -37,6 +40,7 @@ import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -66,7 +70,7 @@ public class OIDCTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -83,124 +87,73 @@ public class OIDCTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initOIDCIdp();
- initRp();
+ idpServer = startServer(true, false, idpHttpsPort);
+ idpOIDCServer = startServer(false, true, idpOIDCHttpsPort);
+ rpServer = startServer(false, false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ private static Tomcat startServer(boolean idp, boolean realmb, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else if (realmb) {
+ server.getHost().setAppBase("tomcat/idpoidc/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
-
- private static void initOIDCIdp() {
- try {
- idpOIDCServer = new Tomcat();
- idpOIDCServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpOIDCServer.setBaseDir(currentDir + File.separator + "target");
-
- idpOIDCServer.getHost().setAppBase("tomcat/idpoidc/webapps");
- idpOIDCServer.getHost().setAutoDeploy(true);
- idpOIDCServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpOIDCHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
- idpOIDCServer.getService().addConnector(httpsConnector);
-
- idpOIDCServer.addWebapp("/idp", "idpoidc");
-
- idpOIDCServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
- rpServer.getService().addConnector(httpsConnector);
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else if (realmb) {
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "idpoidc");
+ server.addWebapp("/idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_oidc.xml");
cxt.getPipeline().addValve(fa);
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
+ shutdownServer(idpOIDCServer);
shutdownServer(rpServer);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 bd7d7f1..a9b0762 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
@@ -23,6 +23,8 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
import java.io.IOException;
+import javax.servlet.ServletException;
+
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
@@ -30,6 +32,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -58,7 +61,7 @@ public class SAMLSSOFedizTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -75,127 +78,76 @@ public class SAMLSSOFedizTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRealmbIdp();
- initRp();
+ idpServer = startServer(true, false, idpHttpsPort);
+ idpRealmbServer = startServer(false, true, idpRealmbHttpsPort);
+ rpServer = startServer(false, false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, boolean realmb, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else if (realmb) {
+ server.getHost().setAppBase("tomcat/idprealmb/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRealmbIdp() {
- try {
- idpRealmbServer = new Tomcat();
- idpRealmbServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpRealmbServer.setBaseDir(currentDir + File.separator + "target");
-
- idpRealmbServer.getHost().setAppBase("tomcat/idprealmb/webapps");
- idpRealmbServer.getHost().setAutoDeploy(true);
- idpRealmbServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpRealmbHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpRealmbServer.getService().addConnector(httpsConnector);
-
- idpRealmbServer.addWebapp("/fediz-idp-sts-realmb", "fediz-idp-sts-realmb");
- idpRealmbServer.addWebapp("/fediz-idp-realmb", "fediz-idp-realmb");
-
- idpRealmbServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else if (realmb) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts-realmb");
+ server.addWebapp("/fediz-idp-sts-realmb", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-realmb");
+ server.addWebapp("/fediz-idp-realmb", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld3", rpWebapp.getAbsolutePath());
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld3", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_saml_sso.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
+ shutdownServer(idpRealmbServer);
shutdownServer(rpServer);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 7aeac6e..4637be3 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
@@ -23,6 +23,8 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
import java.io.IOException;
+import javax.servlet.ServletException;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -35,6 +37,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -68,7 +71,7 @@ public class SAMLSSOTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -85,128 +88,78 @@ public class SAMLSSOTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initSamlSSOIdp();
- initRp();
- }
-
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ idpServer = startServer(true, false, idpHttpsPort);
+ idpSamlSSOServer = startServer(false, true, idpSamlSSOHttpsPort);
+ rpServer = startServer(false, false, rpHttpsPort);
}
- private static void initSamlSSOIdp() {
- try {
- idpSamlSSOServer = new Tomcat();
- idpSamlSSOServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpSamlSSOServer.setBaseDir(currentDir + File.separator + "target");
-
- idpSamlSSOServer.getHost().setAppBase("tomcat/idpsamlsso/webapps");
- idpSamlSSOServer.getHost().setAutoDeploy(true);
- idpSamlSSOServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpSamlSSOHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpSamlSSOServer.getService().addConnector(httpsConnector);
-
- idpSamlSSOServer.addWebapp("/idp", "idpsaml");
-
- idpSamlSSOServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, boolean realmb, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else if (realmb) {
+ server.getHost().setAppBase("tomcat/idpsamlsso/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else if (realmb) {
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "idpsaml");
+ server.addWebapp("/idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_saml_sso.xml");
cxt.getPipeline().addValve(fa);
- cxt = rpServer.addWebapp("/fedizhelloworld-post-binding", "simpleWebapp2");
+ File rpWebapp2 = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp2");
+ cxt = server.addWebapp("/fedizhelloworld-post-binding", rpWebapp2.getAbsolutePath());
cxt.getPipeline().addValve(fa);
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
+ shutdownServer(idpSamlSSOServer);
shutdownServer(rpServer);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 f5cc0e6..1a72589 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
@@ -24,6 +24,8 @@ import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
+import javax.servlet.ServletException;
+
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
@@ -33,6 +35,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -61,7 +64,7 @@ public class WSFedTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -78,127 +81,76 @@ public class WSFedTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRealmbIdp();
- initRp();
+ idpServer = startServer(true, false, idpHttpsPort);
+ idpRealmbServer = startServer(false, true, idpRealmbHttpsPort);
+ rpServer = startServer(false, false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ private static Tomcat startServer(boolean idp, boolean realmb, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else if (realmb) {
+ server.getHost().setAppBase("tomcat/idprealmb/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
-
- private static void initRealmbIdp() {
- try {
- idpRealmbServer = new Tomcat();
- idpRealmbServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpRealmbServer.setBaseDir(currentDir + File.separator + "target");
-
- idpRealmbServer.getHost().setAppBase("tomcat/idprealmb/webapps");
- idpRealmbServer.getHost().setAutoDeploy(true);
- idpRealmbServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpRealmbHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
- idpRealmbServer.getService().addConnector(httpsConnector);
-
- idpRealmbServer.addWebapp("/fediz-idp-sts-realmb", "fediz-idp-sts-realmb");
- idpRealmbServer.addWebapp("/fediz-idp-realmb", "fediz-idp-realmb");
-
- idpRealmbServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
- rpServer.getService().addConnector(httpsConnector);
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else if (realmb) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts-realmb");
+ server.addWebapp("/fediz-idp-sts-realmb", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-realmb");
+ server.addWebapp("/fediz-idp-realmb", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_wsfed.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
+ shutdownServer(idpRealmbServer);
shutdownServer(rpServer);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 74106e4..bfbcdfc 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
@@ -23,10 +23,12 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
+import javax.servlet.ServletException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
@@ -34,6 +36,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -113,7 +116,7 @@ public class KerberosTest extends AbstractLdapTestUnit {
private static boolean portUpdated;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -130,8 +133,8 @@ public class KerberosTest extends AbstractLdapTestUnit {
WSSConfig.init();
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
@Before
@@ -162,81 +165,57 @@ public class KerberosTest extends AbstractLdapTestUnit {
System.setProperty("java.security.auth.login.config", "src/test/resources/kerberos.jaas");
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/systests/oidc/pom.xml
----------------------------------------------------------------------
diff --git a/systests/oidc/pom.xml b/systests/oidc/pom.xml
index 75bb74c..5639f37 100644
--- a/systests/oidc/pom.xml
+++ b/systests/oidc/pom.xml
@@ -225,6 +225,26 @@
</executions>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <delete>
+ <fileset dir="${basedir}/target/tomcat/rp/webapps/fediz-oidc/META-INF" includes="context.xml" />
+ </delete>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<inherited>true</inherited>
<executions>
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 f57aa1a..c37bf09 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
@@ -35,6 +35,8 @@ import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
+import javax.servlet.ServletException;
+
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.UnexpectedPage;
@@ -54,6 +56,7 @@ import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.gargoylesoftware.htmlunit.util.WebConnectionWrapper;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -99,86 +102,63 @@ public class OIDCTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initOidc();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
loginToClientsPage(rpHttpsPort, idpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initOidc() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-oidc");
+ Context cxt = server.addWebapp("/fediz-oidc", rpWebapp.getAbsolutePath());
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fediz-oidc", "fediz-oidc");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
cxt.getPipeline().addValve(fa);
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 fa75b9d..f67b38e 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
@@ -29,6 +29,8 @@ import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.UUID;
+import javax.servlet.ServletException;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -37,6 +39,7 @@ import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -79,7 +82,7 @@ public class IdpTest {
private static Tomcat idpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -94,45 +97,48 @@ public class IdpTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
+ idpServer = startServer(idpHttpsPort);
WSSConfig.init();
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ private static Tomcat startServer(String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 f20a45f..d9e77ab 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
@@ -21,6 +21,9 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
@@ -31,7 +34,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
-
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -52,7 +55,7 @@ public class Spring2Test extends AbstractTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
@@ -66,8 +69,8 @@ public class Spring2Test extends AbstractTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
@AfterClass
@@ -90,75 +93,53 @@ public class Spring2Test extends AbstractTests {
}
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- rpServer.addWebapp("/fedizhelloworld_spring2", "fediz-systests-webapps-spring2");
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
+ "fediz-systests-webapps-spring2");
+ server.addWebapp("/fedizhelloworld_spring2", rpWebapp.getAbsolutePath());
}
+
+ server.start();
+
+ return server;
}
@Override
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 4da2edc..036b189 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
@@ -20,7 +20,11 @@
package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -38,7 +42,7 @@ public class SpringTest extends AbstractTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
@@ -52,8 +56,8 @@ public class SpringTest extends AbstractTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
@AfterClass
@@ -76,75 +80,53 @@ public class SpringTest extends AbstractTests {
}
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- rpServer.addWebapp("/fedizhelloworld", "fediz-systests-webapps-spring");
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
+ "fediz-systests-webapps-spring");
+ server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
}
+
+ server.start();
+
+ return server;
}
@Override
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 406e4b5..a67838a 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
@@ -20,8 +20,12 @@
package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -43,7 +47,7 @@ public class ClientCertificateTest extends AbstractClientCertTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -58,83 +62,61 @@ public class ClientCertificateTest extends AbstractClientCertTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "true");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
-
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "true");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
- rpServer.getService().addConnector(httpsConnector);
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_client_cert.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
[2/3] cxf-fediz git commit: Consolidate test launch code and avoid
stacktraces when launching Tomcat servers
Posted by co...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 9b996cf..915744e 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
@@ -20,6 +20,9 @@
package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
@@ -29,6 +32,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -53,7 +57,7 @@ public class HolderOfKeyTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -68,83 +72,61 @@ public class HolderOfKeyTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_hok.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 f41f03b..ded4581 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
@@ -21,8 +21,12 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -40,7 +44,7 @@ public class TomcatTest extends AbstractTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -55,85 +59,61 @@ public class TomcatTest extends AbstractTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 0bf7691..57a1575 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
@@ -23,6 +23,8 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
import java.io.IOException;
+import javax.servlet.ServletException;
+
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
@@ -31,6 +33,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -54,7 +57,7 @@ public class WReqTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -69,85 +72,61 @@ public class WReqTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_wreq.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 7a1e24e..04d9e33 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
@@ -20,8 +20,12 @@
package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -43,7 +47,7 @@ public class ClientCertificateTest extends AbstractClientCertTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -58,83 +62,61 @@ public class ClientCertificateTest extends AbstractClientCertTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "true");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
-
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "true");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
- rpServer.getService().addConnector(httpsConnector);
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
+
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_client_cert.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 650b610..7526acd 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
@@ -20,6 +20,9 @@
package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
@@ -29,6 +32,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -53,7 +57,7 @@ public class HolderOfKeyTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -68,83 +72,61 @@ public class HolderOfKeyTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_hok.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 646c9ed..f675c6b 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
@@ -21,8 +21,12 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -40,7 +44,7 @@ public class TomcatTest extends AbstractTests {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -55,85 +59,61 @@ public class TomcatTest extends AbstractTests {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
-
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/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 48e5851..d13d214 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
@@ -23,6 +23,8 @@ package org.apache.cxf.fediz.integrationtests;
import java.io.File;
import java.io.IOException;
+import javax.servlet.ServletException;
+
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
@@ -31,6 +33,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
@@ -54,7 +57,7 @@ public class WReqTest {
private static Tomcat rpServer;
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
@@ -69,85 +72,61 @@ public class WReqTest {
rpHttpsPort = System.getProperty("rp.https.port");
Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
- initIdp();
- initRp();
+ idpServer = startServer(true, idpHttpsPort);
+ rpServer = startServer(false, rpHttpsPort);
}
- private static void initIdp() {
- try {
- idpServer = new Tomcat();
- idpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- idpServer.setBaseDir(currentDir + File.separator + "target");
-
- idpServer.getHost().setAppBase("tomcat/idp/webapps");
- idpServer.getHost().setAutoDeploy(true);
- idpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(idpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("clientAuth", "want");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- idpServer.getService().addConnector(httpsConnector);
-
- idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts");
- idpServer.addWebapp("/fediz-idp", "fediz-idp");
-
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
+ private static Tomcat startServer(boolean idp, String port)
+ throws ServletException, LifecycleException, IOException {
+ Tomcat server = new Tomcat();
+ server.setPort(0);
+ String currentDir = new File(".").getCanonicalPath();
+ String baseDir = currentDir + File.separator + "target";
+ server.setBaseDir(baseDir);
+
+ if (idp) {
+ server.getHost().setAppBase("tomcat/idp/webapps");
+ } else {
+ server.getHost().setAppBase("tomcat/rp/webapps");
}
- }
+ server.getHost().setAutoDeploy(true);
+ server.getHost().setDeployOnStartup(true);
+
+ Connector httpsConnector = new Connector();
+ httpsConnector.setPort(Integer.parseInt(port));
+ httpsConnector.setSecure(true);
+ httpsConnector.setScheme("https");
+ //httpsConnector.setAttribute("keyAlias", keyAlias);
+ httpsConnector.setAttribute("keystorePass", "tompass");
+ httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("truststorePass", "tompass");
+ httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
+ httpsConnector.setAttribute("clientAuth", "want");
+ // httpsConnector.setAttribute("clientAuth", "false");
+ httpsConnector.setAttribute("sslProtocol", "TLS");
+ httpsConnector.setAttribute("SSLEnabled", true);
+
+ server.getService().addConnector(httpsConnector);
+
+ if (idp) {
+ File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
+ server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
- private static void initRp() {
- try {
- rpServer = new Tomcat();
- rpServer.setPort(0);
- String currentDir = new File(".").getCanonicalPath();
- rpServer.setBaseDir(currentDir + File.separator + "target");
-
- rpServer.getHost().setAppBase("tomcat/rp/webapps");
- rpServer.getHost().setAutoDeploy(true);
- rpServer.getHost().setDeployOnStartup(true);
-
- Connector httpsConnector = new Connector();
- httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
- httpsConnector.setSecure(true);
- httpsConnector.setScheme("https");
- //httpsConnector.setAttribute("keyAlias", keyAlias);
- httpsConnector.setAttribute("keystorePass", "tompass");
- httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
- httpsConnector.setAttribute("truststorePass", "tompass");
- httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
- // httpsConnector.setAttribute("clientAuth", "false");
- httpsConnector.setAttribute("clientAuth", "want");
- httpsConnector.setAttribute("sslProtocol", "TLS");
- httpsConnector.setAttribute("SSLEnabled", true);
-
- rpServer.getService().addConnector(httpsConnector);
+ File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
+ server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
+ } else {
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
+ Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
- //Context ctx =
- Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp");
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_wreq.xml");
cxt.getPipeline().addValve(fa);
-
-
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
}
+
+ server.start();
+
+ return server;
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/systests/webapps/simpleWebapp/src/main/webapp/META-INF/context.xml
----------------------------------------------------------------------
diff --git a/systests/webapps/simpleWebapp/src/main/webapp/META-INF/context.xml b/systests/webapps/simpleWebapp/src/main/webapp/META-INF/context.xml
deleted file mode 100644
index 838f156..0000000
--- a/systests/webapps/simpleWebapp/src/main/webapp/META-INF/context.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<Context>
- <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" configFile="conf/fediz_config.xml" />
-</Context>
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/a2e10b87/systests/webapps/springPreauthWebapp/src/main/webapp/META-INF/context.xml
----------------------------------------------------------------------
diff --git a/systests/webapps/springPreauthWebapp/src/main/webapp/META-INF/context.xml b/systests/webapps/springPreauthWebapp/src/main/webapp/META-INF/context.xml
deleted file mode 100644
index 838f156..0000000
--- a/systests/webapps/springPreauthWebapp/src/main/webapp/META-INF/context.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<Context>
- <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" configFile="conf/fediz_config.xml" />
-</Context>