cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r465554 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/handler/soap/ test/java/org/apache/cxf/jaxws/handler/soap/
Date Thu, 19 Oct 2006 10:26:02 GMT
Author: jliu
Date: Thu Oct 19 03:25:52 2006
New Revision: 465554

URL: http://svn.apache.org/viewvc?view=rev&rev=465554
Log:
Added test for SOAPHandlerInterceptor, fixed a problem when SOAPHandler.getHeaders() returns
null.

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?view=diff&rev=465554&r1=465553&r2=465554
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
Thu Oct 19 03:25:52 2006
@@ -49,10 +49,13 @@
     
     @SuppressWarnings("unchecked")
     public Set<QName> getUnderstoodHeaders() {
-        Set<QName> understood = new HashSet<QName>();  
+        Set<QName> understood = new HashSet<QName>();
         for (Handler h : getBinding().getHandlerChain()) {
             if (h instanceof SOAPHandler) {
-                understood.addAll(((SOAPHandler)h).getHeaders());
+                Set<QName> headers = ((SOAPHandler) h).getHeaders();
+                if (headers != null) {
+                    understood.addAll(headers);
+                }
             }
         }
         return understood;

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java?view=auto&rev=465554
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
Thu Oct 19 03:25:52 2006
@@ -0,0 +1,123 @@
+/**
+ * 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.jaxws.handler.soap;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Exchange;
+
+import org.easymock.classextension.IMocksControl;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createNiceControl;
+
+public class SOAPHandlerInterceptorTest extends TestCase {
+
+    public void setUp() {
+    }
+
+    public void tearDown() {
+    }
+
+    public void testInterceptSuccess() {
+        List<Handler> list = new ArrayList<Handler>();
+        list.add(new SOAPHandler<SOAPMessageContext>() {
+            public boolean handleMessage(SOAPMessageContext smc) {
+                return true;
+            }
+
+            public boolean handleFault(SOAPMessageContext smc) {
+                return true;
+            }
+
+            public Set<QName> getHeaders() {
+                return null;
+            }
+
+            public void close(MessageContext messageContext) {
+            }
+        });
+        HandlerChainInvoker invoker = new HandlerChainInvoker(list);
+
+        IMocksControl control = createNiceControl();
+        Binding binding = control.createMock(Binding.class);
+        SoapMessage message = control.createMock(SoapMessage.class);
+        Exchange exchange = control.createMock(Exchange.class);
+        expect(message.getExchange()).andReturn(exchange);
+        expect(message.keySet()).andReturn(new HashSet<String>());
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        control.replay();
+
+        SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
+        li.handleMessage(message);
+        control.verify();
+    }
+
+    public void testgetUnderstoodHeadersReturnsNull() {
+        List<Handler> list = new ArrayList<Handler>();
+        list.add(new SOAPHandler<SOAPMessageContext>() {
+            public boolean handleMessage(SOAPMessageContext smc) {
+                return true;
+            }
+
+            public boolean handleFault(SOAPMessageContext smc) {
+                return true;
+            }
+
+            public Set<QName> getHeaders() {
+                return null;
+            }
+
+            public void close(MessageContext messageContext) {
+            }
+        });
+        HandlerChainInvoker invoker = new HandlerChainInvoker(list);
+
+        IMocksControl control = createNiceControl();
+        Binding binding = control.createMock(Binding.class);
+        SoapMessage message = control.createMock(SoapMessage.class);
+        Exchange exchange = control.createMock(Exchange.class);
+        expect(binding.getHandlerChain()).andReturn(list);
+        expect(message.getExchange()).andReturn(exchange);
+        expect(message.keySet()).andReturn(new HashSet<String>());
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        control.replay();
+
+        SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
+        Set<QName> understood = li.getUnderstoodHeaders();
+        assertNotNull(understood);
+        assertTrue(understood.isEmpty());
+    }
+
+}



Mime
View raw message