You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bm...@apache.org on 2023/06/22 20:13:57 UTC

[shiro] branch #947_junit-jupiter updated: [#947] rewrite spring tests to Junit-Jupiter

This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch #947_junit-jupiter
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/#947_junit-jupiter by this push:
     new ddffd602b [#947] rewrite spring tests to Junit-Jupiter
ddffd602b is described below

commit ddffd602bc37e1b57c42e3057b24ac03c421cf0a
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Thu Jun 22 22:13:45 2023 +0200

    [#947] rewrite spring tests to Junit-Jupiter
---
 .../config/ShiroBeanConfigurationTest.groovy       |   6 +-
 .../spring/config/ShiroConfigurationTest.groovy    |   9 +-
 ...oConfigurationWithOptionalComponentsTest.groovy |   5 +-
 .../ShiroEventBusAwareBeanPostProcessorTest.groovy |  10 +-
 .../spring/config/ShiroWebConfigurationTest.groovy |   9 +-
 .../config/ShiroWebFilterConfigurationTest.groovy  |   3 +
 .../web/config/ShiroWebConfigurationTest.groovy    |   6 +-
 .../ShiroWebConfigurationWithCacheTest.groovy      |  18 +--
 .../AbstractAuthorizationAnnotationTest.java       | 138 ++++++++++-----------
 .../DapcAuthorizationAnnotationTest.java           |  64 +++++-----
 .../SchemaAuthorizationAnnotationTest.java         |   5 +-
 11 files changed, 144 insertions(+), 129 deletions(-)

diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroBeanConfigurationTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroBeanConfigurationTest.groovy
index 84047df76..cd21cf140 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroBeanConfigurationTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroBeanConfigurationTest.groovy
@@ -21,10 +21,10 @@ package org.apache.shiro.spring.config
 import org.apache.shiro.event.EventBus
 import org.apache.shiro.spring.testconfig.EventBusConsumersTestConfiguration
 import org.junit.jupiter.api.Test
-import org.junit.runner.RunWith
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+import org.springframework.test.context.junit.jupiter.SpringExtension
 
 import static org.junit.jupiter.api.Assertions.*
 
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.*
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [ShiroBeanConfiguration, EventBusConsumersTestConfiguration])
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
 public class ShiroBeanConfigurationTest {
 
     @Autowired
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationTest.groovy
index 57810c95c..2137df7c7 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationTest.groovy
@@ -24,13 +24,13 @@ import org.apache.shiro.event.EventBus
 import org.apache.shiro.mgt.DefaultSecurityManager
 import org.apache.shiro.mgt.SecurityManager
 import org.apache.shiro.realm.text.TextConfigurationRealm
-import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
 import org.apache.shiro.spring.testconfig.RealmTestConfiguration
 import org.apache.shiro.subject.Subject
-import org.junit.Assert
 import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit.jupiter.SpringExtension
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
 
 import static org.hamcrest.MatcherAssert.assertThat
@@ -41,7 +41,8 @@ import static org.junit.jupiter.api.Assertions.*
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [RealmTestConfiguration, ShiroConfiguration])
-public class ShiroConfigurationTest extends AbstractJUnit4SpringContextTests {
+@ExtendWith(SpringExtension.class)
+class ShiroConfigurationTest extends AbstractJUnit4SpringContextTests {
 
     @Autowired
     private SecurityManager securityManager
@@ -50,7 +51,7 @@ public class ShiroConfigurationTest extends AbstractJUnit4SpringContextTests {
     private EventBus eventBus;
 
     @Test
-    public void testMinimalConfiguration() {
+    void testMinimalConfiguration() {
 
         // first do a quick check of the injected objects
         assertNotNull securityManager
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationWithOptionalComponentsTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationWithOptionalComponentsTest.groovy
index 31cb62c64..c242d2be1 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationWithOptionalComponentsTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroConfigurationWithOptionalComponentsTest.groovy
@@ -28,8 +28,10 @@ import org.apache.shiro.spring.testconfig.RealmTestConfiguration
 import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
 import org.apache.shiro.subject.Subject
 import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit.jupiter.SpringExtension
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
 
 import static org.junit.jupiter.api.Assertions.*
@@ -40,7 +42,8 @@ import static org.hamcrest.MatcherAssert.*
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [RealmTestConfiguration, OptionalComponentsTestConfiguration, ShiroConfiguration, ShiroAnnotationProcessorConfiguration])
-public class ShiroConfigurationWithOptionalComponentsTest extends AbstractJUnit4SpringContextTests {
+@ExtendWith(SpringExtension.class)
+class ShiroConfigurationWithOptionalComponentsTest extends AbstractJUnit4SpringContextTests {
 
     @Autowired
     private SecurityManager securityManager
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroEventBusAwareBeanPostProcessorTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroEventBusAwareBeanPostProcessorTest.groovy
index 6f98cfe3c..c2f32870c 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroEventBusAwareBeanPostProcessorTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroEventBusAwareBeanPostProcessorTest.groovy
@@ -21,9 +21,9 @@ package org.apache.shiro.spring.config
 import org.apache.shiro.event.EventBus
 import org.apache.shiro.event.EventBusAware
 import org.apache.shiro.spring.ShiroEventBusBeanPostProcessor
-import org.junit.Assert
 import org.junit.jupiter.api.Test
 
+import static org.junit.jupiter.api.Assertions.*
 import static org.mockito.Mockito.mock
 
 /**
@@ -41,8 +41,8 @@ class ShiroEventBusAwareBeanPostProcessorTest {
         def resultAfter = postProcessor.postProcessAfterInitialization(bean, "bean")
         def resultBefore = postProcessor.postProcessBeforeInitialization(bean, "bean")
 
-        Assert.assertSame resultAfter, bean
-        Assert.assertSame resultBefore, bean
+        assertSame resultAfter, bean
+        assertSame resultBefore, bean
     }
 
     @Test
@@ -56,8 +56,8 @@ class ShiroEventBusAwareBeanPostProcessorTest {
         def resultAfter = postProcessor.postProcessAfterInitialization(bean, "bean")
         def resultBefore = postProcessor.postProcessBeforeInitialization(bean, "bean")
 
-        Assert.assertSame resultAfter, bean
-        Assert.assertSame resultBefore, bean
+        assertSame resultAfter, bean
+        assertSame resultBefore, bean
     }
 
 }
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebConfigurationTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebConfigurationTest.groovy
index 0cb4509ea..3382b0e03 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebConfigurationTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebConfigurationTest.groovy
@@ -30,10 +30,13 @@ import org.apache.shiro.spring.web.config.ShiroWebConfiguration
 import org.apache.shiro.spring.web.config.ShiroWebFilterConfiguration
 import org.apache.shiro.subject.Subject
 import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit.jupiter.SpringExtension
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
 
+import static org.hamcrest.MatcherAssert.assertThat
 import static org.hamcrest.Matchers.*
 import static org.junit.jupiter.api.Assertions.*
 
@@ -41,7 +44,8 @@ import static org.junit.jupiter.api.Assertions.*
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [RealmTestConfiguration, ShiroConfiguration, ShiroWebConfiguration, ShiroWebFilterConfiguration])
-public class ShiroWebConfigurationTest extends AbstractJUnit4SpringContextTests {
+@ExtendWith(SpringExtension.class)
+class ShiroWebConfigurationTest extends AbstractJUnit4SpringContextTests {
 
     @Autowired
     private SecurityManager securityManager
@@ -57,7 +61,8 @@ public class ShiroWebConfigurationTest extends AbstractJUnit4SpringContextTests
 
         // first do a quick check of the injected objects
         assertNotNull securityManager
-        assertThat securityManager.realms, allOf(hasSize(1), hasItem(instanceOf(TextConfigurationRealm)))
+        assertThat securityManager.realms, hasSize(1)
+        assertThat securityManager.realms, hasItem(instanceOf(TextConfigurationRealm))
         assertNull securityManager.cacheManager
 
         assertNotNull shiroFilterFactoryBean
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebFilterConfigurationTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebFilterConfigurationTest.groovy
index aa0528089..5c6ee9f50 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebFilterConfigurationTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/config/ShiroWebFilterConfigurationTest.groovy
@@ -27,10 +27,12 @@ import org.apache.shiro.spring.web.config.ShiroWebFilterConfiguration
 import org.apache.shiro.web.filter.InvalidRequestFilter
 import org.apache.shiro.web.filter.mgt.FilterChainManager
 import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
 import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit.jupiter.SpringExtension
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
 import org.springframework.test.context.web.WebAppConfiguration
 
@@ -51,6 +53,7 @@ import static org.hamcrest.MatcherAssert.assertThat
  */
 @WebAppConfiguration
 @ContextConfiguration(classes = [RealmTestConfiguration, FilterConfiguration, ShiroConfiguration, ShiroWebFilterConfiguration])
+@ExtendWith(SpringExtension.class)
 class ShiroWebFilterConfigurationTest extends AbstractJUnit4SpringContextTests {
 
     @Autowired
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationTest.groovy
index 5cecff591..d5565fb02 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationTest.groovy
@@ -28,8 +28,8 @@ import org.apache.shiro.web.mgt.WebSecurityManager
 import org.apache.shiro.web.servlet.Cookie
 import org.junit.jupiter.api.Test
 import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.extension.ExtendWith
 import org.junit.jupiter.api.function.Executable
-import org.junit.runner.RunWith
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
@@ -38,7 +38,7 @@ import org.springframework.expression.Expression
 import org.springframework.expression.ExpressionParser
 import org.springframework.expression.spel.standard.SpelExpressionParser
 import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+import org.springframework.test.context.junit.jupiter.SpringExtension
 
 import static org.hamcrest.MatcherAssert.assertThat
 import static org.hamcrest.Matchers.*
@@ -48,7 +48,7 @@ import static org.junit.jupiter.api.Assertions.*
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [EventBusTestConfiguration, RealmTestConfiguration, ShiroWebConfiguration])
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
 public class ShiroWebConfigurationTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(ShiroWebConfigurationTest.class)
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationWithCacheTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationWithCacheTest.groovy
index d7368125f..72d86cd6e 100644
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationWithCacheTest.groovy
+++ b/support/spring/src/test/groovy/org/apache/shiro/spring/web/config/ShiroWebConfigurationWithCacheTest.groovy
@@ -23,22 +23,23 @@ import org.apache.shiro.realm.text.TextConfigurationRealm
 import org.apache.shiro.spring.testconfig.EventBusTestConfiguration
 import org.apache.shiro.spring.testconfig.RealmTestConfiguration
 import org.apache.shiro.spring.web.testconfig.CacheManagerConfiguration
-import org.junit.Assert
+import org.junit.jupiter.api.Assertions
 import org.junit.jupiter.api.Test
-import org.junit.runner.RunWith
+import org.junit.jupiter.api.extension.ExtendWith
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+import org.springframework.test.context.junit.jupiter.SpringExtension
 
 import static org.hamcrest.MatcherAssert.assertThat
 import static org.hamcrest.Matchers.*
+import static org.junit.jupiter.api.Assertions.assertNotNull
 
 /**
  * @since 1.4.0
  */
 @ContextConfiguration(classes = [EventBusTestConfiguration, RealmTestConfiguration, CacheManagerConfiguration, ShiroWebConfiguration])
-@RunWith(SpringJUnit4ClassRunner.class)
-public class ShiroWebConfigurationWithCacheTest {
+@ExtendWith(SpringExtension.class)
+class ShiroWebConfigurationWithCacheTest {
 
     @Autowired
     private SecurityManager securityManager
@@ -47,9 +48,10 @@ public class ShiroWebConfigurationWithCacheTest {
     public void testMinimalConfiguration() {
 
         // first do a quick check of the injected objects
-        Assert.assertNotNull securityManager
-        assertThat securityManager.realms, allOf(hasSize(1), hasItem(instanceOf(TextConfigurationRealm)))
-        Assert.assertNotNull securityManager.cacheManager
+        assertNotNull securityManager
+        assertThat securityManager.realms, hasSize(1)
+        assertThat securityManager.realms, hasItem(instanceOf(TextConfigurationRealm))
+        assertNotNull securityManager.cacheManager
     }
 
 }
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 5e54cfb37..a1f93ce6f 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
@@ -24,16 +24,16 @@ import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.SimplePrincipalCollection;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.subject.support.SubjectThreadState;
-import org.apache.shiro.util.ThreadState;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
+import org.apache.shiro.util.ThreadState;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /**
  * Common method tests across implementations.  In actuality, the methods don't change across
  * subclasses - only the mechanism that enables AOP pointcuts and applies advice.  Those differences
@@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
  *
  * @since 1.1
  */
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
 @ContextConfiguration
 public abstract class AbstractAuthorizationAnnotationTest {
 
@@ -80,81 +80,81 @@ public abstract class AbstractAuthorizationAnnotationTest {
         PrincipalCollection principals = new SimplePrincipalCollection("test", realm.getName());
         bind(new Subject.Builder(securityManager).
                 principals(principals).authenticated(true).buildSubject());
-    }
-
-    // GUEST OPERATIONS:
-
-    @Test
+    }
+
+    // GUEST OPERATIONS:
+
+    @Test
     void testGuestImplementation() {
         bindGuest();
         testService.guestImplementation();
-    }
-
-    @Test
-    void testGuestImplementationFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindUser();
-            testService.guestImplementation();
-        });
-    }
-
-    @Test
+    }
+
+    @Test
+    void testGuestImplementationFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindUser();
+            testService.guestImplementation();
+        });
+    }
+
+    @Test
     void testGuestInterface() {
         bindGuest();
         testService.guestInterface();
-    }
-
-    //testGuestInterfaceFailure() cannot be in this class - the SchemaAuthorizationAnnotationTest
-    //subclass does not support annotations on interfaces (Spring AspectJ pointcut expressions
-    //do not support annotations on interface methods).  It is instead in the
-    //DapcAuthorizationAnnotationTest subclass
-
-
-    // USER OPERATIONS
-
-    @Test
+    }
+
+    //testGuestInterfaceFailure() cannot be in this class - the SchemaAuthorizationAnnotationTest
+    //subclass does not support annotations on interfaces (Spring AspectJ pointcut expressions
+    //do not support annotations on interface methods).  It is instead in the
+    //DapcAuthorizationAnnotationTest subclass
+
+
+    // USER OPERATIONS
+
+    @Test
     void testUserImplementation() {
         bindUser();
         testService.userImplementation();
-    }
-
-    @Test
-    void testUserImplementationFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindGuest();
-            testService.userImplementation();
-        });
-    }
-
-    @Test
+    }
+
+    @Test
+    void testUserImplementationFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindGuest();
+            testService.userImplementation();
+        });
+    }
+
+    @Test
     void testUserInterface() {
         bindUser();
         testService.userInterface();
-    }
-
-    //testUserInterfaceFailure() cannot be in this class - the SchemaAuthorizationAnnotationTest
-    //subclass does not support annotations on interfaces (Spring AspectJ pointcut expressions
-    //do not support annotations on interface methods).  It is instead in the
-    //DapcAuthorizationAnnotationTest subclass
-
-
-    // AUTHENTICATED USER OPERATIONS
-
-    @Test
+    }
+
+    //testUserInterfaceFailure() cannot be in this class - the SchemaAuthorizationAnnotationTest
+    //subclass does not support annotations on interfaces (Spring AspectJ pointcut expressions
+    //do not support annotations on interface methods).  It is instead in the
+    //DapcAuthorizationAnnotationTest subclass
+
+
+    // AUTHENTICATED USER OPERATIONS
+
+    @Test
     void testAuthenticatedImplementation() {
         bindAuthenticatedUser();
         testService.authenticatedImplementation();
-    }
-
-    @Test
-    void testAuthenticatedImplementationFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindUser();
-            testService.authenticatedImplementation();
-        });
-    }
-
-    @Test
+    }
+
+    @Test
+    void testAuthenticatedImplementationFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindUser();
+            testService.authenticatedImplementation();
+        });
+    }
+
+    @Test
     void testAuthenticatedInterface() {
         bindAuthenticatedUser();
         testService.authenticatedInterface();
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 e362299db..115721016 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
@@ -18,14 +18,14 @@
  */
 package org.apache.shiro.spring.security.interceptor;
 
-import org.apache.shiro.authz.UnauthenticatedException;
-import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
+import org.apache.shiro.authz.UnauthenticatedException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+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
  * DefaultAutoProxyCreator Spring AOP environment exists and enables annotations correctly as
@@ -35,31 +35,31 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
  *
  * @since 1.1
  */
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
 @ContextConfiguration
-public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
-
-    @Test
-    void testGuestInterfaceFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindUser();
-            testService.guestInterface();
-        });
-    }
-
-    @Test
-    void testUserInterfaceFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindGuest();
-            testService.userInterface();
-        });
-    }
-
-    @Test
-    void testAuthenticatedInterfaceFailure() {
-        assertThrows(UnauthenticatedException.class, () -> {
-            bindGuest();
-            testService.authenticatedInterface();
-        });
+public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
+
+    @Test
+    void testGuestInterfaceFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindUser();
+            testService.guestInterface();
+        });
+    }
+
+    @Test
+    void testUserInterfaceFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindGuest();
+            testService.userInterface();
+        });
+    }
+
+    @Test
+    void testAuthenticatedInterfaceFailure() {
+        assertThrows(UnauthenticatedException.class, () -> {
+            bindGuest();
+            testService.authenticatedInterface();
+        });
     }
 }
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
index 27de3067a..2ff8f324e 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
@@ -18,8 +18,9 @@
  */
 package org.apache.shiro.spring.security.interceptor;
 
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 /**
@@ -31,7 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  *
  * @since 1.1
  */
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
 @ContextConfiguration
 public class SchemaAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
 }