public void testRollbackOnError() throws Exception {
long count = _harvesterSettingRepo.count();
TransactionlessTesting.get().run(new TestTask() {
@Override
public void run() throws Exception {
LocalServiceRequest req = LocalServiceRequest.create("http://localhost/geonetwork/srv/eng/" + SERVICE_NAME);
UserSession userSession = new UserSession();
_service.setService(new ServiceFunction() {
@Override
public Element exec(Element params, ServiceContext context) throws Exception {
saveParentAndChildHarvesterSetting(context);
throw new Exception("test exception");
}
});
_serviceManager.dispatch(req, userSession);
final String resultString = req.getResultString();
assertTrue(resultString.contains("error"));
}
});
assertEquals(count, _harvesterSettingRepo.count());