use of org.apache.cxf.ws.rm.persistence.RMMessage in project cxf by apache.
the class RMTxStoreTestBase method testCreateSequenceStoreInboundMessage.
@Test
public void testCreateSequenceStoreInboundMessage() throws SQLException, IOException {
Identifier sid1 = null;
try {
DestinationSequence seq = control.createMock(DestinationSequence.class);
sid1 = new Identifier();
sid1.setValue("sequence1");
EndpointReferenceType epr = RMUtils.createAnonymousReference();
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getAcksTo()).andReturn(epr);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
store.createDestinationSequence(seq);
Collection<DestinationSequence> seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
assertEquals(1, seqs.size());
DestinationSequence rseq = seqs.iterator().next();
assertFalse(rseq.isAcknowledged(1));
Collection<RMMessage> in = store.getMessages(sid1, false);
assertEquals(0, in.size());
control.reset();
EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
EasyMock.expect(seq.getAcksTo()).andReturn(epr);
setupInboundMessage(seq, 1L, null);
in = store.getMessages(sid1, false);
assertEquals(1, in.size());
checkRecoveredMessages(in);
seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
assertEquals(1, seqs.size());
rseq = seqs.iterator().next();
assertTrue(rseq.isAcknowledged(1));
assertFalse(rseq.isAcknowledged(10));
EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
EasyMock.expect(seq.getAcknowledgment()).andReturn(ack2);
EasyMock.expect(seq.getAcksTo()).andReturn(epr);
control.replay();
store.persistIncoming(seq, null);
control.reset();
seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
assertEquals(1, seqs.size());
rseq = seqs.iterator().next();
assertTrue(rseq.isAcknowledged(10));
} finally {
if (null != sid1) {
store.removeDestinationSequence(sid1);
}
Collection<Long> msgNrs = Arrays.asList(ONE);
store.removeMessages(sid1, msgNrs, false);
}
}
use of org.apache.cxf.ws.rm.persistence.RMMessage in project cxf by apache.
the class RMTxStoreTestBase method setupOutboundMessage.
private void setupOutboundMessage(SourceSequence seq, long mn, String to) throws IOException, SQLException {
RMMessage msg = createRMMessage(ONE, to);
control.replay();
store.persistOutgoing(seq, msg);
control.reset();
}
use of org.apache.cxf.ws.rm.persistence.RMMessage in project cxf by apache.
the class RMTxStoreTestBase method createRMMessage.
private RMMessage createRMMessage(Long mn, String to) throws IOException {
RMMessage msg = control.createMock(RMMessage.class);
EasyMock.expect(msg.getMessageNumber()).andReturn(mn).anyTimes();
EasyMock.expect(msg.getTo()).andReturn(to).anyTimes();
EasyMock.expect(msg.getContentType()).andReturn("text/xml").anyTimes();
EasyMock.expect(msg.getCreatedTime()).andReturn(TIME);
byte[] value = ("Message " + mn.longValue()).getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(value);
CachedOutputStream cos = new CachedOutputStream();
IOUtils.copy(bais, cos);
cos.flush();
bais.close();
EasyMock.expect(msg.getContent()).andReturn(cos).anyTimes();
return msg;
}
Aggregations