Skip to content

Commit 67f24c2

Browse files
lor6pivovarit
authored andcommitted
Non transient exception (eugenp#563)
* non transient data access exception examples * change to derby db * change to in memory derby db * delete failed test * fix invalidresource test
1 parent 7c34948 commit 67f24c2

2 files changed

Lines changed: 18 additions & 40 deletions

File tree

‎spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionTest.java‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,27 @@
1717
@RunWith(SpringJUnit4ClassRunner.class)
1818
@ContextConfiguration(classes = { Cause1NonTransientConfig.class }, loader = AnnotationConfigContextLoader.class)
1919
public class InvalidResourceUsageExceptionTest {
20-
@Autowired
21-
private IFooService fooService;
20+
@Autowired
21+
private IFooService fooService;
2222

23-
@Autowired
24-
private DataSource restDataSource;
23+
@Autowired
24+
private DataSource restDataSource;
2525

26-
@Test(expected = InvalidDataAccessResourceUsageException.class)
27-
public void whenRetrievingDataUserNoSelectRights_thenInvalidResourceUsageException() {
28-
fooService.findAll();
29-
}
26+
@Test(expected = InvalidDataAccessResourceUsageException.class)
27+
public void whenRetrievingDataUserNoSelectRights_thenInvalidResourceUsageException() {
28+
final JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
29+
jdbcTemplate.execute("revoke select from tutorialuser");
3030

31-
@Test(expected = BadSqlGrammarException.class)
32-
public void whenIncorrectSql_thenBadSqlGrammarException() {
33-
final JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
31+
fooService.findAll();
3432

35-
jdbcTemplate.queryForObject("select * fro foo where id=3", Integer.class);
36-
}
33+
jdbcTemplate.execute("grant select to tutorialuser");
34+
}
35+
36+
@Test(expected = BadSqlGrammarException.class)
37+
public void whenIncorrectSql_thenBadSqlGrammarException() {
38+
final JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
39+
40+
jdbcTemplate.queryForObject("select * fro foo where id=3", Integer.class);
41+
}
3742

3843
}

‎spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/PermissionDeniedException.java‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)