Repository: cxf Updated Branches: refs/heads/2.7.x-fixes a30956d3a -> f94b15a61
[CXF-6519] clean up the code and add a test for 2.7.x Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5c9d8f90 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5c9d8f90 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5c9d8f90 Branch: refs/heads/2.7.x-fixes Commit: 5c9d8f90743eaf96a949b0be2239f7faf731a2dd Parents: a30956d Author: Akitoshi Yoshida <[email protected]> Authored: Thu Aug 6 15:29:18 2015 +0200 Committer: Akitoshi Yoshida <[email protected]> Committed: Fri Aug 7 12:03:12 2015 +0200 ---------------------------------------------------------------------- .../org/apache/cxf/ws/rm/RMInInterceptor.java | 4 +- .../org/apache/cxf/ws/rm/SourceSequence.java | 1 + .../java/org/apache/cxf/ws/rm/ServantTest.java | 74 ++++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/5c9d8f90/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java index e4b292f..d5e684c 100644 --- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java +++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java @@ -161,8 +161,8 @@ public class RMInInterceptor extends AbstractRMInterceptor<Message> { if (RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION.equals(action) || RM11Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION.equals(action)) { processAcknowledgments(rme, rmps, protocol); - } else if (RM10Constants.CLOSE_SEQUENCE_ACTION.equals(action) - || RM11Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION.equals(action)) { + } else if (RM10Constants.CLOSE_SEQUENCE_ACTION.equals(action)) { + // RM10 out-of-band CloseSequence/lastMessage is a special case; RM11 needs no special handling processSequence(destination, message); } else if ((RM10Constants.CREATE_SEQUENCE_ACTION.equals(action) || RM11Constants.CREATE_SEQUENCE_ACTION.equals(action)) && !isServer) { http://git-wip-us.apache.org/repos/asf/cxf/blob/5c9d8f90/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java ---------------------------------------------------------------------- diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java index 170d78e..b6431e3 100644 --- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java +++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java @@ -152,6 +152,7 @@ public class SourceSequence extends AbstractSequence { } else { RMEndpoint rme = source.getReliableEndpoint(); Proxy proxy = rme.getProxy(); + // REVIST for rm 1.1, provide an option to how the close and terminate messages are sent proxy.terminate(this); source.removeSequence(this); } http://git-wip-us.apache.org/repos/asf/cxf/blob/5c9d8f90/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ServantTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ServantTest.java b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ServantTest.java index 62b35ba..8c18295 100755 --- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ServantTest.java +++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ServantTest.java @@ -29,6 +29,7 @@ import org.apache.cxf.message.ExchangeImpl; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageContentsList; import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.service.model.OperationInfo; import org.apache.cxf.ws.addressing.AttributedURIType; import org.apache.cxf.ws.addressing.ContextUtils; import org.apache.cxf.ws.addressing.JAXWSAConstants; @@ -41,6 +42,7 @@ import org.apache.cxf.ws.rm.v200502.Expires; import org.apache.cxf.ws.rm.v200502.Identifier; import org.apache.cxf.ws.rm.v200502.OfferType; import org.apache.cxf.ws.rm.v200502.TerminateSequenceType; +import org.apache.cxf.ws.rm.v200702.CloseSequenceType; import org.apache.cxf.ws.rm.v200702.TerminateSequenceResponseType; import org.easymock.EasyMock; import org.easymock.IMocksControl; @@ -277,6 +279,38 @@ public class ServantTest extends Assert { return message; } + private static Message createTestCloseSequenceMessage(String sidstr) { + Message message = new MessageImpl(); + Exchange exchange = new ExchangeImpl(); + exchange.setInMessage(message); + + message.put(Message.REQUESTOR_ROLE, Boolean.FALSE); + + AddressingPropertiesImpl maps = new AddressingPropertiesImpl(); + String msgId = "urn:uuid:12345-" + Math.random(); + AttributedURIType id = ContextUtils.getAttributedURI(msgId); + maps.setMessageID(id); + + maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction())); + maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL)); + + maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL)); + + message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps); + + CloseSequenceType cs = new CloseSequenceType(); + org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier(); + sid.setValue(sidstr); + cs.setIdentifier(sid); + MessageContentsList contents = new MessageContentsList(); + contents.add(cs); + message.setContent(List.class, contents); + + RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508); + + return message; + } + private void verifyTerminateSequenceDefault(Servant servant, RMManager manager, String sidstr, ProtocolVariation protocol) throws SequenceFault { DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType(); @@ -302,5 +336,45 @@ public class ServantTest extends Assert { } + @Test + public void testInvokeForCloseSequence() { + RMEndpoint rme = control.createMock(RMEndpoint.class); + RMManager manager = new RMManager(); + Destination destination = new Destination(rme); + Source source = new Source(rme); + DestinationSequence seq = control.createMock(DestinationSequence.class); + org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier(); + sid.setValue("123"); + EasyMock.expect(seq.getIdentifier()).andReturn(sid).anyTimes(); + + EasyMock.expect(rme.getDestination()).andReturn(destination).anyTimes(); + EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes(); + EasyMock.expect(rme.getSource()).andReturn(source).anyTimes(); + Message message = createTestCloseSequenceMessage(sid.getValue()); + + OperationInfo oi = control.createMock(OperationInfo.class); + EasyMock.expect(oi.getName()).andReturn(RM11Constants.INSTANCE.getCloseSequenceOperationName()).anyTimes(); + message.getExchange().put(OperationInfo.class, oi); + + control.replay(); + + TestServant servant = new TestServant(rme); + + servant.invoke(message.getExchange(), message.getContent(List.class).get(0)); + assertTrue(servant.called); + } + + private static class TestServant extends Servant { + boolean called; + + TestServant(RMEndpoint rme) { + super(rme); + } + @Override + public Object closeSequence(Message message) { + called = true; + return null; + } + } }
