// but verify the operation is idempotent
store.createTables();
}
public void testCreateDeleteSrcSequences() {
IMocksControl control = EasyMock.createNiceControl();
RMSourceSequence seq = control.createMock(RMSourceSequence.class);
Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
sid1.setValue("sequence1");
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getExpiry()).andReturn(null);
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
control.replay();
store.createSourceSequence(seq);
control.verify();
control.reset();
EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
EasyMock.expect(seq.getExpiry()).andReturn(null);
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
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 = RMUtils.getWSRMFactory().createIdentifier();
sid2.setValue("sequence2");
EasyMock.expect(seq.getIdentifier()).andReturn(sid2);
EasyMock.expect(seq.getExpiry()).andReturn(new Date());
Identifier sid3 = RMUtils.getWSRMFactory().createIdentifier();
sid3.setValue("offeringSequence3");
EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3);
EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
control.replay();
store.createSourceSequence(seq);
control.verify();
store.removeSourceSequence(sid1);
store.removeSourceSequence(sid2);
// deleting once again is a no-op