Remove unnecessary default constructors which throw IllegalArgumentException. Favours compile time over runtime errors.
This commit is contained in:
@@ -49,12 +49,14 @@ public class SecurityConfigTests extends TestCase {
|
||||
SecurityConfig config = new SecurityConfig("TEST");
|
||||
assertEquals("TEST".hashCode(), config.hashCode());
|
||||
}
|
||||
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = SecurityConfig.class;
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
try {
|
||||
new SecurityConfig();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ public class NamedEntityObjectIdentityTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testDefaultConstructorRejected() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = NamedEntityObjectIdentity.class;
|
||||
|
||||
try {
|
||||
new NamedEntityObjectIdentity();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,15 +71,6 @@ public class AbstractAdapterAuthenticationTokenTests extends TestCase {
|
||||
assertTrue(!token.isUserInRole("ROLE_XXXX"));
|
||||
}
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
try {
|
||||
new MockDecisionManagerImpl();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void testObjectsEquals() throws Exception {
|
||||
MockDecisionManagerImpl token1 = new MockDecisionManagerImpl("my_password",
|
||||
"Test", "Password",
|
||||
@@ -148,10 +139,6 @@ public class AbstractAdapterAuthenticationTokenTests extends TestCase {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
private MockDecisionManagerImpl() {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public Object getCredentials() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@@ -59,12 +59,14 @@ public class PrincipalAcegiUserTokenTests extends TestCase {
|
||||
assertEquals("Test", token.getName());
|
||||
}
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = PrincipalAcegiUserToken.class;
|
||||
|
||||
try {
|
||||
new PrincipalAcegiUserToken();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,13 @@ public class InterceptorStatusTokenTests extends TestCase {
|
||||
junit.textui.TestRunner.run(InterceptorStatusTokenTests.class);
|
||||
}
|
||||
|
||||
public void testDefaultConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = InterceptorStatusToken.class;
|
||||
|
||||
try {
|
||||
new InterceptorStatusToken();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,11 +154,13 @@ public class FilterInvocationDefinitionSourceEditorTests extends TestCase {
|
||||
assertEquals(2, map.getMapSize());
|
||||
}
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = RegExpBasedFilterInvocationDefinitionMap.EntryHolder.class;
|
||||
|
||||
try {
|
||||
new RegExpBasedFilterInvocationDefinitionMap().new EntryHolder();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,13 @@ public class FilterInvocationDefinitionSourceEditorWithPathsTests
|
||||
assertEquals(2, map.getMapSize());
|
||||
}
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = PathBasedFilterInvocationDefinitionMap.EntryHolder.class;
|
||||
|
||||
try {
|
||||
new PathBasedFilterInvocationDefinitionMap().new EntryHolder();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,13 @@ public class FilterInvocationTests extends MockObjectTestCase {
|
||||
fi.getFullRequestUrl());
|
||||
}
|
||||
|
||||
public void testNoArgsConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = FilterInvocation.class;
|
||||
|
||||
try {
|
||||
new FilterInvocation();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +82,13 @@ public class TicketResponseTests extends TestCase {
|
||||
ticket.getProxyGrantingTicketIou());
|
||||
}
|
||||
|
||||
public void testNoArgConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = TicketResponse.class;
|
||||
|
||||
try {
|
||||
new TicketResponse();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,11 +101,13 @@ public class UserTests extends TestCase {
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE")})));
|
||||
}
|
||||
|
||||
public void testNoArgConstructor() {
|
||||
public void testNoArgConstructorDoesntExist() {
|
||||
Class clazz = User.class;
|
||||
|
||||
try {
|
||||
new User();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
clazz.getDeclaredConstructor((Class[])null);
|
||||
fail("Should have thrown NoSuchMethodException");
|
||||
} catch (NoSuchMethodException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user