@Test
public void testCreateDeleteMessages() throws IOException, SQLException {
RMMessage msg1 = control.createMock(RMMessage.class);
RMMessage msg2 = control.createMock(RMMessage.class);
Identifier sid1 = new Identifier();
sid1.setValue("sequence1");
EasyMock.expect(msg1.getMessageNumber()).andReturn(ONE);
EasyMock.expect(msg2.getMessageNumber()).andReturn(ONE);
byte[] bytes = new byte[89];
EasyMock.expect(msg1.getInputStream()).andReturn(new ByteArrayInputStream(bytes));
EasyMock.expect(msg1.getSize()).andReturn((long)bytes.length);
EasyMock.expect(msg2.getInputStream()).andReturn(new ByteArrayInputStream(bytes));
EasyMock.expect(msg2.getSize()).andReturn((long)bytes.length);
control.replay();
store.beginTransaction();
store.storeMessage(sid1, msg1, true);
store.storeMessage(sid1, msg2, false);
store.commit();
control.verify();
control.reset();
EasyMock.expect(msg1.getMessageNumber()).andReturn(ONE);
EasyMock.expect(msg1.getInputStream()).andReturn(new ByteArrayInputStream(bytes));
EasyMock.expect(msg1.getSize()).andReturn((long)bytes.length);
control.replay();
store.beginTransaction();
try {
store.storeMessage(sid1, msg1, true);
} catch (SQLException ex) {
assertEquals("23505", ex.getSQLState());
}
store.abort();
control.verify();
control.reset();
EasyMock.expect(msg1.getMessageNumber()).andReturn(TEN);
EasyMock.expect(msg2.getMessageNumber()).andReturn(TEN);
EasyMock.expect(msg1.getInputStream()).andReturn(new ByteArrayInputStream(bytes));
EasyMock.expect(msg1.getSize()).andReturn((long)bytes.length);
EasyMock.expect(msg2.getInputStream()).andReturn(new ByteArrayInputStream(bytes));
EasyMock.expect(msg2.getSize()).andReturn((long)bytes.length);
control.replay();
store.beginTransaction();
store.storeMessage(sid1, msg1, true);
store.storeMessage(sid1, msg2, false);
store.commit();
control.verify();
Collection<Long> messageNrs = new ArrayList<Long>();
messageNrs.add(ZERO);
messageNrs.add(TEN);
messageNrs.add(ONE);
messageNrs.add(TEN);
store.removeMessages(sid1, messageNrs, true);
store.removeMessages(sid1, messageNrs, false);
Identifier sid2 = new Identifier();
sid1.setValue("sequence2");
store.removeMessages(sid2, messageNrs, true);
}