cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r529897 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/ testu...
Date Wed, 18 Apr 2007 07:26:12 GMT
Author: ffang
Date: Wed Apr 18 00:26:04 2007
New Revision: 529897

URL: http://svn.apache.org/viewvc?view=rev&rev=529897
Log:
[CXF-474] get testHolderOutIsTheFirstMessagePart system test work again


Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/TestHeaderImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?view=diff&rev=529897&r1=529896&r2=529897
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Wed Apr 18 00:26:04 2007
@@ -127,28 +127,14 @@
                 return endedHeader;
             }
             
-            // This code is really ugly right now. Need to refactor...
-            int offset = 0;
-            int returnIdx = 0;
-            if (!client) {
-                for (int i = 0; i < parts.size(); i++) {
-                    MessagePartInfo part = parts.get(i);
-                    if (part.getIndex() == -1) {
-                        offset++;
-                        returnIdx = i;
-                        break;
-                    }
-                }
-            }
+                        
             
             for (SoapHeaderInfo header : headers) {
                 MessagePartInfo part = header.getPart();
 
                 int idx = parts.indexOf(part);
-                if (!client && idx < returnIdx) {
-                    idx += offset;
-                }
-                
+                //int idx = part.getIndex();
+                                
                 Object arg = objs.get(idx);
                 if (!(startedHeader || preexistingHeaders)) {
                     try {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java?view=diff&rev=529897&r1=529896&r2=529897
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
Wed Apr 18 00:26:04 2007
@@ -19,14 +19,12 @@
 
 package org.apache.cxf.jaxws.interceptors;
 
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Holder;
 
-import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
@@ -80,8 +78,6 @@
             for (int i = 0; i < size; i++) {
                 newObjects.add(null);
             }
-            
-            handleNullHolder(message, outObjects);
             int[] argsOffset = removeOutHolderFromParaList(outObjects, parts, holders, size,
newObjects);
             
             if (holders.size() == 0) {
@@ -121,54 +117,39 @@
             message.setContent(List.class, newObjects);
             message.getExchange().put(HolderInInterceptor.CLIENT_HOLDERS, holders);
         } else {
-            handleResponse(message, outObjects, parts);
-        }
-    }
-
-    private void handleResponse(Message message, List<Object> outObjects, List<MessagePartInfo>
parts) {
-        // Add necessary holders so we match the method signature of the service class
-        List<Object> reqObjects =
-            CastUtils.cast(message.getExchange().getInMessage().getContent(List.class));
-   
-        int outIdx = 0;
-        for (MessagePartInfo part : parts) {
-            if (part.getIndex() == -1) {
-                outIdx++;
-                break;
-            }
-        }
-        
-        for (MessagePartInfo part : parts) {
-            int methodIdx = part.getIndex();
-            if (methodIdx >= 0) {
-                Holder holder = (Holder) reqObjects.get(methodIdx);
-                Object o = holder.value;
-                if (outIdx >= outObjects.size()) {
-                    outObjects.add(o);
+            // Add necessary holders so we match the method signature of the service class
+            List<Object> reqObjects =
+                CastUtils.cast(message.getExchange().getInMessage().getContent(List.class));
+    
+            int outIdx = 0;
+            boolean holderOutIsFirst = false;
+            for (MessagePartInfo part : parts) {
+                if (part.getIndex() == -1) {
+                    outIdx++;
+                    break;
                 } else {
-                    outObjects.add(outIdx, o);
+                    holderOutIsFirst = true;
                 }
-                outIdx++;
             }
-        }
-        message.setContent(List.class, outObjects);
-    }
-
-    private void handleNullHolder(Message message, List<Object> outObjects) {
-        //process outObjects if Holder itself is null
-        Method method = (Method)message.get(Client.REQUEST_METHOD);
-        if (method == null) {
-            return;
-        }
-        Class<?>[] paramTypes = method.getParameterTypes();
-        int idx = 0;
-        for (Class rawClass : paramTypes) {
-            if (rawClass.equals(Holder.class) && outObjects.get(idx) == null) {
-                outObjects.set(idx, new Holder());
+            
+            for (MessagePartInfo part : parts) {
+                int methodIdx = part.getIndex();
+                if (methodIdx >= 0) {
+                    Holder holder = (Holder) reqObjects.get(methodIdx);
+                    Object o = holder.value;
+                    if (methodIdx < outIdx && holderOutIsFirst) {
+                        //Holder is first part of mesage
+                        outObjects.add(methodIdx, o);
+                    } else if (outIdx >= outObjects.size()) {
+                        outObjects.add(o);
+                    } else {
+                        outObjects.add(outIdx, o);
+                    }
+                    outIdx++;
+                }
             }
-            idx++;
+            message.setContent(List.class, outObjects);
         }
-        
     }
 
     private int[] removeOutHolderFromParaList(List<Object> outObjects, 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java?view=diff&rev=529897&r1=529896&r2=529897
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
Wed Apr 18 00:26:04 2007
@@ -52,8 +52,10 @@
 import org.apache.header_test.types.TestHeader5ResponseBody;
 import org.apache.header_test.types.TestHeader6;
 import org.apache.header_test.types.TestHeader6Response;
+import org.apache.tests.type_test.all.SimpleAll;
+import org.apache.tests.type_test.choice.SimpleChoice;
+import org.apache.tests.type_test.sequence.SimpleStruct;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -101,6 +103,7 @@
     } 
 
     @Test
+    
     public void testOutHeader() throws Exception {
         URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
         assertNotNull(wsdl);
@@ -287,34 +290,27 @@
         }
     } 
     
+    
+
     @Test
-    @Ignore("test takes forever for what it does. Why?")
-    public void testHolderNull() {
+    public void testHolderOutIsTheFirstMessagePart() throws Exception {
         URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
         assertNotNull(wsdl);
-        
         SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
         assertNotNull(service);
         TestHeader proxy = service.getPort(portName, TestHeader.class);
-        proxy.testHeader2(null, null, null);
-        proxy.testHeader3(null, null);
-        proxy.testHeader5(null, null, null);
-        proxy.testHeaderPartBeforeBodyPart(null, null);
+        Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
+        SimpleAll sa = new SimpleAll();
+        sa.setVarAttrString("varAttrString");
+        sa.setVarInt(100);
+        sa.setVarString("varString");
+        simpleAll.value = sa;
+        SimpleChoice sc = new SimpleChoice();
+        sc.setVarString("scVarString");
+        SimpleStruct ss = proxy.sendReceiveAnyType(simpleAll, sc);
+        assertEquals(simpleAll.value.getVarString(), "scVarString");
+        assertEquals(ss.getVarInt(), 200);
+        assertEquals(ss.getVarAttrString(), "varAttrStringRet");
     }
-
-  // REVIST: This is not a valid WSDL according to WSI-BP V1.0
-  //     @Test
-  //     public void testHolderNotTheFirstMessagePart() throws Exception {
-  //         URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
-  //         assertNotNull(wsdl);
-  
-  //         SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
-  //         assertNotNull(service);
-  //         TestHeader proxy = service.getPort(portName, TestHeader.class);
-  //         Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
-  //         simpleAll.value = new SimpleAll();
-  //         proxy.sendReceiveAnyType(simpleAll, new SimpleChoice());    
-  
-  //     }
    
 }

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/TestHeaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/TestHeaderImpl.java?view=diff&rev=529897&r1=529896&r2=529897
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/TestHeaderImpl.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/TestHeaderImpl.java
Wed Apr 18 00:26:04 2007
@@ -127,7 +127,14 @@
     }
 
     public SimpleStruct sendReceiveAnyType(Holder<SimpleAll> x, SimpleChoice y) {
-        return new SimpleStruct();
+        SimpleAll sa = new SimpleAll();
+        sa.setVarString(y.getVarString());
+        
+        SimpleStruct ss = new SimpleStruct();
+        ss.setVarAttrString(x.value.getVarAttrString() + "Ret");
+        ss.setVarInt(x.value.getVarInt() + 100);
+        x.value = sa;
+        return ss;
     }
 
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl?view=diff&rev=529897&r1=529896&r2=529897
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl Wed Apr 18 00:26:04
2007
@@ -225,13 +225,10 @@
                 message="tns:testHeaderPartBeforeBodyPartResponse"/>
         </wsdl:operation>
 
-	<!-- this is not a valid operation according to WSI-BP V1.0 R2210
-	     A unit test also commented out in HeaderClientServerTest in rt/frontend/jaxws
         <operation name="send_receive_any_type">
             <input name="send_receive_any_type_request" message="tns:AnyTypeRequest"/>
             <output name="send_receive_any_type_response" message="tns:AnyTypeResponse"/>
         </operation>
-	-->
     </wsdl:portType>
     <wsdl:binding name="TestHeader_SOAPBinding" type="tns:TestHeader">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -300,7 +297,6 @@
                     part="inoutHeader" use="literal"/>
             </wsdl:output>
         </wsdl:operation>
-	<!-- this is not a valid operation according to WSI-BP V1.0 R2210
         <operation name="send_receive_any_type">
             <soap:operation soapAction="" style="document"/>
             <input>
@@ -310,7 +306,6 @@
                 <soap:body use="literal"/>
             </output>
         </operation>
-	-->
     </wsdl:binding>
     <wsdl:service name="SOAPHeaderService">
         <wsdl:port name="SoapHeaderPort" binding="tns:TestHeader_SOAPBinding">



Mime
View raw message