You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by fp...@apache.org on 2019/11/05 15:26:32 UTC
[shiro] branch master updated: Updating remaining Groovy tests to
Junit4
This is an automated email from the ASF dual-hosted git repository.
fpapon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shiro.git
The following commit(s) were added to refs/heads/master by this push:
new 2a1e757 Updating remaining Groovy tests to Junit4
new ffdcf04 Merge pull request #171 from coheigea/junit4
2a1e757 is described below
commit 2a1e757bcacefe3dc58c159094188548bb08ef17
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Nov 5 11:04:14 2019 +0000
Updating remaining Groovy tests to Junit4
---
.../authc/pam/ModularRealmAuthenticatorTest.groovy | 13 ++++++++++-
.../groovy/org/apache/shiro/codec/H64Test.groovy | 8 ++++---
.../apache/shiro/mgt/DefaultSubjectDAOTest.groovy | 21 +++++++++++++++++-
.../AuthenticatingRealmIntegrationTest.groovy | 6 +++++-
.../shiro/realm/AuthenticatingRealmTest.groovy | 18 +++++++++++++++-
.../org/apache/shiro/realm/CachingRealmTest.groovy | 10 ++++++++-
.../AnnotationEventListenerResolverTest.groovy | 9 +++++++-
.../shiro/event/support/DefaultEventBusTest.groovy | 22 ++++++++++++++++---
.../event/support/EventClassComparatorTest.groovy | 20 +++++++++++++----
.../support/EventListenerComparatorTest.groovy | 17 ++++++++++++---
.../org/apache/shiro/cas/CasRealmTest.groovy | 14 +++++++++++-
.../org/apache/shiro/cas/CasTokenTest.groovy | 9 +++++++-
.../IniFilterChainResolverFactoryTest.groovy | 18 +++++++++++++++-
.../mgt/DefaultFilterChainManagerTest.groovy | 25 +++++++++++++++++++++-
.../session/NoSessionCreationFilterTest.groovy | 6 +++++-
.../DefaultWebSessionStorageEvaluatorTest.groovy | 11 +++++++++-
.../web/servlet/AbstractShiroFilterTest.groovy | 7 +++++-
.../shiro/web/servlet/IniShiroFilterTest.groovy | 11 ++++++++--
.../shiro/web/servlet/ShiroFilterTest.groovy | 6 +++++-
.../mgt/ServletContainerSessionManagerTest.groovy | 11 +++++++++-
20 files changed, 232 insertions(+), 30 deletions(-)
diff --git a/core/src/test/groovy/org/apache/shiro/authc/pam/ModularRealmAuthenticatorTest.groovy b/core/src/test/groovy/org/apache/shiro/authc/pam/ModularRealmAuthenticatorTest.groovy
index 9e240a5..414e7e3 100644
--- a/core/src/test/groovy/org/apache/shiro/authc/pam/ModularRealmAuthenticatorTest.groovy
+++ b/core/src/test/groovy/org/apache/shiro/authc/pam/ModularRealmAuthenticatorTest.groovy
@@ -21,21 +21,26 @@ package org.apache.shiro.authc.pam
import org.apache.shiro.realm.Realm
import org.apache.shiro.subject.PrincipalCollection
import org.apache.shiro.authc.*
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link ModularRealmAuthenticator} implementation.
*
* @since 1.2
*/
-class ModularRealmAuthenticatorTest extends GroovyTestCase {
+class ModularRealmAuthenticatorTest {
+ @Test
void testNewInstance() {
ModularRealmAuthenticator mra = new ModularRealmAuthenticator()
assertNotNull mra.authenticationStrategy
assertTrue mra.authenticationStrategy instanceof AtLeastOneSuccessfulStrategy
}
+ @Test
void testDoAuthenticateNoRealms() {
def token = createStrictMock(AuthenticationToken)
@@ -52,6 +57,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify token
}
+ @Test
void testSingleRealmAuthenticationSuccess() {
def realm = createStrictMock(Realm)
@@ -71,6 +77,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify realm, token, info
}
+ @Test
void testSingleRealmAuthenticationWithUnsupportedToken() {
def realm = createStrictMock(Realm)
@@ -92,6 +99,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify realm, token
}
+ @Test
void testSingleRealmAuthenticationWithNullAuthenticationInfo() {
def realm = createStrictMock(Realm)
@@ -114,6 +122,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify realm, token
}
+ @Test
void testMultiRealmAuthenticationSuccess() {
def realm1 = createStrictMock(Realm)
@@ -152,6 +161,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify realm1, realm1Info, realm2, realm2Info, token, aggregate, strategy
}
+ @Test
void testMultiRealmAuthenticationWithAuthenticationException() {
def realm1 = createStrictMock(Realm)
@@ -190,6 +200,7 @@ class ModularRealmAuthenticatorTest extends GroovyTestCase {
verify realm1, realm1Info, realm2, token, aggregate, strategy
}
+ @Test
void testOnLogout() {
def realm = createStrictMock(LogoutAwareRealm)
diff --git a/core/src/test/groovy/org/apache/shiro/codec/H64Test.groovy b/core/src/test/groovy/org/apache/shiro/codec/H64Test.groovy
index 1560c47..765de80 100644
--- a/core/src/test/groovy/org/apache/shiro/codec/H64Test.groovy
+++ b/core/src/test/groovy/org/apache/shiro/codec/H64Test.groovy
@@ -19,14 +19,16 @@
package org.apache.shiro.codec
import org.apache.shiro.crypto.SecureRandomNumberGenerator
+import org.junit.Test
+
+import static org.junit.Assert.*
/**
* Test cases for the {@link H64} implementation.
*/
-class H64Test extends GroovyTestCase {
-
- void testNothing(){}
+class H64Test {
+ @Test
public void testDefault() {
byte[] orig = new SecureRandomNumberGenerator().nextBytes(6).bytes
diff --git a/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy b/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy
index 5f9bb56..2b0eb3b 100644
--- a/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy
+++ b/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy
@@ -23,22 +23,26 @@ import org.apache.shiro.subject.PrincipalCollection
import org.apache.shiro.subject.Subject
import org.apache.shiro.subject.support.DefaultSubjectContext
import org.apache.shiro.subject.support.DelegatingSubject
+import org.junit.Test
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link DefaultSubjectDAO} implementation.
*
* @since 1.2
*/
-class DefaultSubjectDAOTest extends GroovyTestCase {
+class DefaultSubjectDAOTest {
+ @Test
void testIsSessionStorageEnabledDefault() {
def dao = new DefaultSubjectDAO()
assertTrue dao.sessionStorageEvaluator instanceof DefaultSessionStorageEvaluator
assertTrue dao.isSessionStorageEnabled(null)
}
+ @Test
void testIsSessionStorageEnabledDefaultSubject() {
def dao = new DefaultSubjectDAO()
@@ -53,6 +57,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
verify subject
}
+ @Test
void testCustomSessionStorageEvaluator() {
def dao = new DefaultSubjectDAO()
def subject = createMock(Subject)
@@ -68,6 +73,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
verify subject, evaluator
}
+ @Test
void testDeleteWithoutSession() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -81,6 +87,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
verify subject
}
+ @Test
void testDeleteWithSession() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -100,6 +107,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
/**
* Ensures that when save is called and session storage is disabled, that the subject is never asked for its session.
*/
+ @Test
void testSaveWhenSessionStorageIsDisabled() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -122,6 +130,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* Tests the case when the save method is called but the Subject does not yet have any associated
* principals or authentication state or even a session. In this case, the session should never be created.
*/
+ @Test
void testSaveWithoutSessionOrPrincipalsOrAuthentication() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -146,6 +155,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
/**
* SHIRO-380
*/
+ @Test
void testMergePrincipalsWithDelegatingSubject() {
def sessionId = "sessionId"
@@ -173,6 +183,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* Tests the case when the Subject has principals but no session yet. In this case, a session will be created
* and the session will be set with the principals.
*/
+ @Test
void testMergePrincipalsWithSubjectPrincipalsButWithoutSession() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -198,6 +209,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* principals and neither does the session. In this case, the session will be accessed
* but never updated.
*/
+ @Test
void testMergePrincipalsWithoutSubjectPrincipalsOrSessionPrincipals() {
def dao = new DefaultSubjectDAO()
@@ -222,6 +234,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* principals but the session does. In this case, the session will be accessed and the session-principals will
* be removed (to match the Subject's state).
*/
+ @Test
void testMergePrincipalsWithoutSubjectPrincipalsButWithSessionPrincipals() {
def dao = new DefaultSubjectDAO()
@@ -274,6 +287,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* different principals. In this case, the session will be accessed and the session will be set with the
* Subject's principals.
*/
+ @Test
void testMergePrincipalsWithSubjectPrincipalsButWithDifferentSessionPrincipals() {
def sessionPrincipals = createStrictMock(PrincipalCollection)
@@ -317,6 +331,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* Tests the case when the Subject is authenticated but doesn't yet have a session. In this case, a
* session will be created and the session will be set with the authentication state.
*/
+ @Test
void testMergeAuthcWithSubjectAuthcButWithoutSession() {
def dao = new DefaultSubjectDAO()
def subject = createStrictMock(Subject)
@@ -339,6 +354,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* and the session doesn't have an attribute reflecting this. In this case, the session will be accessed
* but never updated.
*/
+ @Test
void testMergeAuthcWithoutSubjectAuthcOrSessionAuthc() {
def dao = new DefaultSubjectDAO()
@@ -362,6 +378,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* has authentication state. In this case, the session will be accessed and the session authc state will
* be removed to match the Subject's state.
*/
+ @Test
void testMergeAuthcWithoutSubjectAuthcButWithSessionAuthc() {
def dao = new DefaultSubjectDAO()
@@ -386,6 +403,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* yet reflect that authentication state. In this case, the session will be accessed and the session will be set
* with the Subject's authentication state.
*/
+ @Test
void testMergeAuthcWithSubjectAuthcButWithoutSessionAuthc() {
testMergeAuthcWithSubjectAuthcButWithSessionAuthc(null)
}
@@ -395,6 +413,7 @@ class DefaultSubjectDAOTest extends GroovyTestCase {
* different state. In this case, the session will be accessed and the session will be set with the
* Subject's authentication state.
*/
+ @Test
void testMergeAuthcWithSubjectAuthcButWithDifferentSessionAuthc() {
testMergeAuthcWithSubjectAuthcButWithSessionAuthc(Boolean.FALSE)
}
diff --git a/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmIntegrationTest.groovy b/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmIntegrationTest.groovy
index 9770cc4..26ead7f 100644
--- a/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmIntegrationTest.groovy
+++ b/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmIntegrationTest.groovy
@@ -24,14 +24,18 @@ import org.apache.shiro.config.Ini
import org.apache.shiro.config.IniSecurityManagerFactory
import org.apache.shiro.mgt.SecurityManager
import org.apache.shiro.subject.Subject
+import org.junit.Test
+
+import static org.junit.Assert.*
/**
* Integration tests for the AuthenticatingRealm implementation.
*
* @since 1.2.1
*/
-class AuthenticatingRealmIntegrationTest extends GroovyTestCase {
+class AuthenticatingRealmIntegrationTest {
+ @Test
void testShiro354() {
Ini ini = new Ini();
diff --git a/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmTest.groovy b/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmTest.groovy
index c3f0f1f..d8c38aa 100644
--- a/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmTest.groovy
+++ b/core/src/test/groovy/org/apache/shiro/realm/AuthenticatingRealmTest.groovy
@@ -23,13 +23,17 @@ import org.apache.shiro.cache.Cache
import org.apache.shiro.cache.CacheManager
import org.apache.shiro.subject.PrincipalCollection
import org.apache.shiro.authc.*
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link AuthenticatingRealm} implementation.
*/
-class AuthenticatingRealmTest extends GroovyTestCase {
+class AuthenticatingRealmTest {
+ @Test
void testSetName() {
AuthenticatingRealm realm = new TestAuthenticatingRealm()
def name = "foo"
@@ -46,6 +50,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
assertEquals "bar", realm.authenticationCacheName
}
+ @Test
void testSupports() {
def password = "foo"
def token = new UsernamePasswordToken("username", password);
@@ -55,6 +60,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
assertTrue realm.supports(token)
}
+ @Test
void testSupportsWithCustomAuthenticationTokenClass() {
def token = createStrictMock(RememberMeAuthenticationToken)
@@ -69,6 +75,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify token
}
+ @Test
void testNewInstanceWithCacheManager() {
def cacheManager = createStrictMock(CacheManager)
@@ -81,6 +88,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify cacheManager
}
+ @Test
void testNewInstanceWithCredentialsMatcher() {
def matcher = createStrictMock(CredentialsMatcher)
@@ -92,6 +100,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify matcher
}
+ @Test
void testSetCache() {
def cache = createStrictMock(Cache)
@@ -105,6 +114,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify cache
}
+ @Test
void testGetAuthenticationInfo() {
def password = "foo"
@@ -126,6 +136,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify token, info
}
+ @Test
void testGetAuthenticationInfoWithNullReturnValue() {
def token = createStrictMock(AuthenticationToken)
@@ -142,6 +153,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify token, info
}
+ @Test
void testAuthenticationCachingEnabledWithCacheMiss() {
def username = "foo"
@@ -176,6 +188,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify cacheManager, cache, token, info
}
+ @Test
void testAuthenticationCachingEnabledWithCacheHit() {
def username = "foo"
@@ -207,6 +220,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify cacheManager, cache, token, info
}
+ @Test
void testLogoutWithAuthenticationCachingEnabled() {
def realmName = "testRealm"
@@ -238,6 +252,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
verify cacheManager, cache, token, info, principals
}
+ @Test
void testAssertCredentialsMatchWithNullCredentialsMatcher() {
AuthenticatingRealm realm = new TestAuthenticatingRealm();
realm.credentialsMatcher = null
@@ -251,6 +266,7 @@ class AuthenticatingRealmTest extends GroovyTestCase {
}
}
+ @Test
void testAssertCredentialsMatchFailure() {
def matcher = createStrictMock(CredentialsMatcher)
diff --git a/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy b/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy
index 3a9da85..32ad5a4 100644
--- a/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy
+++ b/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy
@@ -23,13 +23,16 @@ import org.apache.shiro.authc.AuthenticationToken
import org.apache.shiro.cache.Cache
import org.apache.shiro.cache.CacheManager
import org.apache.shiro.subject.PrincipalCollection
+import org.junit.Test
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link CachingRealm} implementation.
*/
-class CachingRealmTest extends GroovyTestCase {
+class CachingRealmTest {
+ @Test
void testCachingEnabled() {
CachingRealm realm = new TestCachingRealm()
@@ -39,6 +42,7 @@ class CachingRealmTest extends GroovyTestCase {
assertFalse realm.cachingEnabled
}
+ @Test
void testSetName() {
CachingRealm realm = new TestCachingRealm()
@@ -50,6 +54,7 @@ class CachingRealmTest extends GroovyTestCase {
}
+ @Test
void testNewInstanceWithCacheManager() {
def cacheManager = createStrictMock(CacheManager)
@@ -61,6 +66,7 @@ class CachingRealmTest extends GroovyTestCase {
assertTrue realm.templateMethodCalled
}
+ @Test
void testOnLogout() {
def realmName = "testRealm"
@@ -85,6 +91,7 @@ class CachingRealmTest extends GroovyTestCase {
verify cacheManager, cache, principals
}
+ @Test
void testGetAvailablePrincipalWithRealmPrincipals() {
def realmName = "testRealm"
@@ -107,6 +114,7 @@ class CachingRealmTest extends GroovyTestCase {
verify principals
}
+ @Test
void testGetAvailablePrincipalWithoutRealmPrincipals() {
def realmName = "testRealm"
diff --git a/event/src/test/groovy/org/apache/shiro/event/support/AnnotationEventListenerResolverTest.groovy b/event/src/test/groovy/org/apache/shiro/event/support/AnnotationEventListenerResolverTest.groovy
index fb5b1b4..fed278e 100644
--- a/event/src/test/groovy/org/apache/shiro/event/support/AnnotationEventListenerResolverTest.groovy
+++ b/event/src/test/groovy/org/apache/shiro/event/support/AnnotationEventListenerResolverTest.groovy
@@ -18,17 +18,23 @@
*/
package org.apache.shiro.event.support
+import org.junit.Test
+
+import static org.junit.Assert.*
+
/**
* @since 1.3
*/
-class AnnotationEventListenerResolverTest extends GroovyTestCase {
+class AnnotationEventListenerResolverTest {
+ @Test
void testSetGetAnnotationClass() {
def resolver = new AnnotationEventListenerResolver();
resolver.setAnnotationClass(Override.class) //any old annotation will do for the test
assertSame Override.class, resolver.getAnnotationClass()
}
+ @Test
void testNullInstanceArgument() {
def resolver = new AnnotationEventListenerResolver()
def collection = resolver.getEventListeners(null)
@@ -36,6 +42,7 @@ class AnnotationEventListenerResolverTest extends GroovyTestCase {
assertTrue collection.isEmpty()
}
+ @Test
void testNoAnnotationsArgument() {
def resolver = new AnnotationEventListenerResolver()
def collection = resolver.getEventListeners(new NotAnnotatedSubscriber())
diff --git a/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy b/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy
index 9418b21..b8feec3 100644
--- a/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy
+++ b/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy
@@ -18,20 +18,25 @@
*/
package org.apache.shiro.event.support
+import org.junit.Before
+import org.junit.Test
+
+import static org.junit.Assert.*
import static org.easymock.EasyMock.*
/**
* @since 1.3
*/
-class DefaultEventBusTest extends GroovyTestCase {
+class DefaultEventBusTest {
DefaultEventBus bus;
- @Override
- protected void setUp() {
+ @Before
+ void setUp() {
bus = new DefaultEventBus()
}
+ @Test
void testSetEventListenerResolver() {
def resolver = new EventListenerResolver() {
List<EventListener> getEventListeners(Object instance) {
@@ -42,6 +47,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertSame resolver, bus.getEventListenerResolver()
}
+ @Test
void testSimpleSubscribe() {
def subscriber = new TestSubscriber();
@@ -56,6 +62,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertSame event, subscriber.lastEvent
}
+ @Test
void testPublishNullEvent() {
def subscriber = new TestSubscriber();
bus.register(subscriber)
@@ -65,6 +72,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 0, subscriber.count
}
+ @Test
void testSubscribeNullInstance() {
def resolver = createStrictMock(EventListenerResolver) //assert no methods are called on this
bus.eventListenerResolver = resolver
@@ -76,6 +84,7 @@ class DefaultEventBusTest extends GroovyTestCase {
verify(resolver)
}
+ @Test
void testSubscribeWithNullResolvedListeners() {
def resolver = new EventListenerResolver() {
List<EventListener> getEventListeners(Object instance) {
@@ -88,6 +97,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 0, bus.registry.size()
}
+ @Test
void testSubscribeWithoutAnnotations() {
def subscriber = new NotAnnotatedSubscriber()
bus.register(subscriber)
@@ -97,10 +107,12 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 0, bus.registry.size()
}
+ @Test
void testUnsubscribeNullInstance() {
bus.unregister(null)
}
+ @Test
void testUnsubscribe() {
def subscriber = new TestSubscriber()
bus.register(subscriber)
@@ -119,6 +131,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 0, bus.registry.size()
}
+ @Test
void testPolymorphicSubscribeMethodsOnlyOneInvoked() {
def subscriber = new TestSubscriber()
bus.register(subscriber)
@@ -133,6 +146,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 1, subscriber.count
}
+ @Test
void testPolymorphicSubscribeMethodsOnlyOneInvokedWithListenerSubclass() {
def subscriber = new SubclassTestSubscriber()
bus.register(subscriber)
@@ -148,6 +162,7 @@ class DefaultEventBusTest extends GroovyTestCase {
assertEquals 0, subscriber.barCount
}
+ @Test
void testSubscribeWithErroneousAnnotation() {
def subscriber = new ErroneouslyAnnotatedSubscriber()
//noinspection GroovyUnusedCatchParameter
@@ -158,6 +173,7 @@ class DefaultEventBusTest extends GroovyTestCase {
}
}
+ @Test
void testContinueThroughListenerExceptions() {
def ok = new SimpleSubscriber()
def error = new ExceptionThrowingSubscriber()
diff --git a/event/src/test/groovy/org/apache/shiro/event/support/EventClassComparatorTest.groovy b/event/src/test/groovy/org/apache/shiro/event/support/EventClassComparatorTest.groovy
index d39e3c1..3d90717 100644
--- a/event/src/test/groovy/org/apache/shiro/event/support/EventClassComparatorTest.groovy
+++ b/event/src/test/groovy/org/apache/shiro/event/support/EventClassComparatorTest.groovy
@@ -18,47 +18,59 @@
*/
package org.apache.shiro.event.support
+import org.junit.Before
+import org.junit.Test
+
+import static org.junit.Assert.*
+
/**
* Tests for the {@link EventClassComparator} implementation.
*
* @since 1.3
*/
-class EventClassComparatorTest extends GroovyTestCase {
+class EventClassComparatorTest {
EventClassComparator comparator
- @Override
- protected void setUp() {
+ @Before
+ void setUp() {
comparator = new EventClassComparator()
}
+ @Test
void testANull() {
def result = comparator.compare(null, Object)
assertEquals(-1, result)
}
+ @Test
void testBNull() {
def result = comparator.compare(Object, null)
assertEquals 1, result
}
+ @Test
void testBothNull() {
assertEquals 0, comparator.compare(null, null)
}
+ @Test
void testBothSame() {
assertEquals 0, comparator.compare(Object, Object)
}
+ @Test
void testAParentOfB() {
assertEquals 1, comparator.compare(Number, Integer)
}
+ @Test
void testBParentOfA() {
assertEquals(-1, comparator.compare(Integer, Number))
}
+ @Test
void testUnrelated() {
- assertEquals(0, comparator.compare(Integer, Boolean))
+ assertEquals 0, comparator.compare(Integer, Boolean)
}
}
diff --git a/event/src/test/groovy/org/apache/shiro/event/support/EventListenerComparatorTest.groovy b/event/src/test/groovy/org/apache/shiro/event/support/EventListenerComparatorTest.groovy
index 8cae13f..b3321c4 100644
--- a/event/src/test/groovy/org/apache/shiro/event/support/EventListenerComparatorTest.groovy
+++ b/event/src/test/groovy/org/apache/shiro/event/support/EventListenerComparatorTest.groovy
@@ -18,51 +18,62 @@
*/
package org.apache.shiro.event.support
+import org.junit.Before
+import org.junit.Test
+
import static org.easymock.EasyMock.createStrictMock
+import static org.junit.Assert.*
/**
* @since 1.3
*/
-class EventListenerComparatorTest extends GroovyTestCase {
+class EventListenerComparatorTest {
EventListenerComparator comparator
- @Override
- protected void setUp() {
+ @Before
+ void setUp() {
comparator = new EventListenerComparator()
}
+ @Test
void testANull() {
def result = comparator.compare(null, createStrictMock(EventListener))
assertEquals(-1, result)
}
+ @Test
void testBNull() {
def result = comparator.compare(createStrictMock(EventListener), null)
assertEquals 1, result
}
+ @Test
void testBothNull() {
assertEquals 0, comparator.compare(null, null)
}
+ @Test
void testBothSame() {
def mock = createStrictMock(EventListener)
assertEquals 0, comparator.compare(mock, mock)
}
+ @Test
void testBothEventListener() {
def a = createStrictMock(EventListener)
def b = createStrictMock(EventListener)
assertEquals 0, comparator.compare(a, b)
}
+ @Test
void testATypedListenerBNormalListener() {
def a = createStrictMock(TypedEventListener)
def b = createStrictMock(EventListener)
assertEquals(-1, comparator.compare(a, b))
}
+ @Test
void testANormalBTypedListener() {
def a = createStrictMock(EventListener)
def b = createStrictMock(TypedEventListener)
diff --git a/support/cas/src/test/groovy/org/apache/shiro/cas/CasRealmTest.groovy b/support/cas/src/test/groovy/org/apache/shiro/cas/CasRealmTest.groovy
index baf2a57..b917638 100644
--- a/support/cas/src/test/groovy/org/apache/shiro/cas/CasRealmTest.groovy
+++ b/support/cas/src/test/groovy/org/apache/shiro/cas/CasRealmTest.groovy
@@ -21,6 +21,10 @@ package org.apache.shiro.cas
import org.apache.shiro.authc.AuthenticationInfo
import org.apache.shiro.authz.AuthorizationInfo
+import org.junit.Test
+
+import static org.junit.Assert.*
+
/**
* Unit tests for the {@link CasRealm} implementation.
*
@@ -29,7 +33,7 @@ import org.apache.shiro.authz.AuthorizationInfo
* @deprecated replaced with Shiro integration in <a href="https://github.com/bujiio/buji-pac4j">buji-pac4j</a>.
*/
@Deprecated
-class CasRealmTest extends GroovyTestCase {
+class CasRealmTest {
/**
* Creates a CAS realm with a ticket validator mock.
@@ -40,6 +44,7 @@ class CasRealmTest extends GroovyTestCase {
new CasRealm(ticketValidator: new MockServiceTicketValidator());
}
+ @Test
void testNoAttribute() {
CasRealm casRealm = createCasRealm();
CasToken casToken = new CasToken('$=defaultId');
@@ -53,6 +58,7 @@ class CasRealmTest extends GroovyTestCase {
assertNull authorizationInfo.roles
}
+ @Test
void testNoAttributeDefaultRoleAndPermission() {
CasRealm casRealm = createCasRealm();
casRealm.defaultRoles = "defaultRole"
@@ -68,6 +74,7 @@ class CasRealmTest extends GroovyTestCase {
assertTrue authorizationInfo.stringPermissions.contains("defaultPermission")
}
+ @Test
void testNoAttributeDefaultRolesAndPermissions() {
CasRealm casRealm = createCasRealm();
casRealm.defaultRoles = "defaultRole1, defaultRole2"
@@ -87,6 +94,7 @@ class CasRealmTest extends GroovyTestCase {
assertTrue authzInfo.stringPermissions.contains("defaultPermission2")
}
+ @Test
void testRoleAndPermission() {
CasRealm casRealm = createCasRealm();
casRealm.roleAttributeNames = "role"
@@ -104,6 +112,7 @@ class CasRealmTest extends GroovyTestCase {
assertTrue authzInfo.stringPermissions.contains("aPermission")
}
+ @Test
void testRolesAndPermissions() {
CasRealm casRealm = createCasRealm();
casRealm.setRoleAttributeNames("role1 , role2");
@@ -130,6 +139,7 @@ class CasRealmTest extends GroovyTestCase {
assertTrue authzInfo.stringPermissions.contains("permission22")
}
+ @Test
void testNotRememberMe() {
CasRealm casRealm = createCasRealm();
CasToken casToken = new CasToken("\$=defaultId|$CasRealm.DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME=false");
@@ -144,6 +154,7 @@ class CasRealmTest extends GroovyTestCase {
assertNull authzInfo.roles
}
+ @Test
void testRememberMe() {
CasRealm casRealm = createCasRealm();
CasToken casToken = new CasToken("\$=defaultId|$CasRealm.DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME=true");
@@ -158,6 +169,7 @@ class CasRealmTest extends GroovyTestCase {
assertNull authzInfo.roles
}
+ @Test
void testRememberMeNewAttributeName() {
CasRealm casRealm = createCasRealm();
casRealm.rememberMeAttributeName = "rme"
diff --git a/support/cas/src/test/groovy/org/apache/shiro/cas/CasTokenTest.groovy b/support/cas/src/test/groovy/org/apache/shiro/cas/CasTokenTest.groovy
index ae86eee..471111e 100644
--- a/support/cas/src/test/groovy/org/apache/shiro/cas/CasTokenTest.groovy
+++ b/support/cas/src/test/groovy/org/apache/shiro/cas/CasTokenTest.groovy
@@ -18,6 +18,10 @@
*/
package org.apache.shiro.cas
+import org.junit.Test
+
+import static org.junit.Assert.*
+
/**
* Unit tests for the {@link CasToken} implementation.
*
@@ -26,8 +30,9 @@ package org.apache.shiro.cas
* @deprecated replaced with Shiro integration in <a href="https://github.com/bujiio/buji-pac4j">buji-pac4j</a>.
*/
@Deprecated
-class CasTokenTest extends GroovyTestCase {
+class CasTokenTest {
+ @Test
void testPrincipal() {
CasToken casToken = new CasToken("fakeTicket")
assertNull casToken.principal
@@ -35,11 +40,13 @@ class CasTokenTest extends GroovyTestCase {
assertEquals "myUserId", casToken.principal
}
+ @Test
void testCredentials() {
CasToken casToken = new CasToken("fakeTicket")
assertEquals "fakeTicket", casToken.credentials
}
+ @Test
void testRememberMe() {
CasToken casToken = new CasToken("fakeTicket")
assertFalse casToken.rememberMe
diff --git a/web/src/test/groovy/org/apache/shiro/web/config/IniFilterChainResolverFactoryTest.groovy b/web/src/test/groovy/org/apache/shiro/web/config/IniFilterChainResolverFactoryTest.groovy
index 24653bc..6a4e276 100644
--- a/web/src/test/groovy/org/apache/shiro/web/config/IniFilterChainResolverFactoryTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/config/IniFilterChainResolverFactoryTest.groovy
@@ -25,14 +25,18 @@ import org.apache.shiro.config.Ini
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter
import org.apache.shiro.web.filter.authz.SslFilter
import org.apache.shiro.web.filter.mgt.FilterChainResolver
+import org.junit.Before
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link IniFilterChainResolverFactory} implementation.
*
* @since 1.2
*/
-class IniFilterChainResolverFactoryTest extends GroovyTestCase {
+class IniFilterChainResolverFactoryTest {
private IniFilterChainResolverFactory factory;
@@ -43,20 +47,24 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
return mock
}
+ @Before
void setUp() {
this.factory = new IniFilterChainResolverFactory()
}
+ @Test
void testNewInstance() {
assertNull factory.filterConfig
factory.filterConfig = null
assertNull factory.filterConfig
}
+ @Test
void testGetInstanceNoIni() {
assertNotNull factory.getInstance()
}
+ @Test
void testNewInstanceWithIni() {
Ini ini = new Ini()
ini.load("""
@@ -68,16 +76,19 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
assertNotNull resolver
}
+ @Test
void testGetFiltersWithNullOrEmptySection() {
Map<String, Filter> filters = factory.getFilters(null, null);
assertNull(filters);
}
+ @Test
void testCreateChainsWithNullUrlsSection() {
//should do nothing (return immediately, no exceptions):
factory.createChains(null, null);
}
+ @Test
void testNewInstanceWithNonFilter() {
Ini ini = new Ini()
ini.load("""
@@ -91,6 +102,7 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
assertNotNull factory.getInstance()
}
+ @Test
void testNewInstanceWithFilterConfig() {
Ini ini = new Ini()
ini.load("""
@@ -111,12 +123,14 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
}
//asserts SHIRO-306
+ @Test
void testGetFilters() {
def extractedFilters = factory.getFilters(null, null)
assertNull extractedFilters
}
//asserts SHIRO-306
+ @Test
void testGetFiltersWithoutSectionWithDefaults() {
def factory = new IniFilterChainResolverFactory()
@@ -130,6 +144,7 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
}
//asserts SHIRO-306
+ @Test
void testGetFiltersWithSectionWithoutDefaults() {
def factory = new IniFilterChainResolverFactory()
@@ -143,6 +158,7 @@ class IniFilterChainResolverFactoryTest extends GroovyTestCase {
}
//asserts SHIRO-306
+ @Test
void testGetFiltersWithSectionAndDefaults() {
def factory = new IniFilterChainResolverFactory()
diff --git a/web/src/test/groovy/org/apache/shiro/web/filter/mgt/DefaultFilterChainManagerTest.groovy b/web/src/test/groovy/org/apache/shiro/web/filter/mgt/DefaultFilterChainManagerTest.groovy
index 03fd12f..364300b 100644
--- a/web/src/test/groovy/org/apache/shiro/web/filter/mgt/DefaultFilterChainManagerTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/filter/mgt/DefaultFilterChainManagerTest.groovy
@@ -26,21 +26,26 @@ import javax.servlet.Filter
import javax.servlet.FilterChain
import javax.servlet.FilterConfig
import javax.servlet.ServletContext
+import org.junit.Before
+import org.junit.Test
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link DefaultFilterChainManager} implementation.
*/
-class DefaultFilterChainManagerTest extends GroovyTestCase {
+class DefaultFilterChainManagerTest {
DefaultFilterChainManager manager;
+ @Before
void setUp() {
this.manager = new DefaultFilterChainManager();
}
//SHIRO-205
+ @Test
void testToNameConfigPairNoBrackets() {
def token = "foo"
@@ -53,6 +58,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
//SHIRO-205
+ @Test
void testToNameConfigPairWithEmptyBrackets() {
def token = "foo[]"
@@ -65,6 +71,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
//SHIRO-205
+ @Test
void testToNameConfigPairWithPopulatedBrackets() {
def token = "foo[bar, baz]"
@@ -77,6 +84,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
//SHIRO-205 - asserts backwards compatibility before SHIRO-205 was implemented:
+ @Test
void testToNameConfigPairWithNestedQuotesInBrackets() {
def token = 'roles["guest, admin"]'
@@ -90,6 +98,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
//SHIRO-205 - asserts backwards compatibility before SHIRO-205 was implemented:
//@since 1.2.2
+ @Test
void testToNameConfigPairWithIndividualNestedQuotesInBrackets() {
def token = 'roles["guest", "admin"]'
@@ -102,6 +111,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
//SHIRO-205
+ @Test
void testFilterChainConfigWithNestedCommas() {
def chain = "a, b[c], d[e, f], g[h, i, j], k"
@@ -117,6 +127,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
//SHIRO-205
+ @Test
void testFilterChainConfigWithNestedQuotedCommas() {
def chain = "a, b[c], d[e, f], g[h, i, j], k"
@@ -131,6 +142,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
assertEquals "k", tokens[4]
}
+ @Test
void testNewInstanceDefaultFilters() {
for (DefaultFilter defaultFilter : DefaultFilter.values()) {
assertNotNull(manager.getFilter(defaultFilter.name()));
@@ -145,6 +157,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
return mock;
}
+ @Test
void testNewInstanceWithFilterConfig() {
FilterConfig mock = createNiceMockFilterConfig();
replay(mock);
@@ -156,6 +169,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
verify(mock);
}
+ @Test
void testCreateChain() {
try {
manager.createChain(null, null);
@@ -200,6 +214,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
* Helps assert <a href="https://issues.apache.org/jira/browse/SHIRO-429">SHIRO-429</a>
* @since 1.2.2
*/
+ @Test
void testCreateChainWithQuotedInstanceConfig() {
manager.createChain("test", 'authc, perms["perm1", "perm2"]');
@@ -228,12 +243,14 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
assertEquals(DefaultFilter.perms.getFilterClass(), filter.getClass());
}
+ @Test
void testBeanMethods() {
Map<String, Filter> filters = manager.getFilters();
assertEquals(filters.size(), DefaultFilter.values().length);
manager.setFilters(filters);
}
+ @Test
void testAddFilter() {
FilterConfig mockFilterConfig = createNiceMockFilterConfig();
replay(mockFilterConfig);
@@ -245,6 +262,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
verify(mockFilterConfig);
}
+ @Test
void testAddFilterNoInit() {
FilterConfig mockFilterConfig = createNiceMockFilterConfig();
Filter mockFilter = createNiceMock(Filter.class);
@@ -261,6 +279,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
verify mockFilterConfig, mockFilter
}
+ @Test
void testAddFilterNoFilterConfig() {
SslFilter filter = new SslFilter();
manager.addFilter("test", filter);
@@ -268,6 +287,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
assertSame manager.filters['test'], filter
}
+ @Test
void testAddToChain() {
FilterConfig mockFilterConfig = createNiceMockFilterConfig();
replay(mockFilterConfig);
@@ -288,6 +308,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
}
+ @Test
void testAddToChainNotPathProcessor() {
FilterConfig mockFilterConfig = createNiceMockFilterConfig();
replay(mockFilterConfig);
@@ -303,6 +324,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
}
}
+ @Test
void testProxy() {
FilterChain mock = createNiceMock(FilterChain.class);
replay(mock);
@@ -311,6 +333,7 @@ class DefaultFilterChainManagerTest extends GroovyTestCase {
verify(mock);
}
+ @Test
void testProxyNoChain() {
FilterChain mock = createNiceMock(FilterChain.class);
replay(mock);
diff --git a/web/src/test/groovy/org/apache/shiro/web/filter/session/NoSessionCreationFilterTest.groovy b/web/src/test/groovy/org/apache/shiro/web/filter/session/NoSessionCreationFilterTest.groovy
index 3611b29..1b2556a 100644
--- a/web/src/test/groovy/org/apache/shiro/web/filter/session/NoSessionCreationFilterTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/filter/session/NoSessionCreationFilterTest.groovy
@@ -21,15 +21,19 @@ package org.apache.shiro.web.filter.session
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import org.apache.shiro.subject.support.DefaultSubjectContext
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link NoSessionCreationFilter} implementation.
*
* @since 1.2
*/
-class NoSessionCreationFilterTest extends GroovyTestCase {
+class NoSessionCreationFilterTest {
+ @Test
void testDefault() {
NoSessionCreationFilter filter = new NoSessionCreationFilter();
diff --git a/web/src/test/groovy/org/apache/shiro/web/mgt/DefaultWebSessionStorageEvaluatorTest.groovy b/web/src/test/groovy/org/apache/shiro/web/mgt/DefaultWebSessionStorageEvaluatorTest.groovy
index 2a86030..406841e 100644
--- a/web/src/test/groovy/org/apache/shiro/web/mgt/DefaultWebSessionStorageEvaluatorTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/mgt/DefaultWebSessionStorageEvaluatorTest.groovy
@@ -25,15 +25,19 @@ import org.apache.shiro.subject.Subject
import org.apache.shiro.subject.support.DefaultSubjectContext
import org.apache.shiro.web.subject.WebSubject
import org.apache.shiro.web.util.RequestPairSource
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link DefaultWebSessionStorageEvaluator} implementation.
*
* @since 1.2
*/
-class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
+class DefaultWebSessionStorageEvaluatorTest {
+ @Test
void testWithSession() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
@@ -50,6 +54,7 @@ class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
verify subject, session
}
+ @Test
void testWithoutSessionAndNonWebSubject() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
@@ -65,6 +70,7 @@ class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
verify subject
}
+ @Test
void testWithoutSessionAndGenerallyDisabled() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
@@ -81,6 +87,7 @@ class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
verify subject
}
+ @Test
void testWebSubjectWithoutSessionAndGenerallyEnabled() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
@@ -100,6 +107,7 @@ class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
verify subject, request, response
}
+ @Test
void testWebSubjectWithoutSessionAndGenerallyEnabledButRequestDisabled() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
@@ -119,6 +127,7 @@ class DefaultWebSessionStorageEvaluatorTest extends GroovyTestCase {
verify subject, request, response
}
+ @Test
void testWebSubjectWithoutSessionAndGenerallyEnabledWithNonBooleanRequestAttribute() {
DefaultWebSessionStorageEvaluator evaluator = new DefaultWebSessionStorageEvaluator()
diff --git a/web/src/test/groovy/org/apache/shiro/web/servlet/AbstractShiroFilterTest.groovy b/web/src/test/groovy/org/apache/shiro/web/servlet/AbstractShiroFilterTest.groovy
index 876d1c3..c339f6e 100644
--- a/web/src/test/groovy/org/apache/shiro/web/servlet/AbstractShiroFilterTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/servlet/AbstractShiroFilterTest.groovy
@@ -23,13 +23,17 @@ import javax.servlet.ServletContext
import org.apache.shiro.SecurityUtils
import org.apache.shiro.UnavailableSecurityManagerException
import org.apache.shiro.web.mgt.WebSecurityManager
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link AbstractShiroFilter} implementation.
*/
-class AbstractShiroFilterTest extends GroovyTestCase {
+class AbstractShiroFilterTest {
+ @Test
void testInit() {
SecurityUtils.securityManager = null
@@ -57,6 +61,7 @@ class AbstractShiroFilterTest extends GroovyTestCase {
verify securityManager, filterConfig, servletContext
}
+ @Test
void testInitWithStaticReference() {
SecurityUtils.securityManager = null
diff --git a/web/src/test/groovy/org/apache/shiro/web/servlet/IniShiroFilterTest.groovy b/web/src/test/groovy/org/apache/shiro/web/servlet/IniShiroFilterTest.groovy
index c039ec0..10d3dd1 100644
--- a/web/src/test/groovy/org/apache/shiro/web/servlet/IniShiroFilterTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/servlet/IniShiroFilterTest.groovy
@@ -22,13 +22,17 @@ import javax.servlet.FilterConfig
import javax.servlet.ServletContext
import javax.servlet.ServletException
import org.apache.shiro.io.ResourceUtils
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link IniShiroFilter} implementation.
*/
-class IniShiroFilterTest extends GroovyTestCase {
+class IniShiroFilterTest {
+ @Test
void testDefaultWebInfConfig() {
def filterConfig = createMock(FilterConfig)
def servletContext = createStrictMock(ServletContext)
@@ -50,6 +54,7 @@ class IniShiroFilterTest extends GroovyTestCase {
verify filterConfig, servletContext
}
+ @Test
void testResourceConfig() {
def filterConfig = createMock(FilterConfig)
def servletContext = createStrictMock(ServletContext)
@@ -67,6 +72,7 @@ class IniShiroFilterTest extends GroovyTestCase {
verify filterConfig, servletContext
}
+ @Test
void testResourceConfigWithoutResource() {
def filterConfig = createMock(FilterConfig)
def servletContext = createStrictMock(ServletContext)
@@ -90,6 +96,7 @@ class IniShiroFilterTest extends GroovyTestCase {
verify filterConfig, servletContext
}
+ @Test
void testDefaultClasspathConfig() {
def filterConfig = createStrictMock(FilterConfig)
@@ -109,7 +116,7 @@ class IniShiroFilterTest extends GroovyTestCase {
verify filterConfig, servletContext
}
-
+ @Test
void testSimpleConfig() {
def config = """
[filters]
diff --git a/web/src/test/groovy/org/apache/shiro/web/servlet/ShiroFilterTest.groovy b/web/src/test/groovy/org/apache/shiro/web/servlet/ShiroFilterTest.groovy
index c9922a7..4b04e17 100644
--- a/web/src/test/groovy/org/apache/shiro/web/servlet/ShiroFilterTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/servlet/ShiroFilterTest.groovy
@@ -24,13 +24,17 @@ import org.apache.shiro.web.env.EnvironmentLoader
import org.apache.shiro.web.env.WebEnvironment
import org.apache.shiro.web.filter.mgt.FilterChainResolver
import org.apache.shiro.web.mgt.WebSecurityManager
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for {@link ShiroFilter}.
*/
-class ShiroFilterTest extends GroovyTestCase {
+class ShiroFilterTest {
+ @Test
void testInit() {
def filterConfig = createStrictMock(FilterConfig)
diff --git a/web/src/test/groovy/org/apache/shiro/web/session/mgt/ServletContainerSessionManagerTest.groovy b/web/src/test/groovy/org/apache/shiro/web/session/mgt/ServletContainerSessionManagerTest.groovy
index dccb4c7..04ec6ef 100644
--- a/web/src/test/groovy/org/apache/shiro/web/session/mgt/ServletContainerSessionManagerTest.groovy
+++ b/web/src/test/groovy/org/apache/shiro/web/session/mgt/ServletContainerSessionManagerTest.groovy
@@ -24,13 +24,17 @@ import javax.servlet.http.HttpSession
import org.apache.shiro.session.mgt.SessionContext
import org.apache.shiro.session.mgt.SessionKey
import org.apache.shiro.web.session.HttpServletSession
+import org.junit.Test
+
import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
/**
* Unit tests for the {@link ServletContainerSessionManager} implementation.
*/
-class ServletContainerSessionManagerTest extends GroovyTestCase {
+class ServletContainerSessionManagerTest {
+ @Test
void testStartWithNonWebSessionContext() {
def sessionContext = createStrictMock(SessionContext)
@@ -47,6 +51,7 @@ class ServletContainerSessionManagerTest extends GroovyTestCase {
verify sessionContext
}
+ @Test
void testStartWithContextHostValue() {
def host = "host.somecompany.com"
@@ -76,6 +81,7 @@ class ServletContainerSessionManagerTest extends GroovyTestCase {
verify request, response, httpSession
}
+ @Test
void testStartWithoutContextHostValue() {
def host = "host.somecompany.com"
@@ -105,6 +111,7 @@ class ServletContainerSessionManagerTest extends GroovyTestCase {
verify request, response, httpSession
}
+ @Test
void testGetSessionWithNonWebSessionKey() {
def key = createStrictMock(SessionKey)
@@ -121,6 +128,7 @@ class ServletContainerSessionManagerTest extends GroovyTestCase {
verify key
}
+ @Test
void testGetSessionWithExistingRequestSession() {
String host = "www.company.com"
@@ -148,6 +156,7 @@ class ServletContainerSessionManagerTest extends GroovyTestCase {
verify request, response, httpSession
}
+ @Test
void testGetSessionWithoutExistingRequestSession() {
def request = createStrictMock(HttpServletRequest)