You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/06/30 15:05:57 UTC

[cxf] branch master updated: CXF-8730: Fix org.apache.cxf.osgi.itests.jaxrs.JaxRsServiceTest (#967)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 227e81b07f CXF-8730: Fix org.apache.cxf.osgi.itests.jaxrs.JaxRsServiceTest (#967)
227e81b07f is described below

commit 227e81b07f547106af5e76af7e526fc6c3c8ffc2
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Thu Jun 30 07:51:01 2022 -0400

    CXF-8730: Fix org.apache.cxf.osgi.itests.jaxrs.JaxRsServiceTest (#967)
---
 .../org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java   |  1 +
 .../java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java    | 10 +++++++---
 .../org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java     |  4 ++--
 .../java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java  |  2 +-
 .../java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java   |  1 +
 5 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
index b1ed1c991d..479397150e 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
@@ -54,6 +54,7 @@ public class BundlesAndNamespacesTest extends CXFOSGiTestSupport {
     public Option[] config() {
         return OptionUtils.combine(
             cxfBaseConfig(),
+            testUtils(),
             features(cxfUrl, "aries-blueprint", "cxf-core", "cxf-jaxws"),
             logLevel(LogLevel.INFO)
         );
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
index b84bd7b4ee..a330a924b8 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
@@ -23,6 +23,8 @@ package org.apache.cxf.osgi.itests;
 import java.io.File;
 
 import jakarta.inject.Inject;
+
+import org.apache.cxf.testutil.common.TestUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -47,12 +49,14 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDist
 /**
  *
  */
-public class CXFOSGiTestSupport {
+public abstract class CXFOSGiTestSupport {
 
     // Adding apache snapshots as cxf trunk may contain snapshot dependencies
 //    private static final String REPOS = "https://repo1.maven.org/maven2@id=central,"
 //        + "https://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases";
 
+    protected static final String PORT = TestUtil.getPortNumber("osgi-itests");
+
     @Inject
     protected BundleContext bundleContext;
 
@@ -68,7 +72,6 @@ public class CXFOSGiTestSupport {
             .type("xml").classifier("features");
 
         String localRepo = System.getProperty("localRepository");
-        Object urp = System.getProperty("cxf.useRandomFirstPort");
 
         final Option[] basicOptions = new Option[] {
             karafDistributionConfiguration()
@@ -89,7 +92,8 @@ public class CXFOSGiTestSupport {
                 .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
                                                      "org.ops4j.pax.url.mvn.localRepository",
                                                      localRepo)),
-            when(urp != null).useOptions(systemProperty("cxf.useRandomFirstPort").value("true"))
+            systemProperty("testutil.ports.osgi-itests").value(PORT),
+            editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", PORT)
         };
         if (JavaVersionUtil.getMajorVersion() >= 9) {
             final String karafVersion = MavenUtils.getArtifactVersion("org.apache.karaf", "apache-karaf-minimal");
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
index 0f6eb87dea..3243efa4b3 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
@@ -52,7 +52,7 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
 @ExamReactorStrategy(PerClass.class)
 public class JaxRsServiceTest extends CXFOSGiTestSupport {
 
-    private static final String BASE_URL = "http://localhost:8181/cxf/jaxrs/bookstore";
+    private static final String BASE_URL = "http://localhost:" + PORT + "/cxf/jaxrs/bookstore";
 
     private final WebTarget wt = ClientBuilder.newClient().target(BASE_URL);
 
@@ -108,6 +108,7 @@ public class JaxRsServiceTest extends CXFOSGiTestSupport {
             cxfBaseConfig(),
             features(cxfUrl, "cxf-core", "cxf-wsdl", "cxf-jaxrs", "cxf-bean-validation-core", "cxf-bean-validation"),
             logLevel(LogLevel.INFO),
+            testUtils(),
             provision(serviceBundle())
         );
     }
@@ -132,5 +133,4 @@ public class JaxRsServiceTest extends CXFOSGiTestSupport {
                 .build(TinyBundles.withBnd());
         }
     }
-
 }
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
index 3467daaf8f..871d828597 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
@@ -48,7 +48,7 @@ public class HttpServiceTest extends CXFOSGiTestSupport {
 
     @Test
     public void testHttpEndpoint() throws Exception {
-        Greeter greeter = greeterHttpProxy("8181");
+        Greeter greeter = greeterHttpProxy(PORT);
         String res = greeter.greetMe("Chris");
         assertEquals("Hi Chris", res);
     }
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
index 55d9696b97..bf0d21f6ad 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
@@ -76,6 +76,7 @@ public class JmsServiceTest extends CXFOSGiTestSupport {
     public Option[] config() {
         return OptionUtils.combine(
             cxfBaseConfig(),
+            testUtils(),
             features(cxfUrl, "cxf-jaxws", "cxf-transports-jms"),
             features(maven().groupId("org.apache.activemq").artifactId("activemq-karaf").versionAsInProject()
                 .type("xml").classifier("features-core"),