cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/4] cxf git commit: Use a random port for the sts tests
Date Wed, 15 Mar 2017 18:43:45 GMT
Use a random port for the sts tests

# Conflicts:
#	services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/BasicSTSIntegrationTest.java
#	services/sts/systests/sts-itests/src/test/java/org/apache/cxf/systest/sts/itests/unit/STSUnitTest.java


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

Branch: refs/heads/3.1.x-fixes
Commit: 76e415b00a35a66b2254114b102b4259886f10cf
Parents: 171feb8
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 14:06:03 2017 -0400

----------------------------------------------------------------------
 services/sts/systests/sts-itests/pom.xml        |  6 +++++
 .../sts/itests/BasicSTSIntegrationTest.java     | 12 +++++-----
 .../systest/sts/itests/unit/STSUnitTest.java    | 23 ++++++++++++++++++--
 3 files changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/76e415b0/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 037d5cb..e16ad5e 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/76e415b0/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 f9f0768..8330f58 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,12 +39,12 @@ 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 karafVersion = System.getProperty("karaf.version", "3.0.4");
+        String port = TestUtil.getPortNumber(BasicSTSIntegrationTest.class);
+        System.setProperty("BasicSTSIntegrationTest.PORT", port);
+        
         String localRepository = System.getProperty("localRepository");
         
         MavenArtifactUrlReference karafUrl = maven() //
@@ -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/76e415b0/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 7fdb04f..24a400a 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;
@@ -54,14 +55,32 @@ public class STSUnitTest extends BasicSTSIntegrationTest {
         "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0";
     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);
+        SecurityToken token =
+            requestSecurityToken(SAML2_TOKEN_TYPE, BEARER_KEYTYPE, bus, stsEndpoint);
         Assert.assertTrue(SAML2_TOKEN_TYPE.equals(token.getTokenType()));
         Assert.assertTrue(token.getToken() != null);
         


Mime
View raw message