Add access rights in the finally block
This commit is contained in:
parent
8eed2adcc1
commit
797db0f8e9
|
@ -1,7 +1,5 @@
|
|||
package org.baeldung.ex.nontransientdataaccessexception;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig;
|
||||
import org.baeldung.persistence.service.IFooService;
|
||||
import org.junit.Test;
|
||||
|
@ -14,9 +12,12 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause1NonTransientConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class InvalidResourceUsageExceptionTest {
|
||||
|
||||
@Autowired
|
||||
private IFooService fooService;
|
||||
|
||||
|
@ -28,10 +29,12 @@ public class InvalidResourceUsageExceptionTest {
|
|||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
|
||||
jdbcTemplate.execute("revoke select from tutorialuser");
|
||||
|
||||
fooService.findAll();
|
||||
|
||||
jdbcTemplate.execute("grant select to tutorialuser");
|
||||
}
|
||||
try {
|
||||
fooService.findAll();
|
||||
} finally {
|
||||
jdbcTemplate.execute("grant select to tutorialuser");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = BadSqlGrammarException.class)
|
||||
public void whenIncorrectSql_thenBadSqlGrammarException() {
|
||||
|
|
Loading…
Reference in New Issue