use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.
the class RMManagerTest method setUpRecoverReliableEndpointWithAttachment.
void setUpRecoverReliableEndpointWithAttachment(Endpoint endpoint, Conduit conduit, SourceSequence ss, DestinationSequence ds, RMMessage m, Capture<Message> mc) throws IOException {
RMStore store = control.createMock(RMStore.class);
RetransmissionQueue oqueue = control.createMock(RetransmissionQueue.class);
RedeliveryQueue iqueue = control.createMock(RedeliveryQueue.class);
manager.setStore(store);
manager.setRetransmissionQueue(oqueue);
manager.setRedeliveryQueue(iqueue);
Collection<SourceSequence> sss = new ArrayList<>();
if (null != ss) {
sss.add(ss);
}
EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf")).andReturn(sss);
if (null == ss) {
return;
}
Collection<DestinationSequence> dss = new ArrayList<>();
if (null != ds) {
dss.add(ds);
}
EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf")).andReturn(dss);
if (null == ds) {
return;
}
Collection<RMMessage> ms = new ArrayList<>();
if (null != m) {
ms.add(m);
}
Identifier id = new Identifier();
id.setValue("S1");
EasyMock.expect(ss.getIdentifier()).andReturn(id).times(null == m ? 1 : 2);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(store.getMessages(id, true)).andReturn(ms);
RMEndpoint rme = control.createMock(RMEndpoint.class);
EasyMock.expect(manager.createReliableEndpoint(endpoint)).andReturn(rme);
Source source = control.createMock(Source.class);
EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(rme.getDestination()).andReturn(destination);
destination.addSequence(ds, false);
EasyMock.expectLastCall();
Service service = control.createMock(Service.class);
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
Binding binding = control.createMock(Binding.class);
EasyMock.expect(endpoint.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(ss.isLastMessage()).andReturn(true).anyTimes();
EasyMock.expect(ss.getCurrentMessageNr()).andReturn(new Long(10)).anyTimes();
if (null == m) {
return;
}
oqueue.addUnacknowledged(EasyMock.capture(mc));
EasyMock.expectLastCall();
oqueue.start();
EasyMock.expectLastCall();
iqueue.start();
EasyMock.expectLastCall();
}
use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.
the class RMManagerTest method testDefaultSequenceIdentifierGenerator.
@Test
public void testDefaultSequenceIdentifierGenerator() {
manager = new RMManager();
assertNull(manager.getIdGenerator());
SequenceIdentifierGenerator generator = manager.new DefaultSequenceIdentifierGenerator();
manager.setIdGenerator(generator);
assertSame(generator, manager.getIdGenerator());
Identifier id1 = generator.generateSequenceIdentifier();
assertNotNull(id1);
assertNotNull(id1.getValue());
Identifier id2 = generator.generateSequenceIdentifier();
assertTrue(id1 != id2);
assertTrue(!id1.getValue().equals(id2.getValue()));
control.replay();
}
use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.
the class RMManagerTest method setUpRecoverReliableEndpoint.
void setUpRecoverReliableEndpoint(Endpoint endpoint, Conduit conduit, SourceSequence ss, DestinationSequence ds, RMMessage m) throws IOException {
RMStore store = control.createMock(RMStore.class);
RetransmissionQueue oqueue = control.createMock(RetransmissionQueue.class);
RedeliveryQueue iqueue = control.createMock(RedeliveryQueue.class);
manager.setStore(store);
manager.setRetransmissionQueue(oqueue);
manager.setRedeliveryQueue(iqueue);
Collection<SourceSequence> sss = new ArrayList<>();
if (null != ss) {
sss.add(ss);
}
EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf")).andReturn(sss);
if (null == ss) {
return;
}
Collection<DestinationSequence> dss = new ArrayList<>();
if (null != ds) {
dss.add(ds);
}
EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf")).andReturn(dss);
if (null == ds) {
return;
}
Collection<RMMessage> ms = new ArrayList<>();
if (null != m) {
ms.add(m);
}
Identifier id = new Identifier();
id.setValue("S1");
EasyMock.expect(ss.getIdentifier()).andReturn(id).times(null == m ? 1 : 2);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(store.getMessages(id, true)).andReturn(ms);
RMEndpoint rme = control.createMock(RMEndpoint.class);
EasyMock.expect(manager.createReliableEndpoint(endpoint)).andReturn(rme);
Source source = control.createMock(Source.class);
EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(rme.getDestination()).andReturn(destination);
destination.addSequence(ds, false);
EasyMock.expectLastCall();
Service service = control.createMock(Service.class);
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
Binding binding = control.createMock(Binding.class);
EasyMock.expect(endpoint.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(ss.isLastMessage()).andReturn(true).anyTimes();
EasyMock.expect(ss.getCurrentMessageNr()).andReturn(new Long(10)).anyTimes();
if (null == m) {
return;
}
EasyMock.expect(m.getMessageNumber()).andReturn(new Long(10)).times(2);
if (null == conduit) {
EasyMock.expect(m.getTo()).andReturn("toAddress");
}
InputStream is = new ByteArrayInputStream(new byte[0]);
CachedOutputStream cos = new CachedOutputStream();
IOUtils.copy(is, cos);
cos.flush();
is.close();
EasyMock.expect(m.getContent()).andReturn(cos).anyTimes();
oqueue.addUnacknowledged(EasyMock.isA(Message.class));
EasyMock.expectLastCall();
oqueue.start();
EasyMock.expectLastCall();
iqueue.start();
EasyMock.expectLastCall();
}
use of org.apache.cxf.ws.rm.v200702.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.apache.cxf.ws.rm.v200702.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;
}
Aggregations