use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RMTxStoreTestBase method testGetSourceSequence.
@Test
public void testGetSourceSequence() throws SQLException, IOException {
Identifier sid1 = null;
Identifier sid2 = null;
SourceSequence seq = store.getSourceSequence(new Identifier());
assertNull(seq);
try {
sid1 = setupSourceSequence("sequence1");
seq = store.getSourceSequence(sid1);
assertNotNull(seq);
verifySourceSequence("sequence1", seq);
sid2 = setupSourceSequence("sequence2");
seq = store.getSourceSequence(sid2);
assertNotNull(seq);
verifySourceSequence("sequence2", seq);
} finally {
if (null != sid1) {
store.removeSourceSequence(sid1);
}
if (null != sid2) {
store.removeSourceSequence(sid2);
}
}
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RetransmissionQueueImplTest method testCountUnacknowledgedUnknownSequence.
@Test
public void testCountUnacknowledgedUnknownSequence() {
Long[] messageNumbers = { TEN, ONE };
SourceSequence sequence = setUpSequence("sequence1", messageNumbers, null);
ready(false);
assertEquals("unexpected unacked count", 0, queue.countUnacknowledged(sequence));
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RetransmissionQueueImplTest method testCountUnacknowledged.
@Test
public void testCountUnacknowledged() {
Long[] messageNumbers = { TEN, ONE };
SourceSequence sequence = setUpSequence("sequence1", messageNumbers, null);
List<RetransmissionQueueImpl.ResendCandidate> sequenceList = new ArrayList<RetransmissionQueueImpl.ResendCandidate>();
queue.getUnacknowledged().put("sequence1", sequenceList);
SoapMessage message1 = setUpMessage("sequence1", messageNumbers[0], false);
setupMessagePolicies(message1);
SoapMessage message2 = setUpMessage("sequence1", messageNumbers[1], false);
setupMessagePolicies(message2);
ready(false);
sequenceList.add(queue.createResendCandidate(message1));
sequenceList.add(queue.createResendCandidate(message2));
assertEquals("unexpected unacked count", 2, queue.countUnacknowledged(sequence));
assertTrue("queue is empty", !queue.isEmpty());
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RetransmissionQueueImplTest method testPurgeAcknowledgedAll.
@Test
public void testPurgeAcknowledgedAll() {
Long[] messageNumbers = { TEN, ONE };
SourceSequence sequence = setUpSequence("sequence1", messageNumbers, new boolean[] { true, true });
List<RetransmissionQueueImpl.ResendCandidate> sequenceList = new ArrayList<RetransmissionQueueImpl.ResendCandidate>();
queue.getUnacknowledged().put("sequence1", sequenceList);
SoapMessage message1 = setUpMessage("sequence1", messageNumbers[0]);
setupMessagePolicies(message1);
SoapMessage message2 = setUpMessage("sequence1", messageNumbers[1]);
setupMessagePolicies(message2);
endpoint.handleAcknowledgment("sequence1", TEN, message1);
EasyMock.expectLastCall();
endpoint.handleAcknowledgment("sequence1", ONE, message2);
EasyMock.expectLastCall();
ready(false);
sequenceList.add(queue.createResendCandidate(message1));
sequenceList.add(queue.createResendCandidate(message2));
queue.purgeAcknowledged(sequence);
assertEquals("unexpected unacked map size", 0, queue.getUnacknowledged().size());
assertEquals("unexpected unacked list size", 0, sequenceList.size());
}
use of org.apache.cxf.ws.rm.SourceSequence 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