cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r529624 - in /incubator/cxf/trunk: rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/test/java/org/apache/cxf/transport/http/ testutils/src/main/resources/wsdl/
Date Tue, 17 Apr 2007 14:35:09 GMT
Author: eglynn
Date: Tue Apr 17 07:35:08 2007
New Revision: 529624

URL: http://svn.apache.org/viewvc?view=rev&rev=529624
Log:
Reverting ClientServerTest.testBogusAddress() from a non-existant, but valid, URL back to
a malformed URL. Changing HTTPConduit default URL construction strategy from upfront to on-demand,
to avoid a premature MalformedURLException. 

Modified:
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?view=diff&rev=529624&r1=529623&r2=529624
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Tue Apr 17 07:35:08 2007
@@ -182,10 +182,17 @@
     private final EndpointInfo endpointInfo;
     
     /**
-     * This field holds the "default" URL for this particular conduit, which
+     * This field holds the "default" address for this particular conduit, which
      * is set at construction.
      */
-    private final URL defaultEndpointURL;
+    private final String defaultEndpointAddress;
+
+    /**
+     * This field holds the "default" URL for this particular conduit, which
+     * is created on demand.
+     */
+    private URL defaultEndpointURL;
+
     private Destination decoupledDestination;
     private MessageObserver decoupledObserver;
     private int decoupledDestinationRefCount;
@@ -253,25 +260,22 @@
     /**
      * Constructor
      * 
-     * @param associatedBus  The associated Bus.
-     * @param endpoint       The endpoint info of the initiator.
-     * @param epr            The endpoint reference of the target.
+     * @param b the associated Bus.
+     * @param endpoint the endpoint info of the initiator.
+     * @param t the endpoint reference of the target.
      * @throws IOException
      */
-    public HTTPConduit(
-        Bus                   associatedBus, 
-        EndpointInfo          endpoint, 
-        EndpointReferenceType epr
-    ) throws IOException {
-
-        super(getTargetReference(endpoint, epr, associatedBus));
-        
-        bus          = associatedBus;
-        endpointInfo = endpoint;
-
-        defaultEndpointURL = epr == null
-              ? new URL(endpointInfo.getAddress())
-              : new URL(epr.getAddress().getValue());
+    public HTTPConduit(Bus b, 
+                       EndpointInfo ei, 
+                       EndpointReferenceType t) throws IOException {
+        super(getTargetReference(ei, t, b));
+        
+        bus = b;
+        endpointInfo = ei;
+
+        defaultEndpointAddress = t == null
+                                 ? ei.getAddress()
+                                 : t.getAddress().getValue();
 
         initializeConfig();                                    
     }
@@ -595,7 +599,7 @@
         String pathInfo = (String)message.get(Message.PATH_INFO);
         String queryString = (String)message.get(Message.QUERY_STRING);
         
-        String result = value != null ? value : defaultEndpointURL.toString();
+        String result = value != null ? value : getURL().toString();
         
         // REVISIT: is this really correct?
         if (null != pathInfo && !result.endsWith(pathInfo)) { 
@@ -646,9 +650,28 @@
     }
 
     /**
-     * @return the encapsulated URL
+     * @return the default target address
      */
-    protected URL getURL() {
+    protected String getAddress() throws MalformedURLException {
+        return defaultEndpointAddress;
+    }
+
+    /**
+     * @return the default target URL
+     */
+    protected synchronized URL getURL() throws MalformedURLException {
+        return getURL(true);
+    }
+
+    /**
+     * @param createOnDemand create URL on-demand if null
+     * @return the default target URL
+     */
+    protected synchronized URL getURL(boolean createOnDemand)
+        throws MalformedURLException {
+        if (defaultEndpointURL == null && createOnDemand) {
+            defaultEndpointURL = new URL(defaultEndpointAddress);
+        }
         return defaultEndpointURL;
     }
 

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java?view=diff&rev=529624&r1=529623&r2=529624
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
Tue Apr 17 07:35:08 2007
@@ -116,7 +116,13 @@
         assertEquals("unexpected target",
                      EndpointReferenceUtils.getAddress(ref),
                      EndpointReferenceUtils.getAddress(target));
-        assertEquals("unexpected URL",
+
+        assertEquals("unexpected address",
+                     conduit.getAddress(),
+                     "http://nowhere.com/bar/foo");
+        assertNull("unexpected upfront URL",
+                    conduit.getURL(false));
+        assertEquals("unexpected on-demand URL",
                      conduit.getURL().getPath(),
                      "/bar/foo");
     }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl?view=diff&rev=529624&r1=529623&r2=529624
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl Tue Apr 17 07:35:08
2007
@@ -392,7 +392,8 @@
     </wsdl:service>
     <wsdl:service name="SOAPServiceBogusAddressTest">
         <wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
-            <soap:address location="http://nowhere.nada.nil:45678/null/never"/>
+            <!--<soap:address location="http://nowhere.nada.nil:45678/null/never"/>-->
+            <soap:address location="FOO"/>
         </wsdl:port>
     </wsdl:service>
     <wsdl:service name="SOAPServiceMultiPortTypeTest">



Mime
View raw message