cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1425493 - in /cxf/trunk/rt/ws/rm/src: main/java/org/apache/cxf/ws/rm/RMInInterceptor.java test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Date Sun, 23 Dec 2012 17:34:23 GMT
Author: ay
Date: Sun Dec 23 17:34:22 2012
New Revision: 1425493

URL: http://svn.apache.org/viewvc?rev=1425493&view=rev
Log:
fix the robust-mode case for CXF-4694 and add tests

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=1425493&r1=1425492&r2=1425493&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Sun Dec 23
17:34:22 2012
@@ -59,7 +59,8 @@ public class RMInInterceptor extends Abs
             } catch (RMException e) {
                 LOG.log(Level.WARNING, "Failed to revert the delivering status");
             }
-        } else if (!ContextUtils.isRequestor(message)) {
+        } 
+        if (!ContextUtils.isRequestor(message)) {
             // force the fault to be returned.
             Exchange exchange = message.getExchange();
             exchange.setOneWay(false);

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java?rev=1425493&r1=1425492&r2=1425493&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java Sun Dec
23 17:34:22 2012
@@ -26,12 +26,14 @@ import java.util.Iterator;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
 import org.apache.cxf.ws.addressing.MAPAggregator;
@@ -344,8 +346,68 @@ public class RMInInterceptorTest extends
         Message message = control.createMock(Message.class);
         Exchange exchange = control.createMock(Exchange.class);
         EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+        control.replay();
+        
+        try {
+            interceptor.handleFault(message);
+        } catch (Exception e) {
+            fail("unexpected exception thrown from handleFault: " + e);
+        }
+        
+        control.reset();
+        EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)).andReturn(true).anyTimes();
+        control.replay();
+        
+        try {
+            interceptor.handleFault(message);
+        } catch (Exception e) {
+            fail("unexpected exception thrown from handleFault: " + e);
+        }
+    }
+
+    @Test
+    public void testProcessValidMessageOnFault() throws SequenceFault, RMException {
+        interceptor = new RMInInterceptor();
+        manager = control.createMock(RMManager.class);
+        Message message = control.createMock(Message.class);
+        Exchange exchange = control.createMock(Exchange.class);
+        AddressingPropertiesImpl maps = control.createMock(AddressingPropertiesImpl.class);
+        
+        interceptor.setManager(manager);
+        
+        EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+        EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION))
+            .andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
+        exchange.setOneWay(false);
+        EasyMock.expectLastCall();
+        control.replay();
+        
+        try {
+            interceptor.handleFault(message);
+        } catch (Exception e) {
+            fail("unexpected exception thrown from handleFault: " + e);
+        }
+
+        control.verify();
+        
+        control.reset();
+        Destination d = control.createMock(Destination.class);
+        Endpoint ep = control.createMock(Endpoint.class);
+        EndpointInfo epi = control.createMock(EndpointInfo.class);
+        EasyMock.expect(ep.getEndpointInfo()).andReturn(epi).anyTimes();
+        EasyMock.expect(exchange.get(Endpoint.class)).andReturn(ep).anyTimes();
+        EasyMock.expect(maps.getFaultTo())
+            .andReturn(RMUtils.createReference("http://localhost:9999/decoupled")).anyTimes();
+        EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+        EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION))
+            .andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
         exchange.setOneWay(false);
         EasyMock.expectLastCall();
+        exchange.setDestination(EasyMock.anyObject(org.apache.cxf.transport.Destination.class));
+        EasyMock.expectLastCall();
         control.replay();
         
         try {
@@ -353,10 +415,19 @@ public class RMInInterceptorTest extends
         } catch (Exception e) {
             fail("unexpected exception thrown from handleFault: " + e);
         }
+        control.verify();
         
         control.reset();
+        EasyMock.expect(maps.getFaultTo())
+            .andReturn(RMUtils.createAnonymousReference()).anyTimes();
+        EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+        EasyMock.expect(manager.getDestination(message)).andReturn(d);
         EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
         EasyMock.expect(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)).andReturn(true).anyTimes();
+        EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION))
+            .andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
+        exchange.setOneWay(false);
+        EasyMock.expectLastCall();
         control.replay();
         
         try {
@@ -364,6 +435,7 @@ public class RMInInterceptorTest extends
         } catch (Exception e) {
             fail("unexpected exception thrown from handleFault: " + e);
         }
+        // verified in tearDown
     }
 
     private Message setupInboundMessage(String action, boolean serverSide) throws RMException
{



Mime
View raw message