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

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new eac4131d53 ISIS-2297: migrate security.shiro to JUnit5
eac4131d53 is described below

commit eac4131d53d014abde4c5165b84cad2fb6dad48f
Author: Andi Huber <[email protected]>
AuthorDate: Mon Nov 14 17:46:50 2022 +0100

    ISIS-2297: migrate security.shiro to JUnit5
---
 security/shiro/pom.xml                             |  2 +-
 .../shiro/CausewayPermissionTest_setParts.java     | 12 ++++----
 .../shiro/CausewayPermissionTest_typicalUsage.java | 35 +++++++++-------------
 ...AuthenticatorOrAuthorizorTest_authenticate.java |  4 +--
 ...ticatorOrAuthorizorTest_isVisibleInAnyRole.java |  9 +++---
 .../CausewayPermissionTest_equals.java             | 11 ++++---
 .../PermissionToRoleMapperFromIniTest.java         |  8 ++---
 .../PermissionToRoleMapperFromStringTest.java      |  8 ++---
 .../shiro/permrolemapper/UtilTest_parse.java       |  6 ++--
 9 files changed, 42 insertions(+), 53 deletions(-)

diff --git a/security/shiro/pom.xml b/security/shiro/pom.xml
index bbc5289a57..ac4ff8b995 100644
--- a/security/shiro/pom.xml
+++ b/security/shiro/pom.xml
@@ -106,7 +106,7 @@
         
         <dependency>
             <groupId>org.apache.causeway.core</groupId>
-            <artifactId>causeway-core-internaltestvintage</artifactId>
+            <artifactId>causeway-core-internaltestsupport</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_setParts.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_setParts.java
index e5ec58243d..9f9bed6f49 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_setParts.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_setParts.java
@@ -18,36 +18,36 @@
  */
 package org.apache.causeway.security.shiro;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.apache.causeway.security.shiro.authorization.CausewayPermission;
 
-public class CausewayPermissionTest_setParts {
+class CausewayPermissionTest_setParts {
 
     @Test
-    public void noVeto() throws Exception {
+    void noVeto() throws Exception {
         CausewayPermission ip = new 
CausewayPermission("com.mycompany.myapp:Customer:changeAddress:r");
         assertThat(ip.toString(), 
is("com.mycompany.myapp:customer:changeaddress:r"));
     }
 
     @Test
-    public void withVetoableDomain() throws Exception {
+    void withVetoableDomain() throws Exception {
         CausewayPermission ip = new 
CausewayPermission("foo/com.mycompany.myapp:Customer:changeAddress:r");
         assertThat(ip.toString(), 
is("foo/com.mycompany.myapp:customer:changeaddress:r"));
     }
 
     @Test
-    public void withVetoAndVetoableDomain() throws Exception {
+    void withVetoAndVetoableDomain() throws Exception {
         CausewayPermission ip = new 
CausewayPermission("!foo/com.mycompany.myapp:Customer:changeAddress:r");
         assertThat(ip.toString(), 
is("!foo/com.mycompany.myapp:customer:changeaddress:r"));
     }
 
 
     @Test
-    public void xxx() throws Exception {
+    void xxx() throws Exception {
         CausewayPermission ip = new 
CausewayPermission("schwartz/com.mycompany.myapp:Order:submit:*");
         CausewayPermission ip2 = new 
CausewayPermission("com.mycompany.myapp:Customer:remove:r");
 
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_typicalUsage.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_typicalUsage.java
index 0ce1707c68..9f02ecbaad 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_typicalUsage.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/CausewayPermissionTest_typicalUsage.java
@@ -23,32 +23,29 @@ import org.apache.shiro.authz.permission.WildcardPermission;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeMatcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.apache.causeway.security.shiro.authorization.CausewayPermission;
 
-public class CausewayPermissionTest_typicalUsage {
+class CausewayPermissionTest_typicalUsage {
 
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         CausewayPermission.resetVetoedPermissions();
     }
 
-    @After
-    public void tearDown() throws Exception {
+    @AfterEach
+    void tearDown() throws Exception {
         CausewayPermission.resetVetoedPermissions();
     }
 
-
-
     @Test
-    public void typicalUsageWithinCauseway() throws Exception {
+    void typicalUsageWithinCauseway() throws Exception {
 
         // these are the permissions that Causeway will check
         WildcardPermission viewCustomerChangeAddress = new 
WildcardPermission("com.mycompany.myapp:Customer:changeAddress:r");
@@ -90,13 +87,12 @@ public class CausewayPermissionTest_typicalUsage {
         assertThat(viewCustomerChangeAddress, 
not(permittedBy("!foo/com.mycompany.myapp:Customer:changeAddress:r")));
         assertThat(useCustomerChangeAddress, 
not(permittedBy("!foo/com.mycompany.myapp:Customer:changeAddress:w")));
 
-        // and check that two wrongs don't make a right (ie the ! means veto, 
rather than "not") 
+        // and check that two wrongs don't make a right (ie the ! means veto, 
rather than "not")
         assertThat(useCustomerChangeAddress, 
not(permittedBy("!foo/com.mycompany.myapp:Customer:changeAddress:r")));
     }
 
-
     @Test
-    public void vetoableDomains() throws Exception {
+    void vetoableDomains() throws Exception {
 
         // these are the permissions that Causeway will check
         WildcardPermission viewCustomerChangeAddress = new 
WildcardPermission("com.mycompany.myapp:Customer:changeAddress:r");
@@ -112,10 +108,8 @@ public class CausewayPermissionTest_typicalUsage {
         assertThat(viewCustomerChangeAddress, 
permittedBy("bar/com.mycompany.myapp:Customer:*"));
     }
 
-
-
     @Test
-    public void defaultPackage() throws Exception {
+    void defaultPackage() throws Exception {
 
         // these are the permissions that Causeway will check
         WildcardPermission viewCustomerChangeAddress = new 
WildcardPermission(":Customer:changeAddress:r");
@@ -131,7 +125,6 @@ public class CausewayPermissionTest_typicalUsage {
         assertThat(viewCustomerChangeAddress, permittedBy("*"));
     }
 
-
     private static Matcher<? super Permission> permittedBy(final String 
permissionString) {
         return permittedBy(new CausewayPermission(permissionString));
     }
@@ -140,12 +133,12 @@ public class CausewayPermissionTest_typicalUsage {
         return new TypeSafeMatcher<Permission>() {
 
             @Override
-            public void describeTo(Description description) {
+            public void describeTo(final Description description) {
                 description.appendText("permitted by " + wp.toString());
             }
 
             @Override
-            protected boolean matchesSafely(Permission item) {
+            protected boolean matchesSafely(final Permission item) {
                 return wp.implies(item);
             }
         };
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_authenticate.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_authenticate.java
index 0ad28d9c82..a41747eb91 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_authenticate.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_authenticate.java
@@ -50,9 +50,7 @@ class ShiroAuthenticatorOrAuthorizorTest_authenticate {
     @BeforeEach
     public void setUp() throws Exception {
 
-        // PRODUCTION
-
-        val configuration = new CausewayConfiguration(null);
+         val configuration = new CausewayConfiguration(null);
         
configuration.getSecurity().getShiro().setAutoLogoutIfAlreadyAuthenticated(false);
 
         authenticator = new AuthenticatorShiro(configuration);
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
index 52bd0dc76d..4206823f3d 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
@@ -46,7 +46,7 @@ class ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole {
     private AuthorizorShiro authorizor;
 
     @BeforeEach
-    public void setUp() throws Exception {
+    void setUp() throws Exception {
 
         // PRODUCTION
 
@@ -59,7 +59,7 @@ class ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole {
 
 
     @AfterEach
-    public void tearDown() throws Exception {
+    void tearDown() throws Exception {
         Subject subject = ThreadContext.getSubject();
         if(subject != null) {
             subject.logout();
@@ -68,7 +68,7 @@ class ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole {
     }
 
     @Test
-    public void vetoing() throws Exception {
+    void vetoing() throws Exception {
         // given
         Factory<SecurityManager> factory = new 
IniSecurityManagerFactory("classpath:shiro.ini");
         SecurityManager securityManager = factory.getInstance();
@@ -85,7 +85,7 @@ class ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole {
     }
 
     @Test
-    public void vetoingOverridden() throws Exception {
+    void vetoingOverridden() throws Exception {
         // given
         Factory<SecurityManager> factory = new 
IniSecurityManagerFactory("classpath:shiro.ini");
         SecurityManager securityManager = factory.getInstance();
@@ -100,5 +100,4 @@ class ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole 
{
         assertThat(authorizor.isVisible(authentication, 
removeCustomerIdentifier), is(true));
     }
 
-
 }
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/authorization/CausewayPermissionTest_equals.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/authorization/CausewayPermissionTest_equals.java
index 63dd11aee7..c92279a464 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/authorization/CausewayPermissionTest_equals.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/authorization/CausewayPermissionTest_equals.java
@@ -18,19 +18,18 @@
  */
 package org.apache.causeway.security.shiro.authorization;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
-public class CausewayPermissionTest_equals {
+class CausewayPermissionTest_equals {
 
     @Test
-    public void differentByPermGroup() throws Exception {
+    void differentByPermGroup() throws Exception {
         final CausewayPermission perm1 = new CausewayPermission("adm/*");
         final CausewayPermission perm2 = new CausewayPermission("aba/*");
 
-        Assert.assertThat(perm1.equals(perm2), is(false));
+        assertFalse(perm1.equals(perm2));
     }
 
 
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromIniTest.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromIniTest.java
index e7e6dd1750..46c93d60ea 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromIniTest.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromIniTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  *  Licensed to the Apache Software Foundation (ASF) under one or more
  *  contributor license agreements.  See the NOTICE file distributed with
  *  this work for additional information regarding copyright ownership.
@@ -20,7 +20,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.shiro.config.Ini;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
@@ -28,10 +28,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.apache.causeway.commons.internal.collections._Sets;
 
-public class PermissionToRoleMapperFromIniTest {
+class PermissionToRoleMapperFromIniTest {
 
     @Test
-    public void test() {
+    void test() {
         final Ini ini = 
Ini.fromResourcePath("classpath:org/apache/causeway/security/shiro/permrolemapper/my.ini");
         final Map<String, Set<String>> permissionsByRole =
                 new PermissionToRoleMapperFromIni(ini).getPermissionsByRole();
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromStringTest.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromStringTest.java
index 0e7085d896..1de65279fc 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromStringTest.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/PermissionToRoleMapperFromStringTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  *  Licensed to the Apache Software Foundation (ASF) under one or more
  *  contributor license agreements.  See the NOTICE file distributed with
  *  this work for additional information regarding copyright ownership.
@@ -19,7 +19,7 @@ package org.apache.causeway.security.shiro.permrolemapper;
 import java.util.Map;
 import java.util.Set;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
@@ -27,10 +27,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.apache.causeway.commons.internal.collections._Sets;
 
-public class PermissionToRoleMapperFromStringTest {
+class PermissionToRoleMapperFromStringTest {
 
     @Test
-    public void test() {
+    void test() {
         final Map<String, Set<String>> permissionsByRole = new 
PermissionToRoleMapperFromString(
                 "role1 = foo,bar;"
                         + "role2 = fiz:x,bip:bop:* ;"
diff --git 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/UtilTest_parse.java
 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/UtilTest_parse.java
index bccee3f2b6..a8b8a66d81 100644
--- 
a/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/UtilTest_parse.java
+++ 
b/security/shiro/src/test/java/org/apache/causeway/security/shiro/permrolemapper/UtilTest_parse.java
@@ -21,17 +21,17 @@ package org.apache.causeway.security.shiro.permrolemapper;
 import java.util.Map;
 import java.util.Set;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-public class UtilTest_parse {
+class UtilTest_parse {
 
     @Test
-    public void testParse() {
+    void testParse() {
         Map<String, Set<String>> perms = Util.parse("user_role = 
*:ToDoItemsJdo:*:*,*:ToDoItem:*:*;self-install_role = 
*:ToDoItemsFixturesService:install:*;admin_role = *");
         assertThat(perms, is(not(nullValue())));
         Set<String> set = perms.get("user_role");

Reply via email to