You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lp...@apache.org on 2024/05/03 04:28:04 UTC
(shiro) 01/01: Revert "Refactor: AssertJ best practices by @timtebeek"
This is an automated email from the ASF dual-hosted git repository.
lprimak pushed a commit to branch revert-1452-assert-j-best-practices
in repository https://gitbox.apache.org/repos/asf/shiro.git
commit b95f118c5d09d51275f8d8014a484b5ceb80d7f9
Author: Lenny Primak <le...@flowlogix.com>
AuthorDate: Thu May 2 23:27:59 2024 -0500
Revert "Refactor: AssertJ best practices by @timtebeek"
---
.../org/apache/shiro/SecurityUtilsUnwrapTest.java | 27 +-
.../apache/shiro/aop/AnnotationResolverTest.java | 9 +-
.../shiro/authc/AbstractAuthenticatorTest.java | 22 +-
.../shiro/authc/SimpleAuthenticationInfoTest.java | 6 +-
.../AbstractHashedCredentialsMatcherTest.java | 6 +-
.../credential/AllowAllCredentialsMatcherTest.java | 4 +-
.../credential/HashedCredentialsMatcherTest.java | 8 +-
.../shiro/authc/pam/AllSuccessfulStrategyTest.java | 8 +-
.../authc/pam/FirstSuccessfulStrategyTest.java | 23 +-
.../shiro/authz/ModularRealmAuthorizerTest.java | 13 +-
.../authz/aop/DenyAllAnnotationHandlerTest.java | 6 +-
.../authz/aop/PermissionAnnotationHandlerTest.java | 8 +-
.../shiro/authz/aop/RoleAnnotationHandlerTest.java | 8 +-
.../aop/RolesAllowedAnnotationHandlerTest.java | 10 +-
.../shiro/authz/permission/AllPermissionTest.java | 6 +-
.../authz/permission/DomainPermissionTest.java | 136 +++---
.../permission/WildcardPermissionResolverTest.java | 22 +-
.../authz/permission/WildcardPermissionTest.java | 202 ++++-----
.../shiro/concurrent/SubjectAwareExecutorTest.java | 4 +-
.../apache/shiro/jndi/JndiObjectFactoryTest.java | 18 +-
.../shiro/mgt/AbstractRememberMeManagerTest.java | 6 +-
.../shiro/mgt/DefaultSecurityManagerTest.java | 61 +--
.../mgt/VMSingletonDefaultSecurityManagerTest.java | 9 +-
.../apache/shiro/realm/AuthorizingRealmTest.java | 67 +--
.../activedirectory/ActiveDirectoryRealmTest.java | 23 +-
.../org/apache/shiro/realm/jdbc/JDBCRealmTest.java | 13 +-
.../shiro/realm/ldap/DefaultLdapRealmTest.java | 27 +-
.../realm/ldap/JndiLdapContextFactoryTest.java | 68 +--
.../apache/shiro/realm/ldap/JndiLdapRealmTest.java | 4 +-
.../org/apache/shiro/realm/text/IniRealmTest.java | 15 +-
.../realm/text/TextConfigurationRealmTest.java | 13 +-
.../mgt/AbstractValidatingSessionManagerTest.java | 8 +-
.../session/mgt/DefaultSessionManagerTest.java | 26 +-
.../shiro/session/mgt/DelegatingSessionTest.java | 8 +-
...cutorServiceSessionValidationSchedulerTest.java | 21 +-
.../shiro/session/mgt/SimpleSessionTest.java | 13 +-
.../shiro/subject/DelegatingSubjectTest.java | 121 +++---
.../org/apache/shiro/util/AntPathMatcherTests.java | 478 ++++++++++-----------
.../apache/shiro/util/RegExPatternMatcherTest.java | 7 +-
.../org/apache/shiro/util/StringUtilsTest.java | 94 ++--
integration-tests/jakarta-ee/pom.xml | 2 +-
.../shiro/testing/cdi/ComponentInjectionIT.java | 35 +-
.../shiro/testing/jakarta/ee/FacesTagsIT.java | 39 +-
.../shiro/testing/jakarta/ee/ShiroAuthFormsIT.java | 59 +--
.../shiro/testing/jakarta/ee/ShiroBeansIT.java | 44 +-
.../shiro/testing/jakarta/ee/ShiroSSLFilterIT.java | 10 +-
.../apache/shiro/testing/jaxrs/NoIniJaxRsIT.java | 2 +-
integration-tests/jaxrs/tests/pom.xml | 5 -
.../testing/jaxrs/tests/AbstractShiroJaxRsIT.java | 8 +-
integration-tests/support/pom.xml | 7 -
.../shiro/testing/web/AbstractContainerIT.java | 9 +-
.../org/apache/shiro/lang/util/ClassUtilsTest.java | 86 ++--
pom.xml | 7 +-
.../aspectj/bank/SecureBankServiceTest.java | 28 +-
.../web/jakarta/JakartaAbstractContainerIT.java | 6 +-
.../shiro/test/web/jakarta/WebContainerIT.java | 15 +-
.../org/apache/shiro/aspectj/DummyServiceTest.java | 18 +-
.../apache/shiro/cdi/AnnotatedTypeWrapperTest.java | 65 +--
.../java/org/apache/shiro/cdi/AopHelperTest.java | 13 +-
.../shiro/cache/ehcache/EhCacheManagerTest.java | 123 +++---
support/guice/pom.xml | 5 -
.../apache/shiro/guice/BeanTypeListenerTest.java | 23 +-
.../apache/shiro/guice/GuiceEnvironmentTest.java | 6 +-
.../org/apache/shiro/guice/ShiroMatchersTest.java | 7 +-
.../org/apache/shiro/guice/ShiroModuleTest.java | 26 +-
.../apache/shiro/guice/ShiroSessionScopeTest.java | 10 +-
.../AopAllianceMethodInterceptorAdapterTest.java | 4 +-
.../AopAllianceMethodInvocationAdapterTest.java | 10 +-
.../apache/shiro/guice/aop/ShiroAopModuleTest.java | 23 +-
.../guice/web/AbstractInjectionProviderTest.java | 21 +-
.../apache/shiro/guice/web/DefaultFiltersTest.java | 2 +-
.../guice/web/FilterChainResolverProviderTest.java | 20 +-
.../apache/shiro/guice/web/FilterConfigTest.java | 6 +-
.../shiro/guice/web/GuiceShiroFilterTest.java | 15 +-
.../apache/shiro/guice/web/ShiroWebModuleTest.java | 126 +++---
.../guice/web/SimpleFilterChainResolverTest.java | 6 +-
.../shiro/guice/web/WebGuiceEnvironmentTest.java | 14 +-
.../apache/shiro/ee/cdi/ShiroScopeContextTest.java | 19 +-
.../apache/shiro/ee/filters/FormSupportTest.java | 119 ++---
.../SecureRemoteInvocationFactoryTest.java | 7 +-
.../AbstractAuthorizationAnnotationTest.java | 8 +-
.../AuthorizationAttributeSourceAdvisorTest.java | 55 ++-
.../DapcAuthorizationAnnotationTest.java | 8 +-
.../spring/web/ShiroFilterFactoryBeanTest.java | 18 +-
.../ShiroWebConfigurationTestSameSiteStrict.java | 10 +-
.../org/apache/shiro/tools/hasher/HasherTest.java | 11 +-
.../config/WebIniSecurityManagerFactoryTest.java | 11 +-
.../web/env/EnvironmentLoaderServiceTest.java | 21 +-
.../PathMatchingFilterParameterizedTest.java | 7 +-
.../shiro/web/filter/PathMatchingFilterTest.java | 15 +-
.../web/filter/authc/AnonymousFilterTest.java | 4 +-
.../shiro/web/filter/authz/HostFilterTest.java | 6 +-
.../authz/HttpMethodPermissionFilterTest.java | 24 +-
.../web/filter/authz/IpAddressMatcherTests.java | 31 +-
.../shiro/web/filter/authz/IpFilterTest.java | 12 +-
.../shiro/web/filter/authz/PortFilterTest.java | 6 +-
.../shiro/web/filter/authz/SslFilterTest.java | 9 +-
.../mgt/PathMatchingFilterChainResolverTest.java | 57 +--
.../web/filter/mgt/SimpleNamedFilterListTest.java | 84 ++--
.../shiro/web/mgt/CookieRememberMeManagerTest.java | 33 +-
.../web/mgt/DefaultWebSecurityManagerTest.java | 42 +-
.../web/servlet/OncePerRequestFilterTest.java | 8 +-
.../web/servlet/ShiroHttpServletRequestTest.java | 11 +-
.../shiro/web/session/HttpServletSessionTest.java | 6 +-
104 files changed, 1624 insertions(+), 1551 deletions(-)
diff --git a/core/src/test/java/org/apache/shiro/SecurityUtilsUnwrapTest.java b/core/src/test/java/org/apache/shiro/SecurityUtilsUnwrapTest.java
index 7ec695291..fb8aa0f0a 100644
--- a/core/src/test/java/org/apache/shiro/SecurityUtilsUnwrapTest.java
+++ b/core/src/test/java/org/apache/shiro/SecurityUtilsUnwrapTest.java
@@ -34,10 +34,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.apache.shiro.SecurityUtils.getSecurityManager;
import static org.apache.shiro.SecurityUtils.isSecurityManagerTypeOf;
import static org.apache.shiro.SecurityUtils.unwrapSecurityManager;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -79,12 +78,12 @@ class SecurityUtilsUnwrapTest {
@Test
void basicUnwrap() {
SecurityManager sm = unwrapSecurityManager(securityManager, SecurityManager.class);
- assertThat(sm).isEqualTo(securityManager);
+ assertEquals(securityManager, sm);
}
@Test
void basicTypeCheck() {
- assertThat(isSecurityManagerTypeOf(securityManager, SecurityManager.class)).isTrue();
+ assertTrue(isSecurityManagerTypeOf(securityManager, SecurityManager.class));
}
@Test
@@ -92,13 +91,13 @@ class SecurityUtilsUnwrapTest {
try (var threadContext = mockStatic(ThreadContext.class)) {
threadContext.when(ThreadContext::getSecurityManager).thenReturn(defaultSecurityManager);
DefaultSecurityManager dsm = getSecurityManager(DefaultSecurityManager.class);
- assertThat(dsm).isEqualTo(defaultSecurityManager);
+ assertEquals(defaultSecurityManager, dsm);
}
}
@Test
void failedTypeUnwrap() {
- assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> {
+ assertThrows(ClassCastException.class, () -> {
SessionsSecurityManager ssm = unwrapSecurityManager(securityManager, SessionsSecurityManager.class);
});
}
@@ -106,10 +105,10 @@ class SecurityUtilsUnwrapTest {
@Test
void defaultSecurityManager() {
var dsm = unwrapSecurityManager(defaultSecurityManager, DefaultSecurityManager.class);
- assertThat(dsm).isEqualTo(defaultSecurityManager);
+ assertEquals(defaultSecurityManager, dsm);
when(defaultSecurityManager.createSubject(subjectContext)).thenReturn(subject);
Subject subject = dsm.createSubject(subjectContext);
- assertThat(subject).isEqualTo(this.subject);
+ assertEquals(this.subject, subject);
verify(defaultSecurityManager).createSubject(subjectContext);
verifyNoMoreInteractions(defaultSecurityManager, this.subject, subjectContext);
}
@@ -117,7 +116,7 @@ class SecurityUtilsUnwrapTest {
@Test
void invalidCast() {
SecurityManager wrapped = new Wrapped(defaultSecurityManager);
- assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> {
+ assertThrows(ClassCastException.class, () -> {
DefaultSecurityManager sm = (DefaultSecurityManager) wrapped;
});
}
@@ -125,19 +124,19 @@ class SecurityUtilsUnwrapTest {
@Test
void unwrapOne() {
SecurityManager wrapped = new Wrapped(defaultSecurityManager);
- assertThat(unwrapSecurityManager(wrapped, DefaultSecurityManager.class)).isEqualTo(defaultSecurityManager);
+ assertEquals(defaultSecurityManager, unwrapSecurityManager(wrapped, DefaultSecurityManager.class));
}
@Test
void unwrapTwo() {
SecurityManager wrapped = new Wrapped(new Wrapped(defaultSecurityManager));
- assertThat(unwrapSecurityManager(wrapped, DefaultSecurityManager.class)).isEqualTo(defaultSecurityManager);
+ assertEquals(defaultSecurityManager, unwrapSecurityManager(wrapped, DefaultSecurityManager.class));
}
@Test
void invalidWrap() {
SecurityManager wrapped = new Wrapped(new InvalidWrapped(defaultSecurityManager));
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
assertEquals(defaultSecurityManager, unwrapSecurityManager(wrapped, DefaultSecurityManager.class));
});
}
@@ -145,7 +144,7 @@ class SecurityUtilsUnwrapTest {
@Test
void invalidWrapInverted() {
SecurityManager wrapped = new InvalidWrapped(new Wrapped(defaultSecurityManager));
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
assertEquals(defaultSecurityManager, unwrapSecurityManager(wrapped, DefaultSecurityManager.class));
});
}
diff --git a/core/src/test/java/org/apache/shiro/aop/AnnotationResolverTest.java b/core/src/test/java/org/apache/shiro/aop/AnnotationResolverTest.java
index f96ade82f..a60f6f325 100644
--- a/core/src/test/java/org/apache/shiro/aop/AnnotationResolverTest.java
+++ b/core/src/test/java/org/apache/shiro/aop/AnnotationResolverTest.java
@@ -18,10 +18,11 @@
*/
package org.apache.shiro.aop;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.lang.reflect.Method;
@@ -52,7 +53,7 @@ public class AnnotationResolverTest {
expect(methodInvocation.getMethod()).andReturn(method);
expect(methodInvocation.getThis()).andReturn(myFixture);
replay(methodInvocation);
- assertThat(annotationResolver.getAnnotation(methodInvocation, RequiresRoles.class)).isNotNull();
+ assertNotNull(annotationResolver.getAnnotation(methodInvocation, RequiresRoles.class));
}
@Test
@@ -61,7 +62,7 @@ public class AnnotationResolverTest {
Method method = MyFixture.class.getDeclaredMethod("operateThat");
expect(methodInvocation.getMethod()).andReturn(method);
replay(methodInvocation);
- assertThat(annotationResolver.getAnnotation(methodInvocation, RequiresUser.class)).isNotNull();
+ assertNotNull(annotationResolver.getAnnotation(methodInvocation, RequiresUser.class));
}
@Test
@@ -71,7 +72,7 @@ public class AnnotationResolverTest {
expect(methodInvocation.getMethod()).andReturn(method);
expect(methodInvocation.getThis()).andReturn(null);
replay(methodInvocation);
- assertThat(annotationResolver.getAnnotation(methodInvocation, RequiresUser.class)).isNull();
+ assertNull(annotationResolver.getAnnotation(methodInvocation, RequiresUser.class));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java b/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java
index 30d492747..c03b5a608 100644
--- a/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java
@@ -28,12 +28,14 @@ import org.junit.jupiter.api.Test;
import java.net.URI;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @since 0.1
@@ -96,7 +98,7 @@ public class AbstractAuthenticatorTest {
*/
@Test
void authenticateWithNullArgument() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
abstractAuthenticator.authenticate(null);
});
}
@@ -107,7 +109,7 @@ public class AbstractAuthenticatorTest {
*/
@Test
void throwAuthenticationExceptionIfDoAuthenticateReturnsNull() {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
abstractAuthenticator = createAuthcReturnNull();
abstractAuthenticator.authenticate(newToken());
});
@@ -121,7 +123,7 @@ public class AbstractAuthenticatorTest {
@Test
void nonNullAuthenticationInfoAfterAuthenticate() {
AuthenticationInfo authcInfo = abstractAuthenticator.authenticate(newToken());
- assertThat(authcInfo).isNotNull();
+ assertNotNull(authcInfo);
}
@Test
@@ -158,7 +160,7 @@ public class AbstractAuthenticatorTest {
abstractAuthenticator.authenticate(token);
} catch (AuthenticationException e) {
exceptionThrown = true;
- assertThat(ae).isEqualTo(e);
+ assertEquals(e, ae);
}
verify(mockListener);
@@ -169,7 +171,7 @@ public class AbstractAuthenticatorTest {
@Test
void notifyFailureAfterDoAuthenticateThrowsNonAuthenticationException() {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
abstractAuthenticator = new AbstractAuthenticator() {
protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException {
throw new IllegalArgumentException("not an AuthenticationException subclass");
@@ -200,8 +202,8 @@ public class AbstractAuthenticatorTest {
}
String logMsg = String.join("\n", listAppender.getMessages());
- assertThat(logMsg).contains("WARN");
- assertThat(logMsg).contains("java.lang.IllegalArgumentException: " + expectedExceptionMessage);
+ assertTrue(logMsg.contains("WARN"));
+ assertTrue(logMsg.contains("java.lang.IllegalArgumentException: " + expectedExceptionMessage));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/SimpleAuthenticationInfoTest.java b/core/src/test/java/org/apache/shiro/authc/SimpleAuthenticationInfoTest.java
index a395f76cc..fefbdc42d 100644
--- a/core/src/test/java/org/apache/shiro/authc/SimpleAuthenticationInfoTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/SimpleAuthenticationInfoTest.java
@@ -25,10 +25,10 @@ import java.util.List;
import java.util.Set;
import org.apache.shiro.subject.PrincipalCollection;
-
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* @since 0.9
@@ -106,7 +106,7 @@ public class SimpleAuthenticationInfoTest {
aggregate.setPrincipals(principalCollection);
SimpleAuthenticationInfo local = new SimpleAuthenticationInfo("username", "password", "testRealm");
aggregate.merge(local);
- assertThat(aggregate.getPrincipals().asList()).hasSize(2);
+ assertEquals(2, aggregate.getPrincipals().asList().size());
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/credential/AbstractHashedCredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/AbstractHashedCredentialsMatcherTest.java
index 8c1720b27..98802c87b 100644
--- a/core/src/test/java/org/apache/shiro/authc/credential/AbstractHashedCredentialsMatcherTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/credential/AbstractHashedCredentialsMatcherTest.java
@@ -20,6 +20,8 @@ package org.apache.shiro.authc.credential;
import org.apache.shiro.authc.AuthenticationInfo;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
@@ -27,8 +29,6 @@ import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.lang.util.ClassUtils;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-
/**
* @since Jun 10, 2008 4:47:09 PM
*/
@@ -44,6 +44,6 @@ public abstract class AbstractHashedCredentialsMatcherTest {
byte[] hashed = hash("password").getBytes();
AuthenticationInfo account = new SimpleAuthenticationInfo("username", hashed, "realmName");
AuthenticationToken token = new UsernamePasswordToken("username", "password");
- assertThat(matcher.doCredentialsMatch(token, account)).isTrue();
+ assertTrue(matcher.doCredentialsMatch(token, account));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcherTest.java
index dd3c51586..de8f966af 100644
--- a/core/src/test/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcherTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcherTest.java
@@ -20,7 +20,7 @@ package org.apache.shiro.authc.credential;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -30,7 +30,7 @@ public class AllowAllCredentialsMatcherTest {
@Test
void testBasic() {
- assertThat(new AllowAllCredentialsMatcher().doCredentialsMatch(null, null)).isTrue();
+ assertTrue(new AllowAllCredentialsMatcher().doCredentialsMatch(null, null));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/credential/HashedCredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/HashedCredentialsMatcherTest.java
index facafb9fa..f6a0c2064 100644
--- a/core/src/test/java/org/apache/shiro/authc/credential/HashedCredentialsMatcherTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/credential/HashedCredentialsMatcherTest.java
@@ -29,7 +29,7 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the {@link org.apache.shiro.authc.credential.HashedCredentialsMatcher} class.
@@ -54,7 +54,7 @@ public class HashedCredentialsMatcherTest {
AuthenticationToken token = new UsernamePasswordToken("username", "password");
//verify the hashed token matches what is in the account:
- assertThat(matcher.doCredentialsMatch(token, account)).isTrue();
+ assertTrue(matcher.doCredentialsMatch(token, account));
}
/**
@@ -87,7 +87,7 @@ public class HashedCredentialsMatcherTest {
AuthenticationToken token = new UsernamePasswordToken("username", "password");
//verify the hashed token matches what is in the account:
- assertThat(matcher.doCredentialsMatch(token, account)).isTrue();
+ assertTrue(matcher.doCredentialsMatch(token, account));
}
/**
@@ -124,6 +124,6 @@ public class HashedCredentialsMatcherTest {
AuthenticationToken token = new UsernamePasswordToken("username", "password");
//verify the hashed token matches what is in the account:
- assertThat(matcher.doCredentialsMatch(token, account)).isTrue();
+ assertTrue(matcher.doCredentialsMatch(token, account));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java b/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java
index c73b03118..7e9495685 100644
--- a/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java
@@ -22,8 +22,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.apache.shiro.authc.AuthenticationException;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
@@ -46,7 +46,7 @@ public class AllSuccessfulStrategyTest {
@Test
void beforeAllAttempts() {
AuthenticationInfo info = strategy.beforeAllAttempts(null, null);
- assertThat(info).isNotNull();
+ assertNotNull(info);
}
@Test
@@ -56,7 +56,7 @@ public class AllSuccessfulStrategyTest {
@Test
void beforeAttemptRealmDoesntSupportToken() {
- assertThatExceptionOfType(UnsupportedTokenException.class).isThrownBy(() -> {
+ assertThrows(UnsupportedTokenException.class, () -> {
Realm notSupportingRealm = new AuthorizingRealm() {
public boolean supports(AuthenticationToken token) {
diff --git a/core/src/test/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategyTest.java b/core/src/test/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategyTest.java
index 909c74457..76785ecb4 100644
--- a/core/src/test/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategyTest.java
+++ b/core/src/test/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategyTest.java
@@ -24,12 +24,13 @@ import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-
public class FirstSuccessfulStrategyTest {
@@ -44,7 +45,7 @@ public class FirstSuccessfulStrategyTest {
@Test
void beforeAllAttempts() {
AuthenticationInfo authenticationInfo = strategy.beforeAllAttempts(null, null);
- assertThat(authenticationInfo).isNull();
+ assertNull(authenticationInfo);
}
@Test
@@ -66,7 +67,7 @@ public class FirstSuccessfulStrategyTest {
}
};
AuthenticationInfo mergeResult = strategy.merge(new SimpleAuthenticationInfo(), aggregate);
- assertThat(mergeResult).isEqualTo(aggregate);
+ assertEquals(aggregate, mergeResult);
}
@Test
@@ -90,32 +91,32 @@ public class FirstSuccessfulStrategyTest {
AuthenticationInfo authInfo = new SimpleAuthenticationInfo();
AuthenticationInfo mergeResult = strategy.merge(authInfo, aggregate);
- assertThat(mergeResult).isEqualTo(authInfo);
+ assertEquals(authInfo, mergeResult);
AuthenticationInfo info = strategy.beforeAllAttempts(null, null);
- assertThat(info).isNull();
+ assertNull(info);
}
@Test
void testBeforeAttemptNull() {
- assertThat(strategy.beforeAttempt(null, null, null)).isNull();
+ assertNull(strategy.beforeAttempt(null, null, null));
}
@Test
void testBeforeAttemptEmptyPrincipal() {
AuthenticationInfo aggregate = new SimpleAuthenticationInfo();
- assertThat(aggregate).isEqualTo(strategy.beforeAttempt(null, null, aggregate));
+ assertEquals(strategy.beforeAttempt(null, null, aggregate), aggregate);
}
@Test
void testBeforeAttemptEmptyList() {
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
AuthenticationInfo aggregate = new SimpleAuthenticationInfo(principalCollection, null);
- assertThat(aggregate).isEqualTo(strategy.beforeAttempt(null, null, aggregate));
+ assertEquals(strategy.beforeAttempt(null, null, aggregate), aggregate);
}
@Test
void testBeforeAttemptStopAfterFirstSuccess() {
- assertThatExceptionOfType(ShortCircuitIterationException.class).isThrownBy(() -> {
+ assertThrows(ShortCircuitIterationException.class, () -> {
AuthenticationInfo aggregate = new SimpleAuthenticationInfo("principal", null, "a-realm-name");
strategy.beforeAttempt(null, null, aggregate);
});
diff --git a/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java b/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java
index 62b44c8bd..3b86168ae 100644
--- a/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java
@@ -18,12 +18,13 @@
*/
package org.apache.shiro.authz;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.Collection;
import org.apache.shiro.authc.AuthenticationException;
-
-import static org.assertj.core.api.Assertions.assertThat;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.permission.RolePermissionResolver;
@@ -43,7 +44,7 @@ public class ModularRealmAuthorizerTest {
// its null to start with
for (Realm realm : realms) {
- assertThat(((AuthorizingRealm) realm).getRolePermissionResolver()).isNull();
+ assertNull(((AuthorizingRealm) realm).getRolePermissionResolver());
}
ModularRealmAuthorizer modRealmAuthz = new ModularRealmAuthorizer();
@@ -51,7 +52,7 @@ public class ModularRealmAuthorizerTest {
// make sure they are still null
for (Realm realm : realms) {
- assertThat(((AuthorizingRealm) realm).getRolePermissionResolver()).isNull();
+ assertNull(((AuthorizingRealm) realm).getRolePermissionResolver());
}
// now set the RolePermissionResolver
@@ -65,14 +66,14 @@ public class ModularRealmAuthorizerTest {
// make sure they are set
for (Realm realm : realms) {
// check for same instance
- assertThat(((AuthorizingRealm) realm).getRolePermissionResolver() == rolePermissionResolver).isTrue();
+ assertTrue(((AuthorizingRealm) realm).getRolePermissionResolver() == rolePermissionResolver);
}
// add a new realm and make sure the RolePermissionResolver is set
MockAuthorizingRealm mockRealm = new MockAuthorizingRealm();
realms.add(mockRealm);
modRealmAuthz.setRealms(realms);
- assertThat(((AuthorizingRealm) mockRealm).getRolePermissionResolver() == rolePermissionResolver).isTrue();
+ assertTrue(((AuthorizingRealm) mockRealm).getRolePermissionResolver() == rolePermissionResolver);
// TODO: no way to unset them, not sure if that is a valid use case, but this is consistent with the PermissionResolver logic
diff --git a/core/src/test/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandlerTest.java b/core/src/test/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandlerTest.java
index 7b4008818..1b895090b 100644
--- a/core/src/test/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandlerTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandlerTest.java
@@ -26,10 +26,10 @@ import org.junit.jupiter.api.Test;
import javax.annotation.security.DenyAll;
import java.lang.annotation.Annotation;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test cases for the {@link DenyAllAnnotationHandler} class.
@@ -39,7 +39,7 @@ public class DenyAllAnnotationHandlerTest extends SecurityManagerTestSupport {
@Test
void testGuestSingleRoleAssertion() throws Throwable {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
DenyAllAnnotationHandler handler = new DenyAllAnnotationHandler();
Annotation denyAllAnnotation = new DenyAll() {
@@ -55,7 +55,7 @@ public class DenyAllAnnotationHandlerTest extends SecurityManagerTestSupport {
@Test
void testOneOfTheRolesRequired() throws Throwable {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
subject = createMock(Subject.class);
expect(subject.hasRole("blah")).andReturn(true);
replay(subject);
diff --git a/core/src/test/java/org/apache/shiro/authz/aop/PermissionAnnotationHandlerTest.java b/core/src/test/java/org/apache/shiro/authz/aop/PermissionAnnotationHandlerTest.java
index c158af7a6..9bad76553 100644
--- a/core/src/test/java/org/apache/shiro/authz/aop/PermissionAnnotationHandlerTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/aop/PermissionAnnotationHandlerTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
import java.lang.annotation.Annotation;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test cases for the {@link PermissionAnnotationHandler} class.
@@ -57,8 +57,7 @@ public class PermissionAnnotationHandlerTest extends SecurityManagerTestSupport
};
runWithSubject(subject -> {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() ->
- handler.assertAuthorized(requiresPermissionAnnotation));
+ assertThrows(UnauthenticatedException.class, () -> handler.assertAuthorized(requiresPermissionAnnotation));
});
}
@@ -86,8 +85,7 @@ public class PermissionAnnotationHandlerTest extends SecurityManagerTestSupport
};
runWithSubject(subject -> {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() ->
- handler.assertAuthorized(requiresPermissionAnnotation));
+ assertThrows(UnauthenticatedException.class, () -> handler.assertAuthorized(requiresPermissionAnnotation));
});
}
diff --git a/core/src/test/java/org/apache/shiro/authz/aop/RoleAnnotationHandlerTest.java b/core/src/test/java/org/apache/shiro/authz/aop/RoleAnnotationHandlerTest.java
index e42c415a7..6c3fdcbcc 100644
--- a/core/src/test/java/org/apache/shiro/authz/aop/RoleAnnotationHandlerTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/aop/RoleAnnotationHandlerTest.java
@@ -27,10 +27,10 @@ import org.junit.jupiter.api.Test;
import java.lang.annotation.Annotation;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test cases for the {@link RoleAnnotationHandler} class.
@@ -62,8 +62,7 @@ public class RoleAnnotationHandlerTest extends SecurityManagerTestSupport {
};
runWithSubject(subject -> {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() ->
- handler.assertAuthorized(requiresRolesAnnotation));
+ assertThrows(UnauthenticatedException.class, () -> handler.assertAuthorized(requiresRolesAnnotation));
});
}
@@ -91,8 +90,7 @@ public class RoleAnnotationHandlerTest extends SecurityManagerTestSupport {
};
runWithSubject(subject -> {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() ->
- handler.assertAuthorized(requiresRolesAnnotation));
+ assertThrows(UnauthenticatedException.class, () -> handler.assertAuthorized(requiresRolesAnnotation));
});
}
diff --git a/core/src/test/java/org/apache/shiro/authz/aop/RolesAllowedAnnotationHandlerTest.java b/core/src/test/java/org/apache/shiro/authz/aop/RolesAllowedAnnotationHandlerTest.java
index 27364cebf..9dec9db45 100644
--- a/core/src/test/java/org/apache/shiro/authz/aop/RolesAllowedAnnotationHandlerTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/aop/RolesAllowedAnnotationHandlerTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
import javax.annotation.security.RolesAllowed;
import java.lang.annotation.Annotation;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -39,7 +39,7 @@ public class RolesAllowedAnnotationHandlerTest extends SecurityManagerTestSuppor
@Test
void testGuestSingleRoleAssertion() throws Throwable {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
subject = mock(Subject.class);
doThrow(new UnauthenticatedException()).when(subject).checkRole("blah");
@@ -53,7 +53,7 @@ public class RolesAllowedAnnotationHandlerTest extends SecurityManagerTestSuppor
Annotation rolesAllowedAnnotation = new RolesAllowed() {
@Override
public String[] value() {
- return new String[]{"blah"};
+ return new String[] {"blah"};
}
@Override
@@ -68,7 +68,7 @@ public class RolesAllowedAnnotationHandlerTest extends SecurityManagerTestSuppor
@Test
void testGuestMultipleRolesAssertion() throws Throwable {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
subject = mock(Subject.class);
doThrow(new UnauthenticatedException()).when(subject).checkRole("blah");
@@ -85,7 +85,7 @@ public class RolesAllowedAnnotationHandlerTest extends SecurityManagerTestSuppor
Annotation rolesAllowedAnnotation = new RolesAllowed() {
@Override
public String[] value() {
- return new String[]{"blah", "blah2"};
+ return new String[] {"blah", "blah2"};
}
@Override
diff --git a/core/src/test/java/org/apache/shiro/authz/permission/AllPermissionTest.java b/core/src/test/java/org/apache/shiro/authz/permission/AllPermissionTest.java
index 804d3bdde..f9c9685dd 100644
--- a/core/src/test/java/org/apache/shiro/authz/permission/AllPermissionTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/permission/AllPermissionTest.java
@@ -20,7 +20,7 @@ package org.apache.shiro.authz.permission;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -30,11 +30,11 @@ public class AllPermissionTest {
@Test
void testNullArgument() {
- assertThat(new AllPermission().implies(null)).isTrue();
+ assertTrue(new AllPermission().implies(null));
}
@Test
void testNonNullArgument() {
- assertThat(new AllPermission().implies(new AllPermission())).isTrue();
+ assertTrue(new AllPermission().implies(new AllPermission()));
}
}
diff --git a/core/src/test/java/org/apache/shiro/authz/permission/DomainPermissionTest.java b/core/src/test/java/org/apache/shiro/authz/permission/DomainPermissionTest.java
index 6c12082ad..4e474c9c1 100644
--- a/core/src/test/java/org/apache/shiro/authz/permission/DomainPermissionTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/permission/DomainPermissionTest.java
@@ -24,7 +24,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @since 1.3
@@ -41,23 +43,23 @@ public class DomainPermissionTest {
p = new DomainPermission();
// Verify domain
- assertThat(p.getDomain()).isEqualTo("domain");
+ assertEquals("domain", p.getDomain());
// Verify actions
set = p.getActions();
- assertThat(set).isNull();
+ assertNull(set);
// Verify targets
set = p.getTargets();
- assertThat(set).isNull();
+ assertNull(set);
// Verify parts
parts = p.getParts();
- assertThat(parts.size()).as("Number of parts").isEqualTo(1);
+ assertEquals(1, parts.size(), "Number of parts");
set = parts.get(0);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
entry = set.iterator().next();
- assertThat(entry).isEqualTo("domain");
+ assertEquals("domain", entry);
}
@Test
@@ -72,33 +74,33 @@ public class DomainPermissionTest {
p = new DomainPermission("action1");
// Verify domain
- assertThat(p.getDomain()).isEqualTo("domain");
+ assertEquals("domain", p.getDomain());
// Verify actions
set = p.getActions();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(1);
+ assertNotNull(set);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
// Verify targets
set = p.getTargets();
- assertThat(set).isNull();
+ assertNull(set);
// Verify parts
parts = p.getParts();
- assertThat(parts).hasSize(2);
+ assertEquals(2, parts.size());
set = parts.get(0);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("domain");
+ assertEquals("domain", entry);
set = parts.get(1);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
}
@Test
@@ -113,41 +115,41 @@ public class DomainPermissionTest {
p = new DomainPermission("action1,action2,action3");
// Verify domain
- assertThat(p.getDomain()).isEqualTo("domain");
+ assertEquals("domain", p.getDomain());
// Verify actions
set = p.getActions();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(3);
+ assertNotNull(set);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action2");
+ assertEquals("action2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action3");
+ assertEquals("action3", entry);
// Verify targets
set = p.getTargets();
- assertThat(set).isNull();
+ assertNull(set);
// Verify parts
parts = p.getParts();
- assertThat(parts).hasSize(2);
+ assertEquals(2, parts.size());
set = parts.get(0);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("domain");
+ assertEquals("domain", entry);
set = parts.get(1);
- assertThat(set).hasSize(3);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action2");
+ assertEquals("action2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action3");
+ assertEquals("action3", entry);
}
@Test
@@ -162,42 +164,42 @@ public class DomainPermissionTest {
p = new DomainPermission("action1", "target1");
// Verify domain
- assertThat(p.getDomain()).isEqualTo("domain");
+ assertEquals("domain", p.getDomain());
// Verify actions
set = p.getActions();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(1);
+ assertNotNull(set);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
// Verify targets
set = p.getTargets();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(1);
+ assertNotNull(set);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("target1");
+ assertEquals("target1", entry);
// Verify parts
parts = p.getParts();
- assertThat(parts).hasSize(3);
+ assertEquals(3, parts.size());
set = parts.get(0);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("domain");
+ assertEquals("domain", entry);
set = parts.get(1);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
set = parts.get(2);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("target1");
+ assertEquals("target1", entry);
}
@Test
@@ -212,57 +214,57 @@ public class DomainPermissionTest {
p = new DomainPermission("action1,action2,action3", "target1,target2,target3");
// Verify domain
- assertThat(p.getDomain()).isEqualTo("domain");
+ assertEquals("domain", p.getDomain());
// Verify actions
set = p.getActions();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(3);
+ assertNotNull(set);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action2");
+ assertEquals("action2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action3");
+ assertEquals("action3", entry);
// Verify targets
set = p.getTargets();
- assertThat(set).isNotNull();
- assertThat(set).hasSize(3);
+ assertNotNull(set);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("target1");
+ assertEquals("target1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("target2");
+ assertEquals("target2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("target3");
+ assertEquals("target3", entry);
// Verify parts
parts = p.getParts();
- assertThat(parts).hasSize(3);
+ assertEquals(3, parts.size());
set = parts.get(0);
- assertThat(set).hasSize(1);
+ assertEquals(1, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("domain");
+ assertEquals("domain", entry);
set = parts.get(1);
- assertThat(set).hasSize(3);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("action1");
+ assertEquals("action1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action2");
+ assertEquals("action2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("action3");
+ assertEquals("action3", entry);
set = parts.get(2);
- assertThat(set).hasSize(3);
+ assertEquals(3, set.size());
iterator = set.iterator();
entry = iterator.next();
- assertThat(entry).isEqualTo("target1");
+ assertEquals("target1", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("target2");
+ assertEquals("target2", entry);
entry = iterator.next();
- assertThat(entry).isEqualTo("target3");
+ assertEquals("target3", entry);
}
}
diff --git a/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
index 54dd8cdc8..4e4b151e4 100644
--- a/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
@@ -20,48 +20,50 @@ package org.apache.shiro.authz.permission;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class WildcardPermissionResolverTest {
@Test
void testDefaultIsNonCaseSensitive() {
WildcardPermissionResolver resolver = new WildcardPermissionResolver();
- assertThat(resolver.isCaseSensitive()).as("Default sensitivity should be false").isFalse();
+ assertFalse(resolver.isCaseSensitive(), "Default sensitivity should be false");
/* this is a round-about test as permissions don't store case sensitivity just lower case
the string. */
WildcardPermission permission = (WildcardPermission) resolver.resolvePermission("Foo:*");
- assertThat(permission.toString()).as("string should be lowercase").isEqualTo("foo:*");
+ assertEquals("foo:*", permission.toString(), "string should be lowercase");
}
@Test
void testCaseSensitive() {
WildcardPermissionResolver resolver = new WildcardPermissionResolver(true);
- assertThat(resolver.isCaseSensitive()).as("Sensitivity should be true").isTrue();
+ assertTrue(resolver.isCaseSensitive(), "Sensitivity should be true");
/* this is a round-about test as permissions don't store case sensitivity just lower case
the string. */
WildcardPermission permission = (WildcardPermission) resolver.resolvePermission("Foo:*");
- assertThat(permission.toString()).as("string should be mixed case").isEqualTo("Foo:*");
+ assertEquals("Foo:*", permission.toString(), "string should be mixed case");
}
@Test
void testCaseInsensitive() {
WildcardPermissionResolver resolver = new WildcardPermissionResolver(false);
- assertThat(resolver.isCaseSensitive()).as("Sensitivity should be false").isFalse();
+ assertFalse(resolver.isCaseSensitive(), "Sensitivity should be false");
/* this is a round-about test as permissions don't store case sensitivity just lower case
the string. */
WildcardPermission permission = (WildcardPermission) resolver.resolvePermission("Foo:*");
- assertThat(permission.toString()).as("string should be lowercase").isEqualTo("foo:*");
+ assertEquals("foo:*", permission.toString(), "string should be lowercase");
}
@Test
void testCaseSensitiveToggle() {
WildcardPermissionResolver resolver = new WildcardPermissionResolver();
- assertThat(resolver.isCaseSensitive()).as("Default sensitivity should be false").isFalse();
+ assertFalse(resolver.isCaseSensitive(), "Default sensitivity should be false");
resolver.setCaseSensitive(true);
- assertThat(resolver.isCaseSensitive()).as("Sensitivity should be true").isTrue();
+ assertTrue(resolver.isCaseSensitive(), "Sensitivity should be true");
resolver.setCaseSensitive(false);
- assertThat(resolver.isCaseSensitive()).as("Sensitivity should be false").isFalse();
+ assertFalse(resolver.isCaseSensitive(), "Sensitivity should be false");
}
}
diff --git a/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionTest.java b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionTest.java
index e1102c394..b7914b9c2 100644
--- a/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionTest.java
+++ b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionTest.java
@@ -20,8 +20,10 @@ package org.apache.shiro.authz.permission;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @since 0.9
@@ -30,28 +32,28 @@ public class WildcardPermissionTest {
@Test
void testNull() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
new WildcardPermission(null);
});
}
@Test
void testEmpty() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
new WildcardPermission("");
});
}
@Test
void testBlank() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
new WildcardPermission(" ");
});
}
@Test
void testOnlyDelimiters() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
new WildcardPermission("::,,::,:");
});
}
@@ -64,38 +66,38 @@ public class WildcardPermissionTest {
// Case insensitive, same
p1 = new WildcardPermission("something");
p2 = new WildcardPermission("something");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p2.implies(p1));
// Case insensitive, different case
p1 = new WildcardPermission("something");
p2 = new WildcardPermission("SOMETHING");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p2.implies(p1));
// Case insensitive, different word
p1 = new WildcardPermission("something");
p2 = new WildcardPermission("else");
- assertThat(p1.implies(p2)).isFalse();
- assertThat(p2.implies(p1)).isFalse();
+ assertFalse(p1.implies(p2));
+ assertFalse(p2.implies(p1));
// Case sensitive same
p1 = new WildcardPermission("BLAHBLAH", false);
p2 = new WildcardPermission("BLAHBLAH", false);
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p2.implies(p1));
// Case sensitive, different case
p1 = new WildcardPermission("BLAHBLAH", false);
p2 = new WildcardPermission("bLAHBLAH", false);
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p2.implies(p1));
// Case sensitive, different word
p1 = new WildcardPermission("BLAHBLAH", false);
p2 = new WildcardPermission("whatwhat", false);
- assertThat(p1.implies(p2)).isFalse();
- assertThat(p2.implies(p1)).isFalse();
+ assertFalse(p1.implies(p2));
+ assertFalse(p2.implies(p1));
}
@@ -106,36 +108,36 @@ public class WildcardPermissionTest {
p1 = new WildcardPermission("one,two");
p2 = new WildcardPermission("one");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isFalse();
+ assertTrue(p1.implies(p2));
+ assertFalse(p2.implies(p1));
p1 = new WildcardPermission("one,two,three");
p2 = new WildcardPermission("one,three");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isFalse();
+ assertTrue(p1.implies(p2));
+ assertFalse(p2.implies(p1));
p1 = new WildcardPermission("one,two:one,two,three");
p2 = new WildcardPermission("one:three");
p3 = new WildcardPermission("one:two,three");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isFalse();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p2.implies(p3)).isFalse();
- assertThat(p3.implies(p2)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertFalse(p2.implies(p1));
+ assertTrue(p1.implies(p3));
+ assertFalse(p2.implies(p3));
+ assertTrue(p3.implies(p2));
p1 = new WildcardPermission("one,two,three:one,two,three:one,two");
p2 = new WildcardPermission("one:three:two");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p2.implies(p1)).isFalse();
+ assertTrue(p1.implies(p2));
+ assertFalse(p2.implies(p1));
p1 = new WildcardPermission("one");
p2 = new WildcardPermission("one:two,three,four");
p3 = new WildcardPermission("one:two,three,four:five:six:seven");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p2.implies(p1)).isFalse();
- assertThat(p3.implies(p1)).isFalse();
- assertThat(p2.implies(p3)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertFalse(p2.implies(p1));
+ assertFalse(p3.implies(p1));
+ assertTrue(p2.implies(p3));
}
/**
@@ -146,7 +148,7 @@ public class WildcardPermissionTest {
WildcardPermission p6 = new WildcardPermission("one,two:three,four");
WildcardPermission p6DiffOrder = new WildcardPermission("two,one:four,three");
- assertThat(p6DiffOrder).isEqualTo(p6);
+ assertEquals(p6, p6DiffOrder);
}
@SuppressWarnings({"checkstyle:MultipleVariableDeclarations", "checkstyle:MethodLength"})
@@ -159,10 +161,10 @@ public class WildcardPermissionTest {
p3 = new WildcardPermission("one:two");
p4 = new WildcardPermission("one,two:three,four");
p5 = new WildcardPermission("one,two:three,four,five:six:seven,eight");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
- assertThat(p1.implies(p5)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
+ assertTrue(p1.implies(p5));
p1 = new WildcardPermission("newsletter:*");
p2 = new WildcardPermission("newsletter:read");
@@ -173,45 +175,45 @@ public class WildcardPermissionTest {
p7 = new WildcardPermission("newsletter:write:*");
p8 = new WildcardPermission("newsletter:read,write:*");
p9 = new WildcardPermission("newsletter");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
- assertThat(p1.implies(p5)).isTrue();
- assertThat(p1.implies(p6)).isTrue();
- assertThat(p1.implies(p7)).isTrue();
- assertThat(p1.implies(p8)).isTrue();
- assertThat(p1.implies(p9)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
+ assertTrue(p1.implies(p5));
+ assertTrue(p1.implies(p6));
+ assertTrue(p1.implies(p7));
+ assertTrue(p1.implies(p8));
+ assertTrue(p1.implies(p9));
p1 = new WildcardPermission("newsletter:*:*");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
- assertThat(p1.implies(p5)).isTrue();
- assertThat(p1.implies(p6)).isTrue();
- assertThat(p1.implies(p7)).isTrue();
- assertThat(p1.implies(p8)).isTrue();
- assertThat(p1.implies(p9)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
+ assertTrue(p1.implies(p5));
+ assertTrue(p1.implies(p6));
+ assertTrue(p1.implies(p7));
+ assertTrue(p1.implies(p8));
+ assertTrue(p1.implies(p9));
p1 = new WildcardPermission("newsletter:*:*:*");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
- assertThat(p1.implies(p5)).isTrue();
- assertThat(p1.implies(p6)).isTrue();
- assertThat(p1.implies(p7)).isTrue();
- assertThat(p1.implies(p8)).isTrue();
- assertThat(p1.implies(p9)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
+ assertTrue(p1.implies(p5));
+ assertTrue(p1.implies(p6));
+ assertTrue(p1.implies(p7));
+ assertTrue(p1.implies(p8));
+ assertTrue(p1.implies(p9));
p1 = new WildcardPermission("newsletter");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
- assertThat(p1.implies(p5)).isTrue();
- assertThat(p1.implies(p6)).isTrue();
- assertThat(p1.implies(p7)).isTrue();
- assertThat(p1.implies(p8)).isTrue();
- assertThat(p1.implies(p9)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
+ assertTrue(p1.implies(p5));
+ assertTrue(p1.implies(p6));
+ assertTrue(p1.implies(p7));
+ assertTrue(p1.implies(p8));
+ assertTrue(p1.implies(p9));
p1 = new WildcardPermission("newsletter:*:read");
p2 = new WildcardPermission("newsletter:123:read");
@@ -219,15 +221,15 @@ public class WildcardPermissionTest {
p4 = new WildcardPermission("newsletter:read");
p5 = new WildcardPermission("newsletter:read,write");
p6 = new WildcardPermission("newsletter:123:read:write");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isFalse();
- assertThat(p1.implies(p4)).isFalse();
- assertThat(p1.implies(p5)).isFalse();
- assertThat(p1.implies(p6)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertFalse(p1.implies(p3));
+ assertFalse(p1.implies(p4));
+ assertFalse(p1.implies(p5));
+ assertTrue(p1.implies(p6));
p1 = new WildcardPermission("newsletter:*:read:*");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p6)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p6));
}
@@ -239,16 +241,16 @@ public class WildcardPermissionTest {
WildcardPermission p4 = new WildcardPermission("one,two:three,four");
WildcardPermission p5 = new WildcardPermission("one,two:three,four,five:six:seven,eight");
- assertThat(p1.toString()).isEqualTo("*");
- assertThat(new WildcardPermission(p1.toString())).isEqualTo(p1);
- assertThat(p2.toString()).isEqualTo("one");
- assertThat(new WildcardPermission(p2.toString())).isEqualTo(p2);
- assertThat(p3.toString()).isEqualTo("one:two");
- assertThat(new WildcardPermission(p3.toString())).isEqualTo(p3);
- assertThat(p4.toString()).isEqualTo("one,two:three,four");
- assertThat(new WildcardPermission(p4.toString())).isEqualTo(p4);
- assertThat(p5.toString()).isEqualTo("one,two:three,four,five:six:seven,eight");
- assertThat(new WildcardPermission(p5.toString())).isEqualTo(p5);
+ assertEquals("*", p1.toString());
+ assertEquals(p1, new WildcardPermission(p1.toString()));
+ assertEquals("one", p2.toString());
+ assertEquals(p2, new WildcardPermission(p2.toString()));
+ assertEquals("one:two", p3.toString());
+ assertEquals(p3, new WildcardPermission(p3.toString()));
+ assertEquals("one,two:three,four", p4.toString());
+ assertEquals(p4, new WildcardPermission(p4.toString()));
+ assertEquals("one,two:three,four,five:six:seven,eight", p5.toString());
+ assertEquals(p5, new WildcardPermission(p5.toString()));
}
@SuppressWarnings("checkstyle:MultipleVariableDeclarations")
@@ -261,20 +263,20 @@ public class WildcardPermissionTest {
p3 = new WildcardPermission("one:*:*");
p4 = new WildcardPermission("one:read");
- assertThat(p1.implies(p2)).isTrue();
- assertThat(p1.implies(p3)).isTrue();
- assertThat(p1.implies(p4)).isTrue();
+ assertTrue(p1.implies(p2));
+ assertTrue(p1.implies(p3));
+ assertTrue(p1.implies(p4));
- assertThat(p2.implies(p1)).isTrue();
- assertThat(p2.implies(p3)).isTrue();
- assertThat(p2.implies(p4)).isTrue();
+ assertTrue(p2.implies(p1));
+ assertTrue(p2.implies(p3));
+ assertTrue(p2.implies(p4));
- assertThat(p3.implies(p1)).isTrue();
- assertThat(p3.implies(p2)).isTrue();
- assertThat(p3.implies(p4)).isTrue();
+ assertTrue(p3.implies(p1));
+ assertTrue(p3.implies(p2));
+ assertTrue(p3.implies(p4));
- assertThat(p4.implies(p1)).isFalse();
- assertThat(p4.implies(p2)).isFalse();
- assertThat(p4.implies(p3)).isFalse();
+ assertFalse(p4.implies(p1));
+ assertFalse(p4.implies(p2));
+ assertFalse(p4.implies(p3));
}
}
diff --git a/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java b/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java
index 38dc828a5..7147dc48b 100644
--- a/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java
+++ b/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java
@@ -25,7 +25,7 @@ import org.mockito.ArgumentCaptor;
import java.util.concurrent.Executor;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -49,6 +49,6 @@ public class SubjectAwareExecutorTest extends SecurityManagerTestSupport {
ArgumentCaptor<SubjectRunnable> subjectRunnableArgumentCaptor = ArgumentCaptor.forClass(SubjectRunnable.class);
verify(targetMockExecutor).execute(subjectRunnableArgumentCaptor.capture());
SubjectRunnable subjectRunnable = subjectRunnableArgumentCaptor.getValue();
- assertThat(subjectRunnable).isNotNull();
+ assertNotNull(subjectRunnable);
}
}
diff --git a/core/src/test/java/org/apache/shiro/jndi/JndiObjectFactoryTest.java b/core/src/test/java/org/apache/shiro/jndi/JndiObjectFactoryTest.java
index 092e19105..737b46e99 100644
--- a/core/src/test/java/org/apache/shiro/jndi/JndiObjectFactoryTest.java
+++ b/core/src/test/java/org/apache/shiro/jndi/JndiObjectFactoryTest.java
@@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test;
import javax.naming.NamingException;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* This test makes the assumption that {@link JndiLocator} is tested elsewhere and only makes an attempt to test the
@@ -37,8 +37,8 @@ public class JndiObjectFactoryTest {
JndiObjectFactory<String> underTest = new JndiObjectFactory<String>() {
@Override
protected Object lookup(String jndiName, Class requiredType) throws NamingException {
- assertThat(jndiName).isEqualTo(name);
- assertThat(requiredType).isEqualTo(String.class);
+ assertEquals(name, jndiName);
+ assertEquals(String.class, requiredType);
return new String(returnValue);
}
};
@@ -46,7 +46,7 @@ public class JndiObjectFactoryTest {
underTest.setRequiredType(String.class);
underTest.setResourceName(name);
- assertThat(underTest.getInstance()).isEqualTo(returnValue);
+ assertEquals(returnValue, underTest.getInstance());
}
@Test
@@ -56,19 +56,19 @@ public class JndiObjectFactoryTest {
JndiObjectFactory<String> underTest = new JndiObjectFactory<String>() {
@Override
protected Object lookup(String jndiName) throws NamingException {
- assertThat(jndiName).isEqualTo(name);
+ assertEquals(name, jndiName);
return new String(returnValue);
}
};
underTest.setResourceName(name);
- assertThat(underTest.getInstance()).isEqualTo(returnValue);
+ assertEquals(returnValue, underTest.getInstance());
}
@Test
void testJndiLookupFailsWithType() throws Exception {
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
final String name = "my/jndi/resource";
JndiObjectFactory<String> underTest = new JndiObjectFactory<String>() {
@Override
@@ -86,7 +86,7 @@ public class JndiObjectFactoryTest {
@Test
void testJndiLookupFailsNoType() throws Exception {
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
final String name = "my/jndi/resource";
JndiObjectFactory<String> underTest = new JndiObjectFactory<String>() {
@Override
diff --git a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java
index 740515642..ec14a8298 100644
--- a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java
@@ -24,7 +24,7 @@ import org.apache.shiro.subject.SubjectContext;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test cases for the {@link AbstractRememberMeManager} implementation.
@@ -43,7 +43,7 @@ public class AbstractRememberMeManagerTest {
//Since the dummy's getRememberedSerializedIdentity implementation returns an empty byte
//array, we should be ok:
PrincipalCollection principals = rmm.getRememberedPrincipals(new DefaultSubjectContext());
- assertThat(principals).isNull();
+ assertNull(principals);
//try with a null return value too:
rmm = new DummyRememberMeManager() {
@@ -53,7 +53,7 @@ public class AbstractRememberMeManagerTest {
}
};
principals = rmm.getRememberedPrincipals(new DefaultSubjectContext());
- assertThat(principals).isNull();
+ assertNull(principals);
}
@SuppressWarnings("checkstyle:FinalClass")
diff --git a/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java b/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
index f2a4b5d0f..161e8db28 100644
--- a/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
@@ -37,9 +37,12 @@ import org.junit.jupiter.api.Test;
import java.io.Serializable;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @since 0.2
@@ -72,19 +75,19 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
AuthenticationToken token = new UsernamePasswordToken("guest", "guest");
subject.login(token);
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("guest");
- assertThat(subject.hasRole("guest")).isTrue();
+ assertTrue(subject.isAuthenticated());
+ assertEquals("guest", subject.getPrincipal());
+ assertTrue(subject.hasRole("guest"));
Session session = subject.getSession();
session.setAttribute("key", "value");
- assertThat(session.getAttribute("key")).isEqualTo("value");
+ assertEquals("value", session.getAttribute("key"));
subject.logout();
- assertThat(subject.getSession(false)).isNull();
- assertThat(subject.getPrincipal()).isNull();
- assertThat(subject.getPrincipals()).isNull();
+ assertNull(subject.getSession(false));
+ assertNull(subject.getPrincipal());
+ assertNull(subject.getPrincipals());
}
/**
@@ -100,7 +103,7 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
String key = "foo";
String value1 = "bar";
session.setAttribute(key, value1);
- assertThat(session.getAttribute(key)).isEqualTo(value1);
+ assertEquals(value1, session.getAttribute(key));
//now test auto creation:
session.setTimeout(50);
@@ -127,35 +130,35 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
AuthenticationToken token = new UsernamePasswordToken("guest", "guest");
subject.login(token);
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("guest");
- assertThat(subject.hasRole("guest")).isTrue();
+ assertTrue(subject.isAuthenticated());
+ assertEquals("guest", subject.getPrincipal());
+ assertTrue(subject.hasRole("guest"));
Session session = subject.getSession();
Serializable firstSessionId = session.getId();
session.setAttribute("key", "value");
- assertThat(session.getAttribute("key")).isEqualTo("value");
+ assertEquals("value", session.getAttribute("key"));
subject.logout();
- assertThat(subject.getSession(false)).isNull();
- assertThat(subject.getPrincipal()).isNull();
- assertThat(subject.getPrincipals()).isNull();
+ assertNull(subject.getSession(false));
+ assertNull(subject.getPrincipal());
+ assertNull(subject.getPrincipals());
subject.login(new UsernamePasswordToken("lonestarr", "vespa"));
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("lonestarr");
- assertThat(subject.hasRole("goodguy")).isTrue();
+ assertTrue(subject.isAuthenticated());
+ assertEquals("lonestarr", subject.getPrincipal());
+ assertTrue(subject.hasRole("goodguy"));
- assertThat(subject.getSession()).isNotNull();
- assertThat(subject.getSession().getId()).isNotEqualTo(firstSessionId);
+ assertNotNull(subject.getSession());
+ assertNotEquals(firstSessionId, subject.getSession().getId());
subject.logout();
- assertThat(subject.getSession(false)).isNull();
- assertThat(subject.getPrincipal()).isNull();
- assertThat(subject.getPrincipals()).isNull();
+ assertNull(subject.getSession(false));
+ assertNull(subject.getPrincipal());
+ assertNull(subject.getPrincipals());
}
@@ -173,7 +176,7 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
try {
SecurityUtils.getSecurityManager();
} catch (UnavailableSecurityManagerException e) {
- assertThat(e.getMessage()).startsWith("No SecurityManager accessible");
+ assertTrue(e.getMessage().startsWith("No SecurityManager accessible"));
}
// Specify sm to use and build subject with
@@ -183,7 +186,7 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
// Login and verify specified sm is used and no error thrown
AuthenticationToken token = new UsernamePasswordToken("guest", "guest");
subject.login(token);
- assertThat(subject.getSecurityManager()).isEqualTo(sm);
+ assertEquals(sm, subject.getSecurityManager());
}
@Test
@@ -191,6 +194,6 @@ public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
SimplePrincipalCollection principals = new SimplePrincipalCollection("guest", "asd");
Subject subject = new Subject.Builder().principals(principals).sessionCreationEnabled(false).buildSubject();
- assertThat(subject.getPrincipal()).isEqualTo("guest");
+ assertEquals(subject.getPrincipal(), "guest");
}
}
diff --git a/core/src/test/java/org/apache/shiro/mgt/VMSingletonDefaultSecurityManagerTest.java b/core/src/test/java/org/apache/shiro/mgt/VMSingletonDefaultSecurityManagerTest.java
index adc79fb0a..f0c149545 100644
--- a/core/src/test/java/org/apache/shiro/mgt/VMSingletonDefaultSecurityManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/mgt/VMSingletonDefaultSecurityManagerTest.java
@@ -29,7 +29,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -62,12 +63,12 @@ public class VMSingletonDefaultSecurityManagerTest {
AuthenticationToken token = new UsernamePasswordToken("guest", "guest");
subject.login(token);
subject.getSession().setAttribute("key", "value");
- assertThat(subject.getSession().getAttribute("key")).isEqualTo("value");
+ assertEquals("value", subject.getSession().getAttribute("key"));
subject = SecurityUtils.getSubject();
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.getSession().getAttribute("key")).isEqualTo("value");
+ assertTrue(subject.isAuthenticated());
+ assertEquals("value", subject.getSession().getAttribute("key"));
} finally {
sm.destroy();
//SHIRO-270:
diff --git a/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java b/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java
index 83b35c7b2..c1cd5f8cf 100644
--- a/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java
@@ -26,10 +26,6 @@ import java.util.List;
import java.util.Set;
import org.apache.shiro.authc.AuthenticationException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAccount;
@@ -49,6 +45,11 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -81,20 +82,20 @@ public class AuthorizingRealmTest {
void testDefaultConfig() {
AuthenticationInfo info = realm.getAuthenticationInfo(new UsernamePasswordToken(USERNAME, PASSWORD, localhost));
- assertThat(info).isNotNull();
- assertThat(realm.hasRole(info.getPrincipals(), ROLE)).isTrue();
+ assertNotNull(info);
+ assertTrue(realm.hasRole(info.getPrincipals(), ROLE));
Object principal = info.getPrincipals().getPrimaryPrincipal();
- assertThat(principal instanceof UserIdPrincipal).isTrue();
+ assertTrue(principal instanceof UserIdPrincipal);
UsernamePrincipal usernamePrincipal = info.getPrincipals().oneByType(UsernamePrincipal.class);
- assertThat(usernamePrincipal.getUsername()).isEqualTo(USERNAME);
+ assertEquals(USERNAME, usernamePrincipal.getUsername());
UserIdPrincipal userIdPrincipal = info.getPrincipals().oneByType(UserIdPrincipal.class);
- assertThat(userIdPrincipal.getUserId()).isEqualTo(USER_ID);
+ assertEquals(USER_ID, userIdPrincipal.getUserId());
String stringPrincipal = info.getPrincipals().oneByType(String.class);
- assertThat(stringPrincipal).isEqualTo(USER_ID + USERNAME);
+ assertEquals(USER_ID + USERNAME, stringPrincipal);
}
@Test
@@ -110,11 +111,11 @@ public class AuthorizingRealmTest {
};
AuthenticationInfo info = realm.getAuthenticationInfo(new UsernamePasswordToken(USERNAME, PASSWORD, localhost));
- assertThat(info).isNotNull();
- assertThat(realm.hasRole(info.getPrincipals(), ROLE)).isTrue();
+ assertNotNull(info);
+ assertTrue(realm.hasRole(info.getPrincipals(), ROLE));
Object principal = info.getPrincipals().getPrimaryPrincipal();
- assertThat(principal instanceof UsernamePrincipal).isTrue();
- assertThat(((UsernamePrincipal) principal).getUsername()).isEqualTo(USERNAME);
+ assertTrue(principal instanceof UsernamePrincipal);
+ assertEquals(USERNAME, ((UsernamePrincipal) principal).getUsername());
}
@@ -147,7 +148,7 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
thrown = false;
try {
@@ -155,7 +156,7 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
thrown = false;
try {
@@ -163,7 +164,7 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
thrown = false;
try {
@@ -171,7 +172,7 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
thrown = false;
try {
@@ -179,7 +180,7 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
thrown = false;
try {
@@ -187,17 +188,17 @@ public class AuthorizingRealmTest {
} catch (UnauthorizedException e) {
thrown = true;
}
- assertThat(thrown).isTrue();
+ assertTrue(thrown);
- assertThat(realm.hasAllRoles(pCollection, roleList)).isFalse();
- assertThat(realm.hasRole(pCollection, "role1")).isFalse();
+ assertFalse(realm.hasAllRoles(pCollection, roleList));
+ assertFalse(realm.hasRole(pCollection, "role1"));
assertArrayEquals(new boolean[] {false, false}, realm.hasRoles(pCollection, roleList));
- assertThat(realm.isPermitted(pCollection, "perm1")).isFalse();
- assertThat(realm.isPermitted(pCollection, new WildcardPermission("perm1"))).isFalse();
+ assertFalse(realm.isPermitted(pCollection, "perm1"));
+ assertFalse(realm.isPermitted(pCollection, new WildcardPermission("perm1")));
assertArrayEquals(new boolean[] {false, false}, realm.isPermitted(pCollection, "perm1", "perm2"));
assertArrayEquals(new boolean[] {false, false}, realm.isPermitted(pCollection, permList));
- assertThat(realm.isPermittedAll(pCollection, "perm1", "perm2")).isFalse();
- assertThat(realm.isPermittedAll(pCollection, permList)).isFalse();
+ assertFalse(realm.isPermittedAll(pCollection, "perm1", "perm2"));
+ assertFalse(realm.isPermittedAll(pCollection, permList));
}
@Test
@@ -218,11 +219,11 @@ public class AuthorizingRealmTest {
}
});
- assertThat(realm.hasRole(pCollection, ROLE)).isTrue();
- assertThat(realm.isPermitted(pCollection, ROLE + ":perm1")).isTrue();
- assertThat(realm.isPermitted(pCollection, ROLE + ":perm2")).isTrue();
- assertThat(realm.isPermitted(pCollection, ROLE + ":perm3")).isFalse();
- assertThat(realm.isPermitted(pCollection, "other:bar:foo")).isTrue();
+ assertTrue(realm.hasRole(pCollection, ROLE));
+ assertTrue(realm.isPermitted(pCollection, ROLE + ":perm1"));
+ assertTrue(realm.isPermitted(pCollection, ROLE + ":perm2"));
+ assertFalse(realm.isPermitted(pCollection, ROLE + ":perm3"));
+ assertTrue(realm.isPermitted(pCollection, "other:bar:foo"));
}
@Test
@@ -247,13 +248,13 @@ public class AuthorizingRealmTest {
realm.setPermissionResolver(new WildcardPermissionResolver());
SimpleAuthorizationInfo authorizationInfo = (SimpleAuthorizationInfo) realm.getAuthorizationInfo(pCollection);
- assertThat(authorizationInfo).isNotNull();
+ assertNotNull(authorizationInfo);
authorizationInfo.addStringPermission("");
authorizationInfo.addStringPermission(" ");
authorizationInfo.addStringPermission("\t");
authorizationInfo.addStringPermission(null);
Collection<Permission> permissions = realm.getPermissions(authorizationInfo);
- assertThat(permissions).hasSize(4);
+ assertEquals(4, permissions.size());
}
private void assertArrayEquals(boolean[] expected, boolean[] actual) {
diff --git a/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java b/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java
index 79a30d5a9..09ee8aaed 100644
--- a/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java
@@ -52,15 +52,20 @@ import javax.naming.ldap.LdapContext;
import java.util.HashSet;
import java.util.Set;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.is;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Simple test case for ActiveDirectoryRealm.
@@ -100,17 +105,17 @@ public class ActiveDirectoryRealmTest {
String localhost = "localhost";
Subject subject = SecurityUtils.getSubject();
subject.login(new UsernamePasswordToken(USERNAME, PASSWORD, localhost));
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.hasRole(ROLE)).isTrue();
+ assertTrue(subject.isAuthenticated());
+ assertTrue(subject.hasRole(ROLE));
UsernamePrincipal usernamePrincipal = subject.getPrincipals().oneByType(UsernamePrincipal.class);
- assertThat(usernamePrincipal.getUsername()).isEqualTo(USERNAME);
+ assertEquals(USERNAME, usernamePrincipal.getUsername());
UserIdPrincipal userIdPrincipal = subject.getPrincipals().oneByType(UserIdPrincipal.class);
- assertThat(userIdPrincipal.getUserId()).isEqualTo(USER_ID);
+ assertEquals(USER_ID, userIdPrincipal.getUserId());
- assertThat(realm.hasRole(subject.getPrincipals(), ROLE)).isTrue();
+ assertTrue(realm.hasRole(subject.getPrincipals(), ROLE));
subject.logout();
}
@@ -150,8 +155,8 @@ public class ActiveDirectoryRealmTest {
});
Object[] args = captureArgs.getValue();
- assertThat(args).hasSize(1);
- assertThat(args[0]).isEqualTo(expectedPrincipalName);
+ assertThat(args, arrayWithSize(1));
+ assertThat(args[0], is(expectedPrincipalName));
}
public static class TestActiveDirectoryRealm extends ActiveDirectoryRealm {
diff --git a/core/src/test/java/org/apache/shiro/realm/jdbc/JDBCRealmTest.java b/core/src/test/java/org/apache/shiro/realm/jdbc/JDBCRealmTest.java
index c04443d11..a3938f3a4 100644
--- a/core/src/test/java/org/apache/shiro/realm/jdbc/JDBCRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/jdbc/JDBCRealmTest.java
@@ -47,8 +47,9 @@ import java.sql.Statement;
import java.util.HashMap;
import java.util.Optional;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -261,7 +262,7 @@ public class JDBCRealmTest {
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, plainTextPassword);
currentUser.login(token);
- assertThat(currentUser.hasRole(testRole)).isTrue();
+ assertTrue(currentUser.hasRole(testRole));
}
@Test
@@ -275,7 +276,7 @@ public class JDBCRealmTest {
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, plainTextPassword);
currentUser.login(token);
- assertThat(currentUser.hasRole("Game Overall Director")).isFalse();
+ assertFalse(currentUser.hasRole("Game Overall Director"));
}
@Test
@@ -290,7 +291,7 @@ public class JDBCRealmTest {
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, plainTextPassword);
currentUser.login(token);
- assertThat(currentUser.isPermitted(testPermissionString)).isTrue();
+ assertTrue(currentUser.isPermitted(testPermissionString));
}
@Test
@@ -305,7 +306,7 @@ public class JDBCRealmTest {
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, plainTextPassword);
currentUser.login(token);
- assertThat(currentUser.isPermitted("testDomain:testTarget:specialAction")).isFalse();
+ assertFalse(currentUser.isPermitted("testDomain:testTarget:specialAction"));
}
/**
diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java
index f2ab25f5d..6e4d5146f 100644
--- a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java
@@ -29,8 +29,6 @@ import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
import java.util.UUID;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.eq;
@@ -38,6 +36,9 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the {@link DefaultLdapRealm} class.
@@ -61,28 +62,28 @@ public class DefaultLdapRealmTest {
@Test
void testDefaultInstance() {
- assertThat(realm.getCredentialsMatcher() instanceof AllowAllCredentialsMatcher).isTrue();
- assertThat(realm.getAuthenticationTokenClass()).isEqualTo(AuthenticationToken.class);
- assertThat(realm.getContextFactory() instanceof JndiLdapContextFactory).isTrue();
+ assertTrue(realm.getCredentialsMatcher() instanceof AllowAllCredentialsMatcher);
+ assertEquals(AuthenticationToken.class, realm.getAuthenticationTokenClass());
+ assertTrue(realm.getContextFactory() instanceof JndiLdapContextFactory);
}
@Test
void testSetUserDnTemplateNull() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
realm.setUserDnTemplate(null);
});
}
@Test
void testSetUserDnTemplateEmpty() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
realm.setUserDnTemplate(" ");
});
}
@Test
void testSetUserDnTemplateWithoutToken() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
realm.setUserDnTemplate("uid=,ou=users,dc=mycompany,dc=com");
});
}
@@ -91,7 +92,7 @@ public class DefaultLdapRealmTest {
void testUserDnTemplate() {
String template = "uid={0},ou=users,dc=mycompany,dc=com";
realm.setUserDnTemplate(template);
- assertThat(realm.getUserDnTemplate()).isEqualTo(template);
+ assertEquals(template, realm.getUserDnTemplate());
}
@Test
@@ -112,7 +113,7 @@ public class DefaultLdapRealmTest {
@Test
void testGetAuthenticationInfoNamingAuthenticationException() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
realm.setUserDnTemplate("uid={0},ou=users,dc=mycompany,dc=com");
LdapContextFactory factory = createMock(LdapContextFactory.class);
realm.setContextFactory(factory);
@@ -127,7 +128,7 @@ public class DefaultLdapRealmTest {
@Test
void testGetAuthenticationInfoNamingException() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
realm.setUserDnTemplate("uid={0},ou=users,dc=mycompany,dc=com");
LdapContextFactory factory = createMock(LdapContextFactory.class);
realm.setContextFactory(factory);
@@ -173,7 +174,7 @@ public class DefaultLdapRealmTest {
@Test
void testGetUserDnNullArgument() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
realm.getUserDn(null);
});
}
@@ -193,6 +194,6 @@ public class DefaultLdapRealmTest {
};
String principal = "foo";
String userDn = realm.getUserDn(principal);
- assertThat(userDn).isEqualTo(principal);
+ assertEquals(principal, userDn);
}
}
diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
index 0b554cb6e..98a86bc7e 100644
--- a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
@@ -30,9 +30,11 @@ import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createNiceMock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
@@ -62,7 +64,7 @@ public class JndiLdapContextFactoryTest {
*/
@Test
void testGetLdapContext() throws NamingException {
- assertThatExceptionOfType(NamingException.class).isThrownBy(() -> {
+ assertThrows(NamingException.class, () -> {
factory = new JndiLdapContextFactory();
//garbage URL to test that the context is being created, but fails:
String brokenHost = UUID.randomUUID().toString();
@@ -75,26 +77,26 @@ public class JndiLdapContextFactoryTest {
void testAuthenticationMechanism() {
String mech = "MD5-DIGEST";
factory.setAuthenticationMechanism(mech);
- assertThat(factory.getAuthenticationMechanism()).isEqualTo(mech);
+ assertEquals(mech, factory.getAuthenticationMechanism());
}
@Test
void testReferral() {
String referral = "throw";
factory.setReferral(referral);
- assertThat(factory.getReferral()).isEqualTo(referral);
+ assertEquals(referral, factory.getReferral());
}
@Test
void testGetContextFactoryClassName() {
- assertThat(factory.getContextFactoryClassName()).isEqualTo(JndiLdapContextFactory.DEFAULT_CONTEXT_FACTORY_CLASS_NAME);
+ assertEquals(JndiLdapContextFactory.DEFAULT_CONTEXT_FACTORY_CLASS_NAME, factory.getContextFactoryClassName());
}
@Test
void testSetEnvironmentPropertyNull() {
factory.setAuthenticationMechanism("MD5-DIGEST");
factory.setAuthenticationMechanism(null);
- assertThat(factory.getAuthenticationMechanism()).isNull();
+ assertNull(factory.getAuthenticationMechanism());
}
@Test
@@ -102,12 +104,12 @@ public class JndiLdapContextFactoryTest {
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
factory.setEnvironment(map);
- assertThat(factory.getEnvironment()).containsEntry("foo", "bar");
+ assertEquals("bar", factory.getEnvironment().get("foo"));
}
@Test
void testGetLdapContextWithoutUrl() throws NamingException {
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
factory.getLdapContext("foo", "bar");
});
}
@@ -117,11 +119,11 @@ public class JndiLdapContextFactoryTest {
factory = new JndiLdapContextFactory() {
@Override
protected LdapContext createLdapContext(Hashtable env) throws NamingException {
- assertThat(env).containsEntry(Context.PROVIDER_URL, "ldap://localhost:389");
- assertThat(env).containsEntry(Context.SECURITY_PRINCIPAL, "foo");
- assertThat(env).containsEntry(Context.SECURITY_CREDENTIALS, "bar");
- assertThat(env).containsEntry(Context.SECURITY_AUTHENTICATION, "simple");
- assertThat(env.get(SUN_CONNECTION_POOLING_PROPERTY)).isNull();
+ assertEquals("ldap://localhost:389", env.get(Context.PROVIDER_URL));
+ assertEquals("foo", env.get(Context.SECURITY_PRINCIPAL));
+ assertEquals("bar", env.get(Context.SECURITY_CREDENTIALS));
+ assertEquals("simple", env.get(Context.SECURITY_AUTHENTICATION));
+ assertNull(env.get(SUN_CONNECTION_POOLING_PROPERTY));
return createNiceMock(LdapContext.class);
}
};
@@ -136,11 +138,11 @@ public class JndiLdapContextFactoryTest {
factory = new JndiLdapContextFactory() {
@Override
protected LdapContext createLdapContext(Hashtable env) throws NamingException {
- assertThat(env).containsEntry(Context.PROVIDER_URL, "ldap://localhost:389");
- assertThat(env).containsEntry(Context.SECURITY_PRINCIPAL, "foo");
- assertThat(env).containsEntry(Context.SECURITY_CREDENTIALS, "bar");
- assertThat(env).containsEntry(Context.SECURITY_AUTHENTICATION, "simple");
- assertThat(env.get(SUN_CONNECTION_POOLING_PROPERTY)).isNull();
+ assertEquals("ldap://localhost:389", env.get(Context.PROVIDER_URL));
+ assertEquals("foo", env.get(Context.SECURITY_PRINCIPAL));
+ assertEquals("bar", env.get(Context.SECURITY_CREDENTIALS));
+ assertEquals("simple", env.get(Context.SECURITY_AUTHENTICATION));
+ assertNull(env.get(SUN_CONNECTION_POOLING_PROPERTY));
return createNiceMock(LdapContext.class);
}
};
@@ -154,11 +156,11 @@ public class JndiLdapContextFactoryTest {
factory = new JndiLdapContextFactory() {
@Override
protected LdapContext createLdapContext(Hashtable env) throws NamingException {
- assertThat(env).containsEntry(Context.PROVIDER_URL, "ldap://localhost:389");
- assertThat(env).containsEntry(Context.SECURITY_PRINCIPAL, "foo");
- assertThat(env).containsEntry(Context.SECURITY_CREDENTIALS, "bar");
- assertThat(env).containsEntry(Context.SECURITY_AUTHENTICATION, "simple");
- assertThat(env.get(SUN_CONNECTION_POOLING_PROPERTY)).isNotNull();
+ assertEquals("ldap://localhost:389", env.get(Context.PROVIDER_URL));
+ assertEquals("foo", env.get(Context.SECURITY_PRINCIPAL));
+ assertEquals("bar", env.get(Context.SECURITY_CREDENTIALS));
+ assertEquals("simple", env.get(Context.SECURITY_AUTHENTICATION));
+ assertNotNull(env.get(SUN_CONNECTION_POOLING_PROPERTY));
return createNiceMock(LdapContext.class);
}
};
@@ -174,11 +176,11 @@ public class JndiLdapContextFactoryTest {
factory = new JndiLdapContextFactory() {
@Override
protected LdapContext createLdapContext(Hashtable env) throws NamingException {
- assertThat(env).containsEntry(Context.PROVIDER_URL, "ldap://localhost:389");
- assertThat(env).containsEntry(Context.SECURITY_PRINCIPAL, "foo");
- assertThat(env).containsEntry(Context.SECURITY_CREDENTIALS, "bar");
- assertThat(env).containsEntry(Context.SECURITY_AUTHENTICATION, "simple");
- assertThat(env.get(SUN_CONNECTION_POOLING_PROPERTY)).isNull();
+ assertEquals("ldap://localhost:389", env.get(Context.PROVIDER_URL));
+ assertEquals("foo", env.get(Context.SECURITY_PRINCIPAL));
+ assertEquals("bar", env.get(Context.SECURITY_CREDENTIALS));
+ assertEquals("simple", env.get(Context.SECURITY_AUTHENTICATION));
+ assertNull(env.get(SUN_CONNECTION_POOLING_PROPERTY));
return createNiceMock(LdapContext.class);
}
};
@@ -192,7 +194,7 @@ public class JndiLdapContextFactoryTest {
@Test
void testEmptyStringCredentials() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
factory.setUrl("ldap://localhost:389");
factory.getLdapContext("jcoder", "");
});
@@ -200,7 +202,7 @@ public class JndiLdapContextFactoryTest {
@Test
void testEmptyCharArrayCredentials() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
factory.setUrl("ldap://localhost:389");
factory.getLdapContext("jcoder", new char[0]);
});
@@ -208,7 +210,7 @@ public class JndiLdapContextFactoryTest {
@Test
void testEmptyByteArrayCredentials() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
factory.setUrl("ldap://localhost:389");
factory.getLdapContext("jcoder", new byte[0]);
});
@@ -216,7 +218,7 @@ public class JndiLdapContextFactoryTest {
@Test
void testEmptyNullCredentials() throws NamingException {
- assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> {
+ assertThrows(AuthenticationException.class, () -> {
factory.setUrl("ldap://localhost:389");
factory.getLdapContext("jcoder", null);
});
diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java
index e2b36cef2..1426e8e8f 100644
--- a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java
@@ -20,7 +20,7 @@ package org.apache.shiro.realm.ldap;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for the {@link JndiLdapRealm} class.
@@ -51,6 +51,6 @@ public class JndiLdapRealmTest extends DefaultLdapRealmTest {
};
String principal = "foo";
String userDn = realm.getUserDn(principal);
- assertThat(userDn).isEqualTo(principal);
+ assertEquals(principal, userDn);
}
}
diff --git a/core/src/test/java/org/apache/shiro/realm/text/IniRealmTest.java b/core/src/test/java/org/apache/shiro/realm/text/IniRealmTest.java
index 970b1ca51..3ccb596ce 100644
--- a/core/src/test/java/org/apache/shiro/realm/text/IniRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/text/IniRealmTest.java
@@ -23,8 +23,9 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.Ini;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Unit tests for the {@link IniRealm} class.
@@ -45,7 +46,7 @@ public class IniRealmTest {
@Test
void testInitWithoutIniResource() {
- assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ assertThrows(IllegalStateException.class, () -> {
new IniRealm().init();
});
}
@@ -55,11 +56,11 @@ public class IniRealmTest {
IniRealm realm = new IniRealm();
realm.setResourcePath("classpath:org/apache/shiro/realm/text/IniRealmTest.simple.ini");
realm.init();
- assertThat(realm.roleExists("admin")).isTrue();
+ assertTrue(realm.roleExists("admin"));
UsernamePasswordToken token = new UsernamePasswordToken("user1", "user1");
AuthenticationInfo info = realm.getAuthenticationInfo(token);
- assertThat(info).isNotNull();
- assertThat(realm.hasRole(info.getPrincipals(), "admin")).isTrue();
+ assertNotNull(info);
+ assertTrue(realm.hasRole(info.getPrincipals(), "admin"));
}
@Test
@@ -67,6 +68,6 @@ public class IniRealmTest {
IniRealm realm = new IniRealm();
realm.setResourcePath("classpath:org/apache/shiro/realm/text/IniRealmTest.noUsers.ini");
realm.init();
- assertThat(realm.roleExists("admin")).isTrue();
+ assertTrue(realm.roleExists("admin"));
}
}
diff --git a/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java b/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java
index 3bf68ffda..a0d9e13cb 100644
--- a/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java
@@ -26,10 +26,9 @@ import org.junit.jupiter.api.Test;
import java.text.ParseException;
import java.util.Arrays;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
@SuppressWarnings("checkstyle:MagicNumber")
public class TextConfigurationRealmTest {
@@ -195,7 +194,7 @@ public class TextConfigurationRealmTest {
runnable.start();
Thread.sleep(500);
// No role until lock is released and role definitions are processed
- assertThat(realm.roleExists("role1")).as("role exists when it shouldn't").isFalse();
+ assertFalse(realm.roleExists("role1"), "role exists when it shouldn't");
} finally {
rolesLock.writeLock().unlock();
}
@@ -215,7 +214,7 @@ public class TextConfigurationRealmTest {
Thread testTask = new Thread(testThread);
realm.test(testTask);
testTask.join(500);
- assertThat(realm.roleExists("role1")).as("role doesn't exist when it should").isTrue();
+ assertTrue(realm.roleExists("role1"), "role doesn't exist when it should");
testThread.test();
}
@@ -233,7 +232,7 @@ public class TextConfigurationRealmTest {
runnable.start();
Thread.sleep(500);
// No account until lock is released and user definitions are processed
- assertThat(realm.accountExists("user1")).as("account exists when it shouldn't").isFalse();
+ assertFalse(realm.accountExists("user1"), "account exists when it shouldn't");
} finally {
usersLock.writeLock().unlock();
}
@@ -252,7 +251,7 @@ public class TextConfigurationRealmTest {
Thread testTask = new Thread(testThread);
realm.test(testTask);
testTask.join(500);
- assertThat(realm.accountExists("user1")).as("account doesn't exist when it should").isTrue();
+ assertTrue(realm.accountExists("user1"), "account doesn't exist when it should");
testThread.test();
}
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
index d49567c06..10f928467 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
@@ -32,7 +32,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit tests for the {@link org.apache.shiro.session.mgt.AbstractValidatingSessionManager} class.
@@ -90,7 +90,7 @@ public class AbstractValidatingSessionManagerTest {
sessionManager.setSessionListeners(Arrays.asList(sessionListener));
sessionManager.validateSessions();
- assertThat(expirationCount.intValue()).isEqualTo(1);
+ assertEquals(1, expirationCount.intValue());
}
@@ -125,7 +125,7 @@ public class AbstractValidatingSessionManagerTest {
sessionManager.setSessionListeners(Arrays.asList(sessionListener));
Session session = sessionManager.start(null);
- assertThat(sessionManager.getActiveSessions()).hasSize(1);
+ assertEquals(1, sessionManager.getActiveSessions().size());
session.setTimeout(0L);
//last access timestamp needs to be older than the current timestamp when validating, so ensure a delay:
@@ -133,6 +133,6 @@ public class AbstractValidatingSessionManagerTest {
sessionManager.validateSessions();
- assertThat(sessionManager.getActiveSessions()).isEmpty();
+ assertEquals(0, sessionManager.getActiveSessions().size());
}
}
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
index 443a57990..cc8628db2 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
@@ -33,8 +33,6 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
@@ -42,6 +40,10 @@ import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.reset;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit test for the {@link DefaultSessionManager DefaultSessionManager} implementation.
@@ -76,9 +78,9 @@ public class DefaultSessionManagerTest {
long timeout = 1000;
sm.setGlobalSessionTimeout(timeout);
Session session = sm.start(null);
- assertThat(session).isNotNull();
- assertThat(session.getId()).isNotNull();
- assertThat(timeout).isEqualTo(session.getTimeout());
+ assertNotNull(session);
+ assertNotNull(session.getId());
+ assertEquals(session.getTimeout(), timeout);
}
@Test
@@ -91,7 +93,7 @@ public class DefaultSessionManagerTest {
};
sm.getSessionListeners().add(listener);
sm.start(null);
- assertThat(started[0]).isTrue();
+ assertTrue(started[0]);
}
@Test
@@ -105,7 +107,7 @@ public class DefaultSessionManagerTest {
sm.getSessionListeners().add(listener);
Session session = sm.start(null);
sm.stop(new DefaultSessionKey(session.getId()));
- assertThat(stopped[0]).isTrue();
+ assertTrue(stopped[0]);
}
//asserts fix for SHIRO-388:
@@ -127,8 +129,8 @@ public class DefaultSessionManagerTest {
sm.stop(new DefaultSessionKey(session.getId()));
- assertThat(stopped[0]).isTrue();
- assertThat(value[0]).isEqualTo("bar");
+ assertTrue(stopped[0]);
+ assertEquals("bar", value[0]);
}
@SuppressWarnings("checkstyle:MagicNumber")
@@ -150,7 +152,7 @@ public class DefaultSessionManagerTest {
} catch (InvalidSessionException expected) {
//do nothing - expected.
}
- assertThat(expired[0]).isTrue();
+ assertTrue(expired[0]);
}
@SuppressWarnings("checkstyle:MagicNumber")
@@ -177,7 +179,7 @@ public class DefaultSessionManagerTest {
expectLastCall().anyTimes();
replay(sessionDAO);
Session session = sm.start(null);
- assertThat(session).isNotNull();
+ assertNotNull(session);
verify(sessionDAO);
reset(sessionDAO);
@@ -225,7 +227,7 @@ public class DefaultSessionManagerTest {
Session session = sessionManager.start(null);
// now sessionValidationScheduler should be enabled
- assertThat(sessionValidationScheduler.isEnabled()).as("sessionValidationScheduler was not enabled").isTrue();
+ assertTrue(sessionValidationScheduler.isEnabled(), "sessionValidationScheduler was not enabled");
} finally {
// cleanup after test
sessionManager.destroy();
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java b/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
index c65313244..15a3284ff 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
@@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
import java.io.Serializable;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit test for the {@link DelegatingSession} class.
@@ -62,10 +62,10 @@ public class DelegatingSessionTest {
@Test
void testTimeout() {
Serializable origId = session.getId();
- assertThat(session.getTimeout()).isEqualTo(AbstractSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT);
+ assertEquals(AbstractSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT, session.getTimeout());
session.touch();
session.setTimeout(100);
- assertThat(session.getTimeout()).isEqualTo(100);
+ assertEquals(100, session.getTimeout());
sleep(150);
try {
session.getTimeout();
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
index 0e3a09c96..bb2d4b3c4 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
@@ -23,7 +23,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("checkstyle:MagicNumber")
public class ExecutorServiceSessionValidationSchedulerTest {
@@ -48,8 +49,8 @@ public class ExecutorServiceSessionValidationSchedulerTest {
session.setTimeout(2000L);
defaultSessionManager.create(session);
Thread.sleep(5000L);
- assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
+ assertTrue(defaultSessionManager.getActiveSessions().isEmpty());
+ assertTrue(executorServiceSessionValidationScheduler.isEnabled());
}
@Test
@@ -60,19 +61,19 @@ public class ExecutorServiceSessionValidationSchedulerTest {
Thread.sleep(1000L);
session.stop();
Thread.sleep(3000L);
- assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
+ assertTrue(defaultSessionManager.getActiveSessions().isEmpty());
+ assertTrue(executorServiceSessionValidationScheduler.isEnabled());
}
@Test
void enableSessionValidation() throws InterruptedException {
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
+ assertTrue(executorServiceSessionValidationScheduler.isEnabled());
executorServiceSessionValidationScheduler.disableSessionValidation();
Thread.sleep(2000L);
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isFalse();
+ assertFalse(executorServiceSessionValidationScheduler.isEnabled());
executorServiceSessionValidationScheduler.enableSessionValidation();
Thread.sleep(2000L);
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
+ assertTrue(executorServiceSessionValidationScheduler.isEnabled());
}
@Test
@@ -89,8 +90,8 @@ public class ExecutorServiceSessionValidationSchedulerTest {
Thread.sleep(2000L);
session.stop();
Thread.sleep(2000L);
- assertThat(defaultSessionManager.getActiveSessions()).isNotEmpty();
- assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
+ assertFalse(defaultSessionManager.getActiveSessions().isEmpty());
+ assertTrue(executorServiceSessionValidationScheduler.isEnabled());
}
@AfterEach
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java b/core/src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java
index d1873cde1..c231cde55 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java
@@ -27,7 +27,8 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class SimpleSessionTest {
@@ -41,22 +42,22 @@ public class SimpleSessionTest {
SimpleSession deserialized = serializeAndDeserialize(session);
- assertThat(deserialized.getTimeout()).isEqualTo(timeout);
- assertThat(deserialized.getStartTimestamp()).isEqualTo(start);
- assertThat(deserialized.getLastAccessTime()).isEqualTo(lastAccess);
+ assertEquals(timeout, deserialized.getTimeout());
+ assertEquals(start, deserialized.getStartTimestamp());
+ assertEquals(lastAccess, deserialized.getLastAccessTime());
}
@Test
void serializeHost() throws IOException, ClassNotFoundException {
SimpleSession session = new SimpleSession("localhost");
- assertThat(serializeAndDeserialize(session).getHost()).isEqualTo("localhost");
+ assertEquals("localhost", serializeAndDeserialize(session).getHost());
}
@Test
void serializeExpired() throws IOException, ClassNotFoundException {
SimpleSession session = new SimpleSession();
session.setExpired(true);
- assertThat(serializeAndDeserialize(session).isExpired()).isTrue();
+ assertTrue(serializeAndDeserialize(session).isExpired());
}
private SimpleSession serializeAndDeserialize(SimpleSession session) throws IOException, ClassNotFoundException {
diff --git a/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java b/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java
index f02438956..c9dfcc6ce 100644
--- a/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java
+++ b/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java
@@ -36,8 +36,13 @@ import java.io.Serializable;
import java.util.concurrent.Callable;
import static org.apache.shiro.env.BasicIniEnvironment.INI_REALM_NAME;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @since Aug 1, 2008 2:11:17 PM
@@ -64,18 +69,18 @@ public class DelegatingSubjectTest {
Session session = subject.getSession();
session.setAttribute(key, value);
- assertThat(value).isEqualTo(session.getAttribute(key));
+ assertEquals(session.getAttribute(key), value);
Serializable firstSessionId = session.getId();
- assertThat(firstSessionId).isNotNull();
+ assertNotNull(firstSessionId);
session.stop();
session = subject.getSession();
- assertThat(session).isNotNull();
- assertThat(session.getAttribute(key)).isNull();
+ assertNotNull(session);
+ assertNull(session.getAttribute(key));
Serializable secondSessionId = session.getId();
- assertThat(secondSessionId).isNotNull();
- assertThat(secondSessionId).isNotEqualTo(firstSessionId);
+ assertNotNull(secondSessionId);
+ assertNotEquals(firstSessionId, secondSessionId);
subject.logout();
@@ -91,25 +96,25 @@ public class DelegatingSubjectTest {
PrincipalCollection identity = new SimplePrincipalCollection(username, "testRealm");
final Subject sourceSubject = new DelegatingSubject(identity, true, null, null, securityManager);
- assertThat(ThreadContext.getSubject()).isNull();
- assertThat(ThreadContext.getSecurityManager()).isNull();
+ assertNull(ThreadContext.getSubject());
+ assertNull(ThreadContext.getSecurityManager());
Callable<String> callable = new Callable<String>() {
public String call() throws Exception {
Subject callingSubject = SecurityUtils.getSubject();
- assertThat(callingSubject).isNotNull();
- assertThat(SecurityUtils.getSecurityManager()).isNotNull();
- assertThat(sourceSubject).isEqualTo(callingSubject);
+ assertNotNull(callingSubject);
+ assertNotNull(SecurityUtils.getSecurityManager());
+ assertEquals(callingSubject, sourceSubject);
return "Hello " + callingSubject.getPrincipal();
}
};
String response = sourceSubject.execute(callable);
- assertThat(response).isNotNull();
- assertThat(response).isEqualTo("Hello " + username);
+ assertNotNull(response);
+ assertEquals("Hello " + username, response);
- assertThat(ThreadContext.getSubject()).isNull();
- assertThat(ThreadContext.getSecurityManager()).isNull();
+ assertNull(ThreadContext.getSubject());
+ assertNull(ThreadContext.getSecurityManager());
}
@Test
@@ -121,21 +126,21 @@ public class DelegatingSubjectTest {
PrincipalCollection identity = new SimplePrincipalCollection(username, "testRealm");
final Subject sourceSubject = new DelegatingSubject(identity, true, null, null, securityManager);
- assertThat(ThreadContext.getSubject()).isNull();
- assertThat(ThreadContext.getSecurityManager()).isNull();
+ assertNull(ThreadContext.getSubject());
+ assertNull(ThreadContext.getSecurityManager());
Runnable runnable = new Runnable() {
public void run() {
Subject callingSubject = SecurityUtils.getSubject();
- assertThat(callingSubject).isNotNull();
- assertThat(SecurityUtils.getSecurityManager()).isNotNull();
- assertThat(sourceSubject).isEqualTo(callingSubject);
+ assertNotNull(callingSubject);
+ assertNotNull(SecurityUtils.getSecurityManager());
+ assertEquals(callingSubject, sourceSubject);
}
};
sourceSubject.execute(runnable);
- assertThat(ThreadContext.getSubject()).isNull();
- assertThat(ThreadContext.getSecurityManager()).isNull();
+ assertNull(ThreadContext.getSubject());
+ assertNull(ThreadContext.getSecurityManager());
}
@Test
@@ -152,66 +157,66 @@ public class DelegatingSubjectTest {
Subject subject = new Subject.Builder(sm).buildSubject();
subject.login(new UsernamePasswordToken("user1", "user1"));
- assertThat(subject.isRunAs()).isFalse();
- assertThat(subject.getPrincipal()).isEqualTo("user1");
- assertThat(subject.hasRole("role1")).isTrue();
- assertThat(subject.hasRole("role2")).isFalse();
- assertThat(subject.hasRole("role3")).isFalse();
+ assertFalse(subject.isRunAs());
+ assertEquals("user1", subject.getPrincipal());
+ assertTrue(subject.hasRole("role1"));
+ assertFalse(subject.hasRole("role2"));
+ assertFalse(subject.hasRole("role3"));
//no previous principals since we haven't called runAs yet
- assertThat(subject.getPreviousPrincipals()).isNull();
+ assertNull(subject.getPreviousPrincipals());
//runAs user2:
subject.runAs(new SimplePrincipalCollection("user2", INI_REALM_NAME));
- assertThat(subject.isRunAs()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("user2");
- assertThat(subject.hasRole("role2")).isTrue();
- assertThat(subject.hasRole("role1")).isFalse();
- assertThat(subject.hasRole("role3")).isFalse();
+ assertTrue(subject.isRunAs());
+ assertEquals("user2", subject.getPrincipal());
+ assertTrue(subject.hasRole("role2"));
+ assertFalse(subject.hasRole("role1"));
+ assertFalse(subject.hasRole("role3"));
//assert we still have the previous (user1) principals:
PrincipalCollection previous = subject.getPreviousPrincipals();
- assertThat(previous == null || previous.isEmpty()).isFalse();
- assertThat(previous.getPrimaryPrincipal()).isEqualTo("user1");
+ assertFalse(previous == null || previous.isEmpty());
+ assertEquals("user1", previous.getPrimaryPrincipal());
//test the stack functionality: While as user2, run as user3:
subject.runAs(new SimplePrincipalCollection("user3", INI_REALM_NAME));
- assertThat(subject.isRunAs()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("user3");
- assertThat(subject.hasRole("role3")).isTrue();
- assertThat(subject.hasRole("role1")).isFalse();
- assertThat(subject.hasRole("role2")).isFalse();
+ assertTrue(subject.isRunAs());
+ assertEquals("user3", subject.getPrincipal());
+ assertTrue(subject.hasRole("role3"));
+ assertFalse(subject.hasRole("role1"));
+ assertFalse(subject.hasRole("role2"));
//assert we still have the previous (user2) principals in the stack:
previous = subject.getPreviousPrincipals();
- assertThat(previous == null || previous.isEmpty()).isFalse();
- assertThat(previous.getPrimaryPrincipal()).isEqualTo("user2");
+ assertFalse(previous == null || previous.isEmpty());
+ assertEquals("user2", previous.getPrimaryPrincipal());
//drop down to user2:
subject.releaseRunAs();
//assert still run as:
- assertThat(subject.isRunAs()).isTrue();
- assertThat(subject.getPrincipal()).isEqualTo("user2");
- assertThat(subject.hasRole("role2")).isTrue();
- assertThat(subject.hasRole("role1")).isFalse();
- assertThat(subject.hasRole("role3")).isFalse();
+ assertTrue(subject.isRunAs());
+ assertEquals("user2", subject.getPrincipal());
+ assertTrue(subject.hasRole("role2"));
+ assertFalse(subject.hasRole("role1"));
+ assertFalse(subject.hasRole("role3"));
//assert we still have the previous (user1) principals:
previous = subject.getPreviousPrincipals();
- assertThat(previous == null || previous.isEmpty()).isFalse();
- assertThat(previous.getPrimaryPrincipal()).isEqualTo("user1");
+ assertFalse(previous == null || previous.isEmpty());
+ assertEquals("user1", previous.getPrimaryPrincipal());
//drop down to original user1:
subject.releaseRunAs();
//assert we're no longer runAs:
- assertThat(subject.isRunAs()).isFalse();
- assertThat(subject.getPrincipal()).isEqualTo("user1");
- assertThat(subject.hasRole("role1")).isTrue();
- assertThat(subject.hasRole("role2")).isFalse();
- assertThat(subject.hasRole("role3")).isFalse();
+ assertFalse(subject.isRunAs());
+ assertEquals("user1", subject.getPrincipal());
+ assertTrue(subject.hasRole("role1"));
+ assertFalse(subject.hasRole("role2"));
+ assertFalse(subject.hasRole("role3"));
//no previous principals in orig state
- assertThat(subject.getPreviousPrincipals()).isNull();
+ assertNull(subject.getPreviousPrincipals());
subject.logout();
@@ -234,8 +239,8 @@ public class DelegatingSubjectTest {
// then
final Session session = sourceSubject.getSession(true);
String sessionId = (String) session.getId();
- assertThat(subjectToString.contains(sessionId)).as("toString must not leak sessionId").isFalse();
- assertThat(subjectToString.contains(hostname)).as("toString must not leak host").isFalse();
+ assertFalse(subjectToString.contains(sessionId), "toString must not leak sessionId");
+ assertFalse(subjectToString.contains(hostname), "toString must not leak host");
}
}
diff --git a/core/src/test/java/org/apache/shiro/util/AntPathMatcherTests.java b/core/src/test/java/org/apache/shiro/util/AntPathMatcherTests.java
index c24908a12..b065a89cb 100644
--- a/core/src/test/java/org/apache/shiro/util/AntPathMatcherTests.java
+++ b/core/src/test/java/org/apache/shiro/util/AntPathMatcherTests.java
@@ -21,7 +21,9 @@ package org.apache.shiro.util;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("checkstyle:LineLength")
/**
@@ -39,182 +41,182 @@ public class AntPathMatcherTests {
@Test
void match() {
// test exact matching
- assertThat(pathMatcher.match("test", "test")).isTrue();
- assertThat(pathMatcher.match("/test", "/test")).isTrue();
- assertThat(pathMatcher.match("https://example.org", "https://example.org")).isTrue();
- assertThat(pathMatcher.match("/test.jpg", "test.jpg")).isFalse();
- assertThat(pathMatcher.match("test", "/test")).isFalse();
- assertThat(pathMatcher.match("/test", "test")).isFalse();
+ assertTrue(pathMatcher.match("test", "test"));
+ assertTrue(pathMatcher.match("/test", "/test"));
+ assertTrue(pathMatcher.match("https://example.org", "https://example.org"));
+ assertFalse(pathMatcher.match("/test.jpg", "test.jpg"));
+ assertFalse(pathMatcher.match("test", "/test"));
+ assertFalse(pathMatcher.match("/test", "test"));
// test matching with ?'s
- assertThat(pathMatcher.match("t?st", "test")).isTrue();
- assertThat(pathMatcher.match("??st", "test")).isTrue();
- assertThat(pathMatcher.match("tes?", "test")).isTrue();
- assertThat(pathMatcher.match("te??", "test")).isTrue();
- assertThat(pathMatcher.match("?es?", "test")).isTrue();
- assertThat(pathMatcher.match("tes?", "tes")).isFalse();
- assertThat(pathMatcher.match("tes?", "testt")).isFalse();
- assertThat(pathMatcher.match("tes?", "tsst")).isFalse();
+ assertTrue(pathMatcher.match("t?st", "test"));
+ assertTrue(pathMatcher.match("??st", "test"));
+ assertTrue(pathMatcher.match("tes?", "test"));
+ assertTrue(pathMatcher.match("te??", "test"));
+ assertTrue(pathMatcher.match("?es?", "test"));
+ assertFalse(pathMatcher.match("tes?", "tes"));
+ assertFalse(pathMatcher.match("tes?", "testt"));
+ assertFalse(pathMatcher.match("tes?", "tsst"));
// test matching with *'s
- assertThat(pathMatcher.match("*", "test")).isTrue();
- assertThat(pathMatcher.match("test*", "test")).isTrue();
- assertThat(pathMatcher.match("test*", "testTest")).isTrue();
- assertThat(pathMatcher.match("test/*", "test/Test")).isTrue();
- assertThat(pathMatcher.match("test/*", "test/t")).isTrue();
- assertThat(pathMatcher.match("test/*", "test/")).isTrue();
- assertThat(pathMatcher.match("*test*", "AnothertestTest")).isTrue();
- assertThat(pathMatcher.match("*test", "Anothertest")).isTrue();
- assertThat(pathMatcher.match("*.*", "test.")).isTrue();
- assertThat(pathMatcher.match("*.*", "test.test")).isTrue();
- assertThat(pathMatcher.match("*.*", "test.test.test")).isTrue();
- assertThat(pathMatcher.match("test*aaa", "testblaaaa")).isTrue();
- assertThat(pathMatcher.match("test*", "tst")).isFalse();
- assertThat(pathMatcher.match("test*", "tsttest")).isFalse();
- assertThat(pathMatcher.match("test*", "test/")).isFalse();
- assertThat(pathMatcher.match("test*", "test/t")).isFalse();
- assertThat(pathMatcher.match("test/*", "test")).isFalse();
- assertThat(pathMatcher.match("*test*", "tsttst")).isFalse();
- assertThat(pathMatcher.match("*test", "tsttst")).isFalse();
- assertThat(pathMatcher.match("*.*", "tsttst")).isFalse();
- assertThat(pathMatcher.match("test*aaa", "test")).isFalse();
- assertThat(pathMatcher.match("test*aaa", "testblaaab")).isFalse();
+ assertTrue(pathMatcher.match("*", "test"));
+ assertTrue(pathMatcher.match("test*", "test"));
+ assertTrue(pathMatcher.match("test*", "testTest"));
+ assertTrue(pathMatcher.match("test/*", "test/Test"));
+ assertTrue(pathMatcher.match("test/*", "test/t"));
+ assertTrue(pathMatcher.match("test/*", "test/"));
+ assertTrue(pathMatcher.match("*test*", "AnothertestTest"));
+ assertTrue(pathMatcher.match("*test", "Anothertest"));
+ assertTrue(pathMatcher.match("*.*", "test."));
+ assertTrue(pathMatcher.match("*.*", "test.test"));
+ assertTrue(pathMatcher.match("*.*", "test.test.test"));
+ assertTrue(pathMatcher.match("test*aaa", "testblaaaa"));
+ assertFalse(pathMatcher.match("test*", "tst"));
+ assertFalse(pathMatcher.match("test*", "tsttest"));
+ assertFalse(pathMatcher.match("test*", "test/"));
+ assertFalse(pathMatcher.match("test*", "test/t"));
+ assertFalse(pathMatcher.match("test/*", "test"));
+ assertFalse(pathMatcher.match("*test*", "tsttst"));
+ assertFalse(pathMatcher.match("*test", "tsttst"));
+ assertFalse(pathMatcher.match("*.*", "tsttst"));
+ assertFalse(pathMatcher.match("test*aaa", "test"));
+ assertFalse(pathMatcher.match("test*aaa", "testblaaab"));
// test matching with ?'s and /'s
- assertThat(pathMatcher.match("/?", "/a")).isTrue();
- assertThat(pathMatcher.match("/?/a", "/a/a")).isTrue();
- assertThat(pathMatcher.match("/a/?", "/a/b")).isTrue();
- assertThat(pathMatcher.match("/??/a", "/aa/a")).isTrue();
- assertThat(pathMatcher.match("/a/??", "/a/bb")).isTrue();
- assertThat(pathMatcher.match("/?", "/a")).isTrue();
+ assertTrue(pathMatcher.match("/?", "/a"));
+ assertTrue(pathMatcher.match("/?/a", "/a/a"));
+ assertTrue(pathMatcher.match("/a/?", "/a/b"));
+ assertTrue(pathMatcher.match("/??/a", "/aa/a"));
+ assertTrue(pathMatcher.match("/a/??", "/a/bb"));
+ assertTrue(pathMatcher.match("/?", "/a"));
// test matching with **'s
- assertThat(pathMatcher.match("/**", "/testing/testing")).isTrue();
- assertThat(pathMatcher.match("/*/**", "/testing/testing")).isTrue();
- assertThat(pathMatcher.match("/**/*", "/testing/testing")).isTrue();
- assertThat(pathMatcher.match("/bla/**/bla", "/bla/testing/testing/bla")).isTrue();
- assertThat(pathMatcher.match("/bla/**/bla", "/bla/testing/testing/bla/bla")).isTrue();
- assertThat(pathMatcher.match("/**/test", "/bla/bla/test")).isTrue();
- assertThat(pathMatcher.match("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla")).isTrue();
- assertThat(pathMatcher.match("/bla*bla/test", "/blaXXXbla/test")).isTrue();
- assertThat(pathMatcher.match("/*bla/test", "/XXXbla/test")).isTrue();
- assertThat(pathMatcher.match("/bla*bla/test", "/blaXXXbl/test")).isFalse();
- assertThat(pathMatcher.match("/*bla/test", "XXXblab/test")).isFalse();
- assertThat(pathMatcher.match("/*bla/test", "XXXbl/test")).isFalse();
-
- assertThat(pathMatcher.match("/????", "/bala/bla")).isFalse();
- assertThat(pathMatcher.match("/**/*bla", "/bla/bla/bla/bbb")).isFalse();
-
- assertThat(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/")).isTrue();
- assertThat(pathMatcher.match("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing")).isTrue();
- assertThat(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing")).isTrue();
- assertThat(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg")).isTrue();
-
- assertThat(pathMatcher.match("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/")).isTrue();
- assertThat(pathMatcher.match("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing")).isTrue();
- assertThat(pathMatcher.match("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing")).isTrue();
- assertThat(pathMatcher.match("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing")).isFalse();
-
- assertThat(pathMatcher.match("/x/x/**/bla", "/x/x/x/")).isFalse();
-
- assertThat(pathMatcher.match("/foo/bar/**", "/foo/bar")).isTrue();
-
- assertThat(pathMatcher.match("", "")).isTrue();
+ assertTrue(pathMatcher.match("/**", "/testing/testing"));
+ assertTrue(pathMatcher.match("/*/**", "/testing/testing"));
+ assertTrue(pathMatcher.match("/**/*", "/testing/testing"));
+ assertTrue(pathMatcher.match("/bla/**/bla", "/bla/testing/testing/bla"));
+ assertTrue(pathMatcher.match("/bla/**/bla", "/bla/testing/testing/bla/bla"));
+ assertTrue(pathMatcher.match("/**/test", "/bla/bla/test"));
+ assertTrue(pathMatcher.match("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla"));
+ assertTrue(pathMatcher.match("/bla*bla/test", "/blaXXXbla/test"));
+ assertTrue(pathMatcher.match("/*bla/test", "/XXXbla/test"));
+ assertFalse(pathMatcher.match("/bla*bla/test", "/blaXXXbl/test"));
+ assertFalse(pathMatcher.match("/*bla/test", "XXXblab/test"));
+ assertFalse(pathMatcher.match("/*bla/test", "XXXbl/test"));
+
+ assertFalse(pathMatcher.match("/????", "/bala/bla"));
+ assertFalse(pathMatcher.match("/**/*bla", "/bla/bla/bla/bbb"));
+
+ assertTrue(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/"));
+ assertTrue(pathMatcher.match("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing"));
+ assertTrue(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing"));
+ assertTrue(pathMatcher.match("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg"));
+
+ assertTrue(pathMatcher.match("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/"));
+ assertTrue(pathMatcher.match("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing"));
+ assertTrue(pathMatcher.match("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing"));
+ assertFalse(pathMatcher.match("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing"));
+
+ assertFalse(pathMatcher.match("/x/x/**/bla", "/x/x/x/"));
+
+ assertTrue(pathMatcher.match("/foo/bar/**", "/foo/bar"));
+
+ assertTrue(pathMatcher.match("", ""));
}
@Test
void matchWithNullPath() {
- assertThat(pathMatcher.match("/test", null)).isFalse();
- assertThat(pathMatcher.match("/", null)).isFalse();
- assertThat(pathMatcher.match(null, null)).isFalse();
+ assertFalse(pathMatcher.match("/test", null));
+ assertFalse(pathMatcher.match("/", null));
+ assertFalse(pathMatcher.match(null, null));
}
@SuppressWarnings("checkstyle:MethodLength")
@Test
void matchStart() {
// test exact matching
- assertThat(pathMatcher.matchStart("test", "test")).isTrue();
- assertThat(pathMatcher.matchStart("/test", "/test")).isTrue();
- assertThat(pathMatcher.matchStart("/test.jpg", "test.jpg")).isFalse();
- assertThat(pathMatcher.matchStart("test", "/test")).isFalse();
- assertThat(pathMatcher.matchStart("/test", "test")).isFalse();
+ assertTrue(pathMatcher.matchStart("test", "test"));
+ assertTrue(pathMatcher.matchStart("/test", "/test"));
+ assertFalse(pathMatcher.matchStart("/test.jpg", "test.jpg"));
+ assertFalse(pathMatcher.matchStart("test", "/test"));
+ assertFalse(pathMatcher.matchStart("/test", "test"));
// test matching with ?'s
- assertThat(pathMatcher.matchStart("t?st", "test")).isTrue();
- assertThat(pathMatcher.matchStart("??st", "test")).isTrue();
- assertThat(pathMatcher.matchStart("tes?", "test")).isTrue();
- assertThat(pathMatcher.matchStart("te??", "test")).isTrue();
- assertThat(pathMatcher.matchStart("?es?", "test")).isTrue();
- assertThat(pathMatcher.matchStart("tes?", "tes")).isFalse();
- assertThat(pathMatcher.matchStart("tes?", "testt")).isFalse();
- assertThat(pathMatcher.matchStart("tes?", "tsst")).isFalse();
+ assertTrue(pathMatcher.matchStart("t?st", "test"));
+ assertTrue(pathMatcher.matchStart("??st", "test"));
+ assertTrue(pathMatcher.matchStart("tes?", "test"));
+ assertTrue(pathMatcher.matchStart("te??", "test"));
+ assertTrue(pathMatcher.matchStart("?es?", "test"));
+ assertFalse(pathMatcher.matchStart("tes?", "tes"));
+ assertFalse(pathMatcher.matchStart("tes?", "testt"));
+ assertFalse(pathMatcher.matchStart("tes?", "tsst"));
// test matching with *'s
- assertThat(pathMatcher.matchStart("*", "test")).isTrue();
- assertThat(pathMatcher.matchStart("test*", "test")).isTrue();
- assertThat(pathMatcher.matchStart("test*", "testTest")).isTrue();
- assertThat(pathMatcher.matchStart("test/*", "test/Test")).isTrue();
- assertThat(pathMatcher.matchStart("test/*", "test/t")).isTrue();
- assertThat(pathMatcher.matchStart("test/*", "test/")).isTrue();
- assertThat(pathMatcher.matchStart("*test*", "AnothertestTest")).isTrue();
- assertThat(pathMatcher.matchStart("*test", "Anothertest")).isTrue();
- assertThat(pathMatcher.matchStart("*.*", "test.")).isTrue();
- assertThat(pathMatcher.matchStart("*.*", "test.test")).isTrue();
- assertThat(pathMatcher.matchStart("*.*", "test.test.test")).isTrue();
- assertThat(pathMatcher.matchStart("test*aaa", "testblaaaa")).isTrue();
- assertThat(pathMatcher.matchStart("test*", "tst")).isFalse();
- assertThat(pathMatcher.matchStart("test*", "test/")).isFalse();
- assertThat(pathMatcher.matchStart("test*", "tsttest")).isFalse();
- assertThat(pathMatcher.matchStart("test*", "test/")).isFalse();
- assertThat(pathMatcher.matchStart("test*", "test/t")).isFalse();
- assertThat(pathMatcher.matchStart("test/*", "test")).isTrue();
- assertThat(pathMatcher.matchStart("test/t*.txt", "test")).isTrue();
- assertThat(pathMatcher.matchStart("*test*", "tsttst")).isFalse();
- assertThat(pathMatcher.matchStart("*test", "tsttst")).isFalse();
- assertThat(pathMatcher.matchStart("*.*", "tsttst")).isFalse();
- assertThat(pathMatcher.matchStart("test*aaa", "test")).isFalse();
- assertThat(pathMatcher.matchStart("test*aaa", "testblaaab")).isFalse();
+ assertTrue(pathMatcher.matchStart("*", "test"));
+ assertTrue(pathMatcher.matchStart("test*", "test"));
+ assertTrue(pathMatcher.matchStart("test*", "testTest"));
+ assertTrue(pathMatcher.matchStart("test/*", "test/Test"));
+ assertTrue(pathMatcher.matchStart("test/*", "test/t"));
+ assertTrue(pathMatcher.matchStart("test/*", "test/"));
+ assertTrue(pathMatcher.matchStart("*test*", "AnothertestTest"));
+ assertTrue(pathMatcher.matchStart("*test", "Anothertest"));
+ assertTrue(pathMatcher.matchStart("*.*", "test."));
+ assertTrue(pathMatcher.matchStart("*.*", "test.test"));
+ assertTrue(pathMatcher.matchStart("*.*", "test.test.test"));
+ assertTrue(pathMatcher.matchStart("test*aaa", "testblaaaa"));
+ assertFalse(pathMatcher.matchStart("test*", "tst"));
+ assertFalse(pathMatcher.matchStart("test*", "test/"));
+ assertFalse(pathMatcher.matchStart("test*", "tsttest"));
+ assertFalse(pathMatcher.matchStart("test*", "test/"));
+ assertFalse(pathMatcher.matchStart("test*", "test/t"));
+ assertTrue(pathMatcher.matchStart("test/*", "test"));
+ assertTrue(pathMatcher.matchStart("test/t*.txt", "test"));
+ assertFalse(pathMatcher.matchStart("*test*", "tsttst"));
+ assertFalse(pathMatcher.matchStart("*test", "tsttst"));
+ assertFalse(pathMatcher.matchStart("*.*", "tsttst"));
+ assertFalse(pathMatcher.matchStart("test*aaa", "test"));
+ assertFalse(pathMatcher.matchStart("test*aaa", "testblaaab"));
// test matching with ?'s and /'s
- assertThat(pathMatcher.matchStart("/?", "/a")).isTrue();
- assertThat(pathMatcher.matchStart("/?/a", "/a/a")).isTrue();
- assertThat(pathMatcher.matchStart("/a/?", "/a/b")).isTrue();
- assertThat(pathMatcher.matchStart("/??/a", "/aa/a")).isTrue();
- assertThat(pathMatcher.matchStart("/a/??", "/a/bb")).isTrue();
- assertThat(pathMatcher.matchStart("/?", "/a")).isTrue();
+ assertTrue(pathMatcher.matchStart("/?", "/a"));
+ assertTrue(pathMatcher.matchStart("/?/a", "/a/a"));
+ assertTrue(pathMatcher.matchStart("/a/?", "/a/b"));
+ assertTrue(pathMatcher.matchStart("/??/a", "/aa/a"));
+ assertTrue(pathMatcher.matchStart("/a/??", "/a/bb"));
+ assertTrue(pathMatcher.matchStart("/?", "/a"));
// test matching with **'s
- assertThat(pathMatcher.matchStart("/**", "/testing/testing")).isTrue();
- assertThat(pathMatcher.matchStart("/*/**", "/testing/testing")).isTrue();
- assertThat(pathMatcher.matchStart("/**/*", "/testing/testing")).isTrue();
- assertThat(pathMatcher.matchStart("test*/**", "test/")).isTrue();
- assertThat(pathMatcher.matchStart("test*/**", "test/t")).isTrue();
- assertThat(pathMatcher.matchStart("/bla/**/bla", "/bla/testing/testing/bla")).isTrue();
- assertThat(pathMatcher.matchStart("/bla/**/bla", "/bla/testing/testing/bla/bla")).isTrue();
- assertThat(pathMatcher.matchStart("/**/test", "/bla/bla/test")).isTrue();
- assertThat(pathMatcher.matchStart("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla")).isTrue();
- assertThat(pathMatcher.matchStart("/bla*bla/test", "/blaXXXbla/test")).isTrue();
- assertThat(pathMatcher.matchStart("/*bla/test", "/XXXbla/test")).isTrue();
- assertThat(pathMatcher.matchStart("/bla*bla/test", "/blaXXXbl/test")).isFalse();
- assertThat(pathMatcher.matchStart("/*bla/test", "XXXblab/test")).isFalse();
- assertThat(pathMatcher.matchStart("/*bla/test", "XXXbl/test")).isFalse();
-
- assertThat(pathMatcher.matchStart("/????", "/bala/bla")).isFalse();
- assertThat(pathMatcher.matchStart("/**/*bla", "/bla/bla/bla/bbb")).isTrue();
-
- assertThat(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/")).isTrue();
- assertThat(pathMatcher.matchStart("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing")).isTrue();
- assertThat(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing")).isTrue();
- assertThat(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg")).isTrue();
-
- assertThat(pathMatcher.matchStart("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/")).isTrue();
- assertThat(pathMatcher.matchStart("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing")).isTrue();
- assertThat(pathMatcher.matchStart("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing")).isTrue();
- assertThat(pathMatcher.matchStart("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing")).isTrue();
-
- assertThat(pathMatcher.matchStart("/x/x/**/bla", "/x/x/x/")).isTrue();
-
- assertThat(pathMatcher.matchStart("", "")).isTrue();
+ assertTrue(pathMatcher.matchStart("/**", "/testing/testing"));
+ assertTrue(pathMatcher.matchStart("/*/**", "/testing/testing"));
+ assertTrue(pathMatcher.matchStart("/**/*", "/testing/testing"));
+ assertTrue(pathMatcher.matchStart("test*/**", "test/"));
+ assertTrue(pathMatcher.matchStart("test*/**", "test/t"));
+ assertTrue(pathMatcher.matchStart("/bla/**/bla", "/bla/testing/testing/bla"));
+ assertTrue(pathMatcher.matchStart("/bla/**/bla", "/bla/testing/testing/bla/bla"));
+ assertTrue(pathMatcher.matchStart("/**/test", "/bla/bla/test"));
+ assertTrue(pathMatcher.matchStart("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla"));
+ assertTrue(pathMatcher.matchStart("/bla*bla/test", "/blaXXXbla/test"));
+ assertTrue(pathMatcher.matchStart("/*bla/test", "/XXXbla/test"));
+ assertFalse(pathMatcher.matchStart("/bla*bla/test", "/blaXXXbl/test"));
+ assertFalse(pathMatcher.matchStart("/*bla/test", "XXXblab/test"));
+ assertFalse(pathMatcher.matchStart("/*bla/test", "XXXbl/test"));
+
+ assertFalse(pathMatcher.matchStart("/????", "/bala/bla"));
+ assertTrue(pathMatcher.matchStart("/**/*bla", "/bla/bla/bla/bbb"));
+
+ assertTrue(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/"));
+ assertTrue(pathMatcher.matchStart("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing"));
+ assertTrue(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing"));
+ assertTrue(pathMatcher.matchStart("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg"));
+
+ assertTrue(pathMatcher.matchStart("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/"));
+ assertTrue(pathMatcher.matchStart("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing"));
+ assertTrue(pathMatcher.matchStart("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing"));
+ assertTrue(pathMatcher.matchStart("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing"));
+
+ assertTrue(pathMatcher.matchStart("/x/x/**/bla", "/x/x/x/"));
+
+ assertTrue(pathMatcher.matchStart("", ""));
}
@Test
@@ -222,130 +224,112 @@ public class AntPathMatcherTests {
pathMatcher.setPathSeparator(".");
// test exact matching
- assertThat(pathMatcher.match("test", "test")).isTrue();
- assertThat(pathMatcher.match(".test", ".test")).isTrue();
- assertThat(pathMatcher.match(".test/jpg", "test/jpg")).isFalse();
- assertThat(pathMatcher.match("test", ".test")).isFalse();
- assertThat(pathMatcher.match(".test", "test")).isFalse();
+ assertTrue(pathMatcher.match("test", "test"));
+ assertTrue(pathMatcher.match(".test", ".test"));
+ assertFalse(pathMatcher.match(".test/jpg", "test/jpg"));
+ assertFalse(pathMatcher.match("test", ".test"));
+ assertFalse(pathMatcher.match(".test", "test"));
// test matching with ?'s
- assertThat(pathMatcher.match("t?st", "test")).isTrue();
- assertThat(pathMatcher.match("??st", "test")).isTrue();
- assertThat(pathMatcher.match("tes?", "test")).isTrue();
- assertThat(pathMatcher.match("te??", "test")).isTrue();
- assertThat(pathMatcher.match("?es?", "test")).isTrue();
- assertThat(pathMatcher.match("tes?", "tes")).isFalse();
- assertThat(pathMatcher.match("tes?", "testt")).isFalse();
- assertThat(pathMatcher.match("tes?", "tsst")).isFalse();
+ assertTrue(pathMatcher.match("t?st", "test"));
+ assertTrue(pathMatcher.match("??st", "test"));
+ assertTrue(pathMatcher.match("tes?", "test"));
+ assertTrue(pathMatcher.match("te??", "test"));
+ assertTrue(pathMatcher.match("?es?", "test"));
+ assertFalse(pathMatcher.match("tes?", "tes"));
+ assertFalse(pathMatcher.match("tes?", "testt"));
+ assertFalse(pathMatcher.match("tes?", "tsst"));
// test matching with *'s
- assertThat(pathMatcher.match("*", "test")).isTrue();
- assertThat(pathMatcher.match("test*", "test")).isTrue();
- assertThat(pathMatcher.match("test*", "testTest")).isTrue();
- assertThat(pathMatcher.match("*test*", "AnothertestTest")).isTrue();
- assertThat(pathMatcher.match("*test", "Anothertest")).isTrue();
- assertThat(pathMatcher.match("*/*", "test/")).isTrue();
- assertThat(pathMatcher.match("*/*", "test/test")).isTrue();
- assertThat(pathMatcher.match("*/*", "test/test/test")).isTrue();
- assertThat(pathMatcher.match("test*aaa", "testblaaaa")).isTrue();
- assertThat(pathMatcher.match("test*", "tst")).isFalse();
- assertThat(pathMatcher.match("test*", "tsttest")).isFalse();
- assertThat(pathMatcher.match("*test*", "tsttst")).isFalse();
- assertThat(pathMatcher.match("*test", "tsttst")).isFalse();
- assertThat(pathMatcher.match("*/*", "tsttst")).isFalse();
- assertThat(pathMatcher.match("test*aaa", "test")).isFalse();
- assertThat(pathMatcher.match("test*aaa", "testblaaab")).isFalse();
+ assertTrue(pathMatcher.match("*", "test"));
+ assertTrue(pathMatcher.match("test*", "test"));
+ assertTrue(pathMatcher.match("test*", "testTest"));
+ assertTrue(pathMatcher.match("*test*", "AnothertestTest"));
+ assertTrue(pathMatcher.match("*test", "Anothertest"));
+ assertTrue(pathMatcher.match("*/*", "test/"));
+ assertTrue(pathMatcher.match("*/*", "test/test"));
+ assertTrue(pathMatcher.match("*/*", "test/test/test"));
+ assertTrue(pathMatcher.match("test*aaa", "testblaaaa"));
+ assertFalse(pathMatcher.match("test*", "tst"));
+ assertFalse(pathMatcher.match("test*", "tsttest"));
+ assertFalse(pathMatcher.match("*test*", "tsttst"));
+ assertFalse(pathMatcher.match("*test", "tsttst"));
+ assertFalse(pathMatcher.match("*/*", "tsttst"));
+ assertFalse(pathMatcher.match("test*aaa", "test"));
+ assertFalse(pathMatcher.match("test*aaa", "testblaaab"));
// test matching with ?'s and .'s
- assertThat(pathMatcher.match(".?", ".a")).isTrue();
- assertThat(pathMatcher.match(".?.a", ".a.a")).isTrue();
- assertThat(pathMatcher.match(".a.?", ".a.b")).isTrue();
- assertThat(pathMatcher.match(".??.a", ".aa.a")).isTrue();
- assertThat(pathMatcher.match(".a.??", ".a.bb")).isTrue();
- assertThat(pathMatcher.match(".?", ".a")).isTrue();
+ assertTrue(pathMatcher.match(".?", ".a"));
+ assertTrue(pathMatcher.match(".?.a", ".a.a"));
+ assertTrue(pathMatcher.match(".a.?", ".a.b"));
+ assertTrue(pathMatcher.match(".??.a", ".aa.a"));
+ assertTrue(pathMatcher.match(".a.??", ".a.bb"));
+ assertTrue(pathMatcher.match(".?", ".a"));
// test matching with **'s
- assertThat(pathMatcher.match(".**", ".testing.testing")).isTrue();
- assertThat(pathMatcher.match(".*.**", ".testing.testing")).isTrue();
- assertThat(pathMatcher.match(".**.*", ".testing.testing")).isTrue();
- assertThat(pathMatcher.match(".bla.**.bla", ".bla.testing.testing.bla")).isTrue();
- assertThat(pathMatcher.match(".bla.**.bla", ".bla.testing.testing.bla.bla")).isTrue();
- assertThat(pathMatcher.match(".**.test", ".bla.bla.test")).isTrue();
- assertThat(pathMatcher.match(".bla.**.**.bla", ".bla.bla.bla.bla.bla.bla")).isTrue();
- assertThat(pathMatcher.match(".bla*bla.test", ".blaXXXbla.test")).isTrue();
- assertThat(pathMatcher.match(".*bla.test", ".XXXbla.test")).isTrue();
- assertThat(pathMatcher.match(".bla*bla.test", ".blaXXXbl.test")).isFalse();
- assertThat(pathMatcher.match(".*bla.test", "XXXblab.test")).isFalse();
- assertThat(pathMatcher.match(".*bla.test", "XXXbl.test")).isFalse();
+ assertTrue(pathMatcher.match(".**", ".testing.testing"));
+ assertTrue(pathMatcher.match(".*.**", ".testing.testing"));
+ assertTrue(pathMatcher.match(".**.*", ".testing.testing"));
+ assertTrue(pathMatcher.match(".bla.**.bla", ".bla.testing.testing.bla"));
+ assertTrue(pathMatcher.match(".bla.**.bla", ".bla.testing.testing.bla.bla"));
+ assertTrue(pathMatcher.match(".**.test", ".bla.bla.test"));
+ assertTrue(pathMatcher.match(".bla.**.**.bla", ".bla.bla.bla.bla.bla.bla"));
+ assertTrue(pathMatcher.match(".bla*bla.test", ".blaXXXbla.test"));
+ assertTrue(pathMatcher.match(".*bla.test", ".XXXbla.test"));
+ assertFalse(pathMatcher.match(".bla*bla.test", ".blaXXXbl.test"));
+ assertFalse(pathMatcher.match(".*bla.test", "XXXblab.test"));
+ assertFalse(pathMatcher.match(".*bla.test", "XXXbl.test"));
}
@Test
void extractPathWithinPattern() throws Exception {
- assertThat(pathMatcher.extractPathWithinPattern("/docs/commit.html", "/docs/commit.html"))
- .isEmpty();
- assertThat(pathMatcher.extractPathWithinPattern("/docs/*", "/docs/cvs/commit"))
- .isEqualTo("cvs/commit");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/cvs/*.html", "/docs/cvs/commit.html"))
- .isEqualTo("commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/**", "/docs/cvs/commit"))
- .isEqualTo("cvs/commit");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/**/*.html", "/docs/cvs/commit.html"))
- .isEqualTo("cvs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/**/*.html", "/docs/commit.html"))
- .isEqualTo("commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/*.html", "/commit.html"))
- .isEqualTo("commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/*.html", "/docs/commit.html"))
- .isEqualTo("docs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("*.html", "/commit.html"))
- .isEqualTo("/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("*.html", "/docs/commit.html"))
- .isEqualTo("/docs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("**/*.*", "/docs/commit.html"))
- .isEqualTo("/docs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("*", "/docs/commit.html"))
- .isEqualTo("/docs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("**/commit.html", "/docs/cvs/other/commit.html"))
- .isEqualTo("/docs/cvs/other/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/**/commit.html", "/docs/cvs/other/commit.html"))
- .isEqualTo("cvs/other/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/**/**/**/**", "/docs/cvs/other/commit.html"))
- .isEqualTo("cvs/other/commit.html");
-
- assertThat(pathMatcher.extractPathWithinPattern("/d?cs/*", "/docs/cvs/commit"))
- .isEqualTo("docs/cvs/commit");
- assertThat(pathMatcher.extractPathWithinPattern("/docs/c?s/*.html", "/docs/cvs/commit.html"))
- .isEqualTo("cvs/commit.html");
- assertThat(pathMatcher.extractPathWithinPattern("/d?cs/**", "/docs/cvs/commit"))
- .isEqualTo("docs/cvs/commit");
- assertThat(pathMatcher.extractPathWithinPattern("/d?cs/**/*.html", "/docs/cvs/commit.html"))
- .isEqualTo("docs/cvs/commit.html");
+ assertEquals("", pathMatcher.extractPathWithinPattern("/docs/commit.html", "/docs/commit.html"));
+
+ assertEquals("cvs/commit", pathMatcher.extractPathWithinPattern("/docs/*", "/docs/cvs/commit"));
+ assertEquals("commit.html", pathMatcher.extractPathWithinPattern("/docs/cvs/*.html", "/docs/cvs/commit.html"));
+ assertEquals("cvs/commit", pathMatcher.extractPathWithinPattern("/docs/**", "/docs/cvs/commit"));
+ assertEquals("cvs/commit.html", pathMatcher.extractPathWithinPattern("/docs/**/*.html", "/docs/cvs/commit.html"));
+ assertEquals("commit.html", pathMatcher.extractPathWithinPattern("/docs/**/*.html", "/docs/commit.html"));
+ assertEquals("commit.html", pathMatcher.extractPathWithinPattern("/*.html", "/commit.html"));
+ assertEquals("docs/commit.html", pathMatcher.extractPathWithinPattern("/*.html", "/docs/commit.html"));
+ assertEquals("/commit.html", pathMatcher.extractPathWithinPattern("*.html", "/commit.html"));
+ assertEquals("/docs/commit.html", pathMatcher.extractPathWithinPattern("*.html", "/docs/commit.html"));
+ assertEquals("/docs/commit.html", pathMatcher.extractPathWithinPattern("**/*.*", "/docs/commit.html"));
+ assertEquals("/docs/commit.html", pathMatcher.extractPathWithinPattern("*", "/docs/commit.html"));
+ assertEquals("/docs/cvs/other/commit.html", pathMatcher.extractPathWithinPattern("**/commit.html", "/docs/cvs/other/commit.html"));
+ assertEquals("cvs/other/commit.html", pathMatcher.extractPathWithinPattern("/docs/**/commit.html", "/docs/cvs/other/commit.html"));
+ assertEquals("cvs/other/commit.html", pathMatcher.extractPathWithinPattern("/docs/**/**/**/**", "/docs/cvs/other/commit.html"));
+
+ assertEquals("docs/cvs/commit", pathMatcher.extractPathWithinPattern("/d?cs/*", "/docs/cvs/commit"));
+ assertEquals("cvs/commit.html", pathMatcher.extractPathWithinPattern("/docs/c?s/*.html", "/docs/cvs/commit.html"));
+ assertEquals("docs/cvs/commit", pathMatcher.extractPathWithinPattern("/d?cs/**", "/docs/cvs/commit"));
+ assertEquals("docs/cvs/commit.html", pathMatcher.extractPathWithinPattern("/d?cs/**/*.html", "/docs/cvs/commit.html"));
}
@Test
void spaceInTokens() {
- assertThat(pathMatcher.match("/group/sales/members", "/group/sales/members")).isTrue();
- assertThat(pathMatcher.match("/group/sales/members", "/Group/ sales/Members")).isFalse();
+ assertTrue(pathMatcher.match("/group/sales/members", "/group/sales/members"));
+ assertFalse(pathMatcher.match("/group/sales/members", "/Group/ sales/Members"));
}
@Test
void isPattern() {
- assertThat(pathMatcher.isPattern("/test/*")).isTrue();
- assertThat(pathMatcher.isPattern("/test/**/name")).isTrue();
- assertThat(pathMatcher.isPattern("/test?")).isTrue();
+ assertTrue(pathMatcher.isPattern("/test/*"));
+ assertTrue(pathMatcher.isPattern("/test/**/name"));
+ assertTrue(pathMatcher.isPattern("/test?"));
- assertThat(pathMatcher.isPattern("/test/{name}")).isFalse();
- assertThat(pathMatcher.isPattern("/test/name")).isFalse();
- assertThat(pathMatcher.isPattern("/test/foo{bar")).isFalse();
+ assertFalse(pathMatcher.isPattern("/test/{name}"));
+ assertFalse(pathMatcher.isPattern("/test/name"));
+ assertFalse(pathMatcher.isPattern("/test/foo{bar"));
}
@Test
void matches() {
- assertThat(pathMatcher.matches("/foo/*", "/foo/")).isTrue();
+ assertTrue(pathMatcher.matches("/foo/*", "/foo/"));
}
@Test
void isPatternWithNullPath() {
- assertThat(pathMatcher.isPattern(null)).isFalse();
+ assertFalse(pathMatcher.isPattern(null));
}
}
diff --git a/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java b/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
index 283614812..bace34384 100644
--- a/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
+++ b/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
@@ -20,7 +20,8 @@ package org.apache.shiro.util;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit tests for the {@link RegExPatternMatcher}.
@@ -61,7 +62,7 @@ public class RegExPatternMatcherTest {
}
private void assertPatternMatch(String pattern, String path, PatternMatcher pm) {
- assertThat(pm.matches(pattern, path)).as("Expected path '" + path + "' to match pattern '" + pattern + "'").isTrue();
+ assertTrue(pm.matches(pattern, path), "Expected path '" + path + "' to match pattern '" + pattern + "'");
}
private void assertPatternNotMatch(String pattern, String path) {
@@ -69,6 +70,6 @@ public class RegExPatternMatcherTest {
}
private void assertPatternNotMatch(String pattern, String path, PatternMatcher pm) {
- assertThat(pm.matches(pattern, path)).as("Expected path '" + path + "' to NOT match pattern '" + pattern + "'").isFalse();
+ assertFalse(pm.matches(pattern, path), "Expected path '" + path + "' to NOT match pattern '" + pattern + "'");
}
}
diff --git a/core/src/test/java/org/apache/shiro/util/StringUtilsTest.java b/core/src/test/java/org/apache/shiro/util/StringUtilsTest.java
index 0f4a1c3ef..5dc352777 100644
--- a/core/src/test/java/org/apache/shiro/util/StringUtilsTest.java
+++ b/core/src/test/java/org/apache/shiro/util/StringUtilsTest.java
@@ -21,7 +21,9 @@ package org.apache.shiro.util;
import org.apache.shiro.lang.util.StringUtils;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @since 0.9
@@ -32,93 +34,93 @@ public class StringUtilsTest {
void splitWithNullInput() {
String line = null;
String[] split = StringUtils.split(line);
- assertThat(split).isNull();
+ assertNull(split);
}
@Test
void splitWithCommas() {
String line = "shall,we,play,a,game?";
String[] split = StringUtils.split(line);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(5);
- assertThat(split[0]).isEqualTo("shall");
- assertThat(split[1]).isEqualTo("we");
- assertThat(split[2]).isEqualTo("play");
- assertThat(split[3]).isEqualTo("a");
- assertThat(split[4]).isEqualTo("game?");
+ assertNotNull(split);
+ assertEquals(5, split.length);
+ assertEquals("shall", split[0]);
+ assertEquals("we", split[1]);
+ assertEquals("play", split[2]);
+ assertEquals("a", split[3]);
+ assertEquals("game?", split[4]);
}
@Test
void splitWithCommasAndSpaces() {
String line = "shall,we , play, a,game?";
String[] split = StringUtils.split(line);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(5);
- assertThat(split[0]).isEqualTo("shall");
- assertThat(split[1]).isEqualTo("we");
- assertThat(split[2]).isEqualTo("play");
- assertThat(split[3]).isEqualTo("a");
- assertThat(split[4]).isEqualTo("game?");
+ assertNotNull(split);
+ assertEquals(5, split.length);
+ assertEquals("shall", split[0]);
+ assertEquals("we", split[1]);
+ assertEquals("play", split[2]);
+ assertEquals("a", split[3]);
+ assertEquals("game?", split[4]);
}
@Test
void splitWithQuotedCommasAndSpaces() {
String line = "shall, \"we, play\", a, game?";
String[] split = StringUtils.split(line);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(4);
- assertThat(split[0]).isEqualTo("shall");
- assertThat(split[1]).isEqualTo("we, play");
- assertThat(split[2]).isEqualTo("a");
- assertThat(split[3]).isEqualTo("game?");
+ assertNotNull(split);
+ assertEquals(4, split.length);
+ assertEquals("shall", split[0]);
+ assertEquals("we, play", split[1]);
+ assertEquals("a", split[2]);
+ assertEquals("game?", split[3]);
}
@Test
void splitWithQuotedCommasAndSpacesAndDifferentQuoteChars() {
String line = "authc, test[blah], test[1,2,3], test[]";
String[] split = StringUtils.split(line, ',', '[', ']', false, true);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(4);
- assertThat(split[0]).isEqualTo("authc");
- assertThat(split[1]).isEqualTo("testblah");
- assertThat(split[2]).isEqualTo("test1,2,3");
- assertThat(split[3]).isEqualTo("test");
+ assertNotNull(split);
+ assertEquals(4, split.length);
+ assertEquals("authc", split[0]);
+ assertEquals("testblah", split[1]);
+ assertEquals("test1,2,3", split[2]);
+ assertEquals("test", split[3]);
}
@Test
void splitWithQuotedCommasAndSpacesAndDifferentQuoteCharsWhileRetainingQuotes() {
String line = "authc, test[blah], test[1,2,3], test[]";
String[] split = StringUtils.split(line, ',', '[', ']', true, true);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(4);
- assertThat(split[0]).isEqualTo("authc");
- assertThat(split[1]).isEqualTo("test[blah]");
- assertThat(split[2]).isEqualTo("test[1,2,3]");
- assertThat(split[3]).isEqualTo("test[]");
+ assertNotNull(split);
+ assertEquals(4, split.length);
+ assertEquals("authc", split[0]);
+ assertEquals("test[blah]", split[1]);
+ assertEquals("test[1,2,3]", split[2]);
+ assertEquals("test[]", split[3]);
}
@Test
void splitTestWithQuotedCommas() {
String line = "authc, test[blah], test[\"1,2,3\"], test[]";
String[] split = StringUtils.split(line);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(4);
- assertThat(split[0]).isEqualTo("authc");
- assertThat(split[1]).isEqualTo("test[blah]");
- assertThat(split[2]).isEqualTo("test[1,2,3]");
- assertThat(split[3]).isEqualTo("test[]");
+ assertNotNull(split);
+ assertEquals(4, split.length);
+ assertEquals("authc", split[0]);
+ assertEquals("test[blah]", split[1]);
+ assertEquals("test[1,2,3]", split[2]);
+ assertEquals("test[]", split[3]);
}
@Test
void splitWithQuotedCommasAndSpacesAndEscapedQuotes() {
String line = "shall, \"\"\"we, play\", a, \"\"\"game?";
String[] split = StringUtils.split(line);
- assertThat(split).isNotNull();
- assertThat(split.length).isEqualTo(4);
- assertThat(split[0]).isEqualTo("shall");
- assertThat(split[1]).isEqualTo("\"we, play");
- assertThat(split[2]).isEqualTo("a");
- assertThat(split[3]).isEqualTo("\"game?");
+ assertNotNull(split);
+ assertEquals(4, split.length);
+ assertEquals("shall", split[0]);
+ assertEquals("\"we, play", split[1]);
+ assertEquals("a", split[2]);
+ assertEquals("\"game?", split[3]);
}
}
diff --git a/integration-tests/jakarta-ee/pom.xml b/integration-tests/jakarta-ee/pom.xml
index 902bec6ae..cfe571fa9 100644
--- a/integration-tests/jakarta-ee/pom.xml
+++ b/integration-tests/jakarta-ee/pom.xml
@@ -481,7 +481,7 @@
<profiles>
<profile>
- <id>payara-server-local</id>
+ <id>payara-server-remote</id>
<properties>
<payara.start.skip>true</payara.start.skip>
<payara.argLine/>
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/cdi/ComponentInjectionIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/cdi/ComponentInjectionIT.java
index f84d47fb9..d0e5000f9 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/cdi/ComponentInjectionIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/cdi/ComponentInjectionIT.java
@@ -20,7 +20,6 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import static org.apache.shiro.ee.util.JakartaTransformer.jakartify;
-import static org.assertj.core.api.Assertions.assertThat;
import org.apache.shiro.testing.jakarta.ee.PropertyPrincipal;
import org.apache.shiro.testing.jaxrs.NoIniJaxRsIT;
@@ -41,6 +40,12 @@ import org.junit.jupiter.api.parallel.ExecutionMode;
import java.util.Optional;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
/**
* Tests @Injecting Subject, Session, Principal and SecurityManager with CDI
*/
@@ -72,41 +77,40 @@ public class ComponentInjectionIT {
@Test
@OperateOnDeployment(TESTABLE_MODE)
void securityManagerInjection() {
- assertThat(injectedComponents.getSecurityManager()).isNotNull();
- assertThat(injectedComponents.getSecurityManager().getSession(() -> null)).isNull();
+ assertNotNull(injectedComponents.getSecurityManager());
+ assertNull(injectedComponents.getSecurityManager().getSession(() -> null));
}
@Test
@OperateOnDeployment(TESTABLE_MODE)
void subjectInjection() {
- assertThat(injectedComponents.getSubject()).isNotNull();
- assertThat(injectedComponents.getSubject().getPrincipal()).isNull();
- assertThat(injectedComponents.getSubject().isAuthenticated()).isFalse();
+ assertNotNull(injectedComponents.getSubject());
+ assertNull(injectedComponents.getSubject().getPrincipal());
+ assertFalse(injectedComponents.getSubject().isAuthenticated());
UsernamePasswordToken token = new UsernamePasswordToken("user", "password");
injectedComponents.getSubject().login(token);
- assertThat(injectedComponents.getSubject().isAuthenticated()).isTrue();
+ assertTrue(injectedComponents.getSubject().isAuthenticated());
injectedComponents.getSubject().logout();
- assertThat(injectedComponents.getSubject().isAuthenticated()).isFalse();
+ assertFalse(injectedComponents.getSubject().isAuthenticated());
}
@Test
@OperateOnDeployment(TESTABLE_MODE)
void sessionInjection() {
- assertThat(injectedComponents.getSession()).isNotNull();
- assertThat(injectedComponents.getNoCreateionSession()).isNotNull();
+ assertNotNull(injectedComponents.getSession());
+ assertNotNull(injectedComponents.getNoCreateionSession());
injectedComponents.getSession().setAttribute("hello", "bye");
- assertThat(injectedComponents.getSession().getAttribute("hello")).isEqualTo("bye");
- assertThat(injectedComponents.getNoCreateionSession().getAttribute("hello")).isEqualTo("bye");
+ assertEquals("bye", injectedComponents.getSession().getAttribute("hello"));
+ assertEquals("bye", injectedComponents.getNoCreateionSession().getAttribute("hello"));
}
@Test
@OperateOnDeployment(TESTABLE_MODE)
void principalInjection() {
SecurityUtils.getSubject().login(new UsernamePasswordToken("user", "password"));
- assertThat(injectedComponents.getPropertyPrincipal()).isNotNull();
- assertThat(Optional.ofNullable(injectedComponents.getPropertyPrincipal().get()).orElseThrow().getUserName())
- .isEqualTo("user");
+ assertNotNull(injectedComponents.getPropertyPrincipal());
+ assertEquals("user", Optional.ofNullable(injectedComponents.getPropertyPrincipal().get()).orElseThrow().getUserName());
injectedComponents.getSubject().logout();
}
@@ -134,7 +138,6 @@ public class ComponentInjectionIT {
.addClass(NoIniJaxRsIT.class)
.addClass(PropertyPrincipal.class)
.addClass(ComponentInjectionBean.class)
- .addPackages(true, "org.assertj.core")
.addPackages(true, "org.slf4j");
log.debug("Archive contents for {}: {}", archive, webArchive.toString(true));
return webArchive;
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/FacesTagsIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/FacesTagsIT.java
index c4aa72708..bad6cc158 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/FacesTagsIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/FacesTagsIT.java
@@ -17,7 +17,6 @@ import java.net.URL;
import static org.apache.shiro.testing.jakarta.ee.ShiroAuthFormsIT.DEPLOYMENT_DEV_MODE;
import static org.apache.shiro.testing.jakarta.ee.ShiroAuthFormsIT.createDeploymentDev;
-import static org.assertj.core.api.Assertions.assertThat;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
@@ -29,6 +28,8 @@ import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -107,40 +108,40 @@ public class FacesTagsIT {
@OperateOnDeployment(DEPLOYMENT_DEV_MODE)
void guestTag() {
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(guest.getText()).isEqualTo("Guest Content");
+ assertEquals("Guest Content", guest.getText());
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(guest.getText()).isEqualTo("");
+ assertEquals("", guest.getText());
}
@Test
@OperateOnDeployment(DEPLOYMENT_DEV_MODE)
void userTag() {
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(user.getText()).isEqualTo("");
+ assertEquals("", user.getText());
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(user.getText()).isEqualTo("User Content");
+ assertEquals("User Content", user.getText());
}
@Test
@OperateOnDeployment(DEPLOYMENT_DEV_MODE)
void authenticated() {
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(authenticated.getText()).isEqualTo("");
+ assertEquals("", authenticated.getText());
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(authenticated.getText()).isEqualTo("Authenticated Content");
+ assertEquals("Authenticated Content", authenticated.getText());
}
@Test
@OperateOnDeployment(DEPLOYMENT_DEV_MODE)
void notAuthenticated() {
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(notAuthenticated.getText()).isEqualTo("Not Authenticated Content");
+ assertEquals("Not Authenticated Content", notAuthenticated.getText());
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(notAuthenticated.getText()).isEqualTo("");
+ assertEquals("", notAuthenticated.getText());
}
@Test
@@ -148,7 +149,7 @@ public class FacesTagsIT {
void principal() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(principal.getText()).isEqualTo("webuser");
+ assertEquals("webuser", principal.getText());
}
@Test
@@ -157,7 +158,7 @@ public class FacesTagsIT {
void principalByType() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(principalByType.getText()).isEqualTo("5");
+ assertEquals("5", principalByType.getText());
}
@Test
@@ -165,7 +166,7 @@ public class FacesTagsIT {
void principalByProperty() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(principalByProperty.getText()).isEqualTo("webuser");
+ assertEquals("webuser", principalByProperty.getText());
}
@Test
@@ -173,7 +174,7 @@ public class FacesTagsIT {
void hasRegularRole() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(regularRole.getText()).isEqualTo("Regular Role");
+ assertEquals("Regular Role", regularRole.getText());
}
@Test
@@ -181,7 +182,7 @@ public class FacesTagsIT {
void lacksAdminRole() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(lacksAdminRole.getText()).isEqualTo("Lacks Admin Role");
+ assertEquals("Lacks Admin Role", lacksAdminRole.getText());
}
@Test
@@ -189,7 +190,7 @@ public class FacesTagsIT {
void hasAnyRole() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(hasAnyRole.getText()).isEqualTo("Has Some Role");
+ assertEquals("Has Some Role", hasAnyRole.getText());
}
@Test
@@ -197,7 +198,7 @@ public class FacesTagsIT {
void hasAnyPermission() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(hasAnyPermission.getText()).isEqualTo("Has Some Permission");
+ assertEquals("Has Some Permission", hasAnyPermission.getText());
}
@Test
@@ -205,7 +206,7 @@ public class FacesTagsIT {
void hasPermission() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(hasPermission.getText()).isEqualTo("Has Permission");
+ assertEquals("Has Permission", hasPermission.getText());
}
@Test
@@ -213,7 +214,7 @@ public class FacesTagsIT {
void lacksPermissio() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(lacksPermission.getText()).isEqualTo("Lacks Permission");
+ assertEquals("Lacks Permission", lacksPermission.getText());
}
@Test
@@ -221,7 +222,7 @@ public class FacesTagsIT {
void remembered() {
login();
webDriver.get(baseURL + "shiro/unprotected/tags");
- assertThat(remembered.getText()).isEqualTo("");
+ assertEquals("", remembered.getText());
}
private void login() {
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroAuthFormsIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroAuthFormsIT.java
index 0f312b3e7..85c3a58ba 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroAuthFormsIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroAuthFormsIT.java
@@ -28,7 +28,6 @@ import java.util.stream.Stream;
import static org.apache.shiro.ee.util.JakartaTransformer.jakartify;
import static org.apache.shiro.web.servlet.ShiroHttpSession.DEFAULT_SESSION_ID_NAME;
-import static org.assertj.core.api.Assertions.assertThat;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
@@ -45,6 +44,9 @@ import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -133,9 +135,9 @@ public class ShiroAuthFormsIT {
@OperateOnDeployment(DEPLOYMENT_DEV_MODE)
void protectedPageWithLogin() {
webDriver.get(baseURL + "shiro/protected");
- assertThat(webDriver.getCurrentUrl().contains("shiro/auth")).as("redirect to login").isTrue();
+ assertTrue(webDriver.getCurrentUrl().contains("shiro/auth"), "redirect to login");
login();
- assertThat(webDriver.getTitle()).isEqualTo("Protected Page");
+ assertEquals("Protected Page", webDriver.getTitle());
}
@Test
@@ -144,9 +146,9 @@ public class ShiroAuthFormsIT {
webDriver.get(baseURL + "shiro/protected");
login();
guardHttp(logout).click();
- assertThat(webDriver.getCurrentUrl().contains("shiro/auth")).as("redirect to login").isTrue();
+ assertTrue(webDriver.getCurrentUrl().contains("shiro/auth"), "redirect to login");
login();
- assertThat(webDriver.getTitle()).isEqualTo("Protected Page");
+ assertEquals("Protected Page", webDriver.getTitle());
}
@Test
@@ -156,7 +158,7 @@ public class ShiroAuthFormsIT {
username.sendKeys("webuser");
password.sendKeys("webpwd");
guardHttp(nonJSFLogin).click();
- assertThat(webDriver.getTitle()).isEqualTo("Protected Page");
+ assertEquals("Protected Page", webDriver.getTitle());
}
@Test
@@ -167,14 +169,14 @@ public class ShiroAuthFormsIT {
password.sendKeys("webpwd");
guardHttp(nonJSFLogin).click();
guardHttp(logoutViaFilter).click();
- assertThat(webDriver.getCurrentUrl().contains("shiro/auth")).as("redirect to login").isTrue();
+ assertTrue(webDriver.getCurrentUrl().contains("shiro/auth"), "redirect to login");
username.sendKeys("webuser");
password.sendKeys("webpwd");
guardHttp(nonJSFLogin).click();
firstName.sendKeys("Jack");
lastName.sendKeys("Frost");
guardHttp(submitFirst).click();
- assertThat(messages.getText()).isEqualTo("Form Submitted - firstName: Jack, lastName: Frost");
+ assertEquals("Form Submitted - firstName: Jack, lastName: Frost", messages.getText());
}
@Test
@@ -188,9 +190,9 @@ public class ShiroAuthFormsIT {
webDriver.manage().deleteCookieNamed(isShiroNativeSessionsIntegrationTest()
? "native_session_cookie" : DEFAULT_SESSION_ID_NAME);
webDriver.navigate().refresh();
- assertThat(webDriver.getTitle()).isEqualTo("Protected Page");
+ assertEquals("Protected Page", webDriver.getTitle());
guardHttp(logout).click();
- assertThat(webDriver.getCurrentUrl().contains("shiro/auth")).as("redirect to login").isTrue();
+ assertTrue(webDriver.getCurrentUrl().contains("shiro/auth"), "redirect to login");
}
@Test
@@ -198,14 +200,14 @@ public class ShiroAuthFormsIT {
void unauthorized() {
webDriver.get(baseURL + "shiro/adminpage");
login();
- assertThat(webDriver.getTitle()).isEqualTo("Unauthorized");
+ assertEquals("Unauthorized", webDriver.getTitle());
guardHttp(logout).click();
- assertThat(webDriver.getCurrentUrl()).isEqualTo(baseURL + "index");
+ assertEquals(baseURL + "index", webDriver.getCurrentUrl());
webDriver.get(baseURL + "shiro/adminpage");
username.sendKeys("admin");
password.sendKeys("adminpwd");
guardHttp(login).click();
- assertThat(webDriver.getTitle()).isEqualTo("Admin Page");
+ assertEquals("Admin Page", webDriver.getTitle());
}
@Test
@@ -215,9 +217,9 @@ public class ShiroAuthFormsIT {
username.sendKeys("webuser");
password.sendKeys("wrongpwd");
guardHttp(login).click();
- assertThat(loginFailureMessage.getText()).isEqualTo("Login Failed");
+ assertEquals("Login Failed", loginFailureMessage.getText());
login();
- assertThat(webDriver.getTitle()).isEqualTo("Protected Page");
+ assertEquals("Protected Page", webDriver.getTitle());
}
@Test
@@ -231,7 +233,7 @@ public class ShiroAuthFormsIT {
firstName.sendKeys("Jack");
lastName.sendKeys("Frost");
guardHttp(submitFirst).click();
- assertThat(sessionExpiredMessage.getText()).isEqualTo("Your Session Has Expired");
+ assertEquals("Your Session Has Expired", sessionExpiredMessage.getText());
}
@Test
@@ -239,7 +241,7 @@ public class ShiroAuthFormsIT {
void nonAjaxResubmit() {
nonAjaxSessionExpired();
login();
- assertThat(messages.getText()).isEqualTo("Form Submitted - firstName: Jack, lastName: Frost");
+ assertEquals("Form Submitted - firstName: Jack, lastName: Frost", messages.getText());
}
@Test
@@ -250,7 +252,7 @@ public class ShiroAuthFormsIT {
password.sendKeys("yyy");
guardHttp(login).click();
login();
- assertThat(messages.getText()).isEqualTo("Form Submitted - firstName: Jack, lastName: Frost");
+ assertEquals("Form Submitted - firstName: Jack, lastName: Frost", messages.getText());
}
@Test
@@ -265,7 +267,7 @@ public class ShiroAuthFormsIT {
firstName.sendKeys("Jack");
lastName.sendKeys("Frost");
guardHttp(submitFirst).click();
- assertThat(messages.getText()).isEqualTo("Form Submitted - firstName: Jack, lastName: Frost");
+ assertEquals("Form Submitted - firstName: Jack, lastName: Frost", messages.getText());
}
@Test
@@ -279,7 +281,7 @@ public class ShiroAuthFormsIT {
address.sendKeys("1 Houston Street");
city.sendKeys("New York");
waitForHttp(submitSecond).click();
- assertThat(sessionExpiredMessage.getText()).isEqualTo("Your Session Has Expired");
+ assertEquals("Your Session Has Expired", sessionExpiredMessage.getText());
}
@Test
@@ -287,11 +289,13 @@ public class ShiroAuthFormsIT {
void ajaxResubmit() {
ajaxSessionExpired();
login();
- assertThat(secondFormMessages.getText()).isEqualTo("2nd Form Submitted - Address: 1 Houston Street, City: New York");
+ assertEquals("2nd Form Submitted - Address: 1 Houston Street, City: New York",
+ secondFormMessages.getText());
address.sendKeys("Workshop");
city.sendKeys("North Pole");
guardAjax(submitSecond).click();
- assertThat(secondFormMessages.getText()).isEqualTo("2nd Form Submitted - Address: Workshop, City: North Pole");
+ assertEquals("2nd Form Submitted - Address: Workshop, City: North Pole",
+ secondFormMessages.getText());
}
@Test
@@ -312,7 +316,8 @@ public class ShiroAuthFormsIT {
} else {
waitForHttp(submitSecond).click();
}
- assertThat(secondFormMessages.getText()).isEqualTo("2nd Form Submitted - Address: 1 Houston Street, City: New York");
+ assertEquals("2nd Form Submitted - Address: 1 Houston Street, City: New York",
+ secondFormMessages.getText());
address.sendKeys("Workshop");
city.sendKeys("North Pole");
invalidateSession.click();
@@ -325,11 +330,13 @@ public class ShiroAuthFormsIT {
} else {
waitForHttp(submitSecond).click();
}
- assertThat(secondFormMessages.getText()).isEqualTo("2nd Form Submitted - Address: Workshop, City: North Pole");
+ assertEquals("2nd Form Submitted - Address: Workshop, City: North Pole",
+ secondFormMessages.getText());
address.sendKeys("LAX Airport");
city.sendKeys("Los Angeles");
guardAjax(submitSecond).click();
- assertThat(secondFormMessages.getText()).isEqualTo("2nd Form Submitted - Address: LAX Airport, City: Los Angeles");
+ assertEquals("2nd Form Submitted - Address: LAX Airport, City: Los Angeles",
+ secondFormMessages.getText());
}
@Test
@@ -339,7 +346,7 @@ public class ShiroAuthFormsIT {
login();
webDriver.get(baseURL + "shiro/auth/loginform");
login();
- assertThat(webDriver.getTitle()).isEqualTo("Index");
+ assertEquals("Index", webDriver.getTitle());
}
private void login() {
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroBeansIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroBeansIT.java
index ddb7114fa..cd211377c 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroBeansIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroBeansIT.java
@@ -18,7 +18,6 @@ import java.net.URL;
import static org.apache.shiro.ee.util.JakartaTransformer.isJakarta;
import static org.apache.shiro.ee.util.JakartaTransformer.jakartify;
import static org.apache.shiro.testing.jakarta.ee.ShiroAuthFormsIT.DEPLOYMENT_DEV_MODE;
-import static org.assertj.core.api.Assertions.assertThat;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
@@ -32,6 +31,9 @@ import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -102,21 +104,27 @@ public class ShiroBeansIT {
void checkDontCallWhenNotAuth() {
webDriver.get(baseURL + "shiro/unprotected/manybeans");
guardAjax(facesViewScoped).click();
- assertThat(messages.getText()).startsWith("view scope unauth: Attempting to perform a user-only operation");
+ assertTrue(messages.getText().startsWith("view scope unauth: Attempting to perform a user-only operation"),
+ "anonymous user should get an exception");
guardAjax(omniViewScoped).click();
- assertThat(messages.getText()).startsWith("omni view scope unauth: Attempting to perform a user-only operation");
+ assertTrue(messages.getText().startsWith("omni view scope unauth: Attempting to perform a user-only operation"),
+ "anonymous user should get an exception");
guardAjax(sessionScoped).click();
- assertThat(messages.getText()).startsWith("session scoped unauth: Attempting to perform a user-only operation");
+ assertTrue(messages.getText().startsWith("session scoped unauth: Attempting to perform a user-only operation"),
+ "anonymous user should get an exception");
guardAjax(stateless).click();
- assertThat(messages.getText()).startsWith("stateless bean unauth: Attempting to perform a user-only operation");
+ assertTrue(messages.getText().startsWith("stateless bean unauth: Attempting to perform a user-only operation"),
+ "anonymous user should get an exception");
guardAjax(unprotectedMethod).click();
- assertThat(messages.getText()).isEqualTo("unprotected method: hello from unprotected");
+ assertEquals("unprotected method: hello from unprotected", messages.getText());
guardAjax(protectedMethod).click();
- assertThat(messages.getText()).startsWith("protected unauth: Attempting to perform a user-only operation");
+ assertTrue(messages.getText().startsWith("protected unauth: Attempting to perform a user-only operation"),
+ "anonymous user should get an exception");
webDriver.get(baseURL + "lastException");
String exceptionText = webDriver.findElement(By.tagName("body")).getText();
- assertThat(exceptionText).startsWith(
- jakartify("WARNING: javax.ejb.EJBException: Attempting to perform a user-only operation"));
+ assertTrue(exceptionText
+ .startsWith(jakartify("WARNING: javax.ejb.EJBException: Attempting to perform a user-only operation")),
+ String.format("capturing correct warning from the server: %s", exceptionText));
}
@Test
@@ -127,15 +135,15 @@ public class ShiroBeansIT {
webDriver.get(baseURL + "shiro/unprotected/manybeans");
guardAjax(facesViewScoped).click();
- assertThat(messages.getText()).startsWith("Hello from FacesViewScoped");
+ assertTrue(messages.getText().startsWith("Hello from FacesViewScoped"));
guardAjax(omniViewScoped).click();
- assertThat(messages.getText()).startsWith("Hello from OmniViewScoped");
+ assertTrue(messages.getText().startsWith("Hello from OmniViewScoped"));
guardAjax(sessionScoped).click();
- assertThat(messages.getText()).startsWith("Hello from SessionScoped");
+ assertTrue(messages.getText().startsWith("Hello from SessionScoped"));
guardAjax(stateless).click();
- assertThat(messages.getText()).startsWith("Hello from ProtectedStatelessBean");
+ assertTrue(messages.getText().startsWith("Hello from ProtectedStatelessBean"));
guardAjax(protectedMethod).click();
- assertThat(messages.getText()).isEqualTo("protected method: hello from protected");
+ assertEquals("protected method: hello from protected", messages.getText());
}
@Test
@@ -162,13 +170,13 @@ public class ShiroBeansIT {
waitGui(webDriver).until(ExpectedConditions.alertIsPresent());
webDriver.switchTo().alert().accept();
webDriver.get(baseURL + createStatistic);
- assertThat(webDriver.findElement(By.tagName("body")).getText()).isEqualTo("2");
+ assertEquals("2", webDriver.findElement(By.tagName("body")).getText());
webDriver.get(baseURL + destroyStatistic);
- assertThat(webDriver.findElement(By.tagName("body")).getText()).isEqualTo(isBrokenDestructor && webSessions ? "1" : "2");
+ assertEquals(isBrokenDestructor && webSessions ? "1" : "2", webDriver.findElement(By.tagName("body")).getText());
webDriver.get(baseURL + "api/statistics/pc_ss");
- assertThat(webDriver.findElement(By.tagName("body")).getText()).isEqualTo("1");
+ assertEquals("1", webDriver.findElement(By.tagName("body")).getText());
webDriver.get(baseURL + "api/statistics/pd_ss");
- assertThat(webDriver.findElement(By.tagName("body")).getText()).isEqualTo("1");
+ assertEquals("1", webDriver.findElement(By.tagName("body")).getText());
}
private void login() {
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroSSLFilterIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroSSLFilterIT.java
index 19c064921..b1898ab53 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroSSLFilterIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jakarta/ee/ShiroSSLFilterIT.java
@@ -18,8 +18,6 @@ import static com.flowlogix.util.ShrinkWrapManipulator.toHttpsURL;
import java.net.URL;
import static org.apache.shiro.testing.jakarta.ee.ShiroAuthFormsIT.DEPLOYMENT_PROD_MODE;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
@@ -28,6 +26,9 @@ import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -50,15 +51,14 @@ public class ShiroSSLFilterIT {
@Test
@OperateOnDeployment(DEPLOYMENT_PROD_MODE)
void checkNonSSL() {
- assertThatExceptionOfType(WebDriverException.class).isThrownBy(() ->
- webDriver.get(baseURL + "shiro/unprotected/manybeans"));
+ assertThrows(WebDriverException.class, () -> webDriver.get(baseURL + "shiro/unprotected/manybeans"));
}
@Test
@OperateOnDeployment(DEPLOYMENT_PROD_MODE)
void checkSSL() {
webDriver.get(toHttpsURL(baseURL) + "shiro/unprotected/manybeans");
- assertThat(webDriver.getTitle()).isEqualTo("Many Beans Unprotected");
+ assertEquals("Many Beans Unprotected", webDriver.getTitle());
}
@Deployment(testable = false, name = DEPLOYMENT_PROD_MODE)
diff --git a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jaxrs/NoIniJaxRsIT.java b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jaxrs/NoIniJaxRsIT.java
index 55e887551..df56c074d 100644
--- a/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jaxrs/NoIniJaxRsIT.java
+++ b/integration-tests/jakarta-ee/src/test/java/org/apache/shiro/testing/jaxrs/NoIniJaxRsIT.java
@@ -27,7 +27,6 @@ import lombok.SneakyThrows;
import org.apache.shiro.testing.cdi.ComponentInjectionIT;
import static org.apache.shiro.testing.cdi.ComponentInjectionIT.TESTABLE_MODE;
-import static org.assertj.core.api.Assertions.fail;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
@@ -36,6 +35,7 @@ import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
diff --git a/integration-tests/jaxrs/tests/pom.xml b/integration-tests/jaxrs/tests/pom.xml
index 93e1107dc..65367fb0f 100644
--- a/integration-tests/jaxrs/tests/pom.xml
+++ b/integration-tests/jaxrs/tests/pom.xml
@@ -92,11 +92,6 @@
<version>1.1.4</version>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>compile</scope>
- </dependency>
</dependencies>
diff --git a/integration-tests/jaxrs/tests/src/main/java/org/apache/shiro/testing/jaxrs/tests/AbstractShiroJaxRsIT.java b/integration-tests/jaxrs/tests/src/main/java/org/apache/shiro/testing/jaxrs/tests/AbstractShiroJaxRsIT.java
index 541af50a1..9758c9d66 100644
--- a/integration-tests/jaxrs/tests/src/main/java/org/apache/shiro/testing/jaxrs/tests/AbstractShiroJaxRsIT.java
+++ b/integration-tests/jaxrs/tests/src/main/java/org/apache/shiro/testing/jaxrs/tests/AbstractShiroJaxRsIT.java
@@ -36,7 +36,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class AbstractShiroJaxRsIT {
@@ -58,7 +58,7 @@ public abstract class AbstractShiroJaxRsIT {
final Response usersResponse = usersTarget.request(MediaType.APPLICATION_JSON_TYPE)
.buildGet()
.invoke();
- assertThat(usersResponse.getStatus()).isEqualTo(Status.FORBIDDEN.getStatusCode());
+ assertEquals(Status.FORBIDDEN.getStatusCode(), usersResponse.getStatus());
}
@SuppressWarnings({"checkstyle:MagicNumber"})
@@ -70,9 +70,9 @@ public abstract class AbstractShiroJaxRsIT {
.header("Authorization", "Basic " + basicToken)
.buildGet()
.invoke();
- assertThat(usersResponse.getStatus()).isEqualTo(Status.OK.getStatusCode());
+ assertEquals(Status.OK.getStatusCode(), usersResponse.getStatus());
final Stormtrooper[] stormtroopers = usersResponse.readEntity(Stormtrooper[].class);
- assertThat(stormtroopers.length).isEqualTo(50);
+ assertEquals(50, stormtroopers.length);
Arrays.stream(stormtroopers).forEach(stormtrooper
-> assertTrue(stormtrooper.getStormtrooperId().getValue().startsWith("u")));
}
diff --git a/integration-tests/support/pom.xml b/integration-tests/support/pom.xml
index f837c7c9a..f843c4557 100644
--- a/integration-tests/support/pom.xml
+++ b/integration-tests/support/pom.xml
@@ -124,13 +124,6 @@
<scope>compile</scope>
</dependency>
-
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>compile</scope>
- </dependency>
-
<!-- dependency on the Base64 class
in 2.0 this is split out, so this dep will be removed
in the future
diff --git a/integration-tests/support/src/main/java/org/apache/shiro/testing/web/AbstractContainerIT.java b/integration-tests/support/src/main/java/org/apache/shiro/testing/web/AbstractContainerIT.java
index 9b77a8882..429de1ccb 100644
--- a/integration-tests/support/src/main/java/org/apache/shiro/testing/web/AbstractContainerIT.java
+++ b/integration-tests/support/src/main/java/org/apache/shiro/testing/web/AbstractContainerIT.java
@@ -55,7 +55,8 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("checkstyle:ClassDataAbstractionCoupling")
public abstract class AbstractContainerIT {
@@ -151,7 +152,7 @@ public abstract class AbstractContainerIT {
jetty.start();
- assertThat(jetty.isStarted()).isTrue();
+ assertTrue(jetty.isStarted());
}
protected static String getBaseUri() {
@@ -171,9 +172,7 @@ public abstract class AbstractContainerIT {
});
assert warFiles != null;
- assertThat(warFiles.length)
- .as("Expected only one war file in target directory, run 'mvn clean' and try again")
- .isEqualTo(1);
+ assertEquals(1, warFiles.length, "Expected only one war file in target directory, run 'mvn clean' and try again");
return warFiles[0].getAbsolutePath().replaceFirst("\\.war$", "");
}
diff --git a/lang/src/test/java/org/apache/shiro/lang/util/ClassUtilsTest.java b/lang/src/test/java/org/apache/shiro/lang/util/ClassUtilsTest.java
index e1988276e..b9097eefa 100644
--- a/lang/src/test/java/org/apache/shiro/lang/util/ClassUtilsTest.java
+++ b/lang/src/test/java/org/apache/shiro/lang/util/ClassUtilsTest.java
@@ -20,68 +20,68 @@ package org.apache.shiro.lang.util;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
class ClassUtilsTest {
@Test
void testGetPrimitiveClasses() throws UnknownClassException {
- assertThat(ClassUtils.forName("boolean")).isEqualTo(boolean.class);
- assertThat(ClassUtils.forName("byte")).isEqualTo(byte.class);
- assertThat(ClassUtils.forName("char")).isEqualTo(char.class);
- assertThat(ClassUtils.forName("short")).isEqualTo(short.class);
- assertThat(ClassUtils.forName("int")).isEqualTo(int.class);
- assertThat(ClassUtils.forName("long")).isEqualTo(long.class);
- assertThat(ClassUtils.forName("float")).isEqualTo(float.class);
- assertThat(ClassUtils.forName("double")).isEqualTo(double.class);
- assertThat(ClassUtils.forName("void")).isEqualTo(void.class);
+ assertEquals(boolean.class, ClassUtils.forName("boolean"));
+ assertEquals(byte.class, ClassUtils.forName("byte"));
+ assertEquals(char.class, ClassUtils.forName("char"));
+ assertEquals(short.class, ClassUtils.forName("short"));
+ assertEquals(int.class, ClassUtils.forName("int"));
+ assertEquals(long.class, ClassUtils.forName("long"));
+ assertEquals(float.class, ClassUtils.forName("float"));
+ assertEquals(double.class, ClassUtils.forName("double"));
+ assertEquals(void.class, ClassUtils.forName("void"));
- assertThat(ClassUtils.forName(boolean.class.getName())).isEqualTo(boolean.class);
- assertThat(ClassUtils.forName(byte.class.getName())).isEqualTo(byte.class);
- assertThat(ClassUtils.forName(char.class.getName())).isEqualTo(char.class);
- assertThat(ClassUtils.forName(short.class.getName())).isEqualTo(short.class);
- assertThat(ClassUtils.forName(int.class.getName())).isEqualTo(int.class);
- assertThat(ClassUtils.forName(long.class.getName())).isEqualTo(long.class);
- assertThat(ClassUtils.forName(float.class.getName())).isEqualTo(float.class);
- assertThat(ClassUtils.forName(double.class.getName())).isEqualTo(double.class);
- assertThat(ClassUtils.forName(void.class.getName())).isEqualTo(void.class);
+ assertEquals(boolean.class, ClassUtils.forName(boolean.class.getName()));
+ assertEquals(byte.class, ClassUtils.forName(byte.class.getName()));
+ assertEquals(char.class, ClassUtils.forName(char.class.getName()));
+ assertEquals(short.class, ClassUtils.forName(short.class.getName()));
+ assertEquals(int.class, ClassUtils.forName(int.class.getName()));
+ assertEquals(long.class, ClassUtils.forName(long.class.getName()));
+ assertEquals(float.class, ClassUtils.forName(float.class.getName()));
+ assertEquals(double.class, ClassUtils.forName(double.class.getName()));
+ assertEquals(void.class, ClassUtils.forName(void.class.getName()));
}
@Test
void testGetPrimitiveArrays() throws UnknownClassException {
- assertThat(ClassUtils.forName("[Z")).isEqualTo(boolean[].class);
- assertThat(ClassUtils.forName("[B")).isEqualTo(byte[].class);
- assertThat(ClassUtils.forName("[C")).isEqualTo(char[].class);
- assertThat(ClassUtils.forName("[S")).isEqualTo(short[].class);
- assertThat(ClassUtils.forName("[I")).isEqualTo(int[].class);
- assertThat(ClassUtils.forName("[J")).isEqualTo(long[].class);
- assertThat(ClassUtils.forName("[F")).isEqualTo(float[].class);
- assertThat(ClassUtils.forName("[D")).isEqualTo(double[].class);
+ assertEquals(boolean[].class, ClassUtils.forName("[Z"));
+ assertEquals(byte[].class, ClassUtils.forName("[B"));
+ assertEquals(char[].class, ClassUtils.forName("[C"));
+ assertEquals(short[].class, ClassUtils.forName("[S"));
+ assertEquals(int[].class, ClassUtils.forName("[I"));
+ assertEquals(long[].class, ClassUtils.forName("[J"));
+ assertEquals(float[].class, ClassUtils.forName("[F"));
+ assertEquals(double[].class, ClassUtils.forName("[D"));
- assertThat(ClassUtils.forName(boolean[].class.getName())).isEqualTo(boolean[].class);
- assertThat(ClassUtils.forName(byte[].class.getName())).isEqualTo(byte[].class);
- assertThat(ClassUtils.forName(char[].class.getName())).isEqualTo(char[].class);
- assertThat(ClassUtils.forName(short[].class.getName())).isEqualTo(short[].class);
- assertThat(ClassUtils.forName(int[].class.getName())).isEqualTo(int[].class);
- assertThat(ClassUtils.forName(long[].class.getName())).isEqualTo(long[].class);
- assertThat(ClassUtils.forName(float[].class.getName())).isEqualTo(float[].class);
- assertThat(ClassUtils.forName(double[].class.getName())).isEqualTo(double[].class);
+ assertEquals(boolean[].class, ClassUtils.forName(boolean[].class.getName()));
+ assertEquals(byte[].class, ClassUtils.forName(byte[].class.getName()));
+ assertEquals(char[].class, ClassUtils.forName(char[].class.getName()));
+ assertEquals(short[].class, ClassUtils.forName(short[].class.getName()));
+ assertEquals(int[].class, ClassUtils.forName(int[].class.getName()));
+ assertEquals(long[].class, ClassUtils.forName(long[].class.getName()));
+ assertEquals(float[].class, ClassUtils.forName(float[].class.getName()));
+ assertEquals(double[].class, ClassUtils.forName(double[].class.getName()));
}
@Test
void testGetClass() {
- assertThat(ClassUtils.forName("java.lang.String")).isEqualTo(String.class);
- assertThat(ClassUtils.forName("[Ljava.lang.String;")).isEqualTo(String[].class);
- assertThat(ClassUtils.forName(String.class.getName())).isEqualTo(String.class);
- assertThat(ClassUtils.forName(String[].class.getName())).isEqualTo(String[].class);
+ assertEquals(String.class, ClassUtils.forName("java.lang.String"));
+ assertEquals(String[].class, ClassUtils.forName("[Ljava.lang.String;"));
+ assertEquals(String.class, ClassUtils.forName(String.class.getName()));
+ assertEquals(String[].class, ClassUtils.forName(String[].class.getName()));
- assertThat(ClassUtils.forName("org.apache.shiro.lang.util.ClassUtilsTest")).isEqualTo(ClassUtilsTest.class);
- assertThat(ClassUtils.forName("[Lorg.apache.shiro.lang.util.ClassUtilsTest;")).isEqualTo(ClassUtilsTest[].class);
- assertThat(ClassUtils.forName(ClassUtilsTest.class.getName())).isEqualTo(ClassUtilsTest.class);
- assertThat(ClassUtils.forName(ClassUtilsTest[].class.getName())).isEqualTo(ClassUtilsTest[].class);
+ assertEquals(ClassUtilsTest.class, ClassUtils.forName("org.apache.shiro.lang.util.ClassUtilsTest"));
+ assertEquals(ClassUtilsTest[].class, ClassUtils.forName("[Lorg.apache.shiro.lang.util.ClassUtilsTest;"));
+ assertEquals(ClassUtilsTest.class, ClassUtils.forName(ClassUtilsTest.class.getName()));
+ assertEquals(ClassUtilsTest[].class, ClassUtils.forName(ClassUtilsTest[].class.getName()));
}
}
diff --git a/pom.xml b/pom.xml
index 5b12c61da..bc8e0e9e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -879,6 +879,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
+ <version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -1081,12 +1082,6 @@
<version>2.2.0</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>3.25.3</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
diff --git a/samples/aspectj/src/test/java/org/apache/shiro/samples/aspectj/bank/SecureBankServiceTest.java b/samples/aspectj/src/test/java/org/apache/shiro/samples/aspectj/bank/SecureBankServiceTest.java
index 5197c7107..b9bc13b2d 100644
--- a/samples/aspectj/src/test/java/org/apache/shiro/samples/aspectj/bank/SecureBankServiceTest.java
+++ b/samples/aspectj/src/test/java/org/apache/shiro/samples/aspectj/bank/SecureBankServiceTest.java
@@ -33,9 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
@SuppressWarnings({"checkstyle:MemberName", "checkstyle:MethodName", "checkstyle:MagicNumber"})
public class SecureBankServiceTest {
@@ -123,7 +121,7 @@ public class SecureBankServiceTest {
@Test
void testWithdrawFrom_emptyAccount() throws Exception {
- assertThatExceptionOfType(NotEnoughFundsException.class).isThrownBy(() -> {
+ assertThrows(NotEnoughFundsException.class, () -> {
loginAsUser();
long accountId = createAndValidateAccountFor("Wally Smith");
service.withdrawFrom(accountId, 100);
@@ -132,7 +130,7 @@ public class SecureBankServiceTest {
@Test
void testWithdrawFrom_notEnoughFunds() throws Exception {
- assertThatExceptionOfType(NotEnoughFundsException.class).isThrownBy(() -> {
+ assertThrows(NotEnoughFundsException.class, () -> {
loginAsUser();
long accountId = createAndValidateAccountFor("Frank Smith");
makeDepositAndValidateAccount(accountId, 50, "Frank Smith");
@@ -177,7 +175,7 @@ public class SecureBankServiceTest {
logoutCurrentSubject();
loginAsSuperviser();
double closingBalance = service.closeAccount(accountId);
- assertThat((int) closingBalance).isEqualTo(0);
+ assertEquals(0, (int) closingBalance);
assertAccount("Chris Smith", false, 0, 1, accountId);
}
@@ -190,13 +188,13 @@ public class SecureBankServiceTest {
logoutCurrentSubject();
loginAsSuperviser();
double closingBalance = service.closeAccount(accountId);
- assertThat((int) closingBalance).isEqualTo(385);
+ assertEquals(385, (int) closingBalance);
assertAccount("Gerry Smith", false, 0, 2, accountId);
}
@Test
void testCloseAccount_alreadyClosed() throws Exception {
- assertThatExceptionOfType(InactiveAccountException.class).isThrownBy(() -> {
+ assertThrows(InactiveAccountException.class, () -> {
loginAsUser();
long accountId = createAndValidateAccountFor("Chris Smith");
@@ -211,7 +209,7 @@ public class SecureBankServiceTest {
@Test
void testCloseAccount_unauthorizedAttempt() throws Exception {
- assertThatExceptionOfType(UnauthorizedException.class).isThrownBy(() -> {
+ assertThrows(UnauthorizedException.class, () -> {
loginAsUser();
long accountId = createAndValidateAccountFor("Chris Smith");
service.closeAccount(accountId);
@@ -228,7 +226,7 @@ public class SecureBankServiceTest {
double previousBalance = service.getBalanceOf(anAccountId);
int previousTxCount = service.getTxHistoryFor(anAccountId).length;
double newBalance = service.depositInto(anAccountId, anAmount);
- assertThat((int) newBalance).isEqualTo((int) previousBalance + anAmount);
+ assertEquals((int) previousBalance + anAmount, (int) newBalance);
assertAccount(eOwnerName, true, (int) newBalance, 1 + previousTxCount, anAccountId);
return newBalance;
}
@@ -237,7 +235,7 @@ public class SecureBankServiceTest {
double previousBalance = service.getBalanceOf(anAccountId);
int previousTxCount = service.getTxHistoryFor(anAccountId).length;
double newBalance = service.withdrawFrom(anAccountId, anAmount);
- assertThat((int) newBalance).isEqualTo((int) previousBalance - anAmount);
+ assertEquals((int) previousBalance - anAmount, (int) newBalance);
assertAccount(eOwnerName, true, (int) newBalance, 1 + previousTxCount, anAccountId);
return newBalance;
}
@@ -245,10 +243,10 @@ public class SecureBankServiceTest {
public static void assertAccount(String eOwnerName, boolean eIsActive, int eBalance,
int eTxLogCount, long actualAccountId) throws Exception {
- assertThat(service.getOwnerOf(actualAccountId)).isEqualTo(eOwnerName);
- assertThat(service.isAccountActive(actualAccountId)).isEqualTo(eIsActive);
- assertThat((int) service.getBalanceOf(actualAccountId)).isEqualTo(eBalance);
- assertThat(service.getTxHistoryFor(actualAccountId).length).isEqualTo(eTxLogCount);
+ assertEquals(eOwnerName, service.getOwnerOf(actualAccountId));
+ assertEquals(eIsActive, service.isAccountActive(actualAccountId));
+ assertEquals(eBalance, (int) service.getBalanceOf(actualAccountId));
+ assertEquals(eTxLogCount, service.getTxHistoryFor(actualAccountId).length);
}
@RequiresGuest
diff --git a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java b/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java
index c6abdae9a..e8eeb2acd 100644
--- a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java
+++ b/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeAll;
import java.io.File;
import java.io.FilenameFilter;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public abstract class JakartaAbstractContainerIT {
@@ -57,9 +57,7 @@ public abstract class JakartaAbstractContainerIT {
}
});
- assertThat(warFiles.length)
- .as("Expected only one war file in target directory, run 'mvn clean' and try again")
- .isEqualTo(1);
+ assertEquals(1, warFiles.length, "Expected only one war file in target directory, run 'mvn clean' and try again");
return warFiles[0].getAbsolutePath().replaceFirst("\\.war$", "");
}
diff --git a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/WebContainerIT.java b/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/WebContainerIT.java
index 4074d10e6..d4cc4da38 100644
--- a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/WebContainerIT.java
+++ b/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/WebContainerIT.java
@@ -29,7 +29,10 @@ import java.net.URI;
import static jakarta.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
import static jakarta.ws.rs.core.MediaType.TEXT_HTML_TYPE;
-import static org.assertj.core.api.Assertions.assertThat;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class WebContainerIT extends JakartaAbstractContainerIT {
@@ -46,27 +49,27 @@ public class WebContainerIT extends JakartaAbstractContainerIT {
.get()) {
jsessionid = new Cookie("JSESSIONID",
loginPage.getMetadata().get("Set-Cookie").get(0).toString().split(";")[0].split("=")[1]);
- assertThat(loginPage.readEntity(String.class)).contains("loginform");
+ assertTrue(loginPage.readEntity(String.class).contains("loginform"));
}
- assertThat(jsessionid).isNotNull();
+ assertNotNull(jsessionid);
URI location;
try (Response loginAction = client.target(getBaseUri())
.path("/login.jsp")
.request(APPLICATION_FORM_URLENCODED)
.cookie(jsessionid)
.post(Entity.entity("username=root&password=secret&submit=Login", APPLICATION_FORM_URLENCODED))) {
- assertThat(loginAction.getStatus()).isEqualTo(302);
+ assertEquals(302, loginAction.getStatus());
location = loginAction.getLocation();
}
- assertThat(location).isNotNull();
+ assertNotNull(location);
final String loggedPage = client.target(getBaseUri())
.path(location.getPath())
.request(APPLICATION_FORM_URLENCODED)
.cookie(jsessionid)
.get(String.class);
- assertThat(loggedPage).contains("Hi root!");
+ assertTrue(loggedPage.contains("Hi root!"));
} finally {
client.close();
}
diff --git a/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java b/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
index 53779b826..b4d5bb0a5 100644
--- a/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
+++ b/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
*
@@ -102,7 +102,7 @@ public class DummyServiceTest {
@Test
void testGuest_asUser() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
loginAsUser();
securedService.guest();
});
@@ -110,7 +110,7 @@ public class DummyServiceTest {
@Test
void testGuest_asAdmin() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
loginAsAdmin();
securedService.guest();
});
@@ -119,7 +119,7 @@ public class DummyServiceTest {
// TEST PEEK
@Test
void testPeek_asAnonymous() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
securedService.peek();
});
}
@@ -140,7 +140,7 @@ public class DummyServiceTest {
//UnauthenticatedException per SHIRO-146
@Test
void testRetrieve_asAnonymous() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
securedService.retrieve();
});
}
@@ -161,14 +161,14 @@ public class DummyServiceTest {
//UnauthenticatedException per SHIRO-146
@Test
void testChange_asAnonymous() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
securedService.change();
});
}
@Test
void testChange_asUser() throws Exception {
- assertThatExceptionOfType(UnauthorizedException.class).isThrownBy(() -> {
+ assertThrows(UnauthorizedException.class, () -> {
loginAsUser();
securedService.change();
});
@@ -184,14 +184,14 @@ public class DummyServiceTest {
//UnauthenticatedException per SHIRO-146
@Test
void testRetrieveRestricted_asAnonymous() throws Exception {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
restrictedService.retrieve();
});
}
@Test
void testRetrieveRestricted_asUser() throws Exception {
- assertThatExceptionOfType(UnauthorizedException.class).isThrownBy(() -> {
+ assertThrows(UnauthorizedException.class, () -> {
loginAsUser();
restrictedService.retrieve();
});
diff --git a/support/cdi/src/test/java/org/apache/shiro/cdi/AnnotatedTypeWrapperTest.java b/support/cdi/src/test/java/org/apache/shiro/cdi/AnnotatedTypeWrapperTest.java
index 14aa49ce7..98ddfd512 100644
--- a/support/cdi/src/test/java/org/apache/shiro/cdi/AnnotatedTypeWrapperTest.java
+++ b/support/cdi/src/test/java/org/apache/shiro/cdi/AnnotatedTypeWrapperTest.java
@@ -20,10 +20,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.ejb.Stateless;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -31,6 +27,10 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresGuest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@@ -69,14 +69,14 @@ class AnnotatedTypeWrapperTest {
@Test
void noAnnotations() {
var wrapper = new AnnotatedTypeWrapper<>(annotatedType);
- assertThat(wrapper.getAnnotations()).isEmpty();
+ assertEquals(0, wrapper.getAnnotations().size());
}
@Test
void noAdditionalAnnotations() {
initializeStubs();
var wrapper = new AnnotatedTypeWrapper<>(annotatedType);
- assertThat(wrapper.getAnnotations()).hasSize(3);
+ assertEquals(3, wrapper.getAnnotations().size());
}
@Test
@@ -86,12 +86,12 @@ class AnnotatedTypeWrapperTest {
Annotation shiroSecureAnnotation = getAnnotation(ShiroSecureAnnotated.class, ShiroSecureAnnotation.class);
Annotation statelessAnnotation = getAnnotation(StatelessAnnotated.class, Stateless.class);
var wrapper = new AnnotatedTypeWrapper<>(annotatedType, shiroSecureAnnotation, statelessAnnotation);
- assertThat(wrapper.getAnnotations()).hasSize(5);
- assertThat(wrapper.isAnnotationPresent(ShiroSecureAnnotation.class)).isTrue();
- assertThat(wrapper.isAnnotationPresent(Stateless.class)).isTrue();
- assertThat(wrapper.isAnnotationPresent(RequiresAuthentication.class)).isTrue();
- assertThat(wrapper.isAnnotationPresent(RequiresGuest.class)).isTrue();
- assertThat(wrapper.isAnnotationPresent(RequiresPermissions.class)).isTrue();
+ assertEquals(5, wrapper.getAnnotations().size());
+ assertTrue(wrapper.isAnnotationPresent(ShiroSecureAnnotation.class));
+ assertTrue(wrapper.isAnnotationPresent(Stateless.class));
+ assertTrue(wrapper.isAnnotationPresent(RequiresAuthentication.class));
+ assertTrue(wrapper.isAnnotationPresent(RequiresGuest.class));
+ assertTrue(wrapper.isAnnotationPresent(RequiresPermissions.class));
}
@Test
@@ -100,46 +100,49 @@ class AnnotatedTypeWrapperTest {
Set<Annotation> sessionScopeAnnoationsSet = Set.of(getAnnotation(SessionScopedAnnotated.class, SessionScoped.class));
Set<Annotation> requiresGuestAnnoationsSet = Set.of(getAnnotation(Annotated.class, RequiresGuest.class));
var wrapper = new AnnotatedTypeWrapper<>(annotatedType, true, sessionScopeAnnoationsSet, requiresGuestAnnoationsSet);
- assertThat(wrapper.getAnnotations()).hasSize(3);
- assertThat(wrapper.isAnnotationPresent(RequiresGuest.class)).isFalse();
- assertThat(wrapper.isAnnotationPresent(SessionScoped.class)).isTrue();
+ assertEquals(3, wrapper.getAnnotations().size());
+ assertFalse(wrapper.isAnnotationPresent(RequiresGuest.class));
+ assertTrue(wrapper.isAnnotationPresent(SessionScoped.class));
}
@Test
void badLambdaArgument() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new AnnotatedTypeWrapper<>(annotatedType, true,
- Set.of(() -> SessionScoped.class),
- Set.of(() -> RequiresGuest.class)));
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new AnnotatedTypeWrapper<>(annotatedType, true,
- Set.of(() -> RequiresGuest.class),
- Set.of()));
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new AnnotatedTypeWrapper<>(annotatedType, true,
- Set.of(),
- Set.of(() -> RequiresGuest.class)));
+ assertThrows(IllegalArgumentException.class,
+ () -> new AnnotatedTypeWrapper<>(annotatedType, true,
+ Set.of(() -> SessionScoped.class),
+ Set.of(() -> RequiresGuest.class)));
+ assertThrows(IllegalArgumentException.class,
+ () -> new AnnotatedTypeWrapper<>(annotatedType, true,
+ Set.of(() -> RequiresGuest.class),
+ Set.of()));
+ assertThrows(IllegalArgumentException.class,
+ () -> new AnnotatedTypeWrapper<>(annotatedType, true,
+ Set.of(),
+ Set.of(() -> RequiresGuest.class)));
}
@Test
void overriddenAnnotation() {
initializeStubs();
when(annotatedType.getJavaClass()).thenReturn(Void.class);
- assertThat(annotatedType.getAnnotations()).hasSize(3);
+ assertEquals(3, annotatedType.getAnnotations().size());
Annotation shiroSecureAnnoations = getAnnotation(ShiroSecureAnnotated.class, ShiroSecureAnnotation.class);
Annotation statelessAnnoations = getAnnotation(StatelessAnnotated.class, Stateless.class);
var wrapper = new AnnotatedTypeWrapper<>(annotatedType, false,
Set.of(shiroSecureAnnoations, statelessAnnoations),
Set.of());
- assertThat(wrapper.getAnnotations()).hasSize(2);
- assertThat(wrapper.isAnnotationPresent(ShiroSecureAnnotation.class)).isTrue();
- assertThat(wrapper.isAnnotationPresent(Stateless.class)).isTrue();
- assertThat(wrapper.getJavaClass()).isEqualTo(Void.class);
+ assertEquals(2, wrapper.getAnnotations().size());
+ assertTrue(wrapper.isAnnotationPresent(ShiroSecureAnnotation.class));
+ assertTrue(wrapper.isAnnotationPresent(Stateless.class));
+ assertEquals(Void.class, wrapper.getJavaClass());
}
@Test
void decreaseAnnotationsToZero() {
initializeStubs();
- assertThat(annotatedType.getAnnotations()).hasSize(3);
+ assertEquals(3, annotatedType.getAnnotations().size());
var wrapper = new AnnotatedTypeWrapper<>(annotatedType, false, Set.of(), Set.of());
- assertThat(wrapper.getAnnotations()).isEmpty();
+ assertEquals(0, wrapper.getAnnotations().size());
}
private void initializeStubs() {
diff --git a/support/cdi/src/test/java/org/apache/shiro/cdi/AopHelperTest.java b/support/cdi/src/test/java/org/apache/shiro/cdi/AopHelperTest.java
index cd747f72d..0e5affdec 100644
--- a/support/cdi/src/test/java/org/apache/shiro/cdi/AopHelperTest.java
+++ b/support/cdi/src/test/java/org/apache/shiro/cdi/AopHelperTest.java
@@ -26,8 +26,7 @@ import java.lang.annotation.Annotation;
import java.util.List;
import static org.apache.shiro.cdi.AopHelper.autorizationAnnotationClasses;
-import static org.assertj.core.api.Assertions.assertThat;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.times;
@@ -62,7 +61,7 @@ class AopHelperTest {
@SneakyThrows
void numberOfInterceptors() {
createInterceptors();
- assertThat(interceptors).hasSize(2);
+ assertEquals(2, interceptors.size());
}
@Test
@@ -80,17 +79,17 @@ class AopHelperTest {
@Test
@SneakyThrows
void checkNotAnnotated() {
- assertThat(AopHelper.createSecurityInterceptors(NotAnnotated.class.getMethod("method"),
- NotAnnotated.class)).isEmpty();
+ assertEquals(0, AopHelper.createSecurityInterceptors(NotAnnotated.class.getMethod("method"),
+ NotAnnotated.class).size());
}
@Test
@SneakyThrows
@SuppressWarnings("MagicNumber")
void checkAllAnnotationTypes() {
- assertThat(autorizationAnnotationClasses.keySet().stream().distinct().count()).isEqualTo(8);
+ assertEquals(8, autorizationAnnotationClasses.keySet().stream().distinct().count());
for (Class<? extends Annotation> clz : autorizationAnnotationClasses.keySet()) {
- assertThat(autorizationAnnotationClasses.get(clz).call().getAnnotationClass()).isEqualTo(clz);
+ assertEquals(clz, autorizationAnnotationClasses.get(clz).call().getAnnotationClass());
}
}
}
diff --git a/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java b/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java
index 44eda5f08..a13bbb7d7 100644
--- a/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java
+++ b/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java
@@ -24,11 +24,14 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Collection;
import java.util.Set;
-import static org.assertj.core.api.Assertions.assertThat;
-
/**
* TODO - Class JavaDoc
*
@@ -51,17 +54,17 @@ public class EhCacheManagerTest {
@Test
void testCacheManagerCreationDuringInit() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
cacheManager.init();
//now assert that an internal CacheManager has been created:
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
}
@Test
void testLazyCacheManagerCreationWithoutCallingInit() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
//don't call init here - the ehcache CacheManager should be lazily created
//because of the default Shiro ehcache.xml file in the classpath. Just acquire a cache:
@@ -69,133 +72,133 @@ public class EhCacheManagerTest {
//now assert that an internal CacheManager has been created:
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
- assertThat(cache).isNotNull();
+ assertNotNull(cache);
cache.put("hello", "world");
String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
+ assertNotNull(value);
+ assertEquals("world", value);
}
@Test
void testRemove() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
Cache<String, String> cache = cacheManager.getCache("test");
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
- assertThat(cache).isNotNull();
+ assertNotNull(cache);
cache.put("hello", "world");
cache.put("hello2", "world2");
String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
+ assertNotNull(value);
+ assertEquals("world", value);
+ assertEquals("world2", cache.get("hello2"));
+ assertEquals(2, cache.size());
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
- assertThat(cache.remove("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(0);
+ assertEquals("world", cache.remove("hello"));
+ assertEquals(1, cache.size());
+ assertEquals("world2", cache.remove("hello2"));
+ assertEquals(0, cache.size());
- assertThat(cache.remove("blah")).isNull();
+ assertNull(cache.remove("blah"));
}
@Test
void testClear() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
Cache<String, String> cache = cacheManager.getCache("test");
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
- assertThat(cache).isNotNull();
+ assertNotNull(cache);
cache.put("hello", "world");
cache.put("hello2", "world2");
String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
+ assertNotNull(value);
+ assertEquals("world", value);
+ assertEquals("world2", cache.get("hello2"));
+ assertEquals(2, cache.size());
cache.clear();
- assertThat(cache.size()).isEqualTo(0);
+ assertEquals(0, cache.size());
- assertThat(cache.get("hello")).isNull();
+ assertNull(cache.get("hello"));
}
@Test
void testKeys() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
Cache<String, String> cache = cacheManager.getCache("test");
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
- assertThat(cache).isNotNull();
+ assertNotNull(cache);
cache.put("hello", "world");
cache.put("hello2", "world2");
String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
+ assertNotNull(value);
+ assertEquals("world", value);
+ assertEquals("world2", cache.get("hello2"));
+ assertEquals(2, cache.size());
Set<String> keys = cache.keys();
- assertThat(keys).hasSize(2);
- assertThat(keys).contains("hello");
- assertThat(keys).contains("hello2");
+ assertEquals(2, keys.size());
+ assertTrue(keys.contains("hello"));
+ assertTrue(keys.contains("hello2"));
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
+ assertEquals("world", cache.remove("hello"));
+ assertEquals(1, cache.size());
keys = cache.keys();
- assertThat(keys).hasSize(1);
- assertThat(keys).contains("hello2");
+ assertEquals(1, keys.size());
+ assertTrue(keys.contains("hello2"));
- assertThat(cache.remove("blah")).isNull();
+ assertNull(cache.remove("blah"));
}
@Test
void testValues() {
net.sf.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
+ assertNull(ehCacheManager);
Cache<String, String> cache = cacheManager.getCache("test");
ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
+ assertNotNull(ehCacheManager);
- assertThat(cache).isNotNull();
+ assertNotNull(cache);
cache.put("hello", "world");
cache.put("hello2", "world2");
String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
+ assertNotNull(value);
+ assertEquals("world", value);
+ assertEquals("world2", cache.get("hello2"));
+ assertEquals(2, cache.size());
Collection<String> values = cache.values();
- assertThat(values).hasSize(2);
- assertThat(values).contains("world");
- assertThat(values).contains("world2");
+ assertEquals(2, values.size());
+ assertTrue(values.contains("world"));
+ assertTrue(values.contains("world2"));
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
+ assertEquals("world", cache.remove("hello"));
+ assertEquals(1, cache.size());
values = cache.values();
- assertThat(values).hasSize(1);
- assertThat(values).contains("world2");
+ assertEquals(1, values.size());
+ assertTrue(values.contains("world2"));
- assertThat(cache.remove("blah")).isNull();
+ assertNull(cache.remove("blah"));
}
}
diff --git a/support/guice/pom.xml b/support/guice/pom.xml
index c5d94ecce..bd3358bd1 100644
--- a/support/guice/pom.xml
+++ b/support/guice/pom.xml
@@ -88,11 +88,6 @@
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/BeanTypeListenerTest.java b/support/guice/src/test/java/org/apache/shiro/guice/BeanTypeListenerTest.java
index ec1739942..09b2a84e7 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/BeanTypeListenerTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/BeanTypeListenerTest.java
@@ -38,7 +38,10 @@ import org.mockito.ArgumentCaptor;
import java.util.Collections;
import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -56,16 +59,16 @@ import static org.mockito.Mockito.when;
public class BeanTypeListenerTest {
@Test
void testUnmatchedPackage() throws Exception {
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(GuiceEnvironment.class))).isFalse();
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroWebModule.class))).isFalse();
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroAopModule.class))).isFalse();
+ assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(GuiceEnvironment.class)));
+ assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroWebModule.class)));
+ assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroAopModule.class)));
}
@Test
void testMatchedPackage() throws Exception {
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(SecurityUtils.class))).isTrue();
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(DefaultAnnotationResolver.class))).isTrue();
- assertThat(BeanTypeListener.MATCHER.matches(TypeLiteral.get(BlowfishCipherService.class))).isTrue();
+ assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(SecurityUtils.class)));
+ assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(DefaultAnnotationResolver.class)));
+ assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(BlowfishCipherService.class)));
}
@Test
@@ -102,9 +105,9 @@ public class BeanTypeListenerTest {
verify(encounter).register(captor.capture());
captor.getValue().injectMembers(bean);
- assertThat(bean.securityManager).isSameAs(securityManager);
- assertThat(bean.myProperty).isSameAs(property);
- assertThat(bean.unavailableProperty).isNull();
+ assertSame(securityManager, bean.securityManager);
+ assertSame(property, bean.myProperty);
+ assertNull(bean.unavailableProperty);
}
public static class SomeInjectableBean {
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/GuiceEnvironmentTest.java b/support/guice/src/test/java/org/apache/shiro/guice/GuiceEnvironmentTest.java
index e48431269..6e4d349ab 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/GuiceEnvironmentTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/GuiceEnvironmentTest.java
@@ -22,9 +22,9 @@ import com.google.inject.spi.InjectionPoint;
import org.apache.shiro.mgt.SecurityManager;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.createMock;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
public class GuiceEnvironmentTest {
@Test
@@ -32,7 +32,7 @@ public class GuiceEnvironmentTest {
SecurityManager securityManager = createMock(SecurityManager.class);
GuiceEnvironment underTest = new GuiceEnvironment(securityManager);
- assertThat(underTest.getSecurityManager()).isSameAs(securityManager);
+ assertSame(securityManager, underTest.getSecurityManager());
}
@Test
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/ShiroMatchersTest.java b/support/guice/src/test/java/org/apache/shiro/guice/ShiroMatchersTest.java
index ab36c72d2..bdae20a5e 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/ShiroMatchersTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/ShiroMatchersTest.java
@@ -22,11 +22,12 @@ import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matcher;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ShiroMatchersTest {
@Test
@@ -39,8 +40,8 @@ public class ShiroMatchersTest {
Matcher<TypeLiteral> underTest = ShiroMatchers.typeLiteral(classMatcher);
- assertThat(underTest.matches(TypeLiteral.get(MatchingClass.class))).isTrue();
- assertThat(underTest.matches(TypeLiteral.get(NotMatchingClass.class))).isFalse();
+ assertTrue(underTest.matches(TypeLiteral.get(MatchingClass.class)));
+ assertFalse(underTest.matches(TypeLiteral.get(NotMatchingClass.class)));
verify(classMatcher);
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/ShiroModuleTest.java b/support/guice/src/test/java/org/apache/shiro/guice/ShiroModuleTest.java
index 6f2799f12..2631ff8be 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/ShiroModuleTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/ShiroModuleTest.java
@@ -42,12 +42,14 @@ import org.apache.shiro.lang.util.Destroyable;
import java.util.Collection;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ShiroModuleTest {
@@ -68,7 +70,7 @@ public class ShiroModuleTest {
}
});
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
+ assertNotNull(securityManager);
}
@Test
@@ -94,7 +96,7 @@ public class ShiroModuleTest {
}
});
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
+ assertNotNull(securityManager);
SecurityUtils.setSecurityManager(securityManager);
final Subject subject = new Subject.Builder(securityManager).buildSubject();
@@ -124,8 +126,8 @@ public class ShiroModuleTest {
}
});
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
- assertThat(securityManager instanceof MyDefaultSecurityManager).isTrue();
+ assertNotNull(securityManager);
+ assertTrue(securityManager instanceof MyDefaultSecurityManager);
}
@Test
@@ -149,9 +151,9 @@ public class ShiroModuleTest {
}
});
DefaultSecurityManager securityManager = (DefaultSecurityManager) injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
- assertThat(securityManager.getSessionManager()).isNotNull();
- assertThat(securityManager.getSessionManager() instanceof MyDefaultSessionManager).isTrue();
+ assertNotNull(securityManager);
+ assertNotNull(securityManager.getSessionManager());
+ assertTrue(securityManager.getSessionManager() instanceof MyDefaultSessionManager);
}
@Test
@@ -176,8 +178,8 @@ public class ShiroModuleTest {
}
});
Environment environment = injector.getInstance(Environment.class);
- assertThat(environment).isNotNull();
- assertThat(environment instanceof MyEnvironment).isTrue();
+ assertNotNull(environment);
+ assertTrue(environment instanceof MyEnvironment);
}
@Test
@@ -282,8 +284,8 @@ public class ShiroModuleTest {
MockEventBusAware eventBusAware = injector.getInstance(MockEventBusAware.class);
- assertThat(eventBusAware.eventBus).isSameAs(eventBus);
- assertThat(((DefaultSecurityManager) securityManager).getEventBus()).isSameAs(eventBus);
+ assertSame(eventBus, eventBusAware.eventBus);
+ assertSame(eventBus, ((DefaultSecurityManager) securityManager).getEventBus());
}
public interface MockRealm extends Realm {
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/ShiroSessionScopeTest.java b/support/guice/src/test/java/org/apache/shiro/guice/ShiroSessionScopeTest.java
index 57fc2d6e4..ee1f7cc0f 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/ShiroSessionScopeTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/ShiroSessionScopeTest.java
@@ -26,12 +26,12 @@ import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ShiroSessionScopeTest {
@Test
@@ -59,9 +59,9 @@ public class ShiroSessionScopeTest {
ShiroSessionScope underTest = new ShiroSessionScope();
// first time the session doesn't contain it, we expect the provider to be invoked
- assertThat(underTest.scope(key, mockProvider).get()).isSameAs(returned);
+ assertSame(returned, underTest.scope(key, mockProvider).get());
// second time the session does contain it, we expect the provider to not be invoked
- assertThat(underTest.scope(key, mockProvider).get()).isSameAs(returned);
+ assertSame(returned, underTest.scope(key, mockProvider).get());
verify(subject, mockProvider, session);
} finally {
@@ -72,7 +72,7 @@ public class ShiroSessionScopeTest {
@Test
void testOutOfScope() throws Exception {
- assertThatExceptionOfType(OutOfScopeException.class).isThrownBy(() -> {
+ assertThrows(OutOfScopeException.class, () -> {
ShiroSessionScope underTest = new ShiroSessionScope();
Provider<SomeClass> mockProvider = createMock(Provider.class);
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java
index 704797fba..6a00eebc0 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java
@@ -23,13 +23,13 @@ import org.apache.shiro.aop.MethodInterceptor;
import org.easymock.IAnswer;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.getCurrentArguments;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class AopAllianceMethodInterceptorAdapterTest {
@@ -51,7 +51,7 @@ public class AopAllianceMethodInterceptorAdapterTest {
Object invocation = underTest.invoke(allianceInvocation);
Object value = ((AopAllianceMethodInvocationAdapter) invocation).proceed();
- assertThat(value).as("Adapter invocation returned a different value.").isSameAs(expectedValue);
+ assertSame(expectedValue, value, "Adapter invocation returned a different value.");
verify(mockShiroInterceptor, allianceInvocation);
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapterTest.java b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapterTest.java
index cf58330a6..e9b9f2632 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapterTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapterTest.java
@@ -23,11 +23,11 @@ import org.junit.jupiter.api.Test;
import java.lang.reflect.Method;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Created by IntelliJ IDEA.
@@ -46,7 +46,7 @@ public class AopAllianceMethodInvocationAdapterTest {
replay(mock);
- assertThat(underTest.getMethod()).isSameAs(method);
+ assertSame(method, underTest.getMethod());
verify(mock);
}
@@ -60,7 +60,7 @@ public class AopAllianceMethodInvocationAdapterTest {
replay(mock);
- assertThat(underTest.getArguments()).isSameAs(args);
+ assertSame(args, underTest.getArguments());
verify(mock);
}
@@ -74,7 +74,7 @@ public class AopAllianceMethodInvocationAdapterTest {
replay(mock);
- assertThat(underTest.proceed()).isSameAs(value);
+ assertSame(value, underTest.proceed());
verify(mock);
}
@@ -88,7 +88,7 @@ public class AopAllianceMethodInvocationAdapterTest {
replay(mock);
- assertThat(underTest.getThis()).isSameAs(value);
+ assertSame(value, underTest.getThis());
verify(mock);
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java b/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java
index fea773241..b0b597867 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java
@@ -54,9 +54,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class ShiroAopModuleTest {
@@ -78,13 +79,13 @@ public class ShiroAopModuleTest {
@Override
protected void configureDefaultInterceptors(AnnotationResolver resolver) {
- assertThat(resolver).isSameAs(annotationResolver);
+ assertSame(annotationResolver, resolver);
bind(Object.class).annotatedWith(Names.named("configureDefaultInterceptors"));
}
@Override
protected void configureInterceptors(AnnotationResolver resolver) {
- assertThat(resolver).isSameAs(annotationResolver);
+ assertSame(annotationResolver, resolver);
bind(Object.class).annotatedWith(Names.named("configureInterceptors"));
}
};
@@ -125,7 +126,7 @@ public class ShiroAopModuleTest {
for (Element element : elements) {
if (element instanceof InterceptorBinding) {
InterceptorBinding binding = (InterceptorBinding) element;
- assertThat(binding.getClassMatcher().matches(getClass())).isTrue();
+ assertTrue(binding.getClassMatcher().matches(getClass()));
Method method = null;
Class<? extends Annotation> theAnnotation = null;
@@ -143,15 +144,15 @@ public class ShiroAopModuleTest {
}
List<MethodInterceptor> interceptors = binding.getInterceptors();
- assertThat(interceptors).hasSize(1);
- assertThat(interceptors.get(0) instanceof AopAllianceMethodInterceptorAdapter).isTrue();
- assertThat(interceptorTypes.get(theAnnotation)
- .isInstance(((AopAllianceMethodInterceptorAdapter) interceptors.get(0)).shiroInterceptor)).isTrue();
+ assertEquals(1, interceptors.size());
+ assertTrue(interceptors.get(0) instanceof AopAllianceMethodInterceptorAdapter);
+ assertTrue(interceptorTypes.get(theAnnotation)
+ .isInstance(((AopAllianceMethodInterceptorAdapter) interceptors.get(0)).shiroInterceptor));
}
}
- assertThat(protectedMethods.isEmpty()).as("Not all interceptors were bound.").isTrue();
+ assertTrue(protectedMethods.isEmpty(), "Not all interceptors were bound.");
}
@Target({ElementType.TYPE, ElementType.METHOD})
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/AbstractInjectionProviderTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/AbstractInjectionProviderTest.java
index e32c415f6..77b4abf16 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/AbstractInjectionProviderTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/AbstractInjectionProviderTest.java
@@ -31,13 +31,14 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class AbstractInjectionProviderTest {
@@ -75,10 +76,10 @@ public class AbstractInjectionProviderTest {
SomeInjectedClass got = underTest.get();
- assertThat(got.c1).as("Wrong parameter passed to constructor (index 0).").isEqualTo(c1);
- assertThat(got.c2).as("Wrong parameter passed to constructor (index 1).").isEqualTo(c2);
+ assertEquals(c1, got.c1, "Wrong parameter passed to constructor (index 0).");
+ assertEquals(c2, got.c2, "Wrong parameter passed to constructor (index 1).");
- assertThat(postProcessCalled.get()).as("postProcess method was not called.").isTrue();
+ assertTrue(postProcessCalled.get(), "postProcess method was not called.");
verify(mockInjector);
}
@@ -123,11 +124,11 @@ public class AbstractInjectionProviderTest {
}
}
- assertThat(foundC1).as("Did not find dependency C1").isTrue();
- assertThat(foundC2).as("Did not find dependency C2").isTrue();
- assertThat(foundV1).as("Did not find dependency V1").isTrue();
- assertThat(foundV2).as("Did not find dependency V2").isTrue();
- assertThat(foundF1).as("Did not find dependency F1").isTrue();
+ assertTrue(foundC1, "Did not find dependency C1");
+ assertTrue(foundC2, "Did not find dependency C2");
+ assertTrue(foundV1, "Did not find dependency V1");
+ assertTrue(foundV2, "Did not find dependency V2");
+ assertTrue(foundF1, "Did not find dependency F1");
}
static class SomeInjectedClass {
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/DefaultFiltersTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/DefaultFiltersTest.java
index dfc126ae0..453e13ffa 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/DefaultFiltersTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/DefaultFiltersTest.java
@@ -27,7 +27,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.EnumSet;
-import static org.assertj.core.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.fail;
public class DefaultFiltersTest {
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/FilterChainResolverProviderTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/FilterChainResolverProviderTest.java
index e634db15a..889adb24a 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/FilterChainResolverProviderTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/FilterChainResolverProviderTest.java
@@ -33,8 +33,10 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This test relies on the internal structure of FilterChainResolver in order to check that it got created correctly.
@@ -69,12 +71,12 @@ public class FilterChainResolverProviderTest {
void testGetDependencies() throws Exception {
Set<Dependency<?>> dependencySet = underTest.getDependencies();
- assertThat(dependencySet).hasSize(4);
+ assertEquals(4, dependencySet.size());
- assertThat(dependencySet.contains(Dependency.get(key1a))).as("Dependency set doesn't contain key1a.").isTrue();
- assertThat(dependencySet.contains(Dependency.get(key1b))).as("Dependency set doesn't contain key1b.").isTrue();
- assertThat(dependencySet.contains(Dependency.get(key1c))).as("Dependency set doesn't contain key1c.").isTrue();
- assertThat(dependencySet.contains(Dependency.get(key2a))).as("Dependency set doesn't contain key2a.").isTrue();
+ assertTrue(dependencySet.contains(Dependency.get(key1a)), "Dependency set doesn't contain key1a.");
+ assertTrue(dependencySet.contains(Dependency.get(key1b)), "Dependency set doesn't contain key1b.");
+ assertTrue(dependencySet.contains(Dependency.get(key1c)), "Dependency set doesn't contain key1c.");
+ assertTrue(dependencySet.contains(Dependency.get(key2a)), "Dependency set doesn't contain key2a.");
}
@@ -96,8 +98,8 @@ public class FilterChainResolverProviderTest {
Field patternMatcherField = SimpleFilterChainResolver.class.getDeclaredField("patternMatcher");
patternMatcherField.setAccessible(true);
- assertThat(chainsField.get(resolver)).isSameAs(chains);
- assertThat(injectorField.get(resolver)).isSameAs(injector);
- assertThat(patternMatcherField.get(resolver)).isSameAs(patternMatcher);
+ assertSame(chains, chainsField.get(resolver));
+ assertSame(injector, injectorField.get(resolver));
+ assertSame(patternMatcher, patternMatcherField.get(resolver));
}
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/FilterConfigTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/FilterConfigTest.java
index 255844c5d..1bbe66d00 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/FilterConfigTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/FilterConfigTest.java
@@ -30,12 +30,12 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FilterConfigTest {
private FilterChainResolver setupResolver() {
@@ -69,7 +69,7 @@ public class FilterConfigTest {
HttpServletRequest request = createMockRequest("/index.html");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request);
}
@@ -81,7 +81,7 @@ public class FilterConfigTest {
HttpServletRequest request = createMockRequest("/index2.html");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request);
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/GuiceShiroFilterTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/GuiceShiroFilterTest.java
index acab49ee2..f3d988ecd 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/GuiceShiroFilterTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/GuiceShiroFilterTest.java
@@ -24,9 +24,10 @@ import org.apache.shiro.web.filter.mgt.FilterChainResolver;
import org.apache.shiro.web.mgt.WebSecurityManager;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -51,9 +52,9 @@ public class GuiceShiroFilterTest {
GuiceShiroFilter underTest = new GuiceShiroFilter(securityManager, filterChainResolver, filterConfiguration);
- assertThat(underTest.getSecurityManager()).isSameAs(securityManager);
- assertThat(underTest.getFilterChainResolver()).isSameAs(filterChainResolver);
- assertThat(underTest.isStaticSecurityManagerEnabled()).isTrue();
- assertThat(underTest.isFilterOncePerRequest()).isFalse();
+ assertSame(securityManager, underTest.getSecurityManager());
+ assertSame(filterChainResolver, underTest.getFilterChainResolver());
+ assertTrue(underTest.isStaticSecurityManagerEnabled());
+ assertFalse(underTest.isFilterOncePerRequest());
}
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
index c5b87c37f..1c0416896 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
@@ -63,12 +63,17 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ShiroWebModuleTest {
@@ -95,13 +100,12 @@ public class ShiroWebModuleTest {
// we're not getting a WebSecurityManager here b/c it's not exposed. There didn't seem to be a good reason to
// expose it outside the Shiro module.
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
- assertThat(securityManager instanceof WebSecurityManager).isTrue();
+ assertNotNull(securityManager);
+ assertTrue(securityManager instanceof WebSecurityManager);
SessionManager sessionManager = injector.getInstance(SessionManager.class);
- assertThat(sessionManager).isNotNull();
- assertThat(sessionManager instanceof ServletContainerSessionManager).isTrue();
- assertThat(((DefaultWebSecurityManager) securityManager).getSessionManager())
- .isInstanceOf(ServletContainerSessionManager.class);
+ assertNotNull(sessionManager);
+ assertTrue(sessionManager instanceof ServletContainerSessionManager);
+ assertTrue(((DefaultWebSecurityManager) securityManager).getSessionManager() instanceof ServletContainerSessionManager);
}
@Test
@@ -132,13 +136,13 @@ public class ShiroWebModuleTest {
}
});
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
- assertThat(securityManager).isNotNull();
- assertThat(securityManager instanceof MyDefaultWebSecurityManager).isTrue();
+ assertNotNull(securityManager);
+ assertTrue(securityManager instanceof MyDefaultWebSecurityManager);
WebSecurityManager webSecurityManager = injector.getInstance(WebSecurityManager.class);
- assertThat(webSecurityManager).isNotNull();
- assertThat(webSecurityManager instanceof MyDefaultWebSecurityManager).isTrue();
+ assertNotNull(webSecurityManager);
+ assertTrue(webSecurityManager instanceof MyDefaultWebSecurityManager);
// SHIRO-435: Check both keys SecurityManager and WebSecurityManager are bound to the same instance
- assertThat(securityManager == webSecurityManager).isTrue();
+ assertTrue(securityManager == webSecurityManager);
}
@Test
@@ -165,13 +169,13 @@ public class ShiroWebModuleTest {
}
});
Environment environment = injector.getInstance(Environment.class);
- assertThat(environment).isNotNull();
- assertThat(environment instanceof MyWebEnvironment).isTrue();
+ assertNotNull(environment);
+ assertTrue(environment instanceof MyWebEnvironment);
WebEnvironment webEnvironment = injector.getInstance(WebEnvironment.class);
- assertThat(webEnvironment).isNotNull();
- assertThat(webEnvironment instanceof MyWebEnvironment).isTrue();
+ assertNotNull(webEnvironment);
+ assertTrue(webEnvironment instanceof MyWebEnvironment);
// SHIRO-435: Check both keys Environment and WebEnvironment are bound to the same instance
- assertThat(environment == webEnvironment).isTrue();
+ assertTrue(environment == webEnvironment);
}
/**
@@ -217,48 +221,48 @@ public class ShiroWebModuleTest {
});
FilterChainResolver resolver = injector.getInstance(FilterChainResolver.class);
- assertThat(resolver).isInstanceOf(SimpleFilterChainResolver.class);
+ assertThat(resolver, instanceOf(SimpleFilterChainResolver.class));
SimpleFilterChainResolver simpleFilterChainResolver = (SimpleFilterChainResolver) resolver;
// test the /test_authc resource
FilterChain filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
Filter nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(InvalidRequestFilter.class);
+ assertThat(nextFilter, instanceOf(InvalidRequestFilter.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(FormAuthenticationFilter.class);
+ assertThat(nextFilter, instanceOf(FormAuthenticationFilter.class));
// test the /test_custom_filter resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(InvalidRequestFilter.class);
+ assertThat(nextFilter, instanceOf(InvalidRequestFilter.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(CustomFilter.class);
+ assertThat(nextFilter, instanceOf(CustomFilter.class));
// test the /test_authc_basic resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(InvalidRequestFilter.class);
+ assertThat(nextFilter, instanceOf(InvalidRequestFilter.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(BasicHttpAuthenticationFilter.class);
+ assertThat(nextFilter, instanceOf(BasicHttpAuthenticationFilter.class));
// test the /test_perms resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(InvalidRequestFilter.class);
+ assertThat(nextFilter, instanceOf(InvalidRequestFilter.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(PermissionsAuthorizationFilter.class);
+ assertThat(nextFilter, instanceOf(PermissionsAuthorizationFilter.class));
// test the /multiple_configs resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(InvalidRequestFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(FormAuthenticationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(RolesAuthorizationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(PermissionsAuthorizationFilter.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(InvalidRequestFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(FormAuthenticationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(RolesAuthorizationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(PermissionsAuthorizationFilter.class));
verify(servletContext, request);
}
@@ -309,33 +313,33 @@ public class ShiroWebModuleTest {
});
FilterChainResolver resolver = injector.getInstance(FilterChainResolver.class);
- assertThat(resolver).isInstanceOf(SimpleFilterChainResolver.class);
+ assertThat(resolver, instanceOf(SimpleFilterChainResolver.class));
SimpleFilterChainResolver simpleFilterChainResolver = (SimpleFilterChainResolver) resolver;
// test the /test_authc resource
FilterChain filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
Filter nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(FormAuthenticationFilter.class);
+ assertThat(nextFilter, instanceOf(FormAuthenticationFilter.class));
// test the /test_custom_filter resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(CustomFilter.class);
+ assertThat(nextFilter, instanceOf(CustomFilter.class));
// test the /test_perms resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
nextFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(nextFilter).isInstanceOf(PermissionsAuthorizationFilter.class);
+ assertThat(nextFilter, instanceOf(PermissionsAuthorizationFilter.class));
// test the /multiple_configs resource
filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(FormAuthenticationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(RolesAuthorizationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(PermissionsAuthorizationFilter.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(FormAuthenticationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(RolesAuthorizationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(PermissionsAuthorizationFilter.class));
verify(servletContext, request);
}
@@ -370,15 +374,15 @@ public class ShiroWebModuleTest {
});
FilterChainResolver resolver = injector.getInstance(FilterChainResolver.class);
- assertThat(resolver).isInstanceOf(SimpleFilterChainResolver.class);
+ assertThat(resolver, instanceOf(SimpleFilterChainResolver.class));
SimpleFilterChainResolver simpleFilterChainResolver = (SimpleFilterChainResolver) resolver;
// test the /test_authc resource
FilterChain filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(InvalidRequestFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isNull();
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(InvalidRequestFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), nullValue());
verify(servletContext, request);
}
@@ -418,15 +422,15 @@ public class ShiroWebModuleTest {
});
FilterChainResolver resolver = injector.getInstance(FilterChainResolver.class);
- assertThat(resolver).isInstanceOf(SimpleFilterChainResolver.class);
+ assertThat(resolver, instanceOf(SimpleFilterChainResolver.class));
SimpleFilterChainResolver simpleFilterChainResolver = (SimpleFilterChainResolver) resolver;
// test the /test_authc resource
FilterChain filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(FormAuthenticationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isNull();
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(FormAuthenticationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), nullValue());
verify(servletContext, request);
}
@@ -464,20 +468,18 @@ public class ShiroWebModuleTest {
});
FilterChainResolver resolver = injector.getInstance(FilterChainResolver.class);
- assertThat(resolver).isInstanceOf(SimpleFilterChainResolver.class);
+ assertThat(resolver, instanceOf(SimpleFilterChainResolver.class));
SimpleFilterChainResolver simpleFilterChainResolver = (SimpleFilterChainResolver) resolver;
// test the /test_authc resource
FilterChain filterChain = simpleFilterChainResolver.getChain(request, null, null);
- assertThat(filterChain).isInstanceOf(SimpleFilterChain.class);
+ assertThat(filterChain, instanceOf(SimpleFilterChain.class));
Filter invalidRequestFilter = getNextFilter((SimpleFilterChain) filterChain);
- assertThat(invalidRequestFilter).isInstanceOf(InvalidRequestFilter.class);
- assertThat(((InvalidRequestFilter) invalidRequestFilter).isBlockBackslash())
- .as("Expected 'blockBackslash' to be false")
- .isFalse();
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isInstanceOf(FormAuthenticationFilter.class);
- assertThat(getNextFilter((SimpleFilterChain) filterChain)).isNull();
+ assertThat(invalidRequestFilter, instanceOf(InvalidRequestFilter.class));
+ assertFalse(((InvalidRequestFilter) invalidRequestFilter).isBlockBackslash(), "Expected 'blockBackslash' to be false");
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), instanceOf(FormAuthenticationFilter.class));
+ assertThat(getNextFilter((SimpleFilterChain) filterChain), nullValue());
verify(servletContext, request);
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/SimpleFilterChainResolverTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/SimpleFilterChainResolverTest.java
index 35903bb89..ea0035268 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/SimpleFilterChainResolverTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/SimpleFilterChainResolverTest.java
@@ -35,11 +35,11 @@ import javax.servlet.http.HttpServletResponse;
import java.util.LinkedHashMap;
import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createStrictControl;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.same;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
@@ -124,8 +124,8 @@ public class SimpleFilterChainResolverTest {
ctrl.replay();
- assertThat(underTest.getChain(request, response, originalChain))
- .as("Expected no chain to match, did not get a null value in return.").isNull();
+ assertNull(underTest.getChain(request, response, originalChain),
+ "Expected no chain to match, did not get a null value in return.");
ctrl.verify();
}
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/WebGuiceEnvironmentTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/WebGuiceEnvironmentTest.java
index b08c74a18..ebad2cff5 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/WebGuiceEnvironmentTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/WebGuiceEnvironmentTest.java
@@ -28,8 +28,6 @@ import org.junit.jupiter.api.Test;
import javax.servlet.ServletContext;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.and;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.capture;
@@ -37,6 +35,8 @@ import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
public class WebGuiceEnvironmentTest {
@@ -65,12 +65,12 @@ public class WebGuiceEnvironmentTest {
WebGuiceEnvironment underTest =
new WebGuiceEnvironment(filterChainResolver, servletContext, securityManager, filterConfiguration);
- assertThat(underTest.getSecurityManager()).isSameAs(securityManager);
- assertThat(underTest.getFilterChainResolver()).isSameAs(filterChainResolver);
- assertThat(underTest.getWebSecurityManager()).isSameAs(securityManager);
- assertThat(underTest.getServletContext()).isSameAs(servletContext);
+ assertSame(securityManager, underTest.getSecurityManager());
+ assertSame(filterChainResolver, underTest.getFilterChainResolver());
+ assertSame(securityManager, underTest.getWebSecurityManager());
+ assertSame(servletContext, underTest.getServletContext());
- assertThat(capture.getValue()).isSameAs(underTest);
+ assertSame(underTest, capture.getValue());
verify(servletContext);
}
diff --git a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/cdi/ShiroScopeContextTest.java b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/cdi/ShiroScopeContextTest.java
index 1d47a183a..70381115a 100644
--- a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/cdi/ShiroScopeContextTest.java
+++ b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/cdi/ShiroScopeContextTest.java
@@ -33,8 +33,9 @@ import java.io.Serializable;
import java.lang.annotation.Annotation;
import static org.apache.shiro.ee.cdi.ShiroScopeContext.isWebContainerSessions;
-import static org.assertj.core.api.Assertions.assertThat;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.lenient;
@@ -81,14 +82,14 @@ public class ShiroScopeContextTest {
@Test
void basics() {
- assertThat(ctx.isActive()).isTrue();
- assertThat(ctx.getScope()).isEqualTo(ViewScoped.class);
+ assertTrue(ctx.isActive());
+ assertEquals(ViewScoped.class, ctx.getScope());
}
@Test
void webSessionsBasic() {
setupWebSessions();
- assertThat(isWebContainerSessions(SecurityUtils.getSecurityManager())).isTrue();
+ assertTrue(isWebContainerSessions(SecurityUtils.getSecurityManager()));
}
@Test
@@ -96,8 +97,8 @@ public class ShiroScopeContextTest {
setupWebSessions();
try (var cdim = mockStatic(CDI.class, Answers.RETURNS_DEEP_STUBS)) {
when(CDI.current().getBeanManager().getContext(SessionScoped.class).get(contextual)).thenReturn(bean);
- assertThat(ctx.get(contextual)).isEqualTo(bean);
- assertThat((Object) ctx.get(null)).isNull();
+ assertEquals(bean, ctx.get(contextual));
+ assertNull(ctx.get(null));
verify(CDI.current().getBeanManager(), atLeast(2)).getContext(any());
}
}
@@ -108,8 +109,8 @@ public class ShiroScopeContextTest {
try (var cdim = mockStatic(CDI.class, Answers.RETURNS_DEEP_STUBS)) {
when(CDI.current().getBeanManager().getContext(SessionScoped.class)
.get(contextual, creationalContext)).thenReturn(bean);
- assertThat(ctx.get(contextual, creationalContext)).isEqualTo(bean);
- assertThat((Object) ctx.get(null)).isNull();
+ assertEquals(bean, ctx.get(contextual, creationalContext));
+ assertNull(ctx.get(null));
verify(CDI.current().getBeanManager(), atLeast(2)).getContext(any());
}
}
diff --git a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
index ce8f47720..874eeed83 100644
--- a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
+++ b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
@@ -28,8 +28,11 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import static org.apache.shiro.ee.util.JakartaTransformer.jakartify;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -50,31 +53,31 @@ public class FormSupportTest {
@Test
void nullReferer() {
when(request.getHeader("referer")).thenReturn(null);
- assertThat(getReferer(request)).isNull();
+ assertNull(getReferer(request));
}
@Test
void plainStringReferer() {
when(request.getHeader("referer")).thenReturn("hello");
- assertThat(getReferer(request)).isEqualTo("hello");
+ assertEquals("hello", getReferer(request));
}
@Test
void switchToHttps() {
when(request.getHeader("referer")).thenReturn("http://example.com");
- assertThat(getReferer(request)).isEqualTo("https://example.com");
+ assertEquals("https://example.com", getReferer(request));
}
@Test
void dontSwitchToHttpsWhenCustomPort() {
when(request.getHeader("referer")).thenReturn("http://example.com:8080/");
- assertThat(getReferer(request)).isEqualTo("http://example.com:8080/");
+ assertEquals("http://example.com:8080/", getReferer(request));
}
@Test
void dontSwitchToHttpsWhenCustomPortNoTrailingSlash() {
when(request.getHeader("referer")).thenReturn("http://example.com:8080");
- assertThat(getReferer(request)).isEqualTo("http://example.com:8080");
+ assertEquals("http://example.com:8080", getReferer(request));
}
@Test
@@ -83,75 +86,77 @@ public class FormSupportTest {
= "j_idt5%3Dj_idt5%26j_idt5%3Aj_idt7%3Daaa%26j_idt5%3Aj_idt9%3Dbbb%26j_idt5%3A"
+ "j_idt11%3DSubmit+...%26" + jakartify("javax.faces.ViewState")
+ "%3D-8335355445345003673%3A-6008443334776649058";
- assertThat(isJSFStatefulForm(decode(statefulFormData))).isTrue();
+ assertTrue(isJSFStatefulForm(decode(statefulFormData)));
String statelessFormData
= "j_idt5%3Dj_idt5%26j_idt5%3Aj_idt7%3Daaa%26j_idt5%3Aj_idt9%3Dbbb%26j_idt5%3A"
+ "j_idt11%3DSubmit+...%26" + jakartify("javax.faces.ViewState") + "%3Dstateless";
- assertThat(isJSFStatefulForm(statelessFormData)).isFalse();
- assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> isJSFStatefulForm(null));
+ assertFalse(isJSFStatefulForm(statelessFormData));
+ assertThrows(NullPointerException.class, () -> isJSFStatefulForm(null));
String nonJSFFormData
= "j_idt5%3Dj_idt5%26j_idt5%3Aj_idt7%3Daaa%26j_idt5%3Aj_idt9%3Dbbb%26j_idt5%3A"
+ "j_idt11%3DSubmit+...";
- assertThat(isJSFStatefulForm("xxx")).isFalse();
- assertThat(isJSFStatefulForm(nonJSFFormData)).isFalse();
+ assertFalse(isJSFStatefulForm("xxx"));
+ assertFalse(isJSFStatefulForm(nonJSFFormData));
}
@Test
void extractViewState() {
- assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> extractJSFNewViewState(null, null));
- assertThat(extractJSFNewViewState("", "hello")).isEqualTo("hello");
- assertThat(extractJSFNewViewState("xxx", jakartify("javax.faces.ViewState=stateless&hello=bye")))
- .isEqualTo(jakartify("javax.faces.ViewState=stateless&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
- jakartify("javax.faces.ViewState=stateless&hello=bye")))
- .isEqualTo(jakartify("javax.faces.ViewState=stateless&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
- jakartify("aaa=bbb&javax.faces.ViewState=xxx:yyy&hello=bye")))
- .isEqualTo(jakartify("aaa=bbb&javax.faces.ViewState=xxx:yyy&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
- jakartify("javax.faces.ViewState=987:654&hello=bye")))
- .isEqualTo(jakartify("javax.faces.ViewState=123:456&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
- jakartify("javax.faces.ViewState=987:654&hello=bye")))
- .isEqualTo(jakartify("javax.faces.ViewState=-123:-456&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
- jakartify("javax.faces.ViewState=-987:-654&hello=bye")))
- .isEqualTo(jakartify("javax.faces.ViewState=-123:-456&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
- jakartify("aaa=bbb&javax.faces.ViewState=-987:-654&hello=bye")))
- .isEqualTo(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456&hello=bye"));
- assertThat(extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
- jakartify("aaa=bbb&javax.faces.ViewState=-987:-654")))
- .isEqualTo(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456"));
+ assertThrows(NullPointerException.class, () -> extractJSFNewViewState(null, null));
+ assertEquals("hello", extractJSFNewViewState("", "hello"));
+ assertEquals(jakartify("javax.faces.ViewState=stateless&hello=bye"),
+ extractJSFNewViewState("xxx", jakartify("javax.faces.ViewState=stateless&hello=bye")));
+ assertEquals(jakartify("javax.faces.ViewState=stateless&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
+ jakartify("javax.faces.ViewState=stateless&hello=bye")));
+ assertEquals(jakartify("aaa=bbb&javax.faces.ViewState=xxx:yyy&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
+ jakartify("aaa=bbb&javax.faces.ViewState=xxx:yyy&hello=bye")));
+ assertEquals(jakartify("javax.faces.ViewState=123:456&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"123:456\"/>"),
+ jakartify("javax.faces.ViewState=987:654&hello=bye")));
+ assertEquals(jakartify("javax.faces.ViewState=-123:-456&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
+ jakartify("javax.faces.ViewState=987:654&hello=bye")));
+ assertEquals(jakartify("javax.faces.ViewState=-123:-456&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
+ jakartify("javax.faces.ViewState=-987:-654&hello=bye")));
+ assertEquals(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456&hello=bye"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
+ jakartify("aaa=bbb&javax.faces.ViewState=-987:-654&hello=bye")));
+ assertEquals(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456"),
+ extractJSFNewViewState(jakartify("<input name=\"javax.faces.ViewState\" value=\"-123:-456\"/>"),
+ jakartify("aaa=bbb&javax.faces.ViewState=-987:-654")));
}
@Test
void noAjaxRequests() {
- assertThat(noJSFAjaxRequests(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456")
- + jakartify("&javax.faces.partial.ajax=true&hello=bye"), false)).isEqualTo(new PartialAjaxResult(
- jakartify("aaa=bbb&javax.faces.ViewState=-123:-456&hello=bye"),
- true, false));
- assertThat(noJSFAjaxRequests("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
- + jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
- + jakartify("&javax.faces.source=j_idt12:j_idt18")
- + jakartify("&javax.faces.partial.event=click")
- + jakartify("&javax.faces.partial.execute=j_idt12:j_idt18 j_idt12")
- + jakartify("&javax.faces.partial.render=j_idt12")
- + jakartify("&javax.faces.behavior.event=action")
- + jakartify("&javax.faces.partial.ajax=false"), false))
- .isEqualTo(new PartialAjaxResult("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
- + jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
- + jakartify("&javax.faces.source=j_idt12:j_idt18")
- + jakartify("&javax.faces.behavior.event=action"), true, false));
+ assertEquals(
+ new PartialAjaxResult(
+ jakartify("aaa=bbb&javax.faces.ViewState=-123:-456&hello=bye"),
+ true, false),
+ noJSFAjaxRequests(jakartify("aaa=bbb&javax.faces.ViewState=-123:-456")
+ + jakartify("&javax.faces.partial.ajax=true&hello=bye"), false));
+ assertEquals(new PartialAjaxResult("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
+ + jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
+ + jakartify("&javax.faces.source=j_idt12:j_idt18")
+ + jakartify("&javax.faces.behavior.event=action"), true, false),
+ noJSFAjaxRequests("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
+ + jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
+ + jakartify("&javax.faces.source=j_idt12:j_idt18")
+ + jakartify("&javax.faces.partial.event=click")
+ + jakartify("&javax.faces.partial.execute=j_idt12:j_idt18 j_idt12")
+ + jakartify("&javax.faces.partial.render=j_idt12")
+ + jakartify("&javax.faces.behavior.event=action")
+ + jakartify("&javax.faces.partial.ajax=false"), false));
}
@Test
void parseCookies() {
var map = Map.of("name1", "value1", "name2", "value2", "name3", "value3");
- assertThat(transformCookieHeader(List.of("name1=value1", "name2=value2; path=/my/path", "name3=value3"))).isEqualTo(map);
- assertThat(transformCookieHeader(List.of("name="))).isEqualTo(Map.of("name", ""));
- assertThat(transformCookieHeader(List.of("JSESSIONID=\"abc\"; $Version=\"1\"; $Path=\"/mypath\"")))
- .isEqualTo(Map.of("JSESSIONID", "abc"));
+ assertEquals(map, transformCookieHeader(List.of("name1=value1", "name2=value2; path=/my/path", "name3=value3")));
+ assertEquals(Map.of("name", ""), transformCookieHeader(List.of("name=")));
+ assertEquals(Map.of("JSESSIONID", "abc"),
+ transformCookieHeader(List.of("JSESSIONID=\"abc\"; $Version=\"1\"; $Path=\"/mypath\"")));
}
private static String decode(String plain) {
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java b/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
index e06d83ab4..078999bfa 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
@@ -31,11 +31,12 @@ import org.springframework.remoting.support.RemoteInvocation;
import java.lang.reflect.Method;
import java.util.UUID;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* //TODO - Class JavaDoc!
@@ -80,7 +81,7 @@ public class SecureRemoteInvocationFactoryTest {
verify(mi);
- assertThat(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY)).isNull();
+ assertNull(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY));
}
@Test
@@ -103,7 +104,7 @@ public class SecureRemoteInvocationFactoryTest {
verify(mi);
- assertThat(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY)).isEqualTo(dummySessionId);
+ assertEquals(dummySessionId, ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY));
}
/*@Test
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
index 40f34d585..3d7dee9b4 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
@@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Common method tests across implementations. In actuality, the methods don't change across
@@ -92,7 +92,7 @@ public abstract class AbstractAuthorizationAnnotationTest {
@Test
void testGuestImplementationFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindUser();
testService.guestImplementation();
});
@@ -120,7 +120,7 @@ public abstract class AbstractAuthorizationAnnotationTest {
@Test
void testUserImplementationFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindGuest();
testService.userImplementation();
});
@@ -148,7 +148,7 @@ public abstract class AbstractAuthorizationAnnotationTest {
@Test
void testAuthenticatedImplementationFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindUser();
testService.authenticatedImplementation();
});
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
index a44ba4c13..c1cddd50f 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
@@ -21,7 +21,8 @@ package org.apache.shiro.spring.security.interceptor;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class AuthorizationAttributeSourceAdvisorTest {
@@ -69,26 +70,38 @@ public class AuthorizationAttributeSourceAdvisorTest {
@Test
void matches() throws NoSuchMethodException {
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- Secured.class.getDeclaredMethod("secureMethod"), Secured.class
- )).as("the method is annotated, should match").isTrue();
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- Secured.class.getDeclaredMethod("unsecuredMethod"), Secured.class
- )).as("the method is not annotated, should not match").isFalse();
-
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- ServiceInterface.class.getDeclaredMethod("secureMethod"), ServiceImpl.class
- )).as("the method declaration is annotated in the interface, should match").isTrue();
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- ServiceInterface.class.getDeclaredMethod("unsecuredMethod"), ServiceImpl.class
- )).as("not annotated method, should not match").isFalse();
-
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- SafeServiceInterface.class.getDeclaredMethod("someMethod"), SafeServiceInterface.class
- )).as("the method declaration is in the interface with type-annotation, should match").isTrue();
- assertThat(new AuthorizationAttributeSourceAdvisor().matches(
- SafeServiceImpl.class.getDeclaredMethod("someMethod"), SafeServiceImpl.class
- )).as("the method declaration is in the interface with type-annotation, should match").isTrue();
+ assertTrue(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ Secured.class.getDeclaredMethod("secureMethod"), Secured.class
+ ),
+ "the method is annotated, should match");
+ assertFalse(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ Secured.class.getDeclaredMethod("unsecuredMethod"), Secured.class
+ ),
+ "the method is not annotated, should not match");
+
+ assertTrue(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ ServiceInterface.class.getDeclaredMethod("secureMethod"), ServiceImpl.class
+ ),
+ "the method declaration is annotated in the interface, should match");
+ assertFalse(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ ServiceInterface.class.getDeclaredMethod("unsecuredMethod"), ServiceImpl.class
+ ),
+ "not annotated method, should not match");
+
+ assertTrue(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ SafeServiceInterface.class.getDeclaredMethod("someMethod"), SafeServiceInterface.class
+ ),
+ "the method declaration is in the interface with type-annotation, should match");
+ assertTrue(
+ new AuthorizationAttributeSourceAdvisor().matches(
+ SafeServiceImpl.class.getDeclaredMethod("someMethod"), SafeServiceImpl.class
+ ),
+ "the method declaration is in the interface with type-annotation, should match");
}
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
index 4dc41aaa7..a1807b281 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* All the tests in the parent class are run. This class only exists to ensure that a
@@ -41,7 +41,7 @@ public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnota
@Test
void testGuestInterfaceFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindUser();
testService.guestInterface();
});
@@ -49,7 +49,7 @@ public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnota
@Test
void testUserInterfaceFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindGuest();
testService.userInterface();
});
@@ -57,7 +57,7 @@ public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnota
@Test
void testAuthenticatedInterfaceFailure() {
- assertThatExceptionOfType(UnauthenticatedException.class).isThrownBy(() -> {
+ assertThrows(UnauthenticatedException.class, () -> {
bindGuest();
testService.authenticatedInterface();
});
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
index fd0f7f9bb..c2a81c0d0 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
@@ -38,11 +38,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -65,14 +67,14 @@ public class ShiroFilterFactoryBeanTest {
PathMatchingFilterChainResolver resolver = (PathMatchingFilterChainResolver) shiroFilter.getFilterChainResolver();
DefaultFilterChainManager fcManager = (DefaultFilterChainManager) resolver.getFilterChainManager();
NamedFilterList chain = fcManager.getChain("/test");
- assertThat(chain).isNotNull();
- assertThat(chain).hasSize(3);
+ assertNotNull(chain);
+ assertEquals(3, chain.size());
Filter[] filters = new Filter[chain.size()];
filters = chain.toArray(filters);
// global filter
- assertThat(filters[0] instanceof InvalidRequestFilter).isTrue();
- assertThat(filters[1] instanceof DummyFilter).isTrue();
- assertThat(filters[2] instanceof FormAuthenticationFilter).isTrue();
+ assertTrue(filters[0] instanceof InvalidRequestFilter);
+ assertTrue(filters[1] instanceof DummyFilter);
+ assertTrue(filters[2] instanceof FormAuthenticationFilter);
}
/**
@@ -106,9 +108,9 @@ public class ShiroFilterFactoryBeanTest {
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
- assertThat(request.getSession()).isNotNull();
+ assertNotNull(request.getSession());
//this line asserts the fix for the user-reported issue:
- assertThat(request.getSession().getServletContext()).isNotNull();
+ assertNotNull(request.getSession().getServletContext());
}
};
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java b/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java
index 588044f37..19d529009 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java
@@ -29,7 +29,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {EventBusTestConfiguration.class, RealmTestConfiguration.class, ShiroWebConfiguration.class})
@@ -45,10 +45,10 @@ public class ShiroWebConfigurationTestSameSiteStrict {
// org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.properties
// then
- assertThat(shiroWebConfiguration.sessionIdCookieSameSite).isEqualTo(Cookie.SameSiteOptions.STRICT);
- assertThat(shiroWebConfiguration.rememberMeSameSite).isEqualTo(Cookie.SameSiteOptions.STRICT);
+ assertEquals(Cookie.SameSiteOptions.STRICT, shiroWebConfiguration.sessionIdCookieSameSite);
+ assertEquals(Cookie.SameSiteOptions.STRICT, shiroWebConfiguration.rememberMeSameSite);
- assertThat(shiroWebConfiguration.sessionCookieTemplate().getSameSite()).isEqualTo(Cookie.SameSiteOptions.STRICT);
- assertThat(shiroWebConfiguration.rememberMeCookieTemplate().getSameSite()).isEqualTo(Cookie.SameSiteOptions.STRICT);
+ assertEquals(Cookie.SameSiteOptions.STRICT, shiroWebConfiguration.sessionCookieTemplate().getSameSite());
+ assertEquals(Cookie.SameSiteOptions.STRICT, shiroWebConfiguration.rememberMeCookieTemplate().getSameSite());
}
}
diff --git a/tools/hasher/src/test/java/org/apache/shiro/tools/hasher/HasherTest.java b/tools/hasher/src/test/java/org/apache/shiro/tools/hasher/HasherTest.java
index 63c493ce2..0995e3393 100644
--- a/tools/hasher/src/test/java/org/apache/shiro/tools/hasher/HasherTest.java
+++ b/tools/hasher/src/test/java/org/apache/shiro/tools/hasher/HasherTest.java
@@ -36,7 +36,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @since 2.0
@@ -86,9 +87,9 @@ public class HasherTest {
Hasher.main(args);
// when
- assertThat(listAppender.getEvents()).hasSize(1);
+ assertEquals(1, listAppender.getEvents().size());
LogEvent iLoggingEvent = listAppender.getEvents().get(0);
- assertThat(iLoggingEvent.getMessage().getFormattedMessage()).contains("$shiro2$argon2id$v=19");
+ assertTrue(iLoggingEvent.getMessage().getFormattedMessage().contains("$shiro2$argon2id$v=19"));
}
@Test
@@ -101,8 +102,8 @@ public class HasherTest {
Hasher.main(args);
// when
- assertThat(listAppender.getEvents()).hasSize(1);
+ assertEquals(1, listAppender.getEvents().size());
LogEvent iLoggingEvent = listAppender.getEvents().get(0);
- assertThat(iLoggingEvent.getMessage().getFormattedMessage()).contains("$shiro2$2y$10$");
+ assertTrue(iLoggingEvent.getMessage().getFormattedMessage().contains("$shiro2$2y$10$"));
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/config/WebIniSecurityManagerFactoryTest.java b/web/src/test/java/org/apache/shiro/web/config/WebIniSecurityManagerFactoryTest.java
index 3258f5084..ed99d9d1b 100644
--- a/web/src/test/java/org/apache/shiro/web/config/WebIniSecurityManagerFactoryTest.java
+++ b/web/src/test/java/org/apache/shiro/web/config/WebIniSecurityManagerFactoryTest.java
@@ -27,7 +27,8 @@ import org.junit.jupiter.api.Test;
import javax.servlet.Filter;
import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* TODO - Class JavaDoc
@@ -53,15 +54,15 @@ public class WebIniSecurityManagerFactoryTest {
@SuppressWarnings("deprecation")
WebIniSecurityManagerFactory factory = new WebIniSecurityManagerFactory(ini);
org.apache.shiro.mgt.SecurityManager sm = factory.getInstance();
- assertThat(sm).isNotNull();
- assertThat(sm instanceof DefaultWebSecurityManager).isTrue();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultWebSecurityManager);
//now assert that all of the default filters exist:
Map<String, ?> beans = factory.getBeans();
for (DefaultFilter defaultFilter : DefaultFilter.values()) {
Filter filter = (Filter) beans.get(defaultFilter.name());
- assertThat(filter).isNotNull();
- assertThat(defaultFilter.getFilterClass().isAssignableFrom(filter.getClass())).isTrue();
+ assertNotNull(filter);
+ assertTrue(defaultFilter.getFilterClass().isAssignableFrom(filter.getClass()));
}
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/env/EnvironmentLoaderServiceTest.java b/web/src/test/java/org/apache/shiro/web/env/EnvironmentLoaderServiceTest.java
index f9bc7abfa..8f1c4d844 100644
--- a/web/src/test/java/org/apache/shiro/web/env/EnvironmentLoaderServiceTest.java
+++ b/web/src/test/java/org/apache/shiro/web/env/EnvironmentLoaderServiceTest.java
@@ -26,13 +26,16 @@ import javax.servlet.ServletContext;
import java.util.Arrays;
import java.util.List;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
import static org.easymock.EasyMock.expect;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -57,10 +60,10 @@ public class EnvironmentLoaderServiceTest {
EasyMock.verify(servletContext);
- assertThat(resultEnvironment).isInstanceOf(IniWebEnvironment.class);
+ assertThat(resultEnvironment, instanceOf(IniWebEnvironment.class));
IniWebEnvironment environmentStub = (IniWebEnvironment) resultEnvironment;
- assertThat(environmentStub.getServletContext()).isSameAs(servletContext);
+ assertThat(environmentStub.getServletContext(), sameInstance(servletContext));
}
@Test
@@ -76,9 +79,9 @@ public class EnvironmentLoaderServiceTest {
EasyMock.verify(servletContext);
- assertThat(environment).isInstanceOf(DefaultWebEnvironment.class);
- assertThat(environment.getShiroFilterConfiguration()).isNotNull();
- assertThat(environment.getServletContext()).isSameAs(servletContext);
+ assertThat(environment, instanceOf(DefaultWebEnvironment.class));
+ assertThat(environment.getShiroFilterConfiguration(), is(notNullValue()));
+ assertThat(environment.getServletContext(), sameInstance(servletContext));
}
@Test
@@ -117,10 +120,10 @@ public class EnvironmentLoaderServiceTest {
EasyMock.verify(servletContext);
- assertThat(resultEnvironment).isInstanceOf(WebEnvironmentStub.class);
+ assertThat(resultEnvironment, instanceOf(WebEnvironmentStub.class));
WebEnvironmentStub environmentStub = (WebEnvironmentStub) resultEnvironment;
- assertThat(environmentStub.getServletContext()).isSameAs(servletContext);
+ assertThat(environmentStub.getServletContext(), sameInstance(servletContext));
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterParameterizedTest.java b/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterParameterizedTest.java
index 7547e7c46..f74265db3 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterParameterizedTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterParameterizedTest.java
@@ -30,11 +30,11 @@ import javax.servlet.http.HttpServletRequest;
import java.util.stream.Stream;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit tests for the {@link PathMatchingFilter} implementation.
@@ -138,8 +138,9 @@ public class PathMatchingFilterParameterizedTest {
initPathMatchingFilterParameterizedTest(pattern, request, shouldMatch);
LOG.debug("Input pattern: [{}], input path: [{}].", this.pattern, this.request.getPathInfo());
boolean matchEnabled = filter.pathsMatch(this.pattern, this.request);
- assertThat(matchEnabled).as("PathMatch can match URL end with multi Separator, ["
- + this.pattern + "] - [" + this.request.getPathInfo() + "]").isEqualTo(this.shouldMatch);
+ assertEquals(this.shouldMatch, matchEnabled,
+ "PathMatch can match URL end with multi Separator, ["
+ + this.pattern + "] - [" + this.request.getPathInfo() + "]");
verify(request);
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterTest.java
index e5b1084fc..01b5adcc2 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/PathMatchingFilterTest.java
@@ -25,11 +25,12 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit tests for the {@link PathMatchingFilter} implementation.
@@ -95,7 +96,7 @@ public class PathMatchingFilterTest {
boolean continueFilterChain = filter.preHandle(request, response);
- assertThat(continueFilterChain).as("FilterChain should continue.").isTrue();
+ assertTrue(continueFilterChain, "FilterChain should continue.");
verify(request);
}
@@ -122,7 +123,7 @@ public class PathMatchingFilterTest {
boolean continueFilterChain = filter.preHandle(request, response);
- assertThat(continueFilterChain).as("FilterChain should NOT continue.").isFalse();
+ assertFalse(continueFilterChain, "FilterChain should NOT continue.");
verify(request);
}
@@ -139,7 +140,7 @@ public class PathMatchingFilterTest {
replay(request);
boolean matchEnabled = filter.pathsMatch("/", request);
- assertThat(matchEnabled).as("PathMatch can match URL end with Separator").isTrue();
+ assertTrue(matchEnabled, "PathMatch can match URL end with Separator");
verify(request);
}
@@ -155,7 +156,7 @@ public class PathMatchingFilterTest {
replay(request);
boolean matchEnabled = filter.pathsMatch("/resource/book", request);
- assertThat(matchEnabled).as("PathMatch can match URL end with Separator").isTrue();
+ assertTrue(matchEnabled, "PathMatch can match URL end with Separator");
verify(request);
}
@@ -171,7 +172,7 @@ public class PathMatchingFilterTest {
replay(request);
boolean matchEnabled = filter.pathsMatch("/resource/book", request);
- assertThat(matchEnabled).as("PathMatch can match URL end with Separator").isTrue();
+ assertTrue(matchEnabled, "PathMatch can match URL end with Separator");
verify(request);
}
@@ -187,7 +188,7 @@ public class PathMatchingFilterTest {
replay(request);
boolean matchEnabled = filter.pathsMatch("/resource/book", request);
- assertThat(matchEnabled).as("PathMatch can match URL end with multi Separator").isTrue();
+ assertTrue(matchEnabled, "PathMatch can match URL end with multi Separator");
verify(request);
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authc/AnonymousFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authc/AnonymousFilterTest.java
index 141fffbf8..4f71b63c9 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authc/AnonymousFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authc/AnonymousFilterTest.java
@@ -20,7 +20,7 @@ package org.apache.shiro.web.filter.authc;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for {@link org.apache.shiro.web.filter.authc.AnonymousFilter}.
@@ -33,7 +33,7 @@ public class AnonymousFilterTest {
void test() {
AnonymousFilter filter = new AnonymousFilter();
boolean allow = filter.onPreHandle(null, null, null);
- assertThat(allow).isTrue();
+ assertTrue(allow);
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/HostFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/HostFilterTest.java
index 65e5315f5..a0d1cac74 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/HostFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/HostFilterTest.java
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @since 1.0
@@ -40,7 +40,7 @@ public class HostFilterTest {
String ibase = base + i;
for (int j = 0; j < 256; j++) {
String ip = ibase + "." + j;
- assertThat(p.matcher(ip).matches()).isTrue();
+ assertTrue(p.matcher(ip).matches());
}
}
}
@@ -58,7 +58,7 @@ public class HostFilterTest {
String jBase = ibase + "." + j;
for (int k = 0; k < 256; k++) {
String ip = jBase + "." + k;
- assertThat(p.matcher(ip).matches()).isTrue();
+ assertTrue(p.matcher(ip).matches());
}
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/HttpMethodPermissionFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/HttpMethodPermissionFilterTest.java
index c5db1aef6..3a3c3d791 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/HttpMethodPermissionFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/HttpMethodPermissionFilterTest.java
@@ -20,7 +20,7 @@ package org.apache.shiro.web.filter.authz;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HttpMethodPermissionFilterTest {
@@ -34,16 +34,16 @@ public class HttpMethodPermissionFilterTest {
String[] permsBefore = {"foo", "bar"};
String[] permsAfter = filter.buildPermissions(permsBefore, filter.getHttpMethodAction("get"));
- assertThat(permsAfter.length).isEqualTo(2);
- assertThat(permsAfter[0]).isEqualTo("foo:read");
- assertThat(permsAfter[1]).isEqualTo("bar:read");
-
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("head"))[0]).isEqualTo("foo:read");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("put"))[0]).isEqualTo("foo:update");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("post"))[0]).isEqualTo("foo:create");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("mkcol"))[0]).isEqualTo("foo:create");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("delete"))[0]).isEqualTo("foo:delete");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("options"))[0]).isEqualTo("foo:read");
- assertThat(filter.buildPermissions(permsBefore, filter.getHttpMethodAction("trace"))[0]).isEqualTo("foo:read");
+ assertEquals(2, permsAfter.length);
+ assertEquals("foo:read", permsAfter[0]);
+ assertEquals("bar:read", permsAfter[1]);
+
+ assertEquals("foo:read", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("head"))[0]);
+ assertEquals("foo:update", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("put"))[0]);
+ assertEquals("foo:create", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("post"))[0]);
+ assertEquals("foo:create", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("mkcol"))[0]);
+ assertEquals("foo:delete", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("delete"))[0]);
+ assertEquals("foo:read", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("options"))[0]);
+ assertEquals("foo:read", filter.buildPermissions(permsBefore, filter.getHttpMethodAction("trace"))[0]);
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/IpAddressMatcherTests.java b/web/src/test/java/org/apache/shiro/web/filter/authz/IpAddressMatcherTests.java
index 3d9e4efe2..1598c9d7e 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/IpAddressMatcherTests.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/IpAddressMatcherTests.java
@@ -17,7 +17,8 @@ package org.apache.shiro.web.filter.authz;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @since 2.0
@@ -30,35 +31,35 @@ public class IpAddressMatcherTests {
@Test
void ipv6MatcherMatchesIpv6Address() {
- assertThat(v6matcher.matches(ipv6Address)).isTrue();
+ assertTrue(v6matcher.matches(ipv6Address));
}
@Test
void ipv6MatcherDoesntMatchIpv4Address() {
- assertThat(v6matcher.matches(ipv4Address)).isFalse();
+ assertFalse(v6matcher.matches(ipv4Address));
}
@Test
void ipv4MatcherMatchesIpv4Address() {
- assertThat(v4matcher.matches(ipv4Address)).isTrue();
+ assertTrue(v4matcher.matches(ipv4Address));
}
@Test
void ipv4SubnetMatchesCorrectly() throws Exception {
IpAddressMatcher matcher = new IpAddressMatcher("192.168.1.0/24");
- assertThat(matcher.matches(ipv4Address)).isTrue();
+ assertTrue(matcher.matches(ipv4Address));
matcher = new IpAddressMatcher("192.168.1.128/25");
- assertThat(matcher.matches(ipv4Address)).isFalse();
- assertThat(matcher.matches("192.168.1.159")).isTrue();
+ assertFalse(matcher.matches(ipv4Address));
+ assertTrue(matcher.matches("192.168.1.159"));
}
@Test
void ipv6RangeMatches() throws Exception {
IpAddressMatcher matcher = new IpAddressMatcher("2001:DB8::/48");
- assertThat(matcher.matches("2001:DB8:0:0:0:0:0:0")).isTrue();
- assertThat(matcher.matches("2001:DB8:0:0:0:0:0:1")).isTrue();
- assertThat(matcher.matches("2001:DB8:0:FFFF:FFFF:FFFF:FFFF:FFFF")).isTrue();
- assertThat(matcher.matches("2001:DB8:1:0:0:0:0:0")).isFalse();
+ assertTrue(matcher.matches("2001:DB8:0:0:0:0:0:0"));
+ assertTrue(matcher.matches("2001:DB8:0:0:0:0:0:1"));
+ assertTrue(matcher.matches("2001:DB8:0:FFFF:FFFF:FFFF:FFFF:FFFF"));
+ assertFalse(matcher.matches("2001:DB8:1:0:0:0:0:0"));
}
// https://github.com/spring-projects/spring-security/issues/1970q
@@ -66,11 +67,11 @@ public class IpAddressMatcherTests {
void zeroMaskMatchesAnything() throws Exception {
IpAddressMatcher matcher = new IpAddressMatcher("0.0.0.0/0");
- assertThat(matcher.matches("123.4.5.6")).isTrue();
- assertThat(matcher.matches("192.168.0.159")).isTrue();
+ assertTrue(matcher.matches("123.4.5.6"));
+ assertTrue(matcher.matches("192.168.0.159"));
matcher = new IpAddressMatcher("192.168.0.159/0");
- assertThat(matcher.matches("123.4.5.6")).isTrue();
- assertThat(matcher.matches("192.168.0.159")).isTrue();
+ assertTrue(matcher.matches("123.4.5.6"));
+ assertTrue(matcher.matches("192.168.0.159"));
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java
index c0076a407..466dcc3c0 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java
@@ -24,11 +24,11 @@ import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Collections;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Test cases for the {@link AuthorizationFilter} class.
@@ -43,7 +43,7 @@ public class IpFilterTest {
HttpServletRequest request = createNiceMock(HttpServletRequest.class);
expect(request.getRemoteAddr()).andReturn("192.168.42.42");
replay(request);
- assertThat(filter.isAccessAllowed(request, null, null)).isFalse();
+ assertFalse(filter.isAccessAllowed(request, null, null));
verify(request);
}
@@ -54,7 +54,7 @@ public class IpFilterTest {
HttpServletRequest request = createNiceMock(HttpServletRequest.class);
expect(request.getRemoteAddr()).andReturn("192.168.42.42");
replay(request);
- assertThat(filter.isAccessAllowed(request, null, null)).isFalse();
+ assertFalse(filter.isAccessAllowed(request, null, null));
verify(request);
}
@@ -65,7 +65,7 @@ public class IpFilterTest {
HttpServletRequest request = createNiceMock(HttpServletRequest.class);
expect(request.getRemoteAddr()).andReturn("192.168.33.44");
replay(request);
- assertThat(filter.isAccessAllowed(request, null, null)).isFalse();
+ assertFalse(filter.isAccessAllowed(request, null, null));
verify(request);
}
@@ -77,7 +77,7 @@ public class IpFilterTest {
HttpServletRequest request = createNiceMock(HttpServletRequest.class);
expect(request.getRemoteAddr()).andReturn("192.168.33.44");
replay(request);
- assertThat(filter.isAccessAllowed(request, null, null)).isFalse();
+ assertFalse(filter.isAccessAllowed(request, null, null));
verify(request);
}
@@ -97,7 +97,7 @@ public class IpFilterTest {
HttpServletRequest request = createNiceMock(HttpServletRequest.class);
expect(request.getRemoteAddr()).andReturn("192.168.33.44");
replay(request);
- assertThat(filter.isAccessAllowed(request, null, null)).isFalse();
+ assertFalse(filter.isAccessAllowed(request, null, null));
verify(request);
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/PortFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/PortFilterTest.java
index 8103b309f..2eab83f23 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/PortFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/PortFilterTest.java
@@ -23,12 +23,12 @@ import org.junit.jupiter.api.Test;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Tests for the {@link PortFilter} class.
@@ -59,7 +59,7 @@ public class PortFilterTest {
verify(request);
verify(response);
- assertThat(result).isFalse();
+ assertFalse(result);
}
/**
@@ -87,7 +87,7 @@ public class PortFilterTest {
verify(request);
verify(response);
- assertThat(result).isFalse();
+ assertFalse(result);
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/SslFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/SslFilterTest.java
index 605a323af..b9a58abd0 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/authz/SslFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/authz/SslFilterTest.java
@@ -30,13 +30,14 @@ import java.util.Map;
import static org.apache.shiro.web.filter.authz.SslFilter.HSTS.DEFAULT_MAX_AGE;
import static org.apache.shiro.web.filter.authz.SslFilter.HSTS.HTTP_HEADER;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.newCapture;
import static org.easymock.EasyMock.replay;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class SslFilterTest {
@@ -83,14 +84,14 @@ public class SslFilterTest {
@Test
void testDisabledByDefault() {
sslFilter.postHandle(request, response);
- assertThat(response.getHeader(HTTP_HEADER)).isNull();
+ assertNull(response.getHeader(HTTP_HEADER));
}
@Test
void testDefaultValues() {
sslFilter.getHsts().setEnabled(true);
sslFilter.postHandle(request, response);
- assertThat(response.getHeader(HTTP_HEADER)).isEqualTo("max-age=" + DEFAULT_MAX_AGE);
+ assertEquals("max-age=" + DEFAULT_MAX_AGE, response.getHeader(HTTP_HEADER));
}
@SuppressWarnings("checkstyle:MagicNumber")
@@ -103,7 +104,7 @@ public class SslFilterTest {
String expected = "max-age=" + 7776000 + "; includeSubDomains";
- assertThat(response.getHeader(HTTP_HEADER)).isEqualTo(expected);
+ assertEquals(expected, response.getHeader(HTTP_HEADER));
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java b/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
index 5d236a328..d4601267c 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
@@ -30,7 +30,12 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -51,31 +56,31 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
@Test
void testNewInstance() {
- assertThat(resolver.getPathMatcher()).isNotNull();
- assertThat(resolver.getPathMatcher() instanceof AntPathMatcher).isTrue();
- assertThat(resolver.getFilterChainManager()).isNotNull();
- assertThat(resolver.getFilterChainManager() instanceof DefaultFilterChainManager).isTrue();
+ assertNotNull(resolver.getPathMatcher());
+ assertTrue(resolver.getPathMatcher() instanceof AntPathMatcher);
+ assertNotNull(resolver.getFilterChainManager());
+ assertTrue(resolver.getFilterChainManager() instanceof DefaultFilterChainManager);
}
@Test
void testNewInstanceWithFilterConfig() {
FilterConfig mock = createNiceMockFilterConfig();
resolver = new PathMatchingFilterChainResolver(mock);
- assertThat(resolver.getPathMatcher()).isNotNull();
- assertThat(resolver.getPathMatcher() instanceof AntPathMatcher).isTrue();
- assertThat(resolver.getFilterChainManager()).isNotNull();
- assertThat(resolver.getFilterChainManager() instanceof DefaultFilterChainManager).isTrue();
- assertThat(mock).isEqualTo(((DefaultFilterChainManager) resolver.getFilterChainManager()).getFilterConfig());
+ assertNotNull(resolver.getPathMatcher());
+ assertTrue(resolver.getPathMatcher() instanceof AntPathMatcher);
+ assertNotNull(resolver.getFilterChainManager());
+ assertTrue(resolver.getFilterChainManager() instanceof DefaultFilterChainManager);
+ assertEquals(((DefaultFilterChainManager) resolver.getFilterChainManager()).getFilterConfig(), mock);
}
@Test
void testSetters() {
resolver.setPathMatcher(new AntPathMatcher());
- assertThat(resolver.getPathMatcher()).isNotNull();
- assertThat(resolver.getPathMatcher() instanceof AntPathMatcher).isTrue();
+ assertNotNull(resolver.getPathMatcher());
+ assertTrue(resolver.getPathMatcher() instanceof AntPathMatcher);
resolver.setFilterChainManager(new DefaultFilterChainManager());
- assertThat(resolver.getFilterChainManager()).isNotNull();
- assertThat(resolver.getFilterChainManager() instanceof DefaultFilterChainManager).isTrue();
+ assertNotNull(resolver.getFilterChainManager());
+ assertTrue(resolver.getFilterChainManager() instanceof DefaultFilterChainManager);
}
@Test
@@ -84,7 +89,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
ServletResponse response = mock(HttpServletResponse.class);
FilterChain chain = mock(FilterChain.class);
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNull();
+ assertNull(resolved);
}
@Test
@@ -100,7 +105,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/index.html");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -117,7 +122,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("./index.html");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -133,7 +138,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("../index.html");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -150,7 +155,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn(null);
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNull();
+ assertNull(resolved);
verify(request).getServletPath();
}
@@ -170,7 +175,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/book");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -190,7 +195,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn(null);
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -210,7 +215,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/book");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -230,7 +235,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/book//");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -248,7 +253,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertThat(resolved, notNullValue());
}
/**
@@ -267,7 +272,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/123/book/");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
@@ -287,7 +292,7 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
when(request.getPathInfo()).thenReturn("/resource/123/book");
FilterChain resolved = resolver.getChain(request, response, chain);
- assertThat(resolved).isNotNull();
+ assertNotNull(resolved);
verify(request).getServletPath();
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterListTest.java b/web/src/test/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterListTest.java
index 3a4bb668f..312dd46ed 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterListTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterListTest.java
@@ -33,10 +33,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createNiceMock;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for the {@link SimpleNamedFilterList} implementation.
@@ -49,13 +53,13 @@ public class SimpleNamedFilterListTest {
void testNewInstance() {
@SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
SimpleNamedFilterList list = new SimpleNamedFilterList("test");
- assertThat(list.getName()).isNotNull();
- assertThat(list.getName()).isEqualTo("test");
+ assertNotNull(list.getName());
+ assertEquals("test", list.getName());
}
@Test
void testNewInstanceNameless() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ assertThrows(IllegalArgumentException.class, () -> {
new SimpleNamedFilterList(null);
});
}
@@ -67,7 +71,7 @@ public class SimpleNamedFilterListTest {
@Test
void testNewInstanceNullBackingList() {
- assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
+ assertThrows(NullPointerException.class, () -> {
new SimpleNamedFilterList("test", null);
});
}
@@ -85,77 +89,77 @@ public class SimpleNamedFilterListTest {
NamedFilterList list = new SimpleNamedFilterList("test");
list.add(filter);
FilterChain chain = list.proxy(mock);
- assertThat(chain).isNotNull();
+ assertNotNull(chain);
assertNotSame(mock, chain);
Filter singleFilter = new SslFilter();
List<? extends Filter> multipleFilters = CollectionUtils.asList(new PortFilter(), new UserFilter());
list.add(0, singleFilter);
- assertThat(list).hasSize(2);
- assertThat(list.get(0) instanceof SslFilter).isTrue();
- assertThat(list.toArray()).containsExactly(new Object[]{singleFilter, filter});
+ assertEquals(2, list.size());
+ assertTrue(list.get(0) instanceof SslFilter);
+ assertArrayEquals(new Object[]{singleFilter, filter}, list.toArray());
list.addAll(multipleFilters);
- assertThat(list).hasSize(4);
- assertThat(list.get(2) instanceof PortFilter).isTrue();
- assertThat(list.get(3) instanceof UserFilter).isTrue();
+ assertEquals(4, list.size());
+ assertTrue(list.get(2) instanceof PortFilter);
+ assertTrue(list.get(3) instanceof UserFilter);
list.addAll(0, CollectionUtils.asList(new PermissionsAuthorizationFilter(), new RolesAuthorizationFilter()));
- assertThat(list).hasSize(6);
- assertThat(list.get(0) instanceof PermissionsAuthorizationFilter).isTrue();
- assertThat(list.get(1) instanceof RolesAuthorizationFilter).isTrue();
- assertThat(list.indexOf(singleFilter)).isEqualTo(2);
- assertThat(list.subList(4, list.size())).isEqualTo(multipleFilters);
+ assertEquals(6, list.size());
+ assertTrue(list.get(0) instanceof PermissionsAuthorizationFilter);
+ assertTrue(list.get(1) instanceof RolesAuthorizationFilter);
+ assertEquals(2, list.indexOf(singleFilter));
+ assertEquals(multipleFilters, list.subList(4, list.size()));
- assertThat(list).contains(singleFilter);
- assertThat(list).containsAll(multipleFilters);
+ assertTrue(list.contains(singleFilter));
+ assertTrue(list.containsAll(multipleFilters));
- assertThat(list).isNotEmpty();
+ assertFalse(list.isEmpty());
list.clear();
- assertThat(list).isEmpty();
+ assertTrue(list.isEmpty());
list.add(singleFilter);
Iterator i = list.iterator();
- assertThat(i.hasNext()).isTrue();
- assertThat(singleFilter).isEqualTo(i.next());
+ assertTrue(i.hasNext());
+ assertEquals(i.next(), singleFilter);
ListIterator li = list.listIterator();
- assertThat(li.hasNext()).isTrue();
- assertThat(singleFilter).isEqualTo(li.next());
+ assertTrue(li.hasNext());
+ assertEquals(li.next(), singleFilter);
li = list.listIterator(0);
- assertThat(li.hasNext()).isTrue();
- assertThat(singleFilter).isEqualTo(li.next());
+ assertTrue(li.hasNext());
+ assertEquals(li.next(), singleFilter);
list.set(0, singleFilter);
- assertThat(singleFilter).isEqualTo(list.get(0));
+ assertEquals(list.get(0), singleFilter);
Filter[] filters = new Filter[list.size()];
filters = list.toArray(filters);
- assertThat(filters.length).isEqualTo(1);
- assertThat(singleFilter).isEqualTo(filters[0]);
+ assertEquals(1, filters.length);
+ assertEquals(filters[0], singleFilter);
- assertThat(list.lastIndexOf(singleFilter)).isEqualTo(0);
+ assertEquals(0, list.lastIndexOf(singleFilter));
list.remove(singleFilter);
- assertThat(list).isEmpty();
+ assertTrue(list.isEmpty());
list.add(singleFilter);
list.remove(0);
- assertThat(list).isEmpty();
+ assertTrue(list.isEmpty());
list.add(singleFilter);
list.addAll(multipleFilters);
- assertThat(list).hasSize(3);
+ assertEquals(3, list.size());
list.removeAll(multipleFilters);
- assertThat(list).hasSize(1);
- assertThat(singleFilter).isEqualTo(list.get(0));
+ assertEquals(1, list.size());
+ assertEquals(list.get(0), singleFilter);
list.addAll(multipleFilters);
- assertThat(list).hasSize(3);
+ assertEquals(3, list.size());
list.retainAll(multipleFilters);
- assertThat(list).hasSize(2);
- assertThat(multipleFilters).isEqualTo(new ArrayList<>(list));
+ assertEquals(2, list.size());
+ assertEquals(new ArrayList<>(list), multipleFilters);
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/mgt/CookieRememberMeManagerTest.java b/web/src/test/java/org/apache/shiro/web/mgt/CookieRememberMeManagerTest.java
index c61b81748..5c5522066 100644
--- a/web/src/test/java/org/apache/shiro/web/mgt/CookieRememberMeManagerTest.java
+++ b/web/src/test/java/org/apache/shiro/web/mgt/CookieRememberMeManagerTest.java
@@ -37,8 +37,6 @@ import javax.servlet.http.HttpServletResponse;
import java.util.UUID;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
@@ -46,6 +44,9 @@ import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
@@ -118,7 +119,7 @@ class CookieRememberMeManagerTest {
replay(mockRequest);
CookieRememberMeManager mgr = new CookieRememberMeManager();
- assertThat(mgr.getRememberedSerializedIdentity(context)).isNull();
+ assertNull(mgr.getRememberedSerializedIdentity(context));
}
@@ -156,14 +157,14 @@ class CookieRememberMeManagerTest {
verify(mockRequest);
- assertThat(collection).isNotNull();
+ assertNotNull(collection);
//noinspection ConstantConditions
- assertThat(collection.iterator().next()).isEqualTo("user");
+ assertEquals("user", collection.iterator().next());
}
@Test
void getRememberedPrincipalsNoMoreDefaultCipher() {
- assertThatExceptionOfType(CryptoException.class).isThrownBy(() -> {
+ assertThrows(CryptoException.class, () -> {
HttpServletRequest mockRequest = createMock(HttpServletRequest.class);
HttpServletResponse mockResponse = createMock(HttpServletResponse.class);
WebSubjectContext context = new DefaultWebSubjectContext();
@@ -177,14 +178,14 @@ class CookieRememberMeManagerTest {
//The following base64 string was determined from the log output of the above 'onSuccessfulLogin' test.
//This will have to change any time the PrincipalCollection implementation changes:
final String userPCAesBase64 = "0o6DCfePYTjK4q579qzUFEfkeGRvbBOdKHp2y8/nGAltt1Vz8uW0Z8igeO"
- + "Tq/yBmcw25f3Q0ui/Leg3x0iQZWhw9Bbu0mFHmHsGxEd6mPwtUpSegIjyX5c/kZpqnb7QLdajPWiczX8P"
- + "Oc2Eku5+8ye1u38Y8uKlklHxcYCPh0pRiDSBxfjPsLaDfOpGbmPjZd4SVg68i/++TvUjqBNJyb+pDix3f"
- + "PeuPvReWGcE50iovezVZrEfDOAQ0cZYW35ShypMWOmE9yZnb+p8++StDyAUegryyuIa4pjuRzfMh9D+sN"
- + "F9tm/EnDC1VCer2S/a0AGlWAQiM7jrWt1sNinZcKIrvShaWI21tONJt8WhozNS2H72lk4p92rfLNHeglT"
- + "xObxIYxLfTI9KiToSe1nYmpQmbBO8x1wWDkWBG//EqRvhgbIfQVqJp12T0fJC1nFuZuVhw/ZanaAZGDk8"
- + "7aLMiw3T6FBZtWaspgvfH+0TJrTD8Ra386ekNXNN8JW8=";
-
- Cookie[] cookies = new Cookie[]{
+ + "Tq/yBmcw25f3Q0ui/Leg3x0iQZWhw9Bbu0mFHmHsGxEd6mPwtUpSegIjyX5c/kZpqnb7QLdajPWiczX8P"
+ + "Oc2Eku5+8ye1u38Y8uKlklHxcYCPh0pRiDSBxfjPsLaDfOpGbmPjZd4SVg68i/++TvUjqBNJyb+pDix3f"
+ + "PeuPvReWGcE50iovezVZrEfDOAQ0cZYW35ShypMWOmE9yZnb+p8++StDyAUegryyuIa4pjuRzfMh9D+sN"
+ + "F9tm/EnDC1VCer2S/a0AGlWAQiM7jrWt1sNinZcKIrvShaWI21tONJt8WhozNS2H72lk4p92rfLNHeglT"
+ + "xObxIYxLfTI9KiToSe1nYmpQmbBO8x1wWDkWBG//EqRvhgbIfQVqJp12T0fJC1nFuZuVhw/ZanaAZGDk8"
+ + "7aLMiw3T6FBZtWaspgvfH+0TJrTD8Ra386ekNXNN8JW8=";
+
+ Cookie[] cookies = new Cookie[] {
new Cookie(CookieRememberMeManager.DEFAULT_REMEMBER_ME_COOKIE_NAME, userPCAesBase64)
};
@@ -250,7 +251,7 @@ class CookieRememberMeManagerTest {
CookieRememberMeManager mgr = new CookieRememberMeManager();
PrincipalCollection rememberedPrincipals = mgr.getRememberedPrincipals(context);
- assertThat(rememberedPrincipals).as("rememberedPrincipals should be null on invalid cookies.").isNull();
+ assertNull(rememberedPrincipals, "rememberedPrincipals should be null on invalid cookies.");
}
@Test
@@ -304,7 +305,7 @@ class CookieRememberMeManagerTest {
final byte[] rememberedSerializedIdentity = mgr.getRememberedSerializedIdentity(context);
// then
- assertThat(rememberedSerializedIdentity).as("should ignore invalid cookie values").isNull();
+ assertNull(rememberedSerializedIdentity, "should ignore invalid cookie values");
}
@SuppressWarnings("checkstyle:MagicNumber")
diff --git a/web/src/test/java/org/apache/shiro/web/mgt/DefaultWebSecurityManagerTest.java b/web/src/test/java/org/apache/shiro/web/mgt/DefaultWebSecurityManagerTest.java
index 84c7f6611..9e5775020 100644
--- a/web/src/test/java/org/apache/shiro/web/mgt/DefaultWebSecurityManagerTest.java
+++ b/web/src/test/java/org/apache/shiro/web/mgt/DefaultWebSecurityManagerTest.java
@@ -42,9 +42,12 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -89,8 +92,7 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
sm.setSessionManager(sessionManager);
- assertThat(sm.isHttpSessionMode())
- .as("The set SessionManager is not being used to determine isHttpSessionMode.").isTrue();
+ assertTrue(sm.isHttpSessionMode(), "The set SessionManager is not being used to determine isHttpSessionMode.");
verify(sessionManager).isServletContainerSessions();
}
@@ -120,13 +122,13 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
Subject subject = newSubject(mockRequest, mockResponse);
- assertThat(subject.isAuthenticated()).isFalse();
+ assertFalse(subject.isAuthenticated());
subject.login(new UsernamePasswordToken("lonestarr", "vespa"));
- assertThat(subject.isAuthenticated()).isTrue();
- assertThat(subject.getPrincipal()).isNotNull();
- assertThat(subject.getPrincipal()).isEqualTo("lonestarr");
+ assertTrue(subject.isAuthenticated());
+ assertNotNull(subject.getPrincipal());
+ assertEquals("lonestarr", subject.getPrincipal());
}
@SuppressWarnings("checkstyle:MagicNumber")
@@ -145,9 +147,9 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
Subject subject = newSubject(mockRequest, mockResponse);
Session session = subject.getSession();
- assertThat(globalTimeout).isEqualTo(session.getTimeout());
+ assertEquals(session.getTimeout(), globalTimeout);
session.setTimeout(125);
- assertThat(session.getTimeout()).isEqualTo(125);
+ assertEquals(125, session.getTimeout());
sleep(200);
try {
session.getTimeout();
@@ -167,10 +169,10 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
Subject subject = newSubject(mockRequest, mockResponse);
- assertThat(subject).isNotNull();
- assertThat(subject.getPrincipals() == null || subject.getPrincipals().isEmpty()).isTrue();
- assertThat(subject.getSession(false)).isNull();
- assertThat(subject.isAuthenticated()).isFalse();
+ assertNotNull(subject);
+ assertTrue(subject.getPrincipals() == null || subject.getPrincipals().isEmpty());
+ assertNull(subject.getSession(false));
+ assertFalse(subject.isAuthenticated());
}
@Test
@@ -186,7 +188,7 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
Session session = subject.getSession();
Serializable sessionId = session.getId();
- assertThat(sessionId).isNotNull();
+ assertNotNull(sessionId);
mockRequest = mock(HttpServletRequest.class);
mockResponse = mock(HttpServletResponse.class);
@@ -198,8 +200,8 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
subject = newSubject(mockRequest, mockResponse);
session = subject.getSession(false);
- assertThat(session).isNotNull();
- assertThat(session.getId()).isEqualTo(sessionId);
+ assertNotNull(session);
+ assertEquals(sessionId, session.getId());
}
/**
@@ -220,8 +222,8 @@ public class DefaultWebSecurityManagerTest extends AbstractWebSecurityManagerTes
PrincipalCollection principals = new SimplePrincipalCollection("user1", "iniRealm");
Subject subject = new Subject.Builder(securityManager).principals(principals).buildSubject();
- assertThat(subject).isNotNull();
- assertThat(subject.getPrincipal()).isEqualTo("user1");
+ assertNotNull(subject);
+ assertEquals("user1", subject.getPrincipal());
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/servlet/OncePerRequestFilterTest.java b/web/src/test/java/org/apache/shiro/web/servlet/OncePerRequestFilterTest.java
index 297abadeb..790833527 100644
--- a/web/src/test/java/org/apache/shiro/web/servlet/OncePerRequestFilterTest.java
+++ b/web/src/test/java/org/apache/shiro/web/servlet/OncePerRequestFilterTest.java
@@ -27,7 +27,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -68,7 +68,7 @@ public class OncePerRequestFilterTest {
filter.doFilter(request, response, chain);
- assertThat(filter.filterCount).as("Filter should have executed").isEqualTo(1);
+ assertEquals(1, filter.filterCount, "Filter should have executed");
}
/**
@@ -84,7 +84,7 @@ public class OncePerRequestFilterTest {
filter.doFilter(request, response, chain);
- assertThat(filter.filterCount).as("Filter should NOT have executed").isEqualTo(0);
+ assertEquals(0, filter.filterCount, "Filter should NOT have executed");
}
@Test
@@ -96,7 +96,7 @@ public class OncePerRequestFilterTest {
filter.doFilter(request, response, chain);
filter.doFilter(request, response, chain);
- assertThat(filter.filterCount).as("Filter should have executed twice").isEqualTo(2);
+ assertEquals(2, filter.filterCount, "Filter should have executed twice");
}
static class CountingOncePerRequestFilter extends OncePerRequestFilter {
diff --git a/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java b/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
index aa3b59e49..1943802a6 100644
--- a/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
+++ b/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
@@ -28,7 +28,8 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -75,13 +76,13 @@ public class ShiroHttpServletRequestTest {
return null;
});
- assertThat(request.getSession(true)).isNotNull();
- assertThat(request.getSession(false)).isNotNull();
+ assertNotNull(request.getSession(true));
+ assertNotNull(request.getSession(false));
mockSubject.logout();
- assertThat(request.getSession(false)).isNull();
- assertThat(request.getSession(true)).isNotNull();
+ assertNull(request.getSession(false));
+ assertNotNull(request.getSession(true));
verify(mockSubject, times(2)).getSession(true);
verify(mockSubject, atLeast(3)).getSession(false);
}
diff --git a/web/src/test/java/org/apache/shiro/web/session/HttpServletSessionTest.java b/web/src/test/java/org/apache/shiro/web/session/HttpServletSessionTest.java
index 2950584a2..2c855ba8d 100644
--- a/web/src/test/java/org/apache/shiro/web/session/HttpServletSessionTest.java
+++ b/web/src/test/java/org/apache/shiro/web/session/HttpServletSessionTest.java
@@ -24,11 +24,11 @@ import org.junit.jupiter.api.Test;
import javax.servlet.http.HttpSession;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.easymock.EasyMock.captureInt;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HttpServletSessionTest {
@@ -61,7 +61,7 @@ public class HttpServletSessionTest {
long timeoutInMilliseconds = servletSession.getTimeout();
- assertThat(timeoutInMilliseconds).isEqualTo(expectedLongValue);
- assertThat(capturedInt.getValue().intValue()).isEqualTo(expectedTimeoutInSeconds);
+ assertEquals(expectedLongValue, timeoutInMilliseconds);
+ assertEquals(expectedTimeoutInSeconds, capturedInt.getValue().intValue());
}
}