store.removeDestinationSequence(sid2);
}
@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();
Connection con = getConnection();
try {
store.beginTransaction();
store.storeMessage(con, sid1, msg1, true);
store.storeMessage(con, sid1, msg2, false);
store.commit(con);
} finally {
releaseConnection(con);
}
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();
con = getConnection();
try {
store.beginTransaction();
store.storeMessage(con, sid1, msg1, true);
} catch (SQLException ex) {
assertEquals("23505", ex.getSQLState());
store.abort(con);
} finally {
releaseConnection(con);
}
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();
con = getConnection();
try {
store.beginTransaction();