use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.
the class RMTxStoreTestBase method testGetMessages.
@Test
public void testGetMessages() throws SQLException, IOException {
Identifier sid1 = new Identifier();
sid1.setValue("sequence1");
Identifier sid2 = new Identifier();
sid2.setValue("sequence2");
Collection<RMMessage> out = store.getMessages(sid1, true);
assertEquals(0, out.size());
Collection<RMMessage> in = store.getMessages(sid1, false);
assertEquals(0, out.size());
try {
setupMessage(sid1, ONE, null, true);
setupMessage(sid1, ONE, null, false);
out = store.getMessages(sid1, true);
assertEquals(1, out.size());
checkRecoveredMessages(out);
in = store.getMessages(sid1, false);
assertEquals(1, in.size());
checkRecoveredMessages(in);
setupMessage(sid1, TEN, NON_ANON_ACKS_TO, true);
setupMessage(sid1, TEN, NON_ANON_ACKS_TO, false);
out = store.getMessages(sid1, true);
assertEquals(2, out.size());
checkRecoveredMessages(out);
in = store.getMessages(sid1, false);
assertEquals(2, in.size());
checkRecoveredMessages(in);
} finally {
Collection<Long> msgNrs = new ArrayList<>();
msgNrs.add(ONE);
msgNrs.add(TEN);
store.removeMessages(sid1, msgNrs, true);
store.removeMessages(sid1, msgNrs, false);
}
}
use of org.apache.cxf.ws.rm.v200502.Identifier 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.v200502.Identifier 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.v200502.Identifier 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.v200502.Identifier in project cxf by apache.
the class RMTxStoreTestBase method testCreateDeleteSrcSequences.
@Test
public void testCreateDeleteSrcSequences() {
SourceSequence seq = control.createMock(SourceSequence.class);
Identifier sid1 = new Identifier();
sid1.setValue("sequence1");
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getExpires()).andReturn(null);
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
store.createSourceSequence(seq);
control.verify();
control.reset();
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getExpires()).andReturn(null);
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
try {
store.createSourceSequence(seq);
fail("Expected RMStoreException was not thrown.");
} catch (RMStoreException ex) {
SQLException se = (SQLException) ex.getCause();
// duplicate key value
assertEquals("23505", se.getSQLState());
}
control.verify();
control.reset();
Identifier sid2 = new Identifier();
sid2.setValue("sequence2");
EasyMock.expect(seq.getIdentifier()).andReturn(sid2);
EasyMock.expect(seq.getExpires()).andReturn(new Date());
Identifier sid3 = new Identifier();
sid3.setValue("offeringSequence3");
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
control.replay();
store.createSourceSequence(seq);
control.verify();
store.removeSourceSequence(sid1);
store.removeSourceSequence(sid2);
// deleting once again is a no-op
store.removeSourceSequence(sid2);
}
Aggregations