Non transient exception (#563)

* non transient data access exception examples

* change to derby db

* change to in memory derby db

* delete failed test

* fix invalidresource test
This commit is contained in:
lor6 2016-08-01 18:36:25 +03:00 committed by Grzegorz Piwowarek
parent 7c34948ade
commit 67f24c25af
2 changed files with 18 additions and 40 deletions

View File

@ -25,7 +25,12 @@ public class InvalidResourceUsageExceptionTest {
@Test(expected = InvalidDataAccessResourceUsageException.class)
public void whenRetrievingDataUserNoSelectRights_thenInvalidResourceUsageException() {
final JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
jdbcTemplate.execute("revoke select from tutorialuser");
fooService.findAll();
jdbcTemplate.execute("grant select to tutorialuser");
}
@Test(expected = BadSqlGrammarException.class)

View File

@ -1,27 +0,0 @@
package org.baeldung.ex.nontransientdataaccessexception;
import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig;
import org.baeldung.persistence.model.Foo;
import org.baeldung.persistence.service.IFooService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.PermissionDeniedDataAccessException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Cause1NonTransientConfig.class }, loader = AnnotationConfigContextLoader.class)
public class PermissionDeniedException {
@Autowired
private IFooService fooService;
@Test(expected = PermissionDeniedDataAccessException.class)
public void whenRetrievingDataUserNoSelectRights_thenPermissionDeniedException() {
final Foo foo = new Foo("foo");
fooService.create(foo);
}
}