Search in sources :

Example 6 with AcknowledgementRange

use of org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange in project cxf by apache.

the class DestinationSequenceTest method testAcknowledgeAppendRange.

/*    @Test
    public void testAcknowledgeLastMessageNumberExceeded() throws SequenceFault {
        Timer timer = control.createMock(Timer.class);
        RMEndpoint rme = EasyMock.createMock(RMEndpoint.class);
        EasyMock.expect(rme.getEncoderDecoder()).andReturn(EncoderDecoder10Impl.INSTANCE).anyTimes();
        setUpDestination(timer, rme);
        Message message1 = setUpMessage("1");
        Message message2 = setUpMessage("2", true);
        control.replay();

        DestinationSequence seq = new DestinationSequence(id, ref, destination);

        seq.acknowledge(message1);
        seq.setLastMessageNumber(1);
        try {
            seq.acknowledge(message2);
            fail("Expected SequenceFault not thrown.");
        } catch (SequenceFault sf) {
            assertEquals("SequenceTerminated", sf.getSequenceFault().getFaultCode().getLocalPart());
        }

        control.verify();
    }   */
@Test
public void testAcknowledgeAppendRange() throws SequenceFault {
    Timer timer = control.createMock(Timer.class);
    setUpDestination(timer, null);
    Message[] messages = new Message[] { setUpMessage("1"), setUpMessage("2"), setUpMessage("5"), setUpMessage("4"), setUpMessage("6") };
    control.replay();
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();
    for (int i = 0; i < messages.length; i++) {
        seq.acknowledge(messages[i]);
    }
    assertEquals(2, ranges.size());
    AcknowledgementRange r = ranges.get(0);
    assertEquals(1, r.getLower().intValue());
    assertEquals(2, r.getUpper().intValue());
    r = ranges.get(1);
    assertEquals(4, r.getLower().intValue());
    assertEquals(6, r.getUpper().intValue());
    control.verify();
}
Also used : Timer(java.util.Timer) Message(org.apache.cxf.message.Message) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) Test(org.junit.Test)

Example 7 with AcknowledgementRange

use of org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange in project cxf by apache.

the class PersistenceUtilsTest method testSerialiseDeserialiseAcknowledgement.

@Test
public void testSerialiseDeserialiseAcknowledgement() {
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    AcknowledgementRange range = new AcknowledgementRange();
    range.setLower(new Long(1));
    range.setUpper(new Long(10));
    ack.getAcknowledgementRange().add(range);
    PersistenceUtils utils = PersistenceUtils.getInstance();
    InputStream is = utils.serialiseAcknowledgment(ack);
    SequenceAcknowledgement refAck = utils.deserialiseAcknowledgment(is);
    assertEquals(refAck.getAcknowledgementRange().size(), refAck.getAcknowledgementRange().size());
    AcknowledgementRange refRange = refAck.getAcknowledgementRange().get(0);
    assertEquals(range.getLower(), refRange.getLower());
    assertEquals(range.getUpper(), refRange.getUpper());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) Test(org.junit.Test)

Example 8 with AcknowledgementRange

use of org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange in project cxf by apache.

the class RMSoapInInterceptorTest method testDecodeAcknowledgements2.

@Test
public void testDecodeAcknowledgements2() throws XMLStreamException {
    SoapMessage message = setUpInboundMessage("resources/Acknowledgment2.xml");
    RMSoapInInterceptor codec = new RMSoapInInterceptor();
    codec.handleMessage(message);
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    assertNotNull(acks);
    assertEquals(1, acks.size());
    SequenceAcknowledgement ack = acks.iterator().next();
    assertNotNull(ack);
    assertEquals(1, ack.getAcknowledgementRange().size());
    AcknowledgementRange r1 = ack.getAcknowledgementRange().get(0);
    verifyRange(r1, 1, 3);
    assertNull(rmps.getSequence());
    assertNull(rmps.getAcksRequested());
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 9 with AcknowledgementRange

use of org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange in project cxf by apache.

the class RMSoapInInterceptorTest method testDecodeAcknowledgements.

@Test
public void testDecodeAcknowledgements() throws XMLStreamException {
    SoapMessage message = setUpInboundMessage("resources/Acknowledgment.xml");
    RMSoapInInterceptor codec = new RMSoapInInterceptor();
    codec.handleMessage(message);
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    assertNotNull(acks);
    assertEquals(1, acks.size());
    SequenceAcknowledgement ack = acks.iterator().next();
    assertNotNull(ack);
    assertEquals(ack.getIdentifier().getValue(), SEQ_IDENTIFIER);
    assertEquals(2, ack.getAcknowledgementRange().size());
    AcknowledgementRange r1 = ack.getAcknowledgementRange().get(0);
    AcknowledgementRange r2 = ack.getAcknowledgementRange().get(1);
    verifyRange(r1, 1, 1);
    verifyRange(r2, 3, 3);
    assertNull(rmps.getSequence());
    assertNull(rmps.getAcksRequested());
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 10 with AcknowledgementRange

use of org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange in project cxf by apache.

the class ManagedRMEndpoint method getSourceSequenceAcknowledgedRange.

@ManagedOperation(description = "Source Sequence Acknowledged Range")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "sequenceId", description = "The sequence identifier") })
public Long[] getSourceSequenceAcknowledgedRange(String sid) {
    SourceSequence ss = getSourceSeq(sid);
    if (null == ss) {
        throw new IllegalArgumentException("no sequence");
    }
    List<Long> list = new ArrayList<>();
    for (AcknowledgementRange r : ss.getAcknowledgement().getAcknowledgementRange()) {
        list.add(r.getLower());
        list.add(r.getUpper());
    }
    return list.toArray(new Long[list.size()]);
}
Also used : ArrayList(java.util.ArrayList) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) ManagedOperationParameters(org.apache.cxf.management.annotation.ManagedOperationParameters) ManagedOperation(org.apache.cxf.management.annotation.ManagedOperation)

Aggregations

AcknowledgementRange (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange)14 Test (org.junit.Test)10 Message (org.apache.cxf.message.Message)5 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)5 ArrayList (java.util.ArrayList)4 Timer (java.util.Timer)4 InputStream (java.io.InputStream)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)2 ManagedOperation (org.apache.cxf.management.annotation.ManagedOperation)2 ManagedOperationParameters (org.apache.cxf.management.annotation.ManagedOperationParameters)2 RMProperties (org.apache.cxf.ws.rm.RMProperties)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 Fault (org.apache.cxf.interceptor.Fault)1 CachedOutputStream (org.apache.cxf.io.CachedOutputStream)1 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)1 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)1 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)1