Polish more AssertJ assertions
This commit is contained in:
parent
e0aca04a28
commit
0771778b81
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -137,9 +137,9 @@ public class ObjectIdentityImplTests {
|
|||
|
||||
String string = "SOME_STRING";
|
||||
assertThat(string).isNotSameAs(obj);
|
||||
assertThat(obj.equals(null)).isFalse();
|
||||
assertThat(obj.equals("DIFFERENT_OBJECT_TYPE")).isFalse();
|
||||
assertThat(obj.equals(new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(2)))).isFalse();
|
||||
assertThat(obj).isNotNull();
|
||||
assertThat(obj).isNotEqualTo("DIFFERENT_OBJECT_TYPE");
|
||||
assertThat(obj).isNotEqualTo(new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(2)));
|
||||
assertThat(obj).isNotEqualTo(new ObjectIdentityImpl(
|
||||
"org.springframework.security.acls.domain.ObjectIdentityImplTests$MockOtherIdDomainObject",
|
||||
Long.valueOf(1)));
|
||||
|
@ -151,7 +151,7 @@ public class ObjectIdentityImplTests {
|
|||
public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception {
|
||||
ObjectIdentity obj = new ObjectIdentityImpl(Object.class, Long.valueOf(1));
|
||||
ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, Long.valueOf(1));
|
||||
assertThat(obj.hashCode() == obj2.hashCode()).isFalse();
|
||||
assertThat(obj.hashCode()).isNotEqualTo(obj2.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -175,7 +175,7 @@ public class ObjectIdentityImplTests {
|
|||
public void stringAndNumericIdsAreNotEqual() throws Exception {
|
||||
ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000");
|
||||
ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Long.valueOf(1000));
|
||||
assertThat(obj.equals(obj2)).isFalse();
|
||||
assertThat(obj).isNotEqualTo(obj2);
|
||||
}
|
||||
|
||||
// ~ Inner Classes
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -104,17 +104,17 @@ public class SpringCacheBasedAclCacheTests {
|
|||
// Try to evict an entry that doesn't exist
|
||||
myCache.evictFromCache(Long.valueOf(3));
|
||||
myCache.evictFromCache(new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(102)));
|
||||
assertThat(4).isEqualTo(realCache.size());
|
||||
assertThat(realCache).hasSize(4);
|
||||
|
||||
myCache.evictFromCache(Long.valueOf(1));
|
||||
assertThat(2).isEqualTo(realCache.size());
|
||||
assertThat(realCache).hasSize(2);
|
||||
|
||||
// Check the second object inserted
|
||||
assertThat(acl2).isEqualTo(myCache.getFromCache(Long.valueOf(2)));
|
||||
assertThat(acl2).isEqualTo(myCache.getFromCache(identity2));
|
||||
|
||||
myCache.evictFromCache(identity2);
|
||||
assertThat(0).isEqualTo(realCache.size());
|
||||
assertThat(realCache).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -181,12 +181,12 @@ public class TestHelperTests {
|
|||
public void testCreateAuthorityList() {
|
||||
List<GrantedAuthority> authorities1 = HierarchicalRolesTestHelper
|
||||
.createAuthorityList("ROLE_A");
|
||||
assertThat(1).isEqualTo(authorities1.size());
|
||||
assertThat(authorities1).hasSize(1);
|
||||
assertThat(authorities1.get(0).getAuthority()).isEqualTo("ROLE_A");
|
||||
|
||||
List<GrantedAuthority> authorities2 = HierarchicalRolesTestHelper
|
||||
.createAuthorityList("ROLE_A", "ROLE_C");
|
||||
assertThat(2).isEqualTo(authorities2.size());
|
||||
assertThat(authorities2).hasSize(2);
|
||||
assertThat(authorities2.get(0).getAuthority()).isEqualTo("ROLE_A");
|
||||
assertThat(authorities2.get(1).getAuthority()).isEqualTo("ROLE_C");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -262,7 +262,7 @@ public class JdbcUserDetailsManagerTests {
|
|||
manager.renameGroup("GROUP_0", "GROUP_X");
|
||||
|
||||
assertThat(template.queryForObject("select id from groups where group_name = 'GROUP_X'",
|
||||
Integer.class)).isEqualTo(0);
|
||||
Integer.class)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -45,14 +45,14 @@ public class SecurityContextHolderMTTests extends TestCase{
|
|||
assertThat(new SecurityContextHolder().toString().isTrue()
|
||||
.lastIndexOf("SecurityContextHolder[strategy='org.springframework.security.context.InheritableThreadLocalSecurityContextHolderStrategy'") != -1);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, true);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isZero();
|
||||
}
|
||||
|
||||
public void testSynchronizationGlobal() throws Exception {
|
||||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, true, false);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isZero();
|
||||
}
|
||||
|
||||
public void testSynchronizationInheritableThreadLocal()
|
||||
|
@ -60,14 +60,14 @@ public class SecurityContextHolderMTTests extends TestCase{
|
|||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, true);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isZero();
|
||||
}
|
||||
|
||||
public void testSynchronizationThreadLocal() throws Exception {
|
||||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_THREADLOCAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, false);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isZero();
|
||||
}
|
||||
|
||||
private void startAndRun(Thread[] threads) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -103,7 +103,7 @@ public class OpenIDAuthenticationFilterTests {
|
|||
URI returnTo = new URI(filter.buildReturnToUrl(req));
|
||||
String query = returnTo.getRawQuery();
|
||||
assertThat(count(query, '=')).isEqualTo(1);
|
||||
assertThat(count(query, '&')).isEqualTo(0);
|
||||
assertThat(count(query, '&')).isZero();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +37,7 @@ public class AppRoleTests {
|
|||
public void bitsAreCorrect() throws Exception {
|
||||
// If this fails, someone has modified the Enum and the Datastore is probably
|
||||
// corrupt!
|
||||
assertThat(ADMIN.getBit()).isEqualTo(0);
|
||||
assertThat(ADMIN.getBit()).isZero();
|
||||
assertThat(NEW_USER.getBit()).isEqualTo(1);
|
||||
assertThat(USER.getBit()).isEqualTo(2);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ public class WebXmlJ2eeDefinedRolesRetrieverTests {
|
|||
|
||||
@Test
|
||||
public void testRole1To4Roles() throws Exception {
|
||||
List<String> ROLE1TO4_EXPECTED_ROLES = Arrays.asList(new String[] { "Role1",
|
||||
"Role2", "Role3", "Role4" });
|
||||
List<String> ROLE1TO4_EXPECTED_ROLES = Arrays.asList("Role1",
|
||||
"Role2", "Role3", "Role4");
|
||||
final Resource webXml = new ClassPathResource("webxml/Role1-4.web.xml");
|
||||
WebXmlMappableAttributesRetriever rolesRetriever = new WebXmlMappableAttributesRetriever();
|
||||
|
||||
|
@ -47,11 +47,9 @@ public class WebXmlJ2eeDefinedRolesRetrieverTests {
|
|||
|
||||
rolesRetriever.afterPropertiesSet();
|
||||
Set<String> j2eeRoles = rolesRetriever.getMappableAttributes();
|
||||
assertThat(j2eeRoles).isNotNull();
|
||||
assertThat(j2eeRoles.size()).withFailMessage("J2eeRoles expected size: " + ROLE1TO4_EXPECTED_ROLES.size()
|
||||
+ ", actual size: " + j2eeRoles).hasSize(ROLE1TO4_EXPECTED_ROLES.size());
|
||||
assertThat(j2eeRoles).withFailMessage("J2eeRoles expected contents (arbitrary order).isTrue(): "
|
||||
+ ROLE1TO4_EXPECTED_ROLES + ", actual content: " + j2eeRoles).containsAll(ROLE1TO4_EXPECTED_ROLES);
|
||||
assertThat(j2eeRoles).isNotNull()
|
||||
.hasSameSizeAs(ROLE1TO4_EXPECTED_ROLES)
|
||||
.containsAll(ROLE1TO4_EXPECTED_ROLES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -69,6 +67,6 @@ public class WebXmlJ2eeDefinedRolesRetrieverTests {
|
|||
});
|
||||
rolesRetriever.afterPropertiesSet();
|
||||
Set<String> j2eeRoles = rolesRetriever.getMappableAttributes();
|
||||
assertThat(j2eeRoles).withFailMessage("actual size: " + j2eeRoles.size() + "J2eeRoles expected size: 0").isEmpty();
|
||||
assertThat(j2eeRoles).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ public class AbstractRememberMeServicesTests {
|
|||
|
||||
Cookie cookie = response.getCookie(
|
||||
AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(cookie.getVersion()).isEqualTo(0);
|
||||
assertThat(cookie.getVersion()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -453,7 +453,7 @@ public class AbstractRememberMeServicesTests {
|
|||
Cookie returnedCookie = response.getCookie(
|
||||
AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
// ~ Inner Classes
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -135,7 +135,7 @@ public class PersistentTokenBasedRememberMeServicesTests {
|
|||
"somepass", "SOME_AUTH"));
|
||||
Cookie returnedCookie = response.getCookie("mycookiename");
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
|
||||
// SEC-1280
|
||||
services.logout(request, response, null);
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -153,7 +153,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -169,7 +169,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -190,7 +190,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -207,7 +207,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -227,7 +227,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
Cookie returnedCookie = response
|
||||
.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(returnedCookie).isNotNull();
|
||||
assertThat(returnedCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(returnedCookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -270,7 +270,7 @@ public class TokenBasedRememberMeServicesTests {
|
|||
|
||||
Cookie cookie = response.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(cookie).isNotNull();
|
||||
assertThat(cookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(cookie.getMaxAge()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -106,7 +106,7 @@ public class CookieCsrfTokenRepositoryTests {
|
|||
Cookie tokenCookie = this.response
|
||||
.getCookie(CookieCsrfTokenRepository.DEFAULT_CSRF_COOKIE_NAME);
|
||||
|
||||
assertThat(tokenCookie.getMaxAge()).isEqualTo(0);
|
||||
assertThat(tokenCookie.getMaxAge()).isZero();
|
||||
assertThat(tokenCookie.getName())
|
||||
.isEqualTo(CookieCsrfTokenRepository.DEFAULT_CSRF_COOKIE_NAME);
|
||||
assertThat(tokenCookie.getPath()).isEqualTo(this.request.getContextPath());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -97,7 +97,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
|
|||
assertThat(savedCookie.getName()).isEqualTo("SESSION");
|
||||
assertThat(savedCookie.getValue()).isEqualTo("123456789");
|
||||
assertThat(savedCookie.isSecure()).isEqualTo(false);
|
||||
assertThat(savedCookie.getVersion()).isEqualTo(0);
|
||||
assertThat(savedCookie.getVersion()).isZero();
|
||||
assertThat(savedCookie.getComment()).isNull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -168,7 +168,7 @@ public class ThrowableAnalyzerTests {
|
|||
};
|
||||
|
||||
assertThat(analyzer.getRegisteredTypes().length).withFailMessage(
|
||||
"Unexpected number of registered types").isEqualTo(0);
|
||||
"Unexpected number of registered types").isZero();
|
||||
|
||||
Throwable t = this.testTrace[0];
|
||||
Throwable[] chain = analyzer.determineCauseChain(t);
|
||||
|
|
Loading…
Reference in New Issue