cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Fixing Swagger2 tests by adding a host property to resource files and ignoring the host ports as ports are allocated dynamically
Date Tue, 04 Aug 2015 13:37:10 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5048d0b5a -> 0696b1660


Fixing Swagger2 tests by adding a host property to resource files and ignoring the host ports
as ports are allocated dynamically


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

Branch: refs/heads/master
Commit: 0696b166015543a1b2ad9c165dd00e27fea8dd18
Parents: 5048d0b
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Aug 4 14:36:47 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Aug 4 14:36:47 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/swagger/Swagger2Feature.java   | 12 +++++++++++-
 .../AbstractSwagger2ServiceDescriptionTest.java         |  1 +
 .../cxf/systest/jaxrs/description/swagger2-json.txt     |  1 +
 .../cxf/systest/jaxrs/description/swagger2-yaml.txt     |  1 +
 4 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0696b166/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
index 1441b5c..d36ab50 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
@@ -43,6 +43,7 @@ import io.swagger.jaxrs.listing.SwaggerSerializers;
 
 public class Swagger2Feature extends AbstractSwaggerFeature {
     private String host;
+    private boolean ignoreHostPort;
 
     @Override
     protected void addSwaggerResource(Server server) {
@@ -93,12 +94,21 @@ public class Swagger2Feature extends AbstractSwaggerFeature {
             // get the path part
             URI u = URI.create(address); 
             setBasePath(u.getPath());
-            setHost(u.getPort() < 0 ? u.getHost() : u.getHost() + ":" + u.getPort());
+            setHost(u.getPort() < 0 || isIgnoreHostPort() 
+                    ? u.getHost() : u.getHost() + ":" + u.getPort());
         } else {
             setBasePath(address);
         }
     }
 
+    public boolean isIgnoreHostPort() {
+        return ignoreHostPort;
+    }
+
+    public void setIgnoreHostPort(boolean ignoreHostPort) {
+        this.ignoreHostPort = ignoreHostPort;
+    }
+
     @PreMatching
     private static class SwaggerContainerRequestFilter extends ApiListingResource implements
ContainerRequestFilter {
         private static final String APIDOCS_LISTING_PATH_JSON = "swagger.json";

http://git-wip-us.apache.org/repos/asf/cxf/blob/0696b166/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
index 285b150..e698143 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
@@ -61,6 +61,7 @@ public abstract class AbstractSwagger2ServiceDescriptionTest extends AbstractBus
                 new SingletonResourceProvider(new BookStoreSwagger2()));
             sf.setProvider(new JacksonJsonProvider());
             final Swagger2Feature feature = new Swagger2Feature();
+            feature.setIgnoreHostPort(true);
             feature.setRunAsFilter(runAsFilter);
             sf.setFeatures(Arrays.asList(feature));
             sf.setAddress("http://localhost:" + port + "/");

http://git-wip-us.apache.org/repos/asf/cxf/blob/0696b166/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
index 8a1ee87..299fcdd 100644
--- a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
+++ b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
@@ -5,6 +5,7 @@
          "contact":{"name":"committer@apache.org"},
          "license":{"name":"Apache 2.0 License",
                     "url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},
+ "host":"localhost",
  "basePath":"/",
  "tags":[{"name":"bookstore"}],
  "paths":{"/bookstore":{"get":{"tags":["bookstore"],

http://git-wip-us.apache.org/repos/asf/cxf/blob/0696b166/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-yaml.txt
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-yaml.txt
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-yaml.txt
index db11154..c007f85 100644
--- a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-yaml.txt
+++ b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-yaml.txt
@@ -9,6 +9,7 @@ info:
   license:
     name: "Apache 2.0 License"
     url: "http://www.apache.org/licenses/LICENSE-2.0.html"
+host: "localhost"    
 basePath: "/"
 tags:
 - name: "bookstore"


Mime
View raw message