use of org.apache.cxf.ws.rm.DestinationSequence in project cxf by apache.
the class RMTxStoreTestBase method testGetDestinationSequences.
@Test
public void testGetDestinationSequences() throws SQLException, IOException {
Identifier sid1 = null;
Identifier sid2 = null;
Collection<DestinationSequence> seqs = store.getDestinationSequences("unknown");
assertEquals(0, seqs.size());
try {
sid1 = setupDestinationSequence("sequence1");
seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
assertEquals(1, seqs.size());
checkRecoveredDestinationSequences(seqs);
sid2 = setupDestinationSequence("sequence2");
seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
assertEquals(2, seqs.size());
checkRecoveredDestinationSequences(seqs);
} finally {
if (null != sid1) {
store.removeDestinationSequence(sid1);
}
if (null != sid2) {
store.removeDestinationSequence(sid2);
}
}
}
use of org.apache.cxf.ws.rm.DestinationSequence in project cxf by apache.
the class RMTxStoreTestBase method testGetDestinationSequence.
@Test
public void testGetDestinationSequence() throws SQLException, IOException {
Identifier sid1 = null;
Identifier sid2 = null;
DestinationSequence seq = store.getDestinationSequence(new Identifier());
assertNull(seq);
try {
sid1 = setupDestinationSequence("sequence1");
seq = store.getDestinationSequence(sid1);
assertNotNull(seq);
verifyDestinationSequence("sequence1", seq);
sid2 = setupDestinationSequence("sequence2");
seq = store.getDestinationSequence(sid2);
assertNotNull(seq);
verifyDestinationSequence("sequence2", seq);
} finally {
if (null != sid1) {
store.removeDestinationSequence(sid1);
}
if (null != sid2) {
store.removeDestinationSequence(sid2);
}
}
}
use of org.apache.cxf.ws.rm.DestinationSequence in project cxf by apache.
the class RMTxStoreTestBase method setupDestinationSequence.
private Identifier setupDestinationSequence(String s) throws IOException, SQLException {
DestinationSequence seq = control.createMock(DestinationSequence.class);
Identifier sid = new Identifier();
sid.setValue(s);
EndpointReferenceType epr = RMUtils.createAnonymousReference();
SequenceAcknowledgement ack = ack1;
Long lmn = ZERO;
ProtocolVariation pv = ProtocolVariation.RM10WSA200408;
if ("sequence2".equals(s)) {
ack = ack2;
lmn = TEN;
pv = ProtocolVariation.RM11WSA200508;
}
EasyMock.expect(seq.getIdentifier()).andReturn(sid);
EasyMock.expect(seq.getAcksTo()).andReturn(epr);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
EasyMock.expect(seq.getLastMessageNumber()).andReturn(lmn);
EasyMock.expect(seq.getAcknowledgment()).andReturn(ack);
EasyMock.expect(seq.getIdentifier()).andReturn(sid);
EasyMock.expect(seq.getProtocol()).andReturn(pv);
control.replay();
store.createDestinationSequence(seq);
Connection con = getConnection();
try {
store.beginTransaction();
store.updateDestinationSequence(con, seq);
store.commit(con);
} finally {
releaseConnection(con);
}
control.reset();
return sid;
}
use of org.apache.cxf.ws.rm.DestinationSequence in project cxf by apache.
the class RMTxStoreTestBase method checkRecoveredDestinationSequences.
private void checkRecoveredDestinationSequences(Collection<DestinationSequence> seqs) {
for (DestinationSequence recovered : seqs) {
assertTrue("sequence1".equals(recovered.getIdentifier().getValue()) || "sequence2".equals(recovered.getIdentifier().getValue()));
assertEquals(Names.WSA_ANONYMOUS_ADDRESS, recovered.getAcksTo().getAddress().getValue());
if ("sequence1".equals(recovered.getIdentifier().getValue())) {
assertEquals(0, recovered.getLastMessageNumber());
assertEquals(1, recovered.getAcknowledgment().getAcknowledgementRange().size());
SequenceAcknowledgement.AcknowledgementRange r = recovered.getAcknowledgment().getAcknowledgementRange().get(0);
assertEquals(ONE, r.getLower());
assertEquals(ONE, r.getUpper());
assertEquals(ProtocolVariation.RM10WSA200408, recovered.getProtocol());
} else {
assertEquals(10, recovered.getLastMessageNumber());
assertEquals(2, recovered.getAcknowledgment().getAcknowledgementRange().size());
SequenceAcknowledgement.AcknowledgementRange r = recovered.getAcknowledgment().getAcknowledgementRange().get(0);
assertEquals(ONE, r.getLower());
assertEquals(ONE, r.getUpper());
r = recovered.getAcknowledgment().getAcknowledgementRange().get(1);
assertEquals(new Long(3), r.getLower());
assertEquals(TEN, r.getUpper());
assertEquals(ProtocolVariation.RM11WSA200508, recovered.getProtocol());
}
}
}
use of org.apache.cxf.ws.rm.DestinationSequence in project cxf by apache.
the class RMTxStoreTestBase method testUpdateDestinationSequence.
@Test
public void testUpdateDestinationSequence() throws SQLException, IOException {
DestinationSequence seq = control.createMock(DestinationSequence.class);
Identifier 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);
control.verify();
control.reset();
EasyMock.expect(seq.getLastMessageNumber()).andReturn(Long.valueOf(0));
EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
Connection con = getConnection();
try {
store.beginTransaction();
store.updateDestinationSequence(con, seq);
store.abort(con);
} finally {
releaseConnection(con);
}
control.reset();
EasyMock.expect(seq.getLastMessageNumber()).andReturn(TEN);
EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
con = getConnection();
try {
store.beginTransaction();
store.updateDestinationSequence(con, seq);
store.abort(con);
} finally {
releaseConnection(con);
}
store.removeDestinationSequence(sid1);
}
Aggregations