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();
}
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());
}
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());
}
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());
}
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()]);
}
Aggregations