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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user