use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.
the class RMOutInterceptorTest method testHandleApplicationMessage.
@Test
public void testHandleApplicationMessage() throws NoSuchMethodException, SequenceFault, RMException {
AddressingProperties maps = createMAPs("greetMe", "localhost:9000/GreeterPort", org.apache.cxf.ws.addressing.Names.WSA_NONE_ADDRESS);
Method[] mocked = new Method[] { AbstractRMInterceptor.class.getDeclaredMethod("getManager", new Class[] {}), RMOutInterceptor.class.getDeclaredMethod("isRuntimeFault", new Class[] { Message.class }), RMOutInterceptor.class.getDeclaredMethod("addAcknowledgements", new Class[] { Destination.class, RMProperties.class, Identifier.class, AttributedURIType.class }) };
RMOutInterceptor interceptor = EasyMock.createMockBuilder(RMOutInterceptor.class).addMockedMethods(mocked).createMock(control);
RMManager manager = control.createMock(RMManager.class);
EasyMock.expect(interceptor.getManager()).andReturn(manager).anyTimes();
Message message = control.createMock(Message.class);
EasyMock.expect(interceptor.isRuntimeFault(message)).andReturn(false).anyTimes();
Exchange ex = control.createMock(Exchange.class);
EasyMock.expect(message.getExchange()).andReturn(ex).anyTimes();
EasyMock.expect(ex.getOutMessage()).andReturn(message).anyTimes();
EasyMock.expect(ex.put("defer.uncorrelated.message.abort", Boolean.TRUE)).andReturn(null).anyTimes();
EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND)).andReturn(maps).anyTimes();
RMProperties rmpsOut = new RMProperties();
EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).andReturn(rmpsOut).anyTimes();
InterceptorChain chain = control.createMock(InterceptorChain.class);
EasyMock.expect(message.getInterceptorChain()).andReturn(chain).anyTimes();
EasyMock.expectLastCall();
RMEndpoint rme = control.createMock(RMEndpoint.class);
RMConfiguration config = new RMConfiguration();
config.setRMNamespace(RM10Constants.NAMESPACE_URI);
config.setRM10AddressingNamespace(Names200408.WSA_NAMESPACE_NAME);
EasyMock.expect(rme.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(config).anyTimes();
Source source = control.createMock(Source.class);
EasyMock.expect(source.getReliableEndpoint()).andReturn(rme).anyTimes();
EasyMock.expect(manager.getSource(message)).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(manager.getDestination(message)).andReturn(destination).anyTimes();
SourceSequence sseq = control.createMock(SourceSequence.class);
EasyMock.expect(sseq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(manager.getSequence((Identifier) EasyMock.isNull(), EasyMock.same(message), EasyMock.same(maps))).andReturn(sseq).anyTimes();
EasyMock.expect(sseq.nextMessageNumber((Identifier) EasyMock.isNull(), (Long) EasyMock.eq(0L), EasyMock.eq(false))).andReturn(new Long(10)).anyTimes();
EasyMock.expect(sseq.isLastMessage()).andReturn(false).anyTimes();
interceptor.addAcknowledgements(EasyMock.same(destination), EasyMock.same(rmpsOut), (Identifier) EasyMock.isNull(), EasyMock.isA(AttributedURIType.class));
EasyMock.expectLastCall();
Identifier sid = control.createMock(Identifier.class);
EasyMock.expect(sseq.getIdentifier()).andReturn(sid).anyTimes();
EasyMock.expect(sseq.getCurrentMessageNr()).andReturn(new Long(10)).anyTimes();
control.replay();
interceptor.handle(message);
control.verify();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.
the class ServantTest method createTestTerminateSequenceMessage.
private static Message createTestTerminateSequenceMessage(String sidstr, ProtocolVariation protocol) {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(message);
message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
AddressingProperties maps = new AddressingProperties();
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);
TerminateSequenceType ts = new TerminateSequenceType();
Identifier sid = new Identifier();
sid.setValue(sidstr);
ts.setIdentifier(sid);
Object tst = ProtocolVariation.RM10WSA200408.getWSRMNamespace().equals(protocol.getWSRMNamespace()) ? ts : ProtocolVariation.RM10WSA200408.getCodec().convertReceivedTerminateSequence(ts);
MessageContentsList contents = new MessageContentsList();
contents.add(tst);
message.setContent(List.class, contents);
RMContextUtils.setProtocolVariation(message, protocol);
return message;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.
the class ServantTest method createTestCloseSequenceMessage.
private static Message createTestCloseSequenceMessage(String sidstr) {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(message);
message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
AddressingProperties maps = new AddressingProperties();
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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.
the class RMOutInterceptor method addAckRequest.
/**
* Add AcknowledgementRequested to message if needed. The AckRequest mode set either in the message
* properties or in the source policy is used to determine whether AcknowledgementRequested is always
* added, never added, or added only when we're waiting for the acknowledgement to a previously-sent
* message.
*
* @param msg
* @param rmpsIn
* @param seq
* @param sequence
*/
protected void addAckRequest(Message msg, RMProperties rmpsIn, SourceSequence seq, SequenceType sequence) {
AckRequestModeType mode = (AckRequestModeType) msg.get(RMMessageConstants.ACK_REQUEST_MODE);
if (mode == null) {
mode = AckRequestModeType.PENDING;
SourcePolicyType policy = getManager().getSourcePolicy();
if (policy.isSetAckRequestMode()) {
mode = policy.getAckRequestMode();
}
}
if (AckRequestModeType.ALWAYS == mode || (mode == AckRequestModeType.PENDING && seq.needAcknowledge(rmpsIn.getMessageNumber()))) {
Collection<AckRequestedType> reqs = rmpsIn.getAcksRequested();
if (reqs == null) {
reqs = new ArrayList<>();
}
Identifier identifier = new Identifier();
identifier.setValue(sequence.getIdentifier().getValue());
AckRequestedType ackRequest = new AckRequestedType();
ackRequest.setIdentifier(identifier);
reqs.add(ackRequest);
rmpsIn.setAcksRequested(reqs);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.
the class Servant method clearUnattachedIdentifier.
Identifier clearUnattachedIdentifier() {
Identifier ret = unattachedIdentifier;
unattachedIdentifier = null;
return ret;
}
Aggregations