1
0
mirror of synced 2026-05-22 13:23:17 +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,8 +58,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test
public void poolingFlagIsSetWhenAuthenticationDnMatchesManagerUserDn()
throws Exception {
public void poolingFlagIsSetWhenAuthenticationDnMatchesManagerUserDn() {
EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource(
"ldap://blah:789/dc=springframework,dc=org");
ctxSrc.setUserDn("manager");
@@ -70,8 +69,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test
public void poolingFlagIsNotSetWhenAuthenticationDnIsNotManagerUserDn()
throws Exception {
public void poolingFlagIsNotSetWhenAuthenticationDnIsNotManagerUserDn() {
EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource(
"ldap://blah:789/dc=springframework,dc=org");
ctxSrc.setUserDn("manager");
@@ -103,7 +101,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test
public void serverUrlWithSpacesIsSupported() throws Exception {
public void serverUrlWithSpacesIsSupported() {
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
this.contextSource.getUrls()[0]
+ "ou=space%20cadets,dc=springframework,dc=org");
@@ -114,7 +112,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test(expected = IllegalArgumentException.class)
public void instantiationFailsWithEmptyServerList() throws Exception {
public void instantiationFailsWithEmptyServerList() {
List<String> serverUrls = new ArrayList<>();
DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource(
serverUrls, "dc=springframework,dc=org");
@@ -122,7 +120,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test
public void instantiationSuceedsWithProperServerList() throws Exception {
public void instantiationSuceedsWithProperServerList() {
List<String> serverUrls = new ArrayList<>();
serverUrls.add("ldap://foo:789");
serverUrls.add("ldap://bar:389");
@@ -136,7 +134,7 @@ public class DefaultSpringSecurityContextSourceTests {
// SEC-2308
@Test
public void instantiationSuceedsWithEmtpyBaseDn() throws Exception {
public void instantiationSuceedsWithEmtpyBaseDn() {
String baseDn = "";
List<String> serverUrls = new ArrayList<>();
serverUrls.add("ldap://foo:789");
@@ -150,7 +148,7 @@ public class DefaultSpringSecurityContextSourceTests {
}
@Test(expected = IllegalArgumentException.class)
public void instantiationFailsWithIncorrectServerUrl() throws Exception {
public void instantiationFailsWithIncorrectServerUrl() {
List<String> serverUrls = new ArrayList<>();
// a simple trailing slash should be ok
serverUrls.add("ldaps://blah:636/");
@@ -56,7 +56,7 @@ public class SpringSecurityLdapTemplateITests {
// ========================================================================================================
@Before
public void setUp() throws Exception {
public void setUp() {
template = new SpringSecurityLdapTemplate(this.contextSource);
}
@@ -181,7 +181,7 @@ public class SpringSecurityLdapTemplateITests {
}
@Test
public void roleSearchWithEscapedCharacterSucceeds() throws Exception {
public void roleSearchWithEscapedCharacterSucceeds() {
String param = "cn=mouse\\, jerry,ou=people,dc=springframework,dc=org";
Set<String> values = template.searchForSingleAttributeValues("ou=groups",
@@ -59,7 +59,7 @@ public class PasswordComparisonAuthenticatorTests {
// ========================================================================================================
@Before
public void setUp() throws Exception {
public void setUp() {
authenticator = new PasswordComparisonAuthenticator(this.contextSource);
authenticator.setPasswordEncoder(NoOpPasswordEncoder.getInstance());
authenticator.setUserDnPatterns(new String[] { "uid={0},ou=people" });
@@ -106,7 +106,7 @@ public class PasswordComparisonAuthenticatorTests {
}
@Test
public void testOnlySpecifiedAttributesAreRetrieved() throws Exception {
public void testOnlySpecifiedAttributesAreRetrieved() {
authenticator.setUserAttributes(new String[] { "uid", "userPassword" });
DirContextAdapter user = (DirContextAdapter) authenticator.authenticate(bob);
@@ -73,7 +73,7 @@ public class FilterBasedLdapUserSearchTests {
// Try some funny business with filters.
@Test
public void extraFilterPartToExcludeBob() throws Exception {
public void extraFilterPartToExcludeBob() {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch(
"ou=people",
"(&(cn=*)(!(|(uid={0})(uid=rod)(uid=jerry)(uid=slashguy)(uid=javadude)(uid=groovydude)(uid=closuredude)(uid=scaladude))))",
@@ -112,7 +112,7 @@ public class FilterBasedLdapUserSearchTests {
}
@Test
public void searchWithDifferentSearchBaseIsSuccessful() throws Exception {
public void searchWithDifferentSearchBaseIsSuccessful() {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch(
"ou=otherpeople", "(cn={0})", this.contextSource);
DirContextOperations joe = locator.searchForUser("Joe Smeth");
@@ -50,7 +50,7 @@ public class ApacheDSEmbeddedLdifTests {
this.ldapTemplate = new SpringSecurityLdapTemplate(createLdapContextSource());
}
private LdapContextSource createLdapContextSource() throws Exception {
private LdapContextSource createLdapContextSource() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl("ldap://localhost:" + LDAP_PORT);
ldapContextSource.setBase(LDAP_ROOT);
@@ -52,7 +52,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
// ========================================================================================================
@Before
public void setUp() throws Exception {
public void setUp() {
populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, "ou=groups");
populator.setIgnorePartialResultException(false);
}
@@ -72,7 +72,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
}
@Test
public void nullSearchBaseIsAccepted() throws Exception {
public void nullSearchBaseIsAccepted() {
populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, null);
populator.setDefaultRole("ROLE_USER");
@@ -154,7 +154,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
}
@Test
public void extraRolesAreAdded() throws Exception {
public void extraRolesAreAdded() {
populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, null) {
@Override
protected Set<GrantedAuthority> getAdditionalRoles(DirContextOperations user,
@@ -60,7 +60,7 @@ public class LdapUserDetailsManagerTests {
private SpringSecurityLdapTemplate template;
@Before
public void setUp() throws Exception {
public void setUp() {
mgr = new LdapUserDetailsManager(this.contextSource);
template = new SpringSecurityLdapTemplate(this.contextSource);
DirContextAdapter ctx = new DirContextAdapter();
@@ -91,7 +91,7 @@ public class LdapUserDetailsManagerTests {
}
@After
public void onTearDown() throws Exception {
public void onTearDown() {
// Iterator people = template.list("ou=testpeople").iterator();
// DirContext rootCtx = new DirContextAdapter(new
@@ -55,7 +55,7 @@ public class NestedLdapAuthoritiesPopulatorTests {
// ========================================================================================================
@Before
public void setUp() throws Exception {
public void setUp() {
populator = new NestedLdapAuthoritiesPopulator(this.contextSource,
"ou=jdeveloper");
populator.setGroupSearchFilter("(member={0})");
@@ -75,7 +75,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator,
// ~ Methods
// ========================================================================================================
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.isTrue((userDnFormat != null) || (userSearch != null),
"Either an LdapUserSearch or DN pattern (or both) must be supplied.");
}
@@ -153,7 +153,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
start();
}
public void destroy() throws Exception {
public void destroy() {
stop();
}
@@ -66,12 +66,12 @@ public class UnboundIdContainer implements InitializingBean, DisposableBean, Lif
}
@Override
public void destroy() throws Exception {
public void destroy() {
stop();
}
@Override
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
start();
}
@@ -66,13 +66,13 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
"joe", "password");
@Before
public void setUp() throws Exception {
public void setUp() {
provider = new ActiveDirectoryLdapAuthenticationProvider("mydomain.eu",
"ldap://192.168.1.200/");
}
@Test
public void bindPrincipalIsCreatedCorrectly() throws Exception {
public void bindPrincipalIsCreatedCorrectly() {
assertThat(provider.createBindPrincipal("joe")).isEqualTo("joe@mydomain.eu");
assertThat(provider.createBindPrincipal("joe@mydomain.eu")).isEqualTo("joe@mydomain.eu");
}
@@ -370,7 +370,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
}
@Test(expected = BadCredentialsException.class)
public void errorWithNoSubcodeIsHandledCleanly() throws Exception {
public void errorWithNoSubcodeIsHandledCleanly() {
provider.contextFactory = createContextFactoryThrowing(new AuthenticationException(
msg));
provider.setConvertSubErrorCodesToExceptions(true);
@@ -378,8 +378,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
}
@Test(expected = org.springframework.ldap.CommunicationException.class)
public void nonAuthenticationExceptionIsConvertedToSpringLdapException()
throws Exception {
public void nonAuthenticationExceptionIsConvertedToSpringLdapException() {
provider.contextFactory = createContextFactoryThrowing(new CommunicationException(
msg));
provider.authenticate(joe);
@@ -404,7 +403,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
}
@Test
public void contextEnvironmentPropertiesUsed() throws Exception {
public void contextEnvironmentPropertiesUsed() {
Hashtable<String, Object> env = new Hashtable<>();
env.put("java.naming.ldap.factory.socket", "unknown.package.NonExistingSocketFactory");
@@ -431,7 +430,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
ContextFactory createContextFactoryReturning(final DirContext ctx) {
return new ContextFactory() {
@Override
DirContext createContext(Hashtable<?, ?> env) throws NamingException {
DirContext createContext(Hashtable<?, ?> env) {
return ctx;
}
};
@@ -36,7 +36,7 @@ public class PasswordPolicyAwareContextSourceTests {
private final LdapContext ctx = mock(LdapContext.class);
@Before
public void setUp() throws Exception {
public void setUp() {
reset(ctx);
ctxSource = new PasswordPolicyAwareContextSource(
"ldap://blah:789/dc=springframework,dc=org") {
@@ -55,8 +55,7 @@ public class PasswordPolicyAwareContextSourceTests {
}
@Test
public void contextIsReturnedWhenNoControlsAreSetAndReconnectIsSuccessful()
throws Exception {
public void contextIsReturnedWhenNoControlsAreSetAndReconnectIsSuccessful() {
assertThat(ctxSource.getContext("user", "ignored")).isNotNull();
}
@@ -28,7 +28,7 @@ import javax.naming.ldap.Control;
public class PasswordPolicyControlFactoryTests {
@Test
public void returnsNullForUnrecognisedOID() throws Exception {
public void returnsNullForUnrecognisedOID() {
PasswordPolicyControlFactory ctrlFactory = new PasswordPolicyControlFactory();
Control wrongCtrl = mock(Control.class);
@@ -37,7 +37,7 @@ public class PasswordPolicyControlFactoryTests {
}
@Test
public void returnsControlForCorrectOID() throws Exception {
public void returnsControlForCorrectOID() {
PasswordPolicyControlFactory ctrlFactory = new PasswordPolicyControlFactory();
Control control = mock(Control.class);
@@ -38,7 +38,7 @@ public class InetOrgPersonTests {
}
@Test
public void hashLookupViaEqualObjectRetrievesOriginal() throws Exception {
public void hashLookupViaEqualObjectRetrievesOriginal() {
InetOrgPerson.Essence essence = new InetOrgPerson.Essence(createUserContext());
InetOrgPerson p = (InetOrgPerson) essence.createUserDetails();
essence = new InetOrgPerson.Essence(createUserContext());
@@ -44,7 +44,7 @@ public class LdapAuthorityTests {
}
@Test
public void testGetDn() throws Exception {
public void testGetDn() {
assertThat(authority.getDn()).isEqualTo(DN);
assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).isNotNull();
assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).hasSize(1);
@@ -52,7 +52,7 @@ public class LdapAuthorityTests {
}
@Test
public void testGetAttributes() throws Exception {
public void testGetAttributes() {
assertThat(authority.getAttributes()).isNotNull();
assertThat(authority.getAttributeValues("mail")).isNotNull();
assertThat(authority.getAttributeValues("mail")).hasSize(2);
@@ -62,7 +62,7 @@ public class LdapAuthorityTests {
}
@Test
public void testGetAuthority() throws Exception {
public void testGetAuthority() {
assertThat(authority.getAuthority()).isNotNull();
assertThat(authority.getAuthority()).isEqualTo("testRole");
}
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class LdapUserDetailsMapperTests {
@Test
public void testMultipleRoleAttributeValuesAreMappedToAuthorities() throws Exception {
public void testMultipleRoleAttributeValuesAreMappedToAuthorities() {
LdapUserDetailsMapper mapper = new LdapUserDetailsMapper();
mapper.setConvertToUpperCase(false);
mapper.setRolePrefix("");
@@ -58,7 +58,7 @@ public class LdapUserDetailsMapperTests {
* SEC-303. Non-retrieved role attribute causes NullPointerException
*/
@Test
public void testNonRetrievedRoleAttributeIsIgnored() throws Exception {
public void testNonRetrievedRoleAttributeIsIgnored() {
LdapUserDetailsMapper mapper = new LdapUserDetailsMapper();
mapper.setRoleAttributes(new String[] { "userRole", "nonRetrievedAttribute" });
@@ -78,7 +78,7 @@ public class LdapUserDetailsMapperTests {
}
@Test
public void testPasswordAttributeIsMappedCorrectly() throws Exception {
public void testPasswordAttributeIsMappedCorrectly() {
LdapUserDetailsMapper mapper = new LdapUserDetailsMapper();
mapper.setPasswordAttributeName("myappsPassword");
@@ -65,7 +65,7 @@ public class LdapUserDetailsServiceTests {
}
@Test
public void nullPopulatorConstructorReturnsEmptyAuthoritiesList() throws Exception {
public void nullPopulatorConstructorReturnsEmptyAuthoritiesList() {
DirContextAdapter userData = new DirContextAdapter(new DistinguishedName(
"uid=joe"));
@@ -35,7 +35,7 @@ import org.springframework.security.ldap.authentication.UserDetailsServiceLdapAu
public class UserDetailsServiceLdapAuthoritiesPopulatorTests {
@Test
public void delegationToUserDetailsServiceReturnsCorrectRoles() throws Exception {
public void delegationToUserDetailsServiceReturnsCorrectRoles() {
UserDetailsService uds = mock(UserDetailsService.class);
UserDetails user = mock(UserDetails.class);
when(uds.loadUserByUsername("joe")).thenReturn(user);