Author: ay
Date: Tue Aug 20 15:45:20 2013
New Revision: 1515848
URL: http://svn.apache.org/r1515848
Log:
Merged revisions 1515822 via svn merge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1515822 | ay | 2013-08-20 15:36:39 +0200 (Tue, 20 Aug 2013) | 1 line
[CXF-5218] WS-RM destination's fault handling to distinguish protocol related
faults from other faults
........
Added:
cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RobustServiceWithFaultTest.java
- copied unchanged from r1515822,
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RobustServiceWithFaultTest.java
Modified:
cxf/branches/2.7.x-fixes/ (props changed)
cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
cxf/branches/2.7.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Propchange: cxf/branches/2.7.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=1515848&r1=1515847&r2=1515848&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
Tue Aug 20 15:45:20 2013
@@ -59,9 +59,11 @@ public class RMInInterceptor extends Abs
} catch (RMException e) {
LOG.log(Level.WARNING, "Failed to revert the delivering
status");
}
- }
- if (!ContextUtils.isRequestor(message)) {
- // force the fault to be returned.
+ }
+ // make sure the fault is returned for an ws-rm related fault or an
invalid ws-rm message
+ // note that OneWayProcessingInterceptor handles the robust case,
hence not handled here.
+ if (isProtocolFault(message)
+ &&
!MessageUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)))
{
Exchange exchange = message.getExchange();
exchange.setOneWay(false);
@@ -73,6 +75,12 @@ public class RMInInterceptor extends Abs
}
}
+ private boolean isProtocolFault(Message message) {
+ return !ContextUtils.isRequestor(message)
+ && (RMContextUtils.getProtocolVariation(message) == null
+ || message.getContent(Exception.class) instanceof
SequenceFault);
+ }
+
protected void handle(Message message) throws SequenceFault, RMException {
LOG.entering(getClass().getName(), "handleMessage");
Modified:
cxf/branches/2.7.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java?rev=1515848&r1=1515847&r2=1515848&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Tue Aug 20 15:45:20 2013
@@ -378,10 +378,12 @@ public class RMInInterceptorTest extends
interceptor.setManager(manager);
+ // test 1. a normal sequence fault case without non-anonymous faultTo
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();
+ EasyMock.expect(message.getContent(Exception.class)).andReturn(new
SequenceFault("test")).anyTimes();
exchange.setOneWay(false);
EasyMock.expectLastCall();
control.replay();
@@ -394,6 +396,7 @@ public class RMInInterceptorTest extends
control.verify();
+ // 2. a sequence fault case with non anonymous faultTo
control.reset();
Destination d = control.createMock(Destination.class);
Endpoint ep = control.createMock(Endpoint.class);
@@ -406,6 +409,7 @@ public class RMInInterceptorTest extends
EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION))
.andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
+ EasyMock.expect(message.getContent(Exception.class)).andReturn(new
SequenceFault("test")).anyTimes();
exchange.setOneWay(false);
EasyMock.expectLastCall();
exchange.setDestination(EasyMock.anyObject(org.apache.cxf.transport.Destination.class));
@@ -419,17 +423,16 @@ public class RMInInterceptorTest extends
}
control.verify();
+ // 3. a robust oneway case
control.reset();
EasyMock.expect(maps.getFaultTo())
.andReturn(RMUtils.createAnonymousReference()).anyTimes();
-
EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+
EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps).anyTimes();
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 {
@@ -437,7 +440,24 @@ public class RMInInterceptorTest extends
} catch (Exception e) {
fail("unexpected exception thrown from handleFault: " + e);
}
- // verified in tearDown
+
+ // 4. a runtime exception case
+ control.reset();
+ EasyMock.expect(maps.getFaultTo())
+ .andReturn(RMUtils.createAnonymousReference()).anyTimes();
+
EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps).anyTimes();
+ EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+ EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION))
+ .andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
+ EasyMock.expect(message.getContent(Exception.class)).andReturn(new
RuntimeException("test")).anyTimes();
+ control.replay();
+
+ try {
+ interceptor.handleFault(message);
+ } catch (Exception e) {
+ fail("unexpected exception thrown from handleFault: " + e);
+ }
+// verified in tearDown
}
private Message setupInboundMessage(String action, boolean serverSide)
throws RMException {