cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r465539 - 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/ systests/src/test/java/org/apache/cxf/systest/jms/ systests/src/test/java/...
Date Thu, 19 Oct 2006 09:03:19 GMT
Author: ningjiang
Date: Thu Oct 19 02:03:15 2006
New Revision: 465539

URL: http://svn.apache.org/viewvc?view=rev&rev=465539
Log:
[JIRA CXF-133] Support sending HTTP GET using JAX-WS dispatch
Changed HTTPConduit.java to get HTTP_REQUEST_METHOD work
updated the REST systest
Enabled JMS systest to soap fault test
update the trunk\pom.xml's CXF homepage url

Modified:
    incubator/cxf/trunk/pom.xml
    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/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerAllResp.xml

Modified: incubator/cxf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/pom.xml?view=diff&rev=465539&r1=465538&r2=465539
==============================================================================
--- incubator/cxf/trunk/pom.xml (original)
+++ incubator/cxf/trunk/pom.xml Thu Oct 19 02:03:15 2006
@@ -26,7 +26,7 @@
     <artifactId>cxf</artifactId>
     <version>2.0-incubator-M1-SNAPSHOT</version>
     <name>CXF</name>
-    <url>http://cwiki.apache.org/confluence/display/CXF/CeltiXfire+space</url>
+    <url>http://cwiki.apache.org/confluence/display/CXF</url>
 
     <packaging>pom</packaging>
 

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=465539&r1=465538&r2=465539
==============================================================================
--- 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
Thu Oct 19 02:03:15 2006
@@ -25,6 +25,7 @@
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
 import java.net.Proxy;
 import java.net.URL;
 import java.net.URLConnection;
@@ -87,6 +88,7 @@
     private URL decoupledURL;
     private DecoupledDestination decoupledDestination;
     private EndpointInfo endpointInfo;
+    
 
     /**
      * Constructor
@@ -168,20 +170,22 @@
      */
     public void send(Message message) throws IOException {
         Map<String, List<String>> headers = setHeaders(message);
-        
-        String value = (String)message.get(Message.ENDPOINT_ADDRESS);
-        URL currentURL = value != null ? new URL(value) : url;
+        URL currentURL = setupURL(message);
         URLConnection connection = 
             connectionFactory.createConnection(getProxy(), currentURL);
-        connection.setDoOutput(true);
-
+        connection.setDoOutput(true);        
+                       
         if (connection instanceof HttpURLConnection) {
-            HttpURLConnection hc = (HttpURLConnection)connection;
-            hc.setRequestMethod("POST");
-        }
-
-        //TODO using Message context to deceided HTTP send properties
-        
+            String httpRequestMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
+            HttpURLConnection hc = (HttpURLConnection)connection;           
+            if (null != httpRequestMethod) {
+                hc.setRequestMethod(httpRequestMethod);                 
+            } else {
+                hc.setRequestMethod("POST");
+            }
+        }     
+      
+        //TODO using Message context to deceided HTTP send properties        
         connection.setConnectTimeout((int)getClient().getConnectionTimeout());
         connection.setReadTimeout((int)getClient().getReceiveTimeout());
 
@@ -194,7 +198,7 @@
                 hc.setInstanceFollowRedirects(true);
             } else {
                 hc.setInstanceFollowRedirects(false);
-                if (getClient().isAllowChunking()) {
+                if (!hc.getRequestMethod().equals("GET") && client.isAllowChunking())
{
                     hc.setChunkedStreamingMode(2048);
                 }
             }
@@ -205,6 +209,22 @@
         message.setContent(OutputStream.class,
                            new WrappedOutputStream(message, connection));
     }
+    
+    
+    private URL setupURL(Message message) throws MalformedURLException {
+        String value = (String)message.get(Message.ENDPOINT_ADDRESS);
+        String pathInfo = (String)message.get(Message.PATH_INFO);
+        String queryString = (String)message.get(Message.QUERY_STRING);
+        
+        String result = value != null ? value : url.toString();
+        if (null != pathInfo && !result.endsWith(pathInfo)) { 
+            result = result + pathInfo;
+        }
+        if (queryString != null) {
+            result = result + "?" + queryString;
+        }        
+        return new URL(result);    
+    }
 
     /**
      * @return the reference associated with the target Destination
@@ -418,8 +438,14 @@
          * reset output stream ... etc.)
          */
         protected void doFlush() throws IOException {
-            if (!alreadyFlushed()) {
+            if (!alreadyFlushed()) {                
                 flushHeaders(outMessage);
+                if (connection instanceof HttpURLConnection) {            
+                    HttpURLConnection hc = (HttpURLConnection)connection;               
    
+                    if (hc.getRequestMethod().equals("GET")) {
+                        return;
+                    }
+                }
                 resetOut(connection.getOutputStream(), true);
             }
         }

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=465539&r1=465538&r2=465539
==============================================================================
--- 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
Thu Oct 19 02:03:15 2006
@@ -175,7 +175,7 @@
             EasyMock.expectLastCall();
             
             if (httpConnection) {
-                ((HttpURLConnection)connection).setRequestMethod("POST");
+                ((HttpURLConnection)connection).setRequestMethod("POST");               

             }
             
             connection.setConnectTimeout(303030);
@@ -184,21 +184,27 @@
             EasyMock.expectLastCall();
             connection.setUseCaches(false);
             EasyMock.expectLastCall();
+            
+            
 
             if (httpConnection) {
                 ((HttpURLConnection)connection).setInstanceFollowRedirects(autoRedirect);
-                EasyMock.expectLastCall();
+                EasyMock.expectLastCall();                
                 if (!autoRedirect) {
+                    ((HttpURLConnection)connection).getRequestMethod();
+                    EasyMock.expectLastCall().andReturn("POST");
                     ((HttpURLConnection)connection).setChunkedStreamingMode(2048);
-                    EasyMock.expectLastCall();
+                    EasyMock.expectLastCall();                    
                 }
             }
             
             if (decoupled) {
                 decoupledEngine = new TestServerEngine();
                 parameters = control.createMock(MultiMap.class);
-            }
+            }            
+            
         }
+               
         
         control.replay();
         
@@ -258,6 +264,12 @@
         control.reset();
                 
         OutputStream wrappedOS = verifyRequestHeaders(message, expectHeaders);
+        
+        if (connection instanceof HttpURLConnection) {
+            ((HttpURLConnection)connection).getRequestMethod();
+            EasyMock.expectLastCall().andReturn("POST");
+        }
+        
         
         os = EasyMock.createMock(OutputStream.class);
         connection.getOutputStream();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?view=diff&rev=465539&r1=465538&r2=465539
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Thu Oct 19 02:03:15 2006
@@ -31,18 +31,21 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+//import org.apache.cxf.hello_world_jms.BadRecordLitFault;
 import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;
 import org.apache.cxf.hello_world_jms.HelloWorldOneWayQueueService;
 import org.apache.cxf.hello_world_jms.HelloWorldPortType;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubPort;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubService;
 import org.apache.cxf.hello_world_jms.HelloWorldService;
+//import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
 import org.apache.cxf.systest.common.ClientServerSetupBase;
 import org.apache.cxf.systest.common.ClientServerTestBase;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transports.jms.context.JMSMessageHeadersType;
 import org.apache.cxf.transports.jms.context.JMSPropertyType;
 import org.apache.hello_world_doc_lit.Greeter;
+import org.apache.hello_world_doc_lit.PingMeFault;
 import org.apache.hello_world_doc_lit.SOAPService2;
 
 public class JMSClientServerTest extends ClientServerTestBase {
@@ -94,12 +97,12 @@
                 assertNotNull("no response received from service", reply);
                 assertEquals(response2, reply);
                 
-                /*try {
+                try {
                     greeter.pingMe();
                     fail("Should have thrown FaultException");
                 } catch (PingMeFault ex) {
                     assertNotNull(ex.getFaultInfo());
-                }*/                
+                }                
               
             }
         } catch (UndeclaredThrowableException ex) {
@@ -144,7 +147,7 @@
                 } catch (NoSuchCodeLitFault nslf) {
                     assertNotNull(nslf.getFaultInfo());
                     assertNotNull(nslf.getFaultInfo().getCode());
-                }*/ 
+                } */
             }
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java?view=diff&rev=465539&r1=465538&r2=465539
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
Thu Oct 19 02:03:15 2006
@@ -31,6 +31,7 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
+
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.ws.Dispatch;
@@ -92,17 +93,11 @@
         URL url = new URL(endpointAddress + "?name=john&address=20");
         InputStream in = url.openStream();
         assertNotNull(in);
-        //StreamSource source = new StreamSource(in);
-        //printSource(source);
-
-        /*
-         * url = new URL(endpointAddress + "/num1/10/num2/20");
-         * System.out.println("Invoking URL=" + url); process(url);
-         */
+       
     }
 
    
-    public void utestHttpGETDispatcher() throws Exception { 
+    public void testHttpGETDispatcher() throws Exception { 
         String endpointAddress =
             "http://localhost:9023/XMLService/RestProviderPort/Customer"; 
         Service service = Service.create(serviceName); 
@@ -122,10 +117,22 @@
         requestContext.put(MessageContext.PATH_INFO, path);
         System.out.println("Invoking Restful GET Request with query string ");
         Source result = d.invoke(null);
-        assertNotNull("result shoud not be null", result);
-        printSource(result); 
+        assertNotNull("result shoud not be null", result);        
+        String tempstring = source2String(result);
+        assertTrue("Result should start with Customer", tempstring.startsWith("<ns4:Customer"));
+        assertTrue("Result should have CustomerID", tempstring.lastIndexOf("CustomerID>123456<")
> 0);
+    }
+    
+    private String source2String(Source source) throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        StreamResult sr = new StreamResult(bos);
+        Transformer trans = TransformerFactory.newInstance().newTransformer();
+        Properties oprops = new Properties();
+        oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+        trans.setOutputProperties(oprops);
+        trans.transform(source, sr);
+        return bos.toString();
     }
-     
 
     void printSource(Source source) {
         try {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerAllResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerAllResp.xml?view=diff&rev=465539&r1=465538&r2=465539
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerAllResp.xml
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerAllResp.xml
Thu Oct 19 02:03:15 2006
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8" ?>
+<ns4:Customers xmlns:ns4="http://apache.org/hello_world_soap_http/types">
 <ns4:Customer xmlns:ns4="http://apache.org/hello_world_soap_http/types">
   <ns4:CustomerName>John</ns4:CustomerName>
   <ns4:CustomerID>123456</ns4:CustomerID>
@@ -6,4 +7,5 @@
 <ns4:Customer xmlns:ns4="http://apache.org/hello_world_soap_http/types">
   <ns4:CustomerName>Eric</ns4:CustomerName>
   <ns4:CustomerID>123457</ns4:CustomerID>
-</ns4:Customer> 
+</ns4:Customer>
+</ns4:Customers> 



Mime
View raw message