cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6216] Stripping away the matrix parameters if any from the base URL
Date Tue, 18 Oct 2016 12:04:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c212240f6 -> 45b1b5b94


[CXF-6216] Stripping away the matrix parameters if any from the base URL


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

Branch: refs/heads/master
Commit: 45b1b5b94aaebca6900cfff6c62a5d038e9ad28b
Parents: c212240
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Oct 18 13:04:04 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Oct 18 13:04:04 2016 +0100

----------------------------------------------------------------------
 .../cxf/transport/servlet/BaseUrlHelper.java    |  5 ++++
 .../servicelist/FormattedServiceListWriter.java |  6 +++-
 .../ServiceListGeneratorServlet.java            | 12 ++++++--
 .../jaxrs/JAXRSClientServerSpringBookTest.java  | 29 +++++++++++++++++++-
 4 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/45b1b5b9/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/BaseUrlHelper.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/BaseUrlHelper.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/BaseUrlHelper.java
index 4b820c9..bdc6f55 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/BaseUrlHelper.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/BaseUrlHelper.java
@@ -55,6 +55,11 @@ public final class BaseUrlHelper {
             }
             
             reqPrefix = sb.toString();
+        } else {
+            int matrixParamIndex = reqPrefix.indexOf(";");
+            if (matrixParamIndex > 0) {
+                reqPrefix = reqPrefix.substring(0, matrixParamIndex);
+            }
         }
         return reqPrefix;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/45b1b5b9/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
index ae9a4d4..67241b4 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
@@ -146,7 +146,11 @@ public class FormattedServiceListWriter implements ServiceListWriter
{
                 return null;
             }
         } else {
-            return basePath + endpointAddress;
+            String address = basePath;
+            if (address.endsWith("/") && endpointAddress.startsWith("/")) { 
+                address = address.substring(0, address.length() - 1);
+            }
+            return address + endpointAddress;
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/45b1b5b9/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
index 93266fa..0ab092d 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
@@ -102,9 +102,17 @@ public class ServiceListGeneratorServlet extends HttpServlet {
             String styleSheetPath;
             if (serviceListStyleSheet != null) {
                 styleSheetPath = request.getContextPath() + "/" + serviceListStyleSheet;
-                
             } else {
-                styleSheetPath = request.getRequestURI() + "/?stylesheet=1";
+                String requestUri = request.getRequestURI();
+                int matrixParamIndex = requestUri.indexOf(";");
+                if (matrixParamIndex > 0) {
+                    requestUri = requestUri.substring(0, matrixParamIndex);
+                }
+                styleSheetPath = requestUri;
+                if (!styleSheetPath.endsWith("/")) {
+                    styleSheetPath += "/";
+                }
+                styleSheetPath += "?stylesheet=1";
             }
             serviceListWriter = 
                 new FormattedServiceListWriter(styleSheetPath, title, showForeignContexts,
bus);

http://git-wip-us.apache.org/repos/asf/cxf/blob/45b1b5b9/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index 9dae3ae..5aab183 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -85,7 +85,6 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     public void testGetGenericBook() throws Exception {
         String baseAddress = "http://localhost:" + PORT + "/the/thebooks8/books"; 
         WebClient wc = WebClient.create(baseAddress);
-        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
         Long id = wc.type("application/xml").accept("text/plain").post(new Book("CXF", 1L),
Long.class);
         assertEquals(new Long(1), id);
         Book book = wc.replaceHeader("Accept", "application/xml").query("id", 1L).get(Book.class);
@@ -103,11 +102,39 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     public void testGetBookText() throws Exception {
         final String address = "http://localhost:" + PORT + "/the/thebooks/bookstore/books/text";

         WebClient wc = WebClient.create(address).accept("text/*");
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
         assertEquals(406, wc.get().getStatus());
         
     }
     
     @Test
+    public void testGetServicesPageNotFound() throws Exception {
+        final String address = "http://localhost:" + PORT + "/the/services;a=b"; 
+        WebClient wc = WebClient.create(address).accept("text/*");
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
+        assertEquals(404, wc.get().getStatus());
+    }
+    @Test
+    public void testGetServicesPage() throws Exception {
+        final String address = "http://localhost:" + PORT + "/the/services"; 
+        WebClient wc = WebClient.create(address).accept("text/*");
+        String s = wc.get(String.class);
+        assertTrue(s.contains("href=\"/the/services/?stylesheet=1\""));
+        assertTrue(s.contains("<title>CXF - Service list</title>"));
+        assertTrue(s.contains("<a href=\"http://localhost:" + PORT + "/the/"));
+    }
+    @Test
+    public void testGetServicesPageWithServletPatternMatchOnly() throws Exception {
+        final String address = "http://localhost:" + PORT + "/the/;a=b"; 
+        WebClient wc = WebClient.create(address).accept("text/*");
+        String s = wc.get(String.class);
+        assertTrue(s.contains("href=\"/the/?stylesheet=1\""));
+        assertTrue(s.contains("<title>CXF - Service list</title>"));
+        assertFalse(s.contains(";a=b"));
+        assertTrue(s.contains("<a href=\"http://localhost:" + PORT + "/the/"));
+    }
+    
+    @Test
     public void testEchoBookForm() throws Exception {
         String address = "http://localhost:" + PORT + "/bus/thebooksform/bookform";
         doTestEchoBookForm(address);


Mime
View raw message