PrincipalProviderTest fails with java 14
*/
package org.apache.jackrabbit.oak.spi.security.principal;
-import org.apache.jackrabbit.api.security.principal.PrincipalManager;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.junit.Test;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import java.security.Principal;
import java.util.Iterator;
import java.util.Set;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doCallRealMethod;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
public class PrincipalProviderTest {
- private PrincipalProvider pp = mock(PrincipalProvider.class);
+ private PrincipalProvider pp = new PrincipalProvider() {
+ @Override
+ public @Nullable Principal getPrincipal(@NotNull String principalName) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public @NotNull Set<? extends Principal> getPrincipals(@NotNull String userID) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public @NotNull Iterator<? extends Principal> findPrincipals(@Nullable String nameHint, int searchType) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public @NotNull Iterator<? extends Principal> findPrincipals(int searchType) {
+ throw new RuntimeException();
+ }
+ };
@Test
public void testGetItemBasedPrincipal() {
- doCallRealMethod().when(pp).getItemBasedPrincipal("/some/path");
assertNull(pp.getItemBasedPrincipal("/some/path"));
}
@Test
public void testGetGroupMembership() {
Principal p = mock(Principal.class);
- doCallRealMethod().when(pp).getGroupMembership(p);
assertTrue(pp.getGroupMembership(p).isEmpty());
}
@Test
public void testGetMembershipPrincipals() {
- Principal p = mock(Principal.class);
- doCallRealMethod().when(pp).getMembershipPrincipals(p);
- assertTrue(pp.getMembershipPrincipals(p).isEmpty());
+ assertTrue(pp.getMembershipPrincipals(mock(Principal.class)).isEmpty());
}
-
-
@Test(expected = IllegalArgumentException.class)
public void testNegativeOffset() {
- doCallRealMethod().when(pp).findPrincipals("hint", true, PrincipalManager.SEARCH_TYPE_GROUP, -1, 12);
pp.findPrincipals("hint", true, PrincipalManager.SEARCH_TYPE_GROUP, -1, 12);
}
}
\ No newline at end of file
