Use a random port for the sts tests
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cf806d5c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cf806d5c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cf806d5c
Branch: refs/heads/master
Commit: cf806d5cba74e47c6e5ba3231df4228cbaad3e90
Parents: f51d755
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 15 11:55:44 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Mar 15 11:55:44 2017 -0400
----------------------------------------------------------------------
services/sts/systests/sts-itests/pom.xml | 6 ++++++
.../sts/itests/BasicSTSIntegrationTest.java | 12 ++++++-----
.../systest/sts/itests/unit/STSUnitTest.java | 21 +++++++++++++++++++-
3 files changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/cf806d5c/services/sts/systests/sts-itests/pom.xml
----------------------------------------------------------------------
diff --git a/services/sts/systests/sts-itests/pom.xml b/services/sts/systests/sts-itests/pom.xml
index cb83cce..9c3f5d8 100644
--- a/services/sts/systests/sts-itests/pom.xml
+++ b/services/sts/systests/sts-itests/pom.xml
@@ -97,6 +97,12 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/cxf/blob/cf806d5c/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
b/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
index 7568825..e8a2edf 100644
--- a/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
+++ b/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
@@ -20,6 +20,7 @@ package org.apache.cxf.systest.sts.itests;
import java.io.File;
+import org.apache.cxf.testutil.common.TestUtil;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
@@ -38,11 +39,11 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceCo
@ExamReactorStrategy(PerClass.class)
public class BasicSTSIntegrationTest {
- protected static final String HTTP_PORT = "9191";
- protected static final String STS_ENDPOINT = "http://localhost:" + HTTP_PORT + "/cxf/X509";
-
@Configuration
public Option[] getConfig() {
+ String port = TestUtil.getPortNumber(BasicSTSIntegrationTest.class);
+ System.setProperty("BasicSTSIntegrationTest.PORT", port);
+
String karafVersion = System.getProperty("karaf.version", "4.0.8");
String localRepository = System.getProperty("localRepository");
@@ -61,17 +62,18 @@ public class BasicSTSIntegrationTest {
karafDistributionConfiguration().frameworkUrl(karafUrl).karafVersion(karafVersion)
.unpackDirectory(new File("target/paxexam/unpack/")).useDeployFolder(false),
systemProperty("java.awt.headless").value("true"),
+ systemProperty("BasicSTSIntegrationTest.PORT").value(port),
copy("clientKeystore.properties"),
copy("clientstore.jks"),
copy("etc/org.ops4j.pax.logging.cfg"),
- editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port",
HTTP_PORT),
+ editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port",
port),
when(localRepository != null)
.useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.localRepository",
localRepository)),
features(stsFeatures, "cxf-sts-service"),
- configureConsole().ignoreLocalConsole(),
+ configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
};
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/cf806d5c/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java
b/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java
index 24a6ee4..15459ee 100644
--- a/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java
+++ b/services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java
@@ -19,6 +19,7 @@
package org.apache.cxf.systest.sts.itests.unit;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -55,13 +56,31 @@ public class STSUnitTest extends BasicSTSIntegrationTest {
private static final String BEARER_KEYTYPE =
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer";
+ void waitForWSDL(String loc) throws Exception {
+ URL url = new URL(loc + "?wsdl");
+ for (int x = 0; x < 10; x++) {
+ try {
+ url.openStream().close();
+ return;
+ } catch (Throwable t) {
+ Thread.sleep(100);
+ }
+ }
+ }
+
@Test
public void testBearerSAML2Token() throws URISyntaxException, Exception {
Bus bus = BusFactory.getDefaultBus();
+ String stsEndpoint = "http://localhost:"
+ + System.getProperty("BasicSTSIntegrationTest.PORT")
+ + "/cxf/X509";
+ //sts could take a second or two to fully startup, make sure we can get the wsdl
+ waitForWSDL(stsEndpoint);
+
// Get a token
SecurityToken token =
- requestSecurityToken(SAML2_TOKEN_TYPE, BEARER_KEYTYPE, bus, STS_ENDPOINT);
+ requestSecurityToken(SAML2_TOKEN_TYPE, BEARER_KEYTYPE, bus, stsEndpoint);
Assert.assertTrue(SAML2_TOKEN_TYPE.equals(token.getTokenType()));
Assert.assertTrue(token.getToken() != null);
|