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

bdemers pushed a commit to branch aop-1-10-x
in repository https://gitbox.apache.org/repos/asf/shiro.git

commit f33bdd1673d95b496aa01934f06a8b704d830bbf
Author: Brian Demers <[email protected]>
AuthorDate: Fri Oct 7 06:04:18 2022 -0500

    Migrate aop tests to groovy
---
 ...va => AspectjAndDefaultProxyCreatorTest.groovy} | 53 ++++++++++------------
 ...nnotationProcessorAutoConfigurationTest.groovy} | 41 ++++++++---------
 2 files changed, 44 insertions(+), 50 deletions(-)

diff --git 
a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.java
 
b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.groovy
similarity index 53%
rename from 
support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.java
rename to 
support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.groovy
index b2e405b0..bfedb915 100644
--- 
a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.java
+++ 
b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/AspectjAndDefaultProxyCreatorTest.groovy
@@ -18,45 +18,40 @@
  */
 package org.apache.shiro.spring.boot.autoconfigure;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import 
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
-import org.springframework.aop.config.AopConfigUtils;
-import 
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator;
-import 
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.junit.Test
+import org.junit.runner.RunWith
+import 
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
+import org.springframework.aop.config.AopConfigUtils
+import 
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
+import 
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator
+import org.springframework.beans.BeansException
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.context.ApplicationContext
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
 
-import java.util.Arrays;
-
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.*
+import static org.hamcrest.MatcherAssert.assertThat
 
 @SpringBootTest(classes = AspectjAndDefaultProxyCreatorApplication.class)
 @RunWith(SpringJUnit4ClassRunner.class)
-public class AspectjAndDefaultProxyCreatorTest {
+class AspectjAndDefaultProxyCreatorTest {
 
     @Autowired
-    private ApplicationContext applicationContext;
+    private ApplicationContext applicationContext
 
     @Test
-    public void defaultAdvisorAutoProxyCreator() throws BeansException {
+    void defaultAdvisorAutoProxyCreator() throws BeansException {
         // There are two proxy creators before SHIRO-890 which causes problem 
when @EnableAspectJAutoProxy is enabled.
-        String[] names = new String[]{"defaultAdvisorAutoProxyCreator", 
AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME};
+        String[] names = ["defaultAdvisorAutoProxyCreator", 
AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME]
         for (String name : names) {
-            Object creator = applicationContext.getBean(name);
-            assertNotNull(creator);
-            if (!(creator instanceof DefaultAdvisorAutoProxyCreator
-                    || creator instanceof 
AnnotationAwareAspectJAutoProxyCreator)) {
-                fail("It supposed to be one of these two types only.");
-            }
+            Object creator = applicationContext.getBean(name)
+            assertThat(creator, anyOf(
+                    instanceOf(DefaultAdvisorAutoProxyCreator.class),
+                    instanceOf(AnnotationAwareAspectJAutoProxyCreator.class)
+            ))
         }
-        String[] beanNames = 
applicationContext.getBeanNamesForType(AbstractAdvisorAutoProxyCreator.class);
-        assertEquals(2, beanNames.length);
-        Arrays.sort(names);
-        Arrays.sort(beanNames);
-        assertArrayEquals(names, beanNames);
+        String[] beanNames = 
applicationContext.getBeanNamesForType(AbstractAdvisorAutoProxyCreator.class)
+        assertThat(names, arrayContainingInAnyOrder(beanNames))
     }
 }
\ No newline at end of file
diff --git 
a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.java
 
b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.groovy
similarity index 58%
rename from 
support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.java
rename to 
support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.groovy
index fad98549..68602321 100644
--- 
a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.java
+++ 
b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfigurationTest.groovy
@@ -18,35 +18,34 @@
  */
 package org.apache.shiro.spring.boot.autoconfigure;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import 
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
-import org.springframework.aop.config.AopConfigUtils;
-import 
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.junit.Test
+import org.junit.runner.RunWith
+import 
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
+import org.springframework.aop.config.AopConfigUtils
+import 
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
+import org.springframework.beans.BeansException
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.context.ApplicationContext
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.hamcrest.MatcherAssert.assertThat
+import static org.hamcrest.Matchers.*
 
 @SpringBootTest(classes = AspectjEnabledApplication.class)
 @RunWith(SpringJUnit4ClassRunner.class)
-public class ShiroAnnotationProcessorAutoConfigurationTest {
+class ShiroAnnotationProcessorAutoConfigurationTest {
 
     @Autowired
-    private ApplicationContext applicationContext;
+    private ApplicationContext applicationContext
 
     @Test
-    public void defaultAdvisorAutoProxyCreator() throws BeansException {
+    void defaultAdvisorAutoProxyCreator() throws BeansException {
         //  There is only one proxy creator, and it's 
AnnotationAwareAspectJAutoProxyCreator as expected.
-        Object creator = 
applicationContext.getBean(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
-        if (!(creator instanceof AnnotationAwareAspectJAutoProxyCreator)) {
-            fail("@EnableAspectJAutoProxy will create an instance of 
AnnotationAwareAspectJAutoProxyCreator");
-        }
-        String[] names = 
applicationContext.getBeanNamesForType(AbstractAdvisorAutoProxyCreator.class);
-        assertEquals(1, names.length);
+        Object creator = 
applicationContext.getBean(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME)
+        assertThat("@EnableAspectJAutoProxy will create an instance of 
AnnotationAwareAspectJAutoProxyCreator",
+                creator, 
instanceOf(AnnotationAwareAspectJAutoProxyCreator.class))
+        String[] names = 
applicationContext.getBeanNamesForType(AbstractAdvisorAutoProxyCreator.class)
+        assertThat(names, arrayWithSize(1))
     }
 }
\ No newline at end of file

Reply via email to