1
0
mirror of synced 2026-05-22 21:33:16 +00:00

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
@@ -58,13 +58,13 @@ public class ReactorContextTestExecutionListener
private static class DelegateTestExecutionListener extends AbstractTestExecutionListener {
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
public void beforeTestMethod(TestContext testContext) {
SecurityContext securityContext = TestSecurityContextHolder.getContext();
Hooks.onLastOperator(CONTEXT_OPERATOR_KEY, Operators.lift((s, sub) -> new SecuritySubContext<>(sub, securityContext)));
}
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
public void afterTestMethod(TestContext testContext) {
Hooks.resetOnLastOperator(CONTEXT_OPERATOR_KEY);
}
@@ -58,7 +58,7 @@ public class WithSecurityContextTestExecutionListener
* still not found, then no {@link SecurityContext} is populated.
*/
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
public void beforeTestMethod(TestContext testContext) {
TestSecurityContext testSecurityContext = createTestSecurityContext(
testContext.getTestMethod(), testContext);
if (testSecurityContext == null) {
@@ -166,7 +166,7 @@ public class WithSecurityContextTestExecutionListener
* {@link SecurityContextHolder} after each test method.
*/
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
public void afterTestMethod(TestContext testContext) {
TestSecurityContextHolder.clearContext();
}
@@ -92,7 +92,7 @@ public final class SecurityMockMvcResultMatchers {
private Consumer<Authentication> assertAuthentication;
@Override
public void match(MvcResult result) throws Exception {
public void match(MvcResult result) {
SecurityContext context = load(result);
Authentication auth = context.getAuthentication();
@@ -252,7 +252,7 @@ public final class SecurityMockMvcResultMatchers {
private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
@Override
public void match(MvcResult result) throws Exception {
public void match(MvcResult result) {
SecurityContext context = load(result);
Authentication authentication = context.getAuthentication();
@@ -106,14 +106,14 @@ public class WithSecurityContextTestExecutionListenerTests {
}
@Test
public void beforeTestExecutionWhenTestContextNullThenSecurityContextNotSet() throws Exception {
public void beforeTestExecutionWhenTestContextNullThenSecurityContextNotSet() {
this.listener.beforeTestExecution(this.testContext);
assertThat(TestSecurityContextHolder.getContext().getAuthentication()).isNull();
}
@Test
public void beforeTestExecutionWhenTestContextNotNullThenSecurityContextSet() throws Exception {
public void beforeTestExecutionWhenTestContextNotNullThenSecurityContextSet() {
SecurityContextImpl securityContext = new SecurityContextImpl();
securityContext.setAuthentication(new TestingAuthenticationToken("user", "passsword", "ROLE_USER"));
when(this.testContext.removeAttribute(WithSecurityContextTestExecutionListener.SECURITY_CONTEXT_ATTR_NAME)).thenReturn(securityContext);
@@ -31,12 +31,12 @@ public class SecurityMockMvcRequestBuildersFormLoginTests {
private MockServletContext servletContext;
@Before
public void setup() throws Exception {
public void setup() {
this.servletContext = new MockServletContext();
}
@Test
public void defaults() throws Exception {
public void defaults() {
MockHttpServletRequest request = formLogin().buildRequest(this.servletContext);
CsrfToken token = (CsrfToken) request
.getAttribute(CsrfRequestPostProcessor.TestCsrfTokenRepository.TOKEN_ATTR_NAME);
@@ -51,7 +51,7 @@ public class SecurityMockMvcRequestBuildersFormLoginTests {
}
@Test
public void custom() throws Exception {
public void custom() {
MockHttpServletRequest request = formLogin("/login").user("username", "admin")
.password("password", "secret").buildRequest(this.servletContext);
@@ -68,7 +68,7 @@ public class SecurityMockMvcRequestBuildersFormLoginTests {
// gh-3920
@Test
public void usesAcceptMediaForContentNegotiation() throws Exception {
public void usesAcceptMediaForContentNegotiation() {
MockHttpServletRequest request = formLogin("/login").user("username", "admin")
.password("password", "secret").buildRequest(this.servletContext);
@@ -34,7 +34,7 @@ public class SecurityMockMvcRequestBuildersFormLogoutTests {
}
@Test
public void defaults() throws Exception {
public void defaults() {
MockHttpServletRequest request = logout().buildRequest(servletContext);
CsrfToken token = (CsrfToken) request.getAttribute(CsrfRequestPostProcessor.TestCsrfTokenRepository.TOKEN_ATTR_NAME);
@@ -46,7 +46,7 @@ public class SecurityMockMvcRequestBuildersFormLogoutTests {
}
@Test
public void custom() throws Exception {
public void custom() {
MockHttpServletRequest request = logout("/admin/logout").buildRequest(
servletContext);
@@ -44,7 +44,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests {
// SEC-3836
@Test
public void findCookieCsrfTokenRepository() throws Exception {
public void findCookieCsrfTokenRepository() {
MockHttpServletRequest request = post("/").buildRequest(wac.getServletContext());
CsrfTokenRepository csrfTokenRepository = WebTestUtils.getCsrfTokenRepository(request);
assertThat(csrfTokenRepository).isNotNull();
@@ -61,9 +61,9 @@ public class SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests {
}
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
// Enable the DebugFilter
web.debug(true);
}
}
}
}
@@ -172,7 +172,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests {
static class CsrfParamResultMatcher implements ResultMatcher {
@Override
public void match(MvcResult result) throws Exception {
public void match(MvcResult result) {
MockHttpServletRequest request = result.getRequest();
assertThat(request.getParameter("_csrf")).isNotNull();
assertThat(request.getHeader("X-CSRF-TOKEN")).isNull();
@@ -186,7 +186,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests {
static class CsrfHeaderResultMatcher implements ResultMatcher {
@Override
public void match(MvcResult result) throws Exception {
public void match(MvcResult result) {
MockHttpServletRequest request = result.getRequest();
assertThat(request.getParameter("_csrf")).isNull();
assertThat(request.getHeader("X-CSRF-TOKEN")).isNotNull();
@@ -224,7 +224,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests {
@EnableWebSecurity
static class Config extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
@RestController
@@ -116,8 +116,7 @@ public class SecurityMockMvcRequestPostProcessorsDigestTests {
private String extractUser() throws IOException, ServletException {
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
public void doFilter(ServletRequest request, ServletResponse response) {
Authentication authentication = SecurityContextHolder.getContext()
.getAuthentication();
username = authentication == null ? null : authentication.getName();
@@ -89,14 +89,14 @@ public class SecurityMockMvcConfigurerTests {
}
@Test(expected = IllegalStateException.class)
public void beforeMockMvcCreatedNoFilter() throws Exception {
public void beforeMockMvcCreatedNoFilter() {
SecurityMockMvcConfigurer configurer = new SecurityMockMvcConfigurer();
configurer.afterConfigurerAdded(this.builder);
configurer.beforeMockMvcCreated(this.builder, this.context);
}
private void assertFilterAdded(Filter filter) throws IOException, ServletException {
private void assertFilterAdded(Filter filter) {
ArgumentCaptor<SecurityMockMvcConfigurer.DelegateFilter> filterArg = ArgumentCaptor.forClass(
SecurityMockMvcConfigurer.DelegateFilter.class);
verify(this.builder).addFilters(filterArg.capture());
@@ -72,7 +72,7 @@ public class CsrfShowcaseTests {
static class Config extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
// @formatter:off
@@ -67,7 +67,7 @@ public class DefaultCsrfShowcaseTests {
static class Config extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
// @formatter:off
@@ -207,7 +207,7 @@ public class WebTestUtilsTests {
// @formatter:off
@Override
public void configure(HttpSecurity http) throws Exception {
public void configure(HttpSecurity http) {
http
.antMatcher("/willnotmatchthis");
}