cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r501377 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/handler/ test/java/org/apache/cxf/jaxws/handler/
Date Tue, 30 Jan 2007 11:49:10 GMT
Author: jliu
Date: Tue Jan 30 03:49:09 2007
New Revision: 501377

URL: http://svn.apache.org/viewvc?view=rev&rev=501377
Log:
Hopefully last patch  from Unreal: cxf-332

Modified:
    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/AbstractProtocolHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.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/HandlerChainInvokerTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java

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=501377&r1=501376&r2=501377
==============================================================================
--- 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
Tue Jan 30 03:49:09 2007
@@ -38,12 +38,11 @@
     
     boolean isOutbound(T message) {
         return message == message.getExchange().getOutMessage()
-               || message == message.getExchange().getOutFaultMessage();
+            || message == message.getExchange().getOutFaultMessage();
     }
     
     protected boolean isRequestor(T message) {
-        Boolean b = (Boolean)message.get(Message.REQUESTOR_ROLE);
-        return b == null ? true : b.booleanValue();
+        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
     }
     
     protected HandlerChainInvoker getInvoker(T message) {
@@ -59,6 +58,15 @@
         } else {
             invoker.setInbound();
         }
+        
+        if (message.getExchange().isOneWay()
+            || ((isRequestor(message) && !isOutbound(message)) 
+                || (!isRequestor(message) && isOutbound(message)))) {
+            invoker.setResponseExpected(false);
+        } else { 
+            invoker.setResponseExpected(true);
+        }
+        
         return invoker;
     }
     

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptor.java?view=diff&rev=501377&r1=501376&r2=501377
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptor.java
Tue Jan 30 03:49:09 2007
@@ -36,7 +36,9 @@
     
     public void handleMessage(T message) {
         MessageContext context = createProtocolMessageContext(message);
-        getInvoker(message).invokeProtocolHandlers(isRequestor(message), context);
+        HandlerChainInvoker invoker = getInvoker(message);
+        invoker.setProtocolMessageContext(context);
+        invoker.invokeProtocolHandlers(isRequestor(message), context);
         onCompletion(message);
     }
     

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java?view=diff&rev=501377&r1=501376&r2=501377
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
Tue Jan 30 03:49:09 2007
@@ -58,7 +58,9 @@
     private boolean handlerProcessingAborted; 
     private boolean closed;  
     private Exception fault;
-
+    private MessageContext logicalMessageContext;
+    private MessageContext protocolMessageContext;
+    
     public HandlerChainInvoker(List<Handler> hc) {
         this(hc, true);
     }    
@@ -94,6 +96,20 @@
         return streamHandlers;
     }
 
+    public MessageContext getLogicalMessageContext() {
+        return logicalMessageContext;
+    }
+    public void setLogicalMessageContext(MessageContext mc) {
+        logicalMessageContext = mc;
+    }
+    
+    public MessageContext getProtocolMessageContext() {
+        return protocolMessageContext;
+    }
+    public void setProtocolMessageContext(MessageContext mc) {
+        protocolMessageContext = mc;
+    }
+    
     public boolean invokeLogicalHandlers(boolean requestor, LogicalMessageContext context)
{ 
         // objectCtx.setRequestorRole(requestor);
         context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, isOutbound()); 
@@ -280,6 +296,7 @@
                     continueProcessing = h.handleMessage(ctx);
                 }
                 if (!continueProcessing) {
+                    callReversedHandlers(ctx);
                     break;
                 }
                 markHandlerInvoked(h); 
@@ -296,6 +313,44 @@
         return continueProcessing;
     } 
 
+    private boolean callReversedHandlers(MessageContext ctx) {
+        int index = invokedHandlers.size() - 1;
+        if (responseExpected) {
+            while (index >= 0) {
+//                if (Boolean.FALSE.equals(invokedHandlers.get(index).handleMessage(ctx)))
{
+//                    return false;
+//                }
+                Handler handler = invokedHandlers.get(index);
+                if (handler instanceof LogicalHandler) {
+                    if (Boolean.FALSE.equals(handler.
+                                             handleMessage(logicalMessageContext))) { 
+                        return false;
+                    }
+                } else {
+                    if (Boolean.FALSE.equals(handler.
+                                             handleMessage(protocolMessageContext))) {
+                        return false;
+                    }
+                }
+                index--;
+            }
+        }
+        closeHandlers(ctx);
+        return true;
+    }
+
+    private void closeHandlers(MessageContext ctx) {
+        int index = invokedHandlers.size() - 1;
+        while (index >= 0) {
+            Handler handler = invokedHandlers.get(index);
+            if (handler instanceof LogicalHandler) {
+                handler.close(logicalMessageContext);
+            } else {
+                handler.close(protocolMessageContext);
+            }
+            index--;
+        }
+    }
     
     private boolean invokeThisHandler(Handler h) {
         boolean ret = true;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java?view=diff&rev=501377&r1=501376&r2=501377
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
Tue Jan 30 03:49:09 2007
@@ -41,6 +41,7 @@
         HandlerChainInvoker invoker = getInvoker(message);
         if (!invoker.getLogicalHandlers().isEmpty()) {
             LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
+            invoker.setLogicalMessageContext(lctx);
             if (!invoker.invokeLogicalHandlers(isRequestor(message), lctx)) {
                 //TODO: reverseHandlers();
 

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=501377&r1=501376&r2=501377
==============================================================================
--- 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
Tue Jan 30 03:49:09 2007
@@ -59,7 +59,7 @@
         expect(message.getExchange()).andReturn(exchange).anyTimes();
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(
-                invoker.invokeProtocolHandlers(eq(true),
+                invoker.invokeProtocolHandlers(eq(false),
                         isA(MessageContext.class))).andReturn(true);
         expect(exchange.getOutMessage()).andReturn(message);
         control.replay();
@@ -73,7 +73,7 @@
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(exchange.getOutMessage()).andReturn(message);
         expect(
-                invoker.invokeProtocolHandlers(eq(true),
+                invoker.invokeProtocolHandlers(eq(false),
                         isA(MessageContext.class))).andReturn(false);
         control.replay();
         IIOPHandlerInterceptor pi = new IIOPHandlerInterceptor(binding);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java?view=diff&rev=501377&r1=501376&r2=501377
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
Tue Jan 30 03:49:09 2007
@@ -39,20 +39,20 @@
 import org.apache.cxf.message.MessageImpl;
 
 public class HandlerChainInvokerTest extends TestCase {
-    
-    private static final int HANDLER_COUNT = 2; 
-    
-    HandlerChainInvoker invoker;    
+
+    private static final int HANDLER_COUNT = 2;
+
+    HandlerChainInvoker invoker;
     Message message = new MessageImpl();
     LogicalMessageContext lmc = new LogicalMessageContextImpl(message);
     MessageContext pmc = new WrappedMessageContext(message);
     StreamMessageContext smc = new StreamMessageContextImpl(message);
-    
+
     TestLogicalHandler[] logicalHandlers = new TestLogicalHandler[HANDLER_COUNT];
     TestProtocolHandler[] protocolHandlers = new TestProtocolHandler[HANDLER_COUNT];
 
     public void setUp() {
-        AbstractHandlerBase.clear(); 
+        AbstractHandlerBase.clear();
 
         List<Handler> handlers = new ArrayList<Handler>();
         for (int i = 0; i < logicalHandlers.length; i++) {
@@ -66,40 +66,40 @@
 
         invoker = new HandlerChainInvoker(handlers);
     }
-    
+
     public void testInvokeEmptyHandlerChain() {
         invoker = new HandlerChainInvoker(new ArrayList<Handler>());
         assertTrue(invoker.invokeLogicalHandlers(false, lmc));
         assertTrue(doInvokeProtocolHandlers(false));
     }
 
-    public void testHandlerPartitioning() { 
-        
+    public void testHandlerPartitioning() {
+
         assertEquals(HANDLER_COUNT, invoker.getLogicalHandlers().size());
         for (Handler h : invoker.getLogicalHandlers()) {
-            assertTrue(h instanceof LogicalHandler); 
+            assertTrue(h instanceof LogicalHandler);
         }
 
         assertEquals(HANDLER_COUNT, invoker.getProtocolHandlers().size());
         for (Handler h : invoker.getProtocolHandlers()) {
-            assertTrue(!(h instanceof LogicalHandler)); 
+            assertTrue(!(h instanceof LogicalHandler));
         }
 
-    } 
-    
+    }
+
     public void testInvokeHandlersOutbound() {
 
         assertEquals(0, invoker.getInvokedHandlers().size());
         assertTrue(invoker.isOutbound());
 
         checkLogicalHandlersInvoked(true, false);
-        
+
         assertTrue(invoker.isOutbound());
         assertEquals(2, invoker.getInvokedHandlers().size());
         checkProtocolHandlersInvoked(true);
         assertTrue(invoker.isOutbound());
         assertEquals(4, invoker.getInvokedHandlers().size());
-        assertFalse(invoker.isClosed()); 
+        assertFalse(invoker.isClosed());
 
         assertTrue(logicalHandlers[0].getInvokedOrder() < logicalHandlers[1].getInvokedOrder());
         assertTrue(logicalHandlers[1].getInvokedOrder() < protocolHandlers[0].getInvokedOrder());
@@ -115,59 +115,59 @@
         assertEquals(2, invoker.getInvokedHandlers().size());
         assertTrue(invoker.isInbound());
 
-        checkLogicalHandlersInvoked(false, true); 
+        checkLogicalHandlersInvoked(false, true);
         assertEquals(4, invoker.getInvokedHandlers().size());
         assertTrue(invoker.isInbound());
 
-        assertFalse(invoker.isClosed()); 
+        assertFalse(invoker.isClosed());
         assertTrue(logicalHandlers[0].getInvokedOrder() > logicalHandlers[1].getInvokedOrder());
         assertTrue(logicalHandlers[1].getInvokedOrder() > protocolHandlers[0].getInvokedOrder());
         assertTrue(protocolHandlers[0].getInvokedOrder() > protocolHandlers[1].getInvokedOrder());
     }
-        
-    public void testLogicalHandlerOutboundProcessingStoppedResponseExpected() { 
+
+    public void testLogicalHandlerOutboundProcessingStoppedResponseExpected() {
 
         assertEquals(0, logicalHandlers[0].getHandleMessageCount());
         assertEquals(0, logicalHandlers[1].getHandleMessageCount());
 
         assertTrue(invoker.isOutbound());
-         
+
         // invoke the handlers.  when a handler returns false, processing
         // of handlers is stopped and message direction is  reversed.
-        logicalHandlers[0].setHandleMessageRet(false);        
+        logicalHandlers[0].setHandleMessageRet(false);
         boolean ret = invoker.invokeLogicalHandlers(false, lmc);
-                
-        assertEquals(false, ret); 
-        assertFalse(invoker.isClosed()); 
+
+        assertEquals(false, ret);
+        assertFalse(invoker.isClosed());
         assertEquals(1, logicalHandlers[0].getHandleMessageCount());
         assertEquals(0, logicalHandlers[1].getHandleMessageCount());
         assertTrue(invoker.isInbound());
-        
+
         // the next time invokeHandler is invoked, the 'next' handler is invoked.
         // As message direction has been reversed this means the that the previous
         // one on the list is actually invoked.
-        logicalHandlers[0].setHandleMessageRet(true);        
-        
+        logicalHandlers[0].setHandleMessageRet(true);
+
         ret = invoker.invokeLogicalHandlers(false, lmc);
         assertTrue(ret);
-        assertFalse(invoker.isClosed()); 
+        assertFalse(invoker.isClosed());
         assertEquals(1, logicalHandlers[0].getHandleMessageCount());
         assertEquals(0, logicalHandlers[1].getHandleMessageCount());
         assertTrue(invoker.isInbound());
     }
-    
-    public void testLogicalHandlerInboundProcessingStoppedResponseExpected() { 
+
+    public void testLogicalHandlerInboundProcessingStoppedResponseExpected() {
 
         assertEquals(0, logicalHandlers[0].getHandleMessageCount());
         assertEquals(0, logicalHandlers[1].getHandleMessageCount());
 
         invoker.setInbound();
-         
-        logicalHandlers[1].setHandleMessageRet(false);        
+
+        logicalHandlers[1].setHandleMessageRet(false);
         boolean ret = invoker.invokeLogicalHandlers(false, lmc);
-        assertFalse(invoker.isClosed()); 
-                
-        assertEquals(false, ret); 
+        assertFalse(invoker.isClosed());
+
+        assertEquals(false, ret);
         assertEquals(0, logicalHandlers[0].getHandleMessageCount());
         assertEquals(1, logicalHandlers[1].getHandleMessageCount());
         assertTrue(invoker.isOutbound());
@@ -176,98 +176,98 @@
 
     public void testHandleMessageThrowsProtocolException() {
 
-        assertFalse(invoker.faultRaised()); 
-        
+        assertFalse(invoker.faultRaised());
+
         ProtocolException pe = new ProtocolException("banzai");
         logicalHandlers[1].setException(pe);
 
-        boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc); 
+        boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
         assertFalse(continueProcessing);
-        assertTrue(invoker.faultRaised()); 
+        assertTrue(invoker.faultRaised());
 
-        assertEquals(1, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
+        assertEquals(1, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
         continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
         assertTrue(continueProcessing);
-        assertTrue(invoker.faultRaised()); 
-        assertFalse(invoker.isClosed()); 
-        assertSame(pe, invoker.getFault()); 
+        assertTrue(invoker.faultRaised());
+        assertFalse(invoker.isClosed());
+        assertSame(pe, invoker.getFault());
 
-        assertEquals(1, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
+        assertEquals(1, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
         assertEquals(1, logicalHandlers[0].getHandleFaultCount());
         assertEquals(0, logicalHandlers[1].getHandleFaultCount());
 
-        assertTrue(logicalHandlers[1].getInvokedOrder() 
+        assertTrue(logicalHandlers[1].getInvokedOrder()
                    < logicalHandlers[0].getInvokedOrder());
     }
 
 
     public void testHandleMessageThrowsRuntimeException() {
 
-        assertFalse(invoker.faultRaised()); 
-        
+        assertFalse(invoker.faultRaised());
+
         RuntimeException re = new RuntimeException("banzai");
         logicalHandlers[1].setException(re);
 
-        boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc); 
+        boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
         assertFalse(continueProcessing);
-        assertFalse(invoker.faultRaised()); 
-        assertTrue(invoker.isClosed()); 
+        assertFalse(invoker.faultRaised());
+        assertTrue(invoker.isClosed());
 
-        assertEquals(1, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
+        assertEquals(1, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
 
         // should this throw exception???
         continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
         assertFalse(continueProcessing);
 
-        assertEquals(1, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
+        assertEquals(1, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
         assertEquals(0, logicalHandlers[0].getHandleFaultCount());
         assertEquals(0, logicalHandlers[1].getHandleFaultCount());
     }
-    
 
-    public void testHandleFault() { 
+
+    public void testHandleFault() {
 
         // put invoker into fault state
         ProtocolException pe = new ProtocolException("banzai");
-        invoker.setFault(pe); 
+        invoker.setFault(pe);
 
         boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
-        assertTrue(continueProcessing); 
+        assertTrue(continueProcessing);
         assertEquals(0, logicalHandlers[0].getHandleMessageCount());
         assertEquals(0, logicalHandlers[1].getHandleMessageCount());
         assertEquals(1, logicalHandlers[0].getHandleFaultCount());
         assertEquals(1, logicalHandlers[1].getHandleFaultCount());
 
         assertTrue(logicalHandlers[0].getInvokedOrder() < logicalHandlers[1].getInvokedOrder());
-    } 
+    }
 
 
-    public void testFaultRaised() {  
+    public void testFaultRaised() {
 
-        assertFalse(invoker.faultRaised()); 
+        assertFalse(invoker.faultRaised());
 
-        invoker.setFault(new ProtocolException("test exception")); 
-        assertTrue(invoker.faultRaised()); 
+        invoker.setFault(new ProtocolException("test exception"));
+        assertTrue(invoker.faultRaised());
 
         // reset
-        invoker.setFault(null); 
-        assertFalse(invoker.faultRaised()); 
+        invoker.setFault(null);
+        assertFalse(invoker.faultRaised());
 
-        invoker.setFault(true); 
-        assertTrue(invoker.faultRaised()); 
+        invoker.setFault(true);
+        assertTrue(invoker.faultRaised());
 
-        // reset 
-        invoker.setFault(false); 
-        invoker.setFault(null); 
-        assertFalse(invoker.faultRaised()); 
-
-        invoker.setFault(true); 
-        invoker.setFault(new ProtocolException("test exception")); 
-    } 
+        // reset
+        invoker.setFault(false);
+        invoker.setFault(null);
+        assertFalse(invoker.faultRaised());
+
+        invoker.setFault(true);
+        invoker.setFault(new ProtocolException("test exception"));
+    }
 
 
 
@@ -282,67 +282,75 @@
     }
 
 
-    public void testMEPComplete() { 
+    public void testMEPComplete() {
 
-        invoker.invokeLogicalHandlers(false, lmc); 
+        invoker.invokeLogicalHandlers(false, lmc);
         doInvokeProtocolHandlers(false);
-        assertEquals(4, invoker.getInvokedHandlers().size()); 
+        assertEquals(4, invoker.getInvokedHandlers().size());
 
-        invoker.mepComplete(message); 
+        invoker.mepComplete(message);
 
-        assertTrue("close not invoked on logicalHandlers", logicalHandlers[0].isCloseInvoked());

-        assertTrue("close not invoked on logicalHandlers", logicalHandlers[1].isCloseInvoked());

+        assertTrue("close not invoked on logicalHandlers", logicalHandlers[0].isCloseInvoked());
+        assertTrue("close not invoked on logicalHandlers", logicalHandlers[1].isCloseInvoked());
         assertTrue("close not invoked on protocolHandlers", protocolHandlers[0].isCloseInvoked());
         assertTrue("close not invoked on protocolHandlers", protocolHandlers[1].isCloseInvoked());
 
-        assertTrue("incorrect invocation order of close", protocolHandlers[1].getInvokedOrder()

+        assertTrue("incorrect invocation order of close", protocolHandlers[1].getInvokedOrder()
                    < protocolHandlers[0].getInvokedOrder());
-        assertTrue("incorrect invocation order of close", protocolHandlers[0].getInvokedOrder()

+        assertTrue("incorrect invocation order of close", protocolHandlers[0].getInvokedOrder()
                    < logicalHandlers[1].getInvokedOrder());
-        assertTrue("incorrect invocation order of close", logicalHandlers[1].getInvokedOrder()

+        assertTrue("incorrect invocation order of close", logicalHandlers[1].getInvokedOrder()
                    < logicalHandlers[0].getInvokedOrder());
-    } 
+    }
 
 
     public void testResponseExpectedDefault() {
         assertTrue(invoker.isResponseExpected());
     }
-    
+
     /* test invoking logical handlers when processing has been aborted
      * with both protocol and logical handlers in invokedHandlers list.
      *
      */
-    public void testInvokedAlreadyInvokedMixed() { 
+    public void testInvokedAlreadyInvokedMixed() {
 
         // simulate an invocation being aborted by a logical handler
         //
-        logicalHandlers[1].setHandleMessageRet(false);        
+        logicalHandlers[1].setHandleMessageRet(false);
         invoker.setInbound();
         //invoker.invokeProtocolHandlers(true, soapContext);
         doInvokeProtocolHandlers(true);
-        invoker.invokeLogicalHandlers(true, lmc); 
+        invoker.invokeLogicalHandlers(true, lmc);
 
         assertEquals(2, invoker.getInvokedHandlers().size());
         assertTrue(!invoker.getInvokedHandlers().contains(logicalHandlers[1]));
         assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[0]));
         assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[1]));
-        assertEquals(0, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
-        assertEquals(1, protocolHandlers[0].getHandleMessageCount()); 
+        assertEquals(0, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
+        assertEquals(2, protocolHandlers[0].getHandleMessageCount());
 
-        assertEquals(1, protocolHandlers[1].getHandleMessageCount()); 
+        assertEquals(2, protocolHandlers[1].getHandleMessageCount());
 
         // now, invoke handlers on outbound leg
-        invoker.invokeLogicalHandlers(true, lmc); 
+        invoker.invokeLogicalHandlers(true, lmc);
 
-        assertEquals(1, logicalHandlers[1].getHandleMessageCount()); 
-        assertEquals(0, logicalHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, protocolHandlers[0].getHandleMessageCount()); 
-        assertEquals(1, protocolHandlers[1].getHandleMessageCount()); 
+        assertEquals(1, logicalHandlers[1].getHandleMessageCount());
+        assertEquals(0, logicalHandlers[0].getHandleMessageCount());
+        assertEquals(2, protocolHandlers[0].getHandleMessageCount());
+        assertEquals(2, protocolHandlers[1].getHandleMessageCount());
 
     }
-    
-    protected void checkLogicalHandlersInvoked(boolean outboundProperty, boolean requestorProperty)
{ 
+
+    /*public void testHandlerReturnFalse() {
+        logicalHandlers[1].setHandleMessageRet(false);
+        invoker.setInbound();
+        doInvokeProtocolHandlers(true);
+        invoker.invokeLogicalHandlers(true, lmc);
+
+    }*/
+
+    protected void checkLogicalHandlersInvoked(boolean outboundProperty, boolean requestorProperty)
{
 
         invoker.invokeLogicalHandlers(requestorProperty, lmc);
 
@@ -352,78 +360,78 @@
         // assertEquals(requestorProperty, message.get(ObjectMessageContext.REQUESTOR_ROLE_PROPERTY));
         assertTrue("handler not invoked", logicalHandlers[0].isHandleMessageInvoked());
         assertTrue("handler not invoked", logicalHandlers[1].isHandleMessageInvoked());
-        assertTrue(invoker.getInvokedHandlers().contains(logicalHandlers[0])); 
-        assertTrue(invoker.getInvokedHandlers().contains(logicalHandlers[1])); 
+        assertTrue(invoker.getInvokedHandlers().contains(logicalHandlers[0]));
+        assertTrue(invoker.getInvokedHandlers().contains(logicalHandlers[1]));
     }
-    
-    protected void checkProtocolHandlersInvoked(boolean outboundProperty) { 
-  
+
+    protected void checkProtocolHandlersInvoked(boolean outboundProperty) {
+
         invoker.invokeProtocolHandlers(false, pmc);
-        
+
         assertTrue("handler not invoked", protocolHandlers[0].isHandleMessageInvoked());
         assertTrue("handler not invoked", protocolHandlers[1].isHandleMessageInvoked());
 
-        assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[0])); 
-        assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[1])); 
+        assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[0]));
+        assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[1]));
     }
-  
-    private void doHandleFaultExceptionTest(RuntimeException e) { 
+
+    private void doHandleFaultExceptionTest(RuntimeException e) {
 
         // put invoker into fault state
         ProtocolException pe = new ProtocolException("banzai");
-        invoker.setFault(pe); 
+        invoker.setFault(pe);
 
         // throw exception during handleFault processing
         logicalHandlers[0].setException(e);
         boolean continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
-        assertFalse(continueProcessing); 
-        assertTrue(invoker.isClosed()); 
+        assertFalse(continueProcessing);
+        assertTrue(invoker.isClosed());
         assertEquals(1, logicalHandlers[0].getHandleFaultCount());
         assertEquals(0, logicalHandlers[1].getHandleFaultCount());
-    } 
- 
+    }
+
     private boolean doInvokeProtocolHandlers(boolean requestor) {
         return invoker.invokeProtocolHandlers(requestor, pmc);
     }
-    
+
     static class TestProtocolHandler extends AbstractHandlerBase<SOAPMessageContext>
{
-        
+
     }
-    
+
     static class TestLogicalHandler extends AbstractHandlerBase<LogicalMessageContextImpl>
         implements LogicalHandler<LogicalMessageContextImpl> {
-        
-    }    
-    
+
+    }
+
     static class AbstractHandlerBase<T extends MessageContext> implements Handler<T>
{
-        
-        private static int sinvokedOrder; 
-        private static int sid; 
-       
-        private int invokeOrder; 
-        private final int id = ++sid; 
-        
+
+        private static int sinvokedOrder;
+        private static int sid;
+
+        private int invokeOrder;
+        private final int id = ++sid;
+
         private int handleMessageInvoked;
         private int handleFaultInvoked;
-        private boolean handleMessageRet = true; 
-        private final boolean handleFaultRet = true; 
-        private RuntimeException exception; 
+        private boolean handleMessageRet = true;
+        private final boolean handleFaultRet = true;
+        private RuntimeException exception;
 
-        private int closeInvoked; 
+        private int closeInvoked;
 
         public void reset() {
-            handleMessageInvoked = 0; 
-            handleFaultInvoked = 0; 
-            handleMessageRet = true; 
+            handleMessageInvoked = 0;
+            handleFaultInvoked = 0;
+            handleMessageRet = true;
         }
-        
+
         public boolean handleMessage(T arg0) {
-            invokeOrder = ++sinvokedOrder; 
+            invokeOrder = ++sinvokedOrder;
             handleMessageInvoked++;
 
             if (exception != null) {
                 RuntimeException e = exception;
-                exception = null; 
+                exception = null;
                 throw e;
             }
 
@@ -431,8 +439,8 @@
         }
 
         public boolean handleFault(T arg0) {
-            invokeOrder = ++sinvokedOrder; 
-            handleFaultInvoked++; 
+            invokeOrder = ++sinvokedOrder;
+            handleFaultInvoked++;
 
             if (exception != null) {
                 throw exception;
@@ -442,16 +450,16 @@
         }
 
         public void close(MessageContext arg0) {
-            invokeOrder = ++sinvokedOrder; 
+            invokeOrder = ++sinvokedOrder;
             closeInvoked++;
         }
 
-        
+
         public void init(Map<String, Object> arg0) {
             // TODO Auto-generated method stub
         }
 
-        
+
         public void destroy() {
             // TODO Auto-generated method stub
         }
@@ -459,7 +467,7 @@
         public int getHandleMessageCount() {
             return handleMessageInvoked;
         }
-        
+
         public int getHandleFaultCount() {
             return handleFaultInvoked;
         }
@@ -468,39 +476,39 @@
             return handleMessageInvoked > 0;
         }
 
-        public boolean isCloseInvoked() { 
-            return closeInvoked > 0; 
-        } 
+        public boolean isCloseInvoked() {
+            return closeInvoked > 0;
+        }
 
-        public int getCloseCount() { 
+        public int getCloseCount() {
             return closeInvoked;
-        } 
+        }
 
         public int getInvokedOrder() {
-            return invokeOrder;            
+            return invokeOrder;
         }
-        
+
         public void setHandleMessageRet(boolean ret) {
-            handleMessageRet = ret; 
+            handleMessageRet = ret;
         }
-        
+
         public void setHandleFaultRet(boolean ret) {
-            //handleFaultRet = ret; 
+            //handleFaultRet = ret;
         }
 
-        public String toString() { 
+        public String toString() {
             return "[" + super.toString() + " id: " + id + " invoke order: " + invokeOrder
+ "]";
         }
 
-        
-        public void setException(RuntimeException rte) { 
+
+        public void setException(RuntimeException rte) {
             exception = rte;
-        } 
+        }
 
-        public static void clear() { 
-            sinvokedOrder = 0; 
-            sid = 0; 
-        } 
+        public static void clear() {
+            sinvokedOrder = 0;
+            sid = 0;
+        }
     }
 
 }

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=501377&r1=501376&r2=501377
==============================================================================
--- 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
Tue Jan 30 03:49:09 2007
@@ -82,7 +82,9 @@
         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);
+        expect(invoker.invokeLogicalHandlers(eq(false), isA(LogicalMessageContext.class)))
+            .andReturn(true);
+
         control.replay();
         LogicalHandlerInterceptor<Message> li = new LogicalHandlerInterceptor<Message>(binding);
         assertEquals("unexpected phase", "user-logical", li.getPhase());



Mime
View raw message