Remove redundant throws clauses
Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
This commit is contained in:
@@ -49,46 +49,46 @@ public class AspectJInterceptorTests {
|
||||
private SecuredService securedService;
|
||||
|
||||
@Test
|
||||
public void publicMethod() throws Exception {
|
||||
public void publicMethod() {
|
||||
service.publicMethod();
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationCredentialsNotFoundException.class)
|
||||
public void securedMethodNotAuthenticated() throws Exception {
|
||||
public void securedMethodNotAuthenticated() {
|
||||
service.secureMethod();
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
public void securedMethodWrongRole() throws Exception {
|
||||
public void securedMethodWrongRole() {
|
||||
SecurityContextHolder.getContext().setAuthentication(admin);
|
||||
service.secureMethod();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securedMethodEverythingOk() throws Exception {
|
||||
public void securedMethodEverythingOk() {
|
||||
SecurityContextHolder.getContext().setAuthentication(user);
|
||||
service.secureMethod();
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationCredentialsNotFoundException.class)
|
||||
public void securedClassNotAuthenticated() throws Exception {
|
||||
public void securedClassNotAuthenticated() {
|
||||
securedService.secureMethod();
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
public void securedClassWrongRole() throws Exception {
|
||||
public void securedClassWrongRole() {
|
||||
SecurityContextHolder.getContext().setAuthentication(admin);
|
||||
securedService.secureMethod();
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
public void securedClassWrongRoleOnNewedInstance() throws Exception {
|
||||
public void securedClassWrongRoleOnNewedInstance() {
|
||||
SecurityContextHolder.getContext().setAuthentication(admin);
|
||||
new SecuredService().secureMethod();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securedClassEverythingOk() throws Exception {
|
||||
public void securedClassEverythingOk() {
|
||||
SecurityContextHolder.getContext().setAuthentication(user);
|
||||
securedService.secureMethod();
|
||||
new SecuredService().secureMethod();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SecurityConfig {
|
||||
|
||||
// @formatter:off
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build();
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ public class SecurityConfig {
|
||||
|
||||
// @formatter:off
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
public UserDetailsService userDetailsService() {
|
||||
User.UserBuilder builder = User.withDefaultPasswordEncoder();
|
||||
UserDetails user = builder.username("user").password("password").roles("USER").build();
|
||||
UserDetails admin = builder.username("admin").password("password").roles("USER", "ADMIN").build();
|
||||
return new InMemoryUserDetailsManager(user, admin);
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user