Search in sources :

Example 6 with RMStore

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();
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Example 7 with RMStore

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();
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 8 with RMStore

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();
    }
}
Also used : RMStore(org.apache.cxf.ws.rm.persistence.RMStore)

Example 9 with RMStore

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();
}
Also used : RMStore(org.apache.cxf.ws.rm.persistence.RMStore)

Example 10 with RMStore

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;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Source(org.apache.cxf.ws.rm.Source) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint)

Aggregations

RMStore (org.apache.cxf.ws.rm.persistence.RMStore)19 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)6 ArrayList (java.util.ArrayList)4 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)4 Test (org.junit.Test)4 Endpoint (org.apache.cxf.endpoint.Endpoint)3 CachedOutputStream (org.apache.cxf.io.CachedOutputStream)3 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Binding (org.apache.cxf.binding.Binding)2 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)2 Client (org.apache.cxf.endpoint.Client)2 Service (org.apache.cxf.service.Service)2 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)2 RMEndpoint (org.apache.cxf.ws.rm.RMEndpoint)2 RMManager (org.apache.cxf.ws.rm.RMManager)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 OutputStream (java.io.OutputStream)1 Map (java.util.Map)1