}
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);