cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r442984 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/addr/src/test/java/org/apache/cxf/ws/ rt/w...
Date Wed, 13 Sep 2006 13:43:38 GMT
Copied: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
(from r438444, incubator/cxf/branches/post_apache_integration/rt/ws/addr/src/test/java/org/objectweb/celtix/ws/addressing/MAPAggregatorTest.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java?view=diff&rev=442984&p1=incubator/cxf/branches/post_apache_integration/rt/ws/addr/src/test/java/org/objectweb/celtix/ws/addressing/MAPAggregatorTest.java&r1=438444&p2=incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java&r2=442984
==============================================================================
--- incubator/cxf/branches/post_apache_integration/rt/ws/addr/src/test/java/org/objectweb/celtix/ws/addressing/MAPAggregatorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
Wed Sep 13 06:43:37 2006
@@ -1,40 +1,60 @@
-package org.objectweb.celtix.ws.addressing;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.addressing;
 
 
 import java.lang.reflect.Method;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
-import javax.wsdl.Binding;
-import javax.wsdl.Port;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.xml.namespace.QName;
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
-import javax.xml.ws.handler.LogicalMessageContext;
-import javax.xml.ws.handler.MessageContext;
 import static javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY;
 
 import junit.framework.TestCase;
 
-import org.easymock.EasyMock;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
 import org.easymock.IArgumentMatcher;
-import org.easymock.IMocksControl;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
 
-import org.objectweb.celtix.bindings.ServerBinding;
-import org.objectweb.celtix.context.OutputStreamMessageContext;
-import org.objectweb.celtix.jaxb.JAXBDataBindingCallback;
-import org.objectweb.celtix.transports.ClientTransport;
-import org.objectweb.celtix.transports.ServerTransport;
-
-import static org.objectweb.celtix.context.ObjectMessageContext.METHOD_OBJ;
-import static org.objectweb.celtix.context.ObjectMessageContext.REQUESTOR_ROLE_PROPERTY;
-import static org.objectweb.celtix.context.OutputStreamMessageContext.ONEWAY_MESSAGE_TF;
-import static org.objectweb.celtix.datamodel.soap.SOAPConstants.SOAP_ENV_ENCSTYLE;
-import static org.objectweb.celtix.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES;
-import static org.objectweb.celtix.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND;
-import static org.objectweb.celtix.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND;
-import static org.objectweb.celtix.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND;
+import static org.apache.cxf.binding.soap.Soap11.SOAP_NAMESPACE;
+import static org.apache.cxf.message.Message.ONEWAY_MESSAGE;
+import static org.apache.cxf.message.Message.REQUESTOR_ROLE;
+import static org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES;
+import static org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND;
+import static org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND;
+import static org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND;
 
 public class MAPAggregatorTest extends TestCase {
 
@@ -48,12 +68,10 @@
     
     public void setUp() {
         aggregator = new MAPAggregator();
-        aggregator.init(null);
         control = EasyMock.createNiceControl();
     }
 
     public void tearDown() {
-        aggregator.destroy();
         expectedMAPs = null;
         expectedTo = null;
         expectedReplyTo = null;
@@ -63,232 +81,184 @@
 
     public void testRequestorOutboundUsingAddressingMAPsInContext() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, true, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, true, true);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
     
     public void testRequestorOutboundUsingAddressingMAPsInContextZeroLengthAction() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, true, true, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, true, true, true);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundUsingAddressingMAPsInContextFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, true, true);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, true, true);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundUsingAddressingNoMAPsInContext() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, true, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, true, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
-
+    
     public void testRequestorOutboundUsingAddressingNoMAPsInContextFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, true, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, true, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundNotUsingAddressing() throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundNotUsingAddressingFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayUsingAddressingMAPsInContext() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, true, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, true, true);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayUsingAddressingMAPsInContextFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, true, true);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, true, true);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayUsingAddressingNoMAPsInContext() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, true, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, true, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayUsingAddressingNoMAPsInContextFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, true, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, true, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayNotUsingAddressing() throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorOutboundOnewayNotUsingAddressingFault() 
         throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, true, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, true, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderInboundValidMAPs() throws Exception {
-        LogicalMessageContext context = setUpContext(false, false, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(false, false, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
     
     public void testResponderInboundDecoupled() throws Exception {
-        LogicalMessageContext context = 
-            setUpContext(false, false, false, true, false, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = 
+            setUpMessage(false, false, false, true, false, true);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
     
     public void testResponderInboundOneway() throws Exception {
-        LogicalMessageContext context = 
-            setUpContext(false, false, true, true, false, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = 
+            setUpMessage(false, false, true, true, false, true);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderInboundValidMAPsFault() throws Exception {
-        LogicalMessageContext context = setUpContext(false, false, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(false, false, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderInboundInvalidMAPs() throws Exception {
         aggregator.messageIDs.put("urn:uuid:12345", "urn:uuid:12345");
-        LogicalMessageContext context = setUpContext(false, false, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertFalse("expected dispatch not to proceed", proceed);
+        Message message = setUpMessage(false, false, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderInboundInvalidMAPsFault() throws Exception {
         aggregator.messageIDs.put("urn:uuid:12345", "urn:uuid:12345");
-        LogicalMessageContext context = setUpContext(false, false, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertFalse("expected dispatch not to proceed", proceed);
+        Message message = setUpMessage(false, false, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderOutbound() throws Exception {
-        LogicalMessageContext context = setUpContext(false, true, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(false, true, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
     
     public void testResponderOutboundZeroLengthAction() throws Exception {
-        LogicalMessageContext context = 
-            setUpContext(false, true, false, false, false, false, true);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = 
+            setUpMessage(false, true, false, false, false, false, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testResponderOutboundFault() throws Exception {
-        LogicalMessageContext context = setUpContext(new boolean[] {false,
-                                                                    true,
-                                                                    false,
-                                                                    false,
-                                                                    false,
-                                                                    true,
-                                                                    false,
-                                                                    true});
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(new boolean[] {false,
+                                                      true,
+                                                      false,
+                                                      false,
+                                                      false,
+                                                      true,
+                                                      false,
+                                                      true});
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorInbound() throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false);
-        boolean proceed = aggregator.handleMessage(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false);
+        aggregator.handleMessage(message);
         control.verify();
-        aggregator.close(context);
     }
 
     public void testRequestorInboundFault() throws Exception {
-        LogicalMessageContext context = setUpContext(true, true, false);
-        boolean proceed = aggregator.handleFault(context);
-        assertTrue("expected dispatch to proceed", proceed);
+        Message message = setUpMessage(true, true, false);
+        aggregator.handleFault(message);
         control.verify();
-        aggregator.close(context);
     }
 
-    private LogicalMessageContext setUpContext(boolean requestor, 
-                                               boolean outbound,
-                                               boolean oneway) 
+    private Message setUpMessage(boolean requestor, 
+                                 boolean outbound,
+                                 boolean oneway) 
         throws Exception {
-        return setUpContext(requestor, outbound, oneway, false, false, false);
+        return setUpMessage(requestor, outbound, oneway, false, false, false);
     }
 
-    private LogicalMessageContext setUpContext(boolean requestor, 
-                                               boolean outbound,
-                                               boolean oneway,
-                                               boolean usingAddressing)
+    private Message setUpMessage(boolean requestor, 
+                                 boolean outbound,
+                                 boolean oneway,
+                                 boolean usingAddressing)
         throws Exception {
-        return setUpContext(requestor,
+        return setUpMessage(requestor,
                             outbound,
                             oneway,
                             usingAddressing,
@@ -296,13 +266,13 @@
                             false);
     }
 
-    private LogicalMessageContext setUpContext(boolean requestor, 
-                                               boolean outbound,
-                                               boolean oneway,
-                                               boolean usingAddressing,
-                                               boolean mapsInContext) 
+    private Message setUpMessage(boolean requestor, 
+                                 boolean outbound,
+                                 boolean oneway,
+                                 boolean usingAddressing,
+                                 boolean mapsInContext) 
         throws Exception {
-        return setUpContext(requestor,
+        return setUpMessage(requestor,
                             outbound,
                             oneway,
                             usingAddressing,
@@ -310,14 +280,14 @@
                             false);
     }
 
-    private LogicalMessageContext setUpContext(boolean requestor, 
-                                               boolean outbound,
-                                               boolean oneway,
-                                               boolean usingAddressing,
-                                               boolean mapsInContext,
-                                               boolean decoupled) 
+    private Message setUpMessage(boolean requestor, 
+                                 boolean outbound,
+                                 boolean oneway,
+                                 boolean usingAddressing,
+                                 boolean mapsInContext,
+                                 boolean decoupled) 
         throws Exception {
-        return setUpContext(requestor, 
+        return setUpMessage(requestor, 
                             outbound,
                             oneway,
                             usingAddressing,
@@ -327,13 +297,13 @@
     }
 
     
-    private LogicalMessageContext setUpContext(boolean requestor, 
-                                               boolean outbound,
-                                               boolean oneway,
-                                               boolean usingAddressing,
-                                               boolean mapsInContext,
-                                               boolean decoupled,
-                                               boolean zeroLengthAction) 
+    private Message setUpMessage(boolean requestor, 
+                                 boolean outbound,
+                                 boolean oneway,
+                                 boolean usingAddressing,
+                                 boolean mapsInContext,
+                                 boolean decoupled,
+                                 boolean zeroLengthAction) 
         throws Exception {
         boolean[] params = {requestor, 
                             outbound,
@@ -343,14 +313,14 @@
                             decoupled,
                             zeroLengthAction,
                             false};  
-        return setUpContext(params);
+        return setUpMessage(params);
     }
 
     /**
      * Boolean array is used to work around checkstyle rule limiting
      * parameter cardinality to 7. 
      */
-    private LogicalMessageContext setUpContext(boolean[] params)
+    private Message setUpMessage(boolean[] params)
         throws Exception {
         boolean requestor = params[0]; 
         boolean outbound = params[1];
@@ -360,23 +330,25 @@
         boolean decoupled = params[5];
         boolean zeroLengthAction = params[6];
         boolean fault = params[7];
-        LogicalMessageContext context =
-            control.createMock(LogicalMessageContext.class);
-        context.get(MESSAGE_OUTBOUND_PROPERTY);
+        Message message = control.createMock(Message.class);
+        message.get(MESSAGE_OUTBOUND_PROPERTY);
         EasyMock.expectLastCall().andReturn(Boolean.valueOf(outbound));
-        context.get(REQUESTOR_ROLE_PROPERTY);
+        message.get(REQUESTOR_ROLE);
         EasyMock.expectLastCall().andReturn(Boolean.valueOf(requestor));
+        Exchange exchange = control.createMock(Exchange.class);
         if (outbound && requestor) {
-            setUpUsingAddressing(context, usingAddressing);
+            setUpUsingAddressing(message, exchange, usingAddressing);
             if (usingAddressing) {
-                setUpRequestor(context, 
+                setUpRequestor(message,
+                               exchange,
                                oneway, 
                                mapsInContext,
                                decoupled,
                                zeroLengthAction);
             } 
         } else if (!requestor) {
-            setUpResponder(context,
+            setUpResponder(message,
+                           exchange,
                            oneway,
                            outbound,
                            decoupled,
@@ -384,55 +356,53 @@
                            fault);
         }
         control.replay();
-        return context;
+        return message;
     }
 
-    private void setUpUsingAddressing(LogicalMessageContext context,
+    private void setUpUsingAddressing(Message message,
+                                      Exchange exchange,
                                       boolean usingAddressing) {
-        Port port = control.createMock(Port.class);
-        aggregator.clientTransport = control.createMock(ClientTransport.class);
-        aggregator.clientTransport.getPort();
-        EasyMock.expectLastCall().andReturn(port);
-        List portExts = control.createMock(List.class);
-        port.getExtensibilityElements();
-        EasyMock.expectLastCall().andReturn(portExts);
-        Iterator portItr = control.createMock(Iterator.class);
-        portExts.iterator();
-        EasyMock.expectLastCall().andReturn(portItr);
-        Binding binding = control.createMock(Binding.class);
-        port.getBinding();
-        EasyMock.expectLastCall().andReturn(binding);
-        List bindingExts = control.createMock(List.class);
-        binding.getExtensibilityElements();
-        EasyMock.expectLastCall().andReturn(bindingExts);
-        Iterator bindingItr = control.createMock(Iterator.class);
-        bindingExts.iterator();
-        EasyMock.expectLastCall().andReturn(bindingItr);
-        portItr.hasNext();
-        EasyMock.expectLastCall().andReturn(Boolean.TRUE);
+        message.getExchange();
+        EasyMock.expectLastCall().andReturn(exchange);
+        Endpoint endpoint = control.createMock(Endpoint.class);
+        exchange.get(Endpoint.class);
+        EasyMock.expectLastCall().andReturn(endpoint);
+        EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
+        endpoint.getEndpointInfo();
+        EasyMock.expectLastCall().andReturn(endpointInfo);
+        List<ExtensibilityElement> endpointExts =
+            new ArrayList<ExtensibilityElement>();
+        endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
+        EasyMock.expectLastCall().andReturn(endpointExts);
+        BindingInfo bindingInfo = control.createMock(BindingInfo.class);
+        endpointInfo.getBinding();
+        EasyMock.expectLastCall().andReturn(bindingInfo).times(2);
+        bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
+        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST);
+        ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
+        endpointInfo.getService();
+        EasyMock.expectLastCall().andReturn(serviceInfo).times(2);
+        serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
+        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST);
         ExtensibilityElement ext = 
             control.createMock(ExtensibilityElement.class);
-        portItr.next();
-        EasyMock.expectLastCall().andReturn(ext);
-        QName elementType = usingAddressing 
-            ? Names.WSAW_USING_ADDRESSING_QNAME 
-            : SOAP_ENV_ENCSTYLE;
-        ext.getElementType();
-        EasyMock.expectLastCall().andReturn(elementType);
-        if (!usingAddressing) {
-            portItr.hasNext();
-            EasyMock.expectLastCall().andReturn(Boolean.FALSE);
-            bindingItr.hasNext();
-            EasyMock.expectLastCall().andReturn(Boolean.FALSE);
+        if (usingAddressing) {
+            QName elementType = usingAddressing 
+                ? Names.WSAW_USING_ADDRESSING_QNAME 
+                : new QName(SOAP_NAMESPACE, "encodingStyle");
+            ext.getElementType();
+            EasyMock.expectLastCall().andReturn(elementType);
+            endpointExts.add(ext);
         }
     }
     
-    private void setUpRequestor(LogicalMessageContext context,
+    private void setUpRequestor(Message message,
+                                Exchange exchange,
                                 boolean oneway,
                                 boolean mapsInContext,
                                 boolean decoupled,
                                 boolean zeroLengthAction) throws Exception {
-        context.get(REQUESTOR_ROLE_PROPERTY);
+        message.get(REQUESTOR_ROLE);
         EasyMock.expectLastCall().andReturn(Boolean.TRUE);
         AddressingPropertiesImpl maps = mapsInContext 
                                         ? new AddressingPropertiesImpl()
@@ -440,19 +410,18 @@
         if (zeroLengthAction) {
             maps.setAction(ContextUtils.getAttributedURI(""));
         }
-        context.get(CLIENT_ADDRESSING_PROPERTIES);
+        message.get(CLIENT_ADDRESSING_PROPERTIES);
         EasyMock.expectLastCall().andReturn(maps);
         Method method = SEI.class.getMethod("op", new Class[0]);
         if (!zeroLengthAction) {
-            context.get(METHOD_OBJ);     
-            EasyMock.expectLastCall().andReturn(method);
-            context.get(REQUESTOR_ROLE_PROPERTY);
+            setUpMethod(message, exchange, method);
+            message.get(REQUESTOR_ROLE);
             EasyMock.expectLastCall().andReturn(Boolean.TRUE);
             expectedAction = "http://foo/bar/SEI/opRequest";
         }
-        context.get(REQUESTOR_ROLE_PROPERTY);
+        message.get(REQUESTOR_ROLE);
         EasyMock.expectLastCall().andReturn(Boolean.TRUE);
-        context.get(ONEWAY_MESSAGE_TF);
+        message.get(ONEWAY_MESSAGE);
         EasyMock.expectLastCall().andReturn(Boolean.valueOf(oneway));
         EasyMock.eq(CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
         expectedMAPs = maps;
@@ -461,22 +430,21 @@
                           ? Names.WSA_NONE_ADDRESS
                           : Names.WSA_ANONYMOUS_ADDRESS;
         EasyMock.reportMatcher(new MAPMatcher());
-        context.put(CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
+        message.put(CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
                     mapsInContext
                     ? maps
                     : new AddressingPropertiesImpl());
         EasyMock.expectLastCall().andReturn(null);
-        context.setScope(CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
-                         MessageContext.Scope.HANDLER);
     }
 
-    private void setUpResponder(LogicalMessageContext context,
+    private void setUpResponder(Message message,
+                                Exchange exchange,
                                 boolean oneway,
                                 boolean outbound,
                                 boolean decoupled,
                                 boolean zeroLengthAction,
                                 boolean fault) throws Exception {
-        context.get(REQUESTOR_ROLE_PROPERTY);
+        message.get(REQUESTOR_ROLE);
         EasyMock.expectLastCall().andReturn(Boolean.FALSE);
         AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
         EndpointReferenceType replyTo = new EndpointReferenceType();
@@ -497,39 +465,29 @@
         if (zeroLengthAction) {
             maps.setAction(ContextUtils.getAttributedURI(""));
         }
-        context.get(SERVER_ADDRESSING_PROPERTIES_INBOUND);
+        message.get(SERVER_ADDRESSING_PROPERTIES_INBOUND);
         EasyMock.expectLastCall().andReturn(maps);
-        aggregator.serverBinding = control.createMock(ServerBinding.class);
-        aggregator.serverTransport = control.createMock(ServerTransport.class);
+        
         if (!outbound && (oneway || decoupled)) {
-            context.get(ONEWAY_MESSAGE_TF);
+            message.get(ONEWAY_MESSAGE);
             EasyMock.expectLastCall().andReturn(Boolean.valueOf(oneway));
-            OutputStreamMessageContext outputContext = 
-                control.createMock(OutputStreamMessageContext.class);
-            aggregator.serverTransport.rebase(context, replyTo);
-            EasyMock.expectLastCall().andReturn(outputContext);
-            aggregator.serverBinding.partialResponse(
-                              EasyMock.isA(OutputStreamMessageContext.class),
-                              EasyMock.isA(JAXBDataBindingCallback.class));
-            EasyMock.expectLastCall();
+            setUpRebase(message);
         }
         if (outbound || aggregator.messageIDs.size() > 0) {
             if (!zeroLengthAction) {
                 Method method = SEI.class.getMethod("op", new Class[0]);
-                context.get(METHOD_OBJ);     
-                EasyMock.expectLastCall().andReturn(method);
-                context.get(REQUESTOR_ROLE_PROPERTY);
+                setUpMethod(message, exchange, method);
+                message.get(REQUESTOR_ROLE);
                 EasyMock.expectLastCall().andReturn(Boolean.FALSE);
                 expectedAction = "http://foo/bar/SEI/opResponse";
             }
-            context.get(REQUESTOR_ROLE_PROPERTY);
+            message.get(REQUESTOR_ROLE);
             EasyMock.expectLastCall().andReturn(Boolean.FALSE);
-            context.get(SERVER_ADDRESSING_PROPERTIES_INBOUND);
+            message.get(SERVER_ADDRESSING_PROPERTIES_INBOUND);
             EasyMock.expectLastCall().andReturn(maps);
             if (fault) {
-                aggregator.serverTransport.rebase(EasyMock.same(context),
-                                                  EasyMock.same(faultTo));
-                EasyMock.expectLastCall().andReturn(null);
+                // REVISIT test double rebase does not occur
+                setUpRebase(message);
             }
             EasyMock.eq(SERVER_ADDRESSING_PROPERTIES_OUTBOUND);
             expectedTo = decoupled
@@ -537,14 +495,44 @@
                          : Names.WSA_ANONYMOUS_ADDRESS;
             expectedRelatesTo = maps.getMessageID().getValue();
             EasyMock.reportMatcher(new MAPMatcher());
-            context.put(SERVER_ADDRESSING_PROPERTIES_OUTBOUND,
+            message.put(SERVER_ADDRESSING_PROPERTIES_OUTBOUND,
                         new AddressingPropertiesImpl());
             EasyMock.expectLastCall().andReturn(null);
-            context.setScope(SERVER_ADDRESSING_PROPERTIES_OUTBOUND,
-                             MessageContext.Scope.HANDLER);
         }
     }
     
+    private void setUpRebase(Message message) throws Exception {
+        message.get("org.apache.cxf.ws.addressing.partial.response.sent");
+        EasyMock.expectLastCall().andReturn(Boolean.FALSE);
+        Destination target = control.createMock(Destination.class);
+        message.getDestination();
+        EasyMock.expectLastCall().andReturn(target);
+        Conduit backChannel = control.createMock(Conduit.class);
+        target.getBackChannel(EasyMock.eq(message),
+                              EasyMock.isA(Message.class),
+                              EasyMock.isA(EndpointReferenceType.class));
+        EasyMock.expectLastCall().andReturn(backChannel);
+        // REVISIT test interceptor chain setup & send
+    }
+
+    private void setUpMethod(Message message, Exchange exchange, Method method) {
+        message.getExchange();
+        EasyMock.expectLastCall().andReturn(exchange);
+        OperationInfo opInfo = new OperationInfo(); 
+        opInfo.setProperty(Method.class.getName(), method);
+        BindingOperationInfo bindingOpInfo = new TestBindingOperationInfo(opInfo);
+        exchange.get(BindingOperationInfo.class);
+        EasyMock.expectLastCall().andReturn(bindingOpInfo);
+        // Usual fun with EasyMock not always working as expected
+        //BindingOperationInfo bindingOpInfo =
+        //    EasyMock.createMock(BindingOperationInfo.class); 
+        //OperationInfo opInfo = EasyMock.createMock(OperationInfo.class); 
+        //bindingOpInfo.getOperationInfo();
+        //EasyMock.expectLastCall().andReturn(opInfo);
+        //opInfo.getProperty(EasyMock.eq(Method.class.getName()));
+        //EasyMock.expectLastCall().andReturn(method);
+    }
+
     private final class MAPMatcher implements IArgumentMatcher {
         public boolean matches(Object obj) {
             if (obj instanceof AddressingPropertiesImpl) {
@@ -590,5 +578,11 @@
         @RequestWrapper(targetNamespace = "http://foo/bar", className = "SEI", localName
= "opRequest")
         @ResponseWrapper(targetNamespace = "http://foo/bar", className = "SEI", localName
= "opResponse")
         String op();
+    }
+    
+    private static class TestBindingOperationInfo extends BindingOperationInfo {
+        public TestBindingOperationInfo(OperationInfo oi) {
+            opInfo = oi;
+        }
     }
 }



Mime
View raw message