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:
Lars Grefer
2019-08-23 01:03:54 +02:00
parent f0515a021c
commit 34dd5fea30
418 changed files with 1146 additions and 1273 deletions

View File

@@ -85,22 +85,22 @@ public class ChannelSecurityInterceptorTests {
}
@Test
public void getSecureObjectClass() throws Exception {
public void getSecureObjectClass() {
assertThat(interceptor.getSecureObjectClass()).isEqualTo(Message.class);
}
@Test
public void obtainSecurityMetadataSource() throws Exception {
public void obtainSecurityMetadataSource() {
assertThat(interceptor.obtainSecurityMetadataSource()).isEqualTo(source);
}
@Test
public void preSendNullAttributes() throws Exception {
public void preSendNullAttributes() {
assertThat(interceptor.preSend(message, channel)).isSameAs(message);
}
@Test
public void preSendGrant() throws Exception {
public void preSendGrant() {
when(source.getAttributes(message)).thenReturn(attrs);
Message<?> result = interceptor.preSend(message, channel);
@@ -109,7 +109,7 @@ public class ChannelSecurityInterceptorTests {
}
@Test(expected = AccessDeniedException.class)
public void preSendDeny() throws Exception {
public void preSendDeny() {
when(source.getAttributes(message)).thenReturn(attrs);
doThrow(new AccessDeniedException("")).when(accessDecisionManager).decide(
any(Authentication.class), eq(message), eq(attrs));
@@ -119,7 +119,7 @@ public class ChannelSecurityInterceptorTests {
@SuppressWarnings("unchecked")
@Test
public void preSendPostSendRunAs() throws Exception {
public void preSendPostSendRunAs() {
when(source.getAttributes(message)).thenReturn(attrs);
when(
runAsManager.buildRunAs(any(Authentication.class), any(),
@@ -137,13 +137,13 @@ public class ChannelSecurityInterceptorTests {
}
@Test
public void afterSendCompletionNotTokenMessageNoExceptionThrown() throws Exception {
public void afterSendCompletionNotTokenMessageNoExceptionThrown() {
interceptor.afterSendCompletion(message, channel, true, null);
}
@SuppressWarnings("unchecked")
@Test
public void preSendFinallySendRunAs() throws Exception {
public void preSendFinallySendRunAs() {
when(source.getAttributes(message)).thenReturn(attrs);
when(
runAsManager.buildRunAs(any(Authentication.class), any(),
@@ -161,17 +161,17 @@ public class ChannelSecurityInterceptorTests {
}
@Test
public void preReceive() throws Exception {
public void preReceive() {
assertThat(interceptor.preReceive(channel)).isTrue();
}
@Test
public void postReceive() throws Exception {
public void postReceive() {
assertThat(interceptor.postReceive(message, channel)).isSameAs(message);
}
@Test
public void afterReceiveCompletionNullExceptionNoExceptionThrown() throws Exception {
public void afterReceiveCompletionNullExceptionNoExceptionThrown() {
interceptor.afterReceiveCompletion(message, channel, null);
}
}

View File

@@ -54,17 +54,17 @@ public class AuthenticationPrincipalArgumentResolverTests {
}
@Test
public void supportsParameterNoAnnotation() throws Exception {
public void supportsParameterNoAnnotation() {
assertThat(resolver.supportsParameter(showUserNoAnnotation())).isFalse();
}
@Test
public void supportsParameterAnnotation() throws Exception {
public void supportsParameterAnnotation() {
assertThat(resolver.supportsParameter(showUserAnnotationObject())).isTrue();
}
@Test
public void supportsParameterCustomAnnotation() throws Exception {
public void supportsParameterCustomAnnotation() {
assertThat(resolver.supportsParameter(showUserCustomAnnotation())).isTrue();
}

View File

@@ -75,7 +75,7 @@ public class SecurityContextChannelInterceptorTests {
}
@Test
public void preSendCustomHeader() throws Exception {
public void preSendCustomHeader() {
String headerName = "header";
interceptor = new SecurityContextChannelInterceptor(headerName);
messageBuilder.setHeader(headerName, authentication);
@@ -87,7 +87,7 @@ public class SecurityContextChannelInterceptorTests {
}
@Test
public void preSendUserSet() throws Exception {
public void preSendUserSet() {
messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, authentication);
interceptor.preSend(messageBuilder.build(), channel);
@@ -102,7 +102,7 @@ public class SecurityContextChannelInterceptorTests {
}
@Test
public void preSendUsesCustomAnonymous() throws Exception {
public void preSendUsesCustomAnonymous() {
expectedAnonymous = new AnonymousAuthenticationToken("customKey",
"customAnonymous", AuthorityUtils.createAuthorityList("ROLE_CUSTOM"));
interceptor.setAnonymousAuthentication(expectedAnonymous);
@@ -114,7 +114,7 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2845
@Test
public void preSendUserNotAuthentication() throws Exception {
public void preSendUserNotAuthentication() {
messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, principal);
interceptor.preSend(messageBuilder.build(), channel);
@@ -124,7 +124,7 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2845
@Test
public void preSendUserNotSet() throws Exception {
public void preSendUserNotSet() {
interceptor.preSend(messageBuilder.build(), channel);
assertAnonymous();
@@ -132,14 +132,14 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2845
@Test
public void preSendUserNotSetCustomAnonymous() throws Exception {
public void preSendUserNotSetCustomAnonymous() {
interceptor.preSend(messageBuilder.build(), channel);
assertAnonymous();
}
@Test
public void afterSendCompletion() throws Exception {
public void afterSendCompletion() {
SecurityContextHolder.getContext().setAuthentication(authentication);
interceptor.afterSendCompletion(messageBuilder.build(), channel, true, null);
@@ -148,14 +148,14 @@ public class SecurityContextChannelInterceptorTests {
}
@Test
public void afterSendCompletionNullAuthentication() throws Exception {
public void afterSendCompletionNullAuthentication() {
interceptor.afterSendCompletion(messageBuilder.build(), channel, true, null);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
}
@Test
public void beforeHandleUserSet() throws Exception {
public void beforeHandleUserSet() {
messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, authentication);
interceptor.beforeHandle(messageBuilder.build(), channel, handler);
@@ -166,7 +166,7 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2845
@Test
public void beforeHandleUserNotAuthentication() throws Exception {
public void beforeHandleUserNotAuthentication() {
messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, principal);
interceptor.beforeHandle(messageBuilder.build(), channel, handler);
@@ -176,21 +176,21 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2845
@Test
public void beforeHandleUserNotSet() throws Exception {
public void beforeHandleUserNotSet() {
interceptor.beforeHandle(messageBuilder.build(), channel, handler);
assertAnonymous();
}
@Test
public void afterMessageHandledUserNotSet() throws Exception {
public void afterMessageHandledUserNotSet() {
interceptor.afterMessageHandled(messageBuilder.build(), channel, handler, null);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
}
@Test
public void afterMessageHandled() throws Exception {
public void afterMessageHandled() {
SecurityContextHolder.getContext().setAuthentication(authentication);
interceptor.afterMessageHandled(messageBuilder.build(), channel, handler, null);
@@ -200,7 +200,7 @@ public class SecurityContextChannelInterceptorTests {
// SEC-2829
@Test
public void restoresOriginalContext() throws Exception {
public void restoresOriginalContext() {
TestingAuthenticationToken original = new TestingAuthenticationToken("original",
"original", "ROLE_USER");
SecurityContextHolder.getContext().setAuthentication(original);
@@ -220,10 +220,9 @@ public class SecurityContextChannelInterceptorTests {
/**
* If a user sends a websocket when processing another websocket
*
* @throws Exception
*/
@Test
public void restoresOriginalContextNestedThreeDeep() throws Exception {
public void restoresOriginalContextNestedThreeDeep() {
AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key",
"anonymous", AuthorityUtils.createAuthorityList("ROLE_USER"));

View File

@@ -49,12 +49,12 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesDoesNotMatchNullDestination() throws Exception {
public void matchesDoesNotMatchNullDestination() {
assertThat(matcher.matches(messageBuilder.build())).isFalse();
}
@Test
public void matchesAllWithDestination() throws Exception {
public void matchesAllWithDestination() {
messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER,
"/destination/1");
@@ -62,7 +62,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesSpecificWithDestination() throws Exception {
public void matchesSpecificWithDestination() {
matcher = new SimpDestinationMessageMatcher("/destination/1");
messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER,
@@ -72,7 +72,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesFalseWithDestination() throws Exception {
public void matchesFalseWithDestination() {
matcher = new SimpDestinationMessageMatcher("/nomatch");
messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER,
@@ -82,7 +82,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesFalseMessageTypeNotDisconnectType() throws Exception {
public void matchesFalseMessageTypeNotDisconnectType() {
matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match",
pathMatcher);
@@ -93,7 +93,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesTrueMessageType() throws Exception {
public void matchesTrueMessageType() {
matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match",
pathMatcher);
@@ -105,7 +105,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesTrueSubscribeType() throws Exception {
public void matchesTrueSubscribeType() {
matcher = SimpDestinationMessageMatcher.createSubscribeMatcher("/match",
pathMatcher);
@@ -117,7 +117,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void matchesNullMessageType() throws Exception {
public void matchesNullMessageType() {
matcher = new SimpDestinationMessageMatcher("/match");
messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/match");
@@ -128,7 +128,7 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void extractPathVariablesFromDestination() throws Exception {
public void extractPathVariablesFromDestination() {
matcher = new SimpDestinationMessageMatcher("/topics/{topic}/**");
messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/topics/someTopic/sub1");
@@ -139,13 +139,13 @@ public class SimpDestinationMessageMatcherTests {
}
@Test
public void extractedVariablesAreEmptyInNullDestination() throws Exception {
public void extractedVariablesAreEmptyInNullDestination() {
matcher = new SimpDestinationMessageMatcher("/topics/{topic}/**");
assertThat(matcher.extractPathVariables(messageBuilder.build())).isEmpty();
}
@Test
public void typeConstructorParameterIsTransmitted() throws Exception {
public void typeConstructorParameterIsTransmitted() {
matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match",
pathMatcher);