cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r467627 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/phase/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/ rt/frontend/jaxws/src/test/java/...
Date Wed, 25 Oct 2006 12:44:59 GMT
Author: jliu
Date: Wed Oct 25 05:44:58 2006
New Revision: 467627

URL: http://svn.apache.org/viewvc?view=rev&rev=467627
Log:
* Moved SOAPHandlerInterceptor before StaxOutInterceptor. Build up SAAJ SOAPMessage in SOAPHandlerInterceptor
for outbound direction. 

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/SmallNumberHandler.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers.xml

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java Wed
Oct 25 05:44:58 2006
@@ -101,13 +101,13 @@
         outPhases.add(new Phase(Phase.PRE_STREAM, ++i * 1000));
         
         outPhases.add(new Phase(Phase.PRE_PROTOCOL, ++i * 1000));        
-        
-        outPhases.add(new Phase(Phase.WRITE, ++i * 1000));
-        outPhases.add(new Phase(Phase.MARSHAL, ++i * 1000));
-        
+
         outPhases.add(new Phase(Phase.USER_PROTOCOL, ++i * 1000));
         outPhases.add(new Phase(Phase.POST_PROTOCOL, ++i * 1000));
 
+        outPhases.add(new Phase(Phase.WRITE, ++i * 1000));
+        outPhases.add(new Phase(Phase.MARSHAL, ++i * 1000));
+        
         
         outPhases.add(new Phase(Phase.USER_STREAM, ++i * 1000));
         outPhases.add(new Phase(Phase.POST_STREAM, ++i * 1000));

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
Wed Oct 25 05:44:58 2006
@@ -53,6 +53,11 @@
                                               isOutbound(message));
             message.getExchange().put(HandlerChainInvoker.class, invoker);
         }
+        if (isOutbound(message)) {
+            invoker.setOutbound();
+        } else {
+            invoker.setInbound();
+        }
         return invoker;
     }
     

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties?view=auto&rev=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
Wed Oct 25 05:44:58 2006
@@ -0,0 +1,22 @@
+#
+#
+#    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.
+#
+#
+SOAPHANDLERINTERCEPTOR_OUTBOUND_IO=SOAPHandlerInterceptor Outbound IO Exception
+

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=467627&r1=467626&r2=467627
==============================================================================
--- 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
Wed Oct 25 05:44:58 2006
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.jaxws.handler.soap;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.net.URI;
 import java.util.HashSet;
+import java.util.ResourceBundle;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
@@ -29,16 +32,27 @@
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPHandler;
 
+import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptor;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+
+public class SOAPHandlerInterceptor extends
+        AbstractProtocolHandlerInterceptor<SoapMessage> implements
+        SoapInterceptor {
+
+    private static final ResourceBundle BUNDLE = BundleUtils
+            .getBundle(SOAPHandlerInterceptor.class);
 
-public class SOAPHandlerInterceptor extends AbstractProtocolHandlerInterceptor<SoapMessage>
-    implements SoapInterceptor {
-    
     public SOAPHandlerInterceptor(Binding binding) {
         super(binding);
+        setPhase(Phase.PRE_PROTOCOL);
+        addBefore((new StaxOutInterceptor()).getId());
     }
 
     public Set<URI> getRoles() {
@@ -46,7 +60,7 @@
         // TODO
         return roles;
     }
-    
+
     @SuppressWarnings("unchecked")
     public Set<QName> getUnderstoodHeaders() {
         Set<QName> understood = new HashSet<QName>();
@@ -61,14 +75,54 @@
         return understood;
     }
 
+    public void handleMessage(SoapMessage message) {
+        if (getInvoker(message).isOutbound()) {
+            OutputStream os = message.getContent(OutputStream.class);
+            CachedStream cs = new CachedStream();
+            message.setContent(OutputStream.class, cs);
+
+            message.getInterceptorChain().doInterceptInSubChain(message);
+
+            super.handleMessage(message);
+
+            // TODO: Stream SOAPMessage to output stream if SOAPMessage has been
+            // changed
+
+            try {
+                cs.flush();
+                AbstractCachedOutputStream.copyStream(cs.getInputStream(), os,
+                        64 * 1024);
+                cs.close();
+                os.flush();
+                message.setContent(OutputStream.class, os);
+            } catch (IOException ioe) {
+                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
+                        "SOAPHANDLERINTERCEPTOR_OUTBOUND_IO", BUNDLE), ioe,
+                        message.getVersion().getSender());
+            }
+        } else {
+            super.handleMessage(message);           
+        }
+    }
+
     @Override
     protected MessageContext createProtocolMessageContext(Message message) {
         return new SOAPMessageContextImpl(message);
     }
 
     public void handleFault(SoapMessage message) {
-        // TODO Auto-generated method stub
-        
+    }
+
+    private class CachedStream extends AbstractCachedOutputStream {
+        protected void doFlush() throws IOException {
+            currentStream.flush();
+        }
+
+        protected void doClose() throws IOException {
+        }
+
+        protected void onWrite() throws IOException {
+        }
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
Wed Oct 25 05:44:58 2006
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Set;
@@ -32,11 +33,13 @@
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
 import org.w3c.dom.Element;
 
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Message;
 
@@ -55,11 +58,26 @@
         if (null == message) {
 
             try {
-                MessageFactory factory = MessageFactory.newInstance();
-                // getMimeHeaders from message
-                MimeHeaders mhs = null;
-                InputStream is = getWrappedMessage().getContent(InputStream.class);
-                message = factory.createMessage(mhs, is);
+                Boolean outboundProperty = (Boolean)get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+                if (outboundProperty) {
+                    MessageFactory factory = MessageFactory.newInstance();
+                    // getMimeHeaders from message
+                    MimeHeaders mhs = null;
+                    //Safe to do this cast as SOAPHandlerInterceptor explictly 
+                    //replace OutputStream with an AbstractCachedOutputStream.
+                    AbstractCachedOutputStream out = (AbstractCachedOutputStream)getWrappedMessage()
+                        .getContent(OutputStream.class);
+                    InputStream is = out.getInputStream();
+                    message = factory.createMessage(mhs, is);
+                } else {
+                    MessageFactory factory = MessageFactory.newInstance();
+                    // getMimeHeaders from message
+                    MimeHeaders mhs = null;
+                    InputStream is = getWrappedMessage().getContent(InputStream.class);
+                    message = factory.createMessage(mhs, is);
+                }
+                
                 getWrappedMessage().setContent(SOAPMessage.class, message);
             } catch (SOAPException ex) {
                 // do something
@@ -67,6 +85,7 @@
                 // do something
             }
         }
+
         return message;
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
Wed Oct 25 05:44:58 2006
@@ -56,22 +56,28 @@
     }
 
     public void testInterceptSuccess() {
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
-        expect(invoker.invokeProtocolHandlers(eq(true), isA(MessageContext.class))).andReturn(true);
+        expect(
+                invoker.invokeProtocolHandlers(eq(true),
+                        isA(MessageContext.class))).andReturn(true);
+        expect(exchange.getOutMessage()).andReturn(message);
         control.replay();
         IIOPHandlerInterceptor pi = new IIOPHandlerInterceptor(binding);
         assertEquals("unexpected phase", "user-protocol", pi.getPhase());
         pi.handleMessage(message);
     }
-    
+
     public void testInterceptFailure() {
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
-        expect(invoker.invokeProtocolHandlers(eq(true), isA(MessageContext.class))).andReturn(false);
+        expect(exchange.getOutMessage()).andReturn(message);
+        expect(
+                invoker.invokeProtocolHandlers(eq(true),
+                        isA(MessageContext.class))).andReturn(false);
         control.replay();
         IIOPHandlerInterceptor pi = new IIOPHandlerInterceptor(binding);
-        pi.handleMessage(message);  
+        pi.handleMessage(message);
     }
 
     class IIOPMessage extends AbstractWrappedMessage {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
Wed Oct 25 05:44:58 2006
@@ -72,8 +72,9 @@
             }
         });
         expect(invoker.getLogicalHandlers()).andReturn(list);
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        expect(exchange.getOutMessage()).andReturn(message);
         expect(invoker.invokeLogicalHandlers(eq(true),
             isA(LogicalMessageContext.class))).andReturn(true);
         control.replay();
@@ -95,8 +96,9 @@
             }
         });
         expect(invoker.getLogicalHandlers()).andReturn(list);
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        expect(exchange.getOutMessage()).andReturn(message);
         expect(invoker.invokeLogicalHandlers(eq(true), 
             isA(LogicalMessageContext.class))).andReturn(false);
         control.replay();
@@ -105,8 +107,9 @@
     }
     
     public void testOnCompletion() {
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        expect(exchange.getOutMessage()).andReturn(message);
         invoker.mepComplete(message);
         expectLastCall();
         control.replay();

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
Wed Oct 25 05:44:58 2006
@@ -68,9 +68,10 @@
     }
 
     public void testInterceptSuccess() {
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeStreamHandlers(isA(StreamMessageContext.class))).andReturn(true);
+        expect(exchange.getOutMessage()).andReturn(message);
         control.replay();
         StreamHandlerInterceptor si = new StreamHandlerInterceptor(binding);
         assertEquals("unexpected phase", "user-stream", si.getPhase());
@@ -78,9 +79,10 @@
     }
     
     public void testInterceptFailure() {
-        expect(message.getExchange()).andReturn(exchange);
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeStreamHandlers(isA(StreamMessageContext.class))).andReturn(false);
+        expect(exchange.getOutMessage()).andReturn(message);
         control.replay();
         StreamHandlerInterceptor si = new StreamHandlerInterceptor(binding);
         si.handleMessage(message); 

Modified: 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=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
Wed Oct 25 05:44:58 2006
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.jaxws.handler.soap;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -34,12 +36,16 @@
 import junit.framework.TestCase;
 
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
 
 import org.easymock.classextension.IMocksControl;
 
 import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
 import static org.easymock.classextension.EasyMock.createNiceControl;
 
 public class SOAPHandlerInterceptorTest extends TestCase {
@@ -69,14 +75,24 @@
             }
         });
         HandlerChainInvoker invoker = new HandlerChainInvoker(list);
+        invoker.setInbound();
 
         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>());
+        InterceptorChain chain = control.createMock(InterceptorChain.class);
+        expect(chain.doInterceptInSubChain(isA(Message.class))).andReturn(true);
+        
+        expect(message.getExchange()).andReturn(exchange).anyTimes();
+        
+        expect(message.getInterceptorChain()).andReturn(chain);
+         //EasyMock.expectLastCall().anyTimes();
+        //message.setInterceptorChain(chain);
+        
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
+        expect(exchange.getOutMessage()).andReturn(message);
+        expect(message.getContent(OutputStream.class)).andReturn(new CachedStream());
         control.replay();
 
         SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
@@ -118,6 +134,18 @@
         Set<QName> understood = li.getUnderstoodHeaders();
         assertNotNull(understood);
         assertTrue(understood.isEmpty());
+    }
+    
+    private class CachedStream extends AbstractCachedOutputStream {
+        protected void doFlush() throws IOException {
+            currentStream.flush();
+        }
+
+        protected void doClose() throws IOException {
+        }
+
+        protected void onWrite() throws IOException {
+        }
     }
 
 }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java?view=auto&rev=467627
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
Wed Oct 25 05:44:58 2006
@@ -0,0 +1,101 @@
+/**
+ * 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.systest.handlers;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/*
+ * This simple SOAPHandler will output the contents of incoming
+ * and outgoing messages.
+ */
+public class LoggingHandler implements SOAPHandler<SOAPMessageContext> {
+
+    private PrintStream out;
+
+    public LoggingHandler() {
+        setLogStream(System.out);
+    }
+
+    protected final void setLogStream(PrintStream ps) {
+        out = ps;
+    }
+
+    public void init(Map c) {
+    }
+
+    public Set<QName> getHeaders() {
+        return null;
+    }
+
+    public boolean handleMessage(SOAPMessageContext smc) {
+        //System.out.println("LoggingHandler : handleMessage Called....");
+        logToSystemOut(smc);
+        return true;
+    }
+
+    public boolean handleFault(SOAPMessageContext smc) {
+        //System.out.println("LoggingHandler : handleFault Called....");
+        logToSystemOut(smc);
+        return true;
+    }
+
+    // nothing to clean up
+    public void close(MessageContext messageContext) {
+        //System.out.println("LoggingHandler : close() Called....");
+    }
+
+    // nothing to clean up
+    public void destroy() {
+        //System.out.println("LoggingHandler : destroy() Called....");
+    }
+
+    /*
+     * Check the MESSAGE_OUTBOUND_PROPERTY in the context
+     * to see if this is an outgoing or incoming message.
+     * Write a brief message to the print stream and
+     * output the message. The writeTo() method can throw
+     * SOAPException or IOException
+     */
+    protected void logToSystemOut(SOAPMessageContext smc) {
+        Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+        if (outboundProperty.booleanValue()) {
+            //out.println("\nOutbound message:");
+        } else {
+            //out.println("\nInbound message:");
+        }
+
+        SOAPMessage message = smc.getMessage();
+        try {
+            message.writeTo(out);
+            //out.println();
+        } catch (Exception e) {
+            //out.println("Exception in handler: " + e);
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/LoggingHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/SmallNumberHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/SmallNumberHandler.java?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/SmallNumberHandler.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/SmallNumberHandler.java
Wed Oct 25 05:44:58 2006
@@ -19,22 +19,25 @@
 package org.apache.cxf.systest.handlers;
 
 import java.util.Map;
-/*import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.ws.LogicalMessage;
-import javax.xml.ws.ProtocolException;*/
+/*
+ * import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException;
+ * import javax.xml.ws.LogicalMessage; import javax.xml.ws.ProtocolException;
+ */
 import javax.xml.ws.handler.LogicalHandler;
 import javax.xml.ws.handler.LogicalMessageContext;
 import javax.xml.ws.handler.MessageContext;
-//import org.apache.handlers.types.AddNumbers;
 
-//import org.apache.handlers.types.AddNumbersResponse;
+// import org.apache.handlers.types.AddNumbers;
+
+// import org.apache.handlers.types.AddNumbersResponse;
 
 /**
  * handles addition of small numbers.
  */
-public class SmallNumberHandler implements LogicalHandler<LogicalMessageContext> {
+public class SmallNumberHandler implements
+        LogicalHandler<LogicalMessageContext> {
     public final boolean handleMessage(LogicalMessageContext messageContext) {
+        //System.out.println("SmallNumberHandler : handleMessage Called....");
         return true;
     }
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers.xml?view=diff&rev=467627&r1=467626&r2=467627
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers.xml
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers.xml
Wed Oct 25 05:44:58 2006
@@ -13,5 +13,13 @@
 			<param-value>String</param-value>
 		</init-param>
 	</handler>
+	<handler>
+		<handler-name>ph1</handler-name>
+		<handler-class>org.apache.cxf.systest.handlers.LoggingHandler</handler-class>
+		<init-param>
+			<param-name>token</param-name>
+			<param-value>String</param-value>
+		</init-param>
+	</handler>
     </handler-chain>
-</handler-chains>
\ No newline at end of file
+</handler-chains>



Mime
View raw message