cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1186634 - in /cxf/trunk: rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ systests/transports/src/test/java/org/apache/cxf/systest/servlet/
Date Thu, 20 Oct 2011 07:10:30 GMT
Author: ffang
Date: Thu Oct 20 07:10:30 2011
New Revision: 1186634

URL: http://svn.apache.org/viewvc?rev=1186634&view=rev
Log:
[CXF-3866]CXF-Service

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1186634&r1=1186633&r2=1186634&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Thu Oct 20 07:10:30 2011
@@ -763,6 +763,9 @@ public abstract class AbstractHTTPDestin
         registry = null;
     }
     
+    public String getPath() {
+        return path;
+    }
 
     @Override
     public void shutdown() {

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java?rev=1186634&r1=1186633&r2=1186634&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
Thu Oct 20 07:10:30 2011
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.transport.AbstractDestination;
+import org.apache.cxf.transport.servlet.ServletDestination;
 
 public class FormattedServiceListWriter implements ServiceListWriter {
     private String styleSheetPath;
@@ -114,7 +115,11 @@ public class FormattedServiceListWriter 
             return endpointAddress;
         }
         endpointAddress = d.getEndpointInfo().getAddress();
-        if (basePath == null || endpointAddress.startsWith(basePath)) {
+        if (d instanceof ServletDestination
+            && (endpointAddress.startsWith("http://") || endpointAddress.startsWith("https://")))
{
+            String path = ((ServletDestination)d).getPath();
+            return basePath + path;
+        } else if (basePath == null || endpointAddress.startsWith(basePath)) {
             return endpointAddress;
         } else {
             return basePath + endpointAddress;

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java?rev=1186634&r1=1186633&r2=1186634&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
Thu Oct 20 07:10:30 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 
 import org.apache.cxf.transport.AbstractDestination;
+import org.apache.cxf.transport.servlet.ServletDestination;
 
 public class UnformattedServiceListWriter implements ServiceListWriter {
     boolean renderWsdlList;
@@ -76,7 +77,11 @@ public class UnformattedServiceListWrite
             return endpointAddress;
         }
         endpointAddress = d.getEndpointInfo().getAddress();
-        if (basePath == null || endpointAddress.startsWith(basePath)) {
+        if (d instanceof ServletDestination
+            && (endpointAddress.startsWith("http://") || endpointAddress.startsWith("https://")))
{
+            String path = ((ServletDestination)d).getPath();
+            return basePath + path;
+        } else if (basePath == null || endpointAddress.startsWith(basePath)) {
             return endpointAddress;
         } else {
             return basePath + endpointAddress;

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?rev=1186634&r1=1186633&r2=1186634&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
Thu Oct 20 07:10:30 2011
@@ -143,6 +143,29 @@ public class CXFServletTest extends Abst
     }
     
     @Test
+    public void testServiceListWithLoopAddress() throws Exception {
+        ServletUnitClient client = newClient();
+        client.setExceptionsThrownOnErrorStatus(false);
+
+        WebResponse res = client.getResponse(CONTEXT_URL + "/services");
+        
+        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter3"));
+        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter2"));
+        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter"));
+        WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl");
+        res = client.getResponse(req); 
+        req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter2?wsdl");
+        res = client.getResponse(req); 
+        req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
+        res = client.getResponse(req); 
+        String loopAddr = "http://127.0.0.1/mycontext";
+        res = client.getResponse(loopAddr + "/services");
+        assertFalse(res.getText().contains(
+             "http://127.0.0.1/mycontext/serviceshttp://localhost/mycontext/services/greeter"));
+                
+    }
+    
+    @Test
     public void testGetWSDL() throws Exception {
         ServletUnitClient client = newClient();
         client.setExceptionsThrownOnErrorStatus(true);



Mime
View raw message