use of org.apache.cxf.ws.rm.persistence.RMStore 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.persistence.RMStore 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.persistence.RMStore in project cxf by apache.
the class Source method removeSequence.
public void removeSequence(SourceSequence seq) {
SourceSequence o;
o = map.remove(seq.getIdentifier().getValue());
RMStore store = getReliableEndpoint().getManager().getStore();
if (null != store) {
store.removeSourceSequence(seq.getIdentifier());
}
if (o != null) {
processingSequenceCount.decrementAndGet();
completedSequenceCount.incrementAndGet();
}
}
use of org.apache.cxf.ws.rm.persistence.RMStore in project cxf by apache.
the class Source method addSequence.
public void addSequence(SourceSequence seq, boolean persist) {
seq.setSource(this);
map.put(seq.getIdentifier().getValue(), seq);
if (persist) {
RMStore store = getReliableEndpoint().getManager().getStore();
if (null != store) {
store.createSourceSequence(seq);
}
}
processingSequenceCount.incrementAndGet();
}
use of org.apache.cxf.ws.rm.persistence.RMStore in project cxf by apache.
the class RetransmissionQueueImplTest method setUpSequence.
private SourceSequence setUpSequence(String sid, Long[] messageNumbers, boolean[] isAcked) {
SourceSequence sequence = createMock(SourceSequence.class);
Identifier id = createMock(Identifier.class);
sequence.getIdentifier();
EasyMock.expectLastCall().andReturn(id).anyTimes();
id.getValue();
EasyMock.expectLastCall().andReturn(sid).anyTimes();
identifiers.add(id);
Source source = createMock(Source.class);
sequence.getSource();
EasyMock.expectLastCall().andReturn(source).anyTimes();
source.getReliableEndpoint();
EasyMock.expectLastCall().andReturn(endpoint).anyTimes();
boolean includesAcked = false;
for (int i = 0; isAcked != null && i < isAcked.length; i++) {
sequence.isAcknowledged(messageNumbers[i]);
EasyMock.expectLastCall().andReturn(isAcked[i]);
if (isAcked[i]) {
includesAcked = true;
}
}
if (includesAcked) {
RMStore store = createMock(RMStore.class);
manager.getStore();
EasyMock.expectLastCall().andReturn(store);
}
return sequence;
}
Aggregations