Repository: cxf
Updated Branches:
  refs/heads/master fcb071c37 -> 5b9e19e8f


reinstate the port check in swagger2 systests


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

Branch: refs/heads/master
Commit: 5b9e19e8fa0076384f0639b55bc50235eeaae051
Parents: fcb071c
Author: Akitoshi Yoshida <[email protected]>
Authored: Mon Aug 31 10:57:11 2015 +0200
Committer: Akitoshi Yoshida <[email protected]>
Committed: Mon Aug 31 10:57:57 2015 +0200

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/swagger/Swagger2Feature.java    | 11 +----------
 .../AbstractSwagger2ServiceDescriptionTest.java          | 11 ++++++++---
 .../cxf/systest/jaxrs/description/swagger2-json.txt      |  2 +-
 .../cxf/systest/jaxrs/description/swagger2-yaml.txt      |  2 +-
 4 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5b9e19e8/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 d36ab50..659e91e 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,7 +43,6 @@ import io.swagger.jaxrs.listing.SwaggerSerializers;
 
 public class Swagger2Feature extends AbstractSwaggerFeature {
     private String host;
-    private boolean ignoreHostPort;
 
     @Override
     protected void addSwaggerResource(Server server) {
@@ -94,20 +93,12 @@ public class Swagger2Feature extends AbstractSwaggerFeature 
{
             // get the path part
             URI u = URI.create(address); 
             setBasePath(u.getPath());
-            setHost(u.getPort() < 0 || isIgnoreHostPort() 
-                    ? u.getHost() : u.getHost() + ":" + u.getPort());
+            setHost(u.getPort() < 0 ? 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 {

http://git-wip-us.apache.org/repos/asf/cxf/blob/5b9e19e8/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 e698143..c40f0ac 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
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.systest.jaxrs.description;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
 
@@ -61,7 +62,6 @@ 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 + "/");
@@ -98,7 +98,7 @@ public abstract class AbstractSwagger2ServiceDescriptionTest 
extends AbstractBus
             assertEquals(Status.OK.getStatusCode(), r.getStatus());
             JSONAssert.assertEquals(
                 IOUtils.readStringFromStream((InputStream)r.getEntity()), 
-                
IOUtils.readStringFromStream(getClass().getResourceAsStream("swagger2-json.txt")),
+                getExpectedValue("swagger2-json.txt", getPort()),
                 false);
         } finally {
             client.close();
@@ -113,7 +113,7 @@ public abstract class 
AbstractSwagger2ServiceDescriptionTest extends AbstractBus
             final Response r = client.get();
             assertEquals(Status.OK.getStatusCode(), r.getStatus());
             Yaml yaml = new Yaml();
-            
assertEquals(yaml.load(getClass().getResourceAsStream("swagger2-yaml.txt")),
+            assertEquals(yaml.load(getExpectedValue("swagger2-yaml.txt", 
getPort())),
                          
yaml.load(IOUtils.readStringFromStream((InputStream)r.getEntity())));
         } finally {
             client.close();
@@ -126,4 +126,9 @@ public abstract class 
AbstractSwagger2ServiceDescriptionTest extends AbstractBus
                 Arrays.< Object >asList(new JacksonJsonProvider()))
             .accept(MediaType.APPLICATION_JSON).accept("application/yaml");
     }
+
+    private static String getExpectedValue(String name, Object... args) throws 
IOException {
+        return String.format(IOUtils.readStringFromStream(
+            
AbstractSwagger2ServiceDescriptionTest.class.getResourceAsStream(name)), args);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/5b9e19e8/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 cba1c72..0cc21d4 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,7 +5,7 @@
          "contact":{"name":"[email protected]"},
          "license":{"name":"Apache 2.0 License",
                     "url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},
- "host":"localhost",
+ "host":"localhost:%s",
  "basePath":"/",
  "tags":[{"name":"bookstore"}],
  "paths":{"/bookstore":{"get":{"tags":["bookstore"],

http://git-wip-us.apache.org/repos/asf/cxf/blob/5b9e19e8/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 5f95ae9..75c34d0 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,7 +9,7 @@ info:
   license:
     name: "Apache 2.0 License"
     url: "http://www.apache.org/licenses/LICENSE-2.0.html";
-host: "localhost"    
+host: "localhost:%s"    
 basePath: "/"
 tags:
 - name: "bookstore"

Reply via email to