}
public void testCreateDeleteMessages() throws IOException, SQLException {
IMocksControl control = EasyMock.createNiceControl();
RMMessage msg = control.createMock(RMMessage.class);
Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
sid1.setValue("sequence1");
EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.ONE).times(2);
InputStream is = new ByteArrayInputStream(new byte[89]);
EasyMock.expect(msg.getContextAsStream()).andReturn(is).times(2);
control.replay();
store.beginTransaction();
store.storeMessage(sid1, msg, true);
store.storeMessage(sid1, msg, false);
store.commit();
control.verify();
control.reset();
EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.ONE);
EasyMock.expect(msg.getContextAsStream()).andReturn(is);
control.replay();
store.beginTransaction();
try {
store.storeMessage(sid1, msg, true);
} catch (SQLException ex) {
assertEquals("23505", ex.getSQLState());
}
store.abort();
control.verify();
control.reset();
EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.TEN).times(2);
EasyMock.expect(msg.getContextAsStream()).andReturn(is).times(2);
control.replay();
store.beginTransaction();
store.storeMessage(sid1, msg, true);
store.storeMessage(sid1, msg, false);
store.commit();
control.verify();
Collection<BigInteger> messageNrs = new ArrayList<BigInteger>();
messageNrs.add(BigInteger.ZERO);
messageNrs.add(BigInteger.TEN);
messageNrs.add(BigInteger.ONE);
messageNrs.add(BigInteger.TEN);
store.removeMessages(sid1, messageNrs, true);
store.removeMessages(sid1, messageNrs, false);
Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
sid1.setValue("sequence2");
store.removeMessages(sid2, messageNrs, true);
}