diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java index 9da36685a8e..38e73d903b1 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java @@ -17,11 +17,10 @@ package org.apache.jackrabbit.oak.spi.security.authentication.external; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Test; @@ -169,7 +168,7 @@ public Iterable getDeclaredGroups() { @Test public void testToString() { - for (ExternalIdentityRef r : ImmutableList.of(ref, refEmptyProvider, refEmptyProvider)) { + for (ExternalIdentityRef r : List.of(ref, refEmptyProvider, refEmptyProvider)) { assertEquals("ExternalIdentityRef{" + "id='" + r.getId() + '\'' + ", providerName='" + r.getProviderName() + '\'' + '}', r.toString()); } } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java index c2a8cbbb660..380f7e8ed1e 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Supplier; @@ -29,8 +30,7 @@ import javax.jcr.SimpleCredentials; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; public class TestIdentityProvider implements ExternalIdentityProvider { @@ -75,7 +75,7 @@ public TestIdentityProvider(@NotNull String idpName) { addUser(new TestUser(ID_SECOND_USER, getName()) .withProperty("profile/name", "Second User") .withProperty("age", 24) - .withProperty("col", ImmutableList.of("v1", "v2", "v3")) + .withProperty("col", List.of("v1", "v2", "v3")) .withProperty("boolArr", new Boolean[]{true, false}) .withProperty("charArr", new char[]{'t', 'o', 'b'}) .withProperty("byteArr", new byte[0]) @@ -237,7 +237,7 @@ public TestIdentity withGroups(@NotNull String ... grps) { @NotNull public TestIdentity withGroups(@NotNull ExternalIdentityRef... groups) { - this.groups.addAll(Set.of(groups)); + this.groups.addAll(ImmutableSet.copyOf(groups)); return this; } } @@ -283,7 +283,7 @@ public ForeignExternalGroup() { @NotNull @Override public Iterable getDeclaredMembers() { - return ImmutableList.of(); + return List.of(); } } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncConfigTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncConfigTest.java index 6f4e295d284..2cc06dd4afc 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncConfigTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncConfigTest.java @@ -17,10 +17,10 @@ package org.apache.jackrabbit.oak.spi.security.authentication.external.basic; import java.util.Collections; -import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; import org.jetbrains.annotations.NotNull; @@ -158,9 +158,9 @@ public void testAutoMembership() { // only global ids for getAutoMembership(Authorizable) as no specific config for 'gr' assertEquals(globalGroupIds, dscA.getAutoMembership(gr)); // for 'user' the combine set of global and conditional config is returned - Set expected = new HashSet<>(); - expected.addAll(globalGroupIds); - expected.addAll(configGroupIds); + Set expected = ImmutableSet.builder() + .addAll(globalGroupIds) + .addAll(configGroupIds).build(); assertEquals(expected, dscA.getAutoMembership(user)); } } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java index 32a607cbaed..444d26698ea 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.basic; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -1451,7 +1450,7 @@ public void testCreateValueFromInputStream() throws Exception { @Test public void testCreateValuesEmptyCollection() throws Exception { - Value[] vs = syncCtx.createValues(ImmutableList.of()); + Value[] vs = syncCtx.createValues(List.of()); assertNotNull(vs); assertEquals(0, vs.length); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java index 41909166559..6094a9774e5 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java @@ -16,12 +16,11 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -36,6 +35,7 @@ import java.security.Principal; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; import static org.junit.Assert.assertSame; @@ -116,17 +116,17 @@ protected void sync(@NotNull ExternalIdentity externalIdentity, @NotNull SyncRes @NotNull static List getIds(@NotNull Iterator authorizables) { - return ImmutableList.copyOf(Iterators.transform(authorizables, authorizable -> { + return CollectionUtils.toStream(authorizables).map(authorizable -> { try { return authorizable.getID(); } catch (RepositoryException repositoryException) { throw new RuntimeException(); } - })); + }).collect(Collectors.toList()); } @NotNull static List getPrincipalNames(@NotNull Iterator groupPrincipals) { - return ImmutableList.copyOf(Iterators.transform(groupPrincipals, Principal::getName)); + return CollectionUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList()); } } \ No newline at end of file diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java index 704f0c1a914..1ba7db49a52 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java @@ -27,7 +27,6 @@ import javax.jcr.SimpleCredentials; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.AuthInfo; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; @@ -71,7 +70,7 @@ public void testLogin() throws Exception { @Test public void testLoginWithUnsupportedCredentials() throws Exception { - List creds = ImmutableList.of( + List creds = List.of( new SimpleCredentials("testUser", new char[0]), new GuestCredentials()); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java index a398d75482a..a6e57907d35 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java @@ -16,9 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -26,6 +23,7 @@ import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider; @@ -294,7 +292,7 @@ public void testCrossIDPMembership() throws Exception { UserManager um = getUserManager(r); PrincipalManager pm = getPrincipalManager(r); - List declaredGroupRefs = ImmutableList.copyOf(previouslySyncedUser.getDeclaredGroups()); + List declaredGroupRefs = CollectionUtils.toList(previouslySyncedUser.getDeclaredGroups()); assertTrue(declaredGroupRefs.size() > 1); String groupId = declaredGroupRefs.get(0).getId(); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java index 40106a43991..6680d231bc3 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -47,6 +46,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -119,7 +119,7 @@ protected void assertDynamicMembership(@NotNull ExternalIdentity externalIdentit private void assertDynamicMembership(@NotNull Authorizable a, @NotNull ExternalIdentity externalIdentity, long depth) throws Exception { Value[] vs = a.getProperty(REP_EXTERNAL_PRINCIPAL_NAMES); - Set pNames = ImmutableList.copyOf(vs).stream().map(value -> { + Set pNames = Arrays.stream(vs).map(value -> { try { return value.getString(); } catch (RepositoryException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/SyncMBeanImplTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/SyncMBeanImplTest.java index 3eda03bb4c9..29c35dc4761 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/SyncMBeanImplTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/SyncMBeanImplTest.java @@ -24,6 +24,7 @@ import javax.jcr.RepositoryException; import javax.jcr.ValueFactory; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -636,7 +637,7 @@ public void testListOrphanedUsers() throws Exception { result = syncMBean.listOrphanedUsers(); assertEquals(2, result.length); - assertEquals(Set.of("thirdUser", "g"), Set.of(result)); + assertEquals(Set.of("thirdUser", "g"), ImmutableSet.copyOf(result)); } @Test @@ -668,7 +669,7 @@ public void testListOrphanedUsersThrowingHandler() throws Exception { result = createThrowingSyncMBean(true).listOrphanedUsers(); assertEquals(2, result.length); - assertEquals(Set.of("thirdUser", "g"), Set.of(result)); + assertEquals(Set.of("thirdUser", "g"), ImmutableSet.copyOf(result)); } @Test diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipPrincipalsTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipPrincipalsTest.java index 571cccdb2ed..965a6b90d87 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipPrincipalsTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipPrincipalsTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -116,7 +117,7 @@ public void testGetPrincipalsMultipleGroups() throws Exception { public void testGetPrincipalsMixed() throws Exception { Collection principals = getAutoMembership(IDP_MIXED_AM, authorizable, false); assertFalse(principals.isEmpty()); - assertEquals(Set.of(automembershipGroup1.getPrincipal()), Set.copyOf(principals)); + assertEquals(Set.of(automembershipGroup1.getPrincipal()), ImmutableSet.copyOf(principals)); verifyNoInteractions(authorizable, amConfig); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipProviderTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipProviderTest.java index 060e04976f5..a07bab29442 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipProviderTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/AutoMembershipProviderTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -23,7 +24,6 @@ import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.QueryEngine; import org.apache.jackrabbit.oak.api.Root; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; @@ -107,14 +107,14 @@ private AutoMembershipProvider createAutoMembershipProvider(@NotNull Root root, } private static void assertMatchingEntries(@NotNull Iterator it, @NotNull String... expectedIds) { - Set ids = CollectionUtils.toSet(Iterators.transform(it, authorizable -> { + Set ids = ImmutableSet.copyOf(Iterators.transform(it, authorizable -> { try { return authorizable.getID(); } catch (RepositoryException repositoryException) { return ""; } })); - assertEquals(Set.of(expectedIds), ids); + assertEquals(ImmutableSet.copyOf(expectedIds), ids); } @Test @@ -378,7 +378,7 @@ public void testGetMembershipSelf() throws Exception { public void testGetMembershipExternalUser() throws Exception { setExternalId(getTestUser().getID(), IDP_VALID_AM); - Set groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), false)); + Set groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), false)); assertEquals(2, groups.size()); assertTrue(groups.contains(automembershipGroup1)); assertTrue(groups.contains(automembershipGroup2)); @@ -388,7 +388,7 @@ public void testGetMembershipExternalUser() throws Exception { public void testGetMembershipExternalUserInherited() throws Exception { setExternalId(getTestUser().getID(), IDP_VALID_AM); - Set groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), true)); + Set groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), true)); assertEquals(2, groups.size()); assertTrue(groups.contains(automembershipGroup1)); } @@ -399,12 +399,12 @@ public void testGetMembershipExternalUserNestedGroups() throws Exception { Group baseGroup = getTestGroup(automembershipGroup1); - Set groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), false)); + Set groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), false)); assertEquals(2, groups.size()); assertTrue(groups.contains(automembershipGroup1)); assertTrue(groups.contains(automembershipGroup2)); - groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), true)); + groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), true)); assertEquals(3, groups.size()); assertTrue(groups.contains(automembershipGroup1)); assertTrue(groups.contains(automembershipGroup2)); @@ -421,12 +421,12 @@ public void testGetMembershipExternalUserEveryoneGroupExists() throws Exception automembershipGroup2.addMember(automembershipGroup1); root.commit(); - Set groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), false)); + Set groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), false)); assertEquals(2, groups.size()); assertTrue(groups.contains(automembershipGroup1)); assertTrue(groups.contains(automembershipGroup2)); - groups = CollectionUtils.toSet(provider.getMembership(getTestUser(), true)); + groups = ImmutableSet.copyOf(provider.getMembership(getTestUser(), true)); assertEquals(2, groups.size()); // all duplicates must be properly filtered and everyone must be omitted assertTrue(groups.contains(automembershipGroup1)); assertTrue(groups.contains(automembershipGroup2)); @@ -512,7 +512,7 @@ public void testGetMembershipAutogroupGroupMemberOfFails() throws Exception { setExternalId(getTestUser().getID(), IDP_VALID_AM); AutoMembershipProvider amp = createAutoMembershipProvider(root, um); - Set membership = CollectionUtils.toSet(amp.getMembership(getTestUser(), true)); + Set membership = ImmutableSet.copyOf(amp.getMembership(getTestUser(), true)); assertEquals(2, membership.size()); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java index 130605c6f3f..b780521f332 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -141,7 +140,7 @@ public void testAddMembersProperty() throws Exception { assertFalse(groupTree.hasProperty(REP_MEMBERS)); String uuid = r.getTree(userManager.getAuthorizable(USER_ID).getPath()).getProperty(JCR_UUID).getValue(Type.STRING); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(uuid), Type.WEAKREFERENCES); + groupTree.setProperty(REP_MEMBERS, List.of(uuid), Type.WEAKREFERENCES); try { r.commit(); fail("CommitFailedException 77 expected."); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java index 98c7e6aec4c..832192d7613 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; @@ -90,7 +90,7 @@ void sync(@NotNull ExternalUser externalUser) throws Exception { @NotNull Set getExpectedGroupPrincipals(@NotNull String userId) throws Exception { if (syncConfig.user().getMembershipNestingDepth() == 1) { - return CollectionUtils.toStream(idp.getUser(userId).getDeclaredGroups()).map(externalIdentityRef -> { + return ImmutableSet.copyOf(idp.getUser(userId).getDeclaredGroups()).stream().map(externalIdentityRef -> { try { return new PrincipalImpl(idp.getIdentity(externalIdentityRef).getPrincipalName()); } catch (ExternalIdentityException e) { @@ -213,7 +213,7 @@ public void testGetPrincipalDynamicGroup() throws Exception { @Test public void testGetPrincipalInheritedGroups() throws Exception { - Set declared = CollectionUtils.toSet(idp.getUser(USER_ID).getDeclaredGroups()); + ImmutableSet declared = ImmutableSet.copyOf(idp.getUser(USER_ID).getDeclaredGroups()); for (ExternalIdentityRef ref : declared) { for (ExternalIdentityRef inheritedGroupRef : idp.getIdentity(ref).getDeclaredGroups()) { @@ -491,20 +491,24 @@ public void testFindPrincipalsByHintTypeNotGroup() { @Test public void testFindPrincipalsByHintTypeGroup() { Set expected = buildExpectedPrincipals("a"); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_GROUP)); + Set res = ImmutableSet + .copyOf(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_GROUP)); assertEquals(expected, res); - Set res2 = CollectionUtils.toSet(principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_GROUP, 0, -1)); + Set res2 = ImmutableSet + .copyOf(principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_GROUP, 0, -1)); assertEquals(expected, res2); } @Test public void testFindPrincipalsByHintTypeAll() { Set expected = buildExpectedPrincipals("a"); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL)); + Set res = ImmutableSet + .copyOf(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL)); assertEquals(expected, res); - Set res2 = CollectionUtils.toSet(principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); + Set res2 = ImmutableSet + .copyOf(principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); assertEquals(expected, res2); } @@ -514,9 +518,11 @@ public void testFindPrincipalsContainingUnderscore() throws Exception { sync(externalUser); Set expected = buildExpectedPrincipals("_gr_u_"); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("_", PrincipalManager.SEARCH_TYPE_ALL)); + Set res = ImmutableSet + .copyOf(principalProvider.findPrincipals("_", PrincipalManager.SEARCH_TYPE_ALL)); assertEquals(expected, res); - Set res2 = CollectionUtils.toSet(principalProvider.findPrincipals("_", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); + Set res2 = ImmutableSet + .copyOf(principalProvider.findPrincipals("_", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); assertEquals(expected, res2); } @@ -526,9 +532,10 @@ public void testFindPrincipalsContainingPercentSign() throws Exception { sync(externalUser); Set expected = buildExpectedPrincipals("g%r%"); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("%", PrincipalManager.SEARCH_TYPE_ALL)); + Set res = ImmutableSet.copyOf(principalProvider.findPrincipals("%", PrincipalManager.SEARCH_TYPE_ALL)); assertEquals(expected, res); - Set res2 = CollectionUtils.toSet(principalProvider.findPrincipals("%", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); + Set res2 = ImmutableSet + .copyOf(principalProvider.findPrincipals("%", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); assertEquals(expected, res2); } @@ -540,16 +547,16 @@ public void testFindPrincipalsByTypeNotGroup() { @Test public void testFindPrincipalsByTypeGroup() throws Exception { - Set res = CollectionUtils.toSet(principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_GROUP)); + Set res = ImmutableSet.copyOf(principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_GROUP)); assertEquals(getExpectedAllSearchResult(USER_ID), res); - Set res2 = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, -1)); + Set res2 = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, -1)); assertEquals(getExpectedAllSearchResult(USER_ID), res2); } @Test public void testFindPrincipalsByTypeAll() throws Exception { - Set res = CollectionUtils.toSet(principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL)); + Set res = ImmutableSet.copyOf(principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL)); assertEquals(getExpectedAllSearchResult(USER_ID), res); } @@ -569,10 +576,10 @@ public void testFindPrincipalsFiltersDuplicates() throws Exception { } Iterator res = principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL); - assertEquals(expected, CollectionUtils.toSet(res)); + assertEquals(expected, ImmutableSet.copyOf(res)); Iterator res2 = principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1); - assertEquals(expected, CollectionUtils.toSet(res2)); + assertEquals(expected, ImmutableSet.copyOf(res2)); } @Test @@ -586,7 +593,7 @@ public Iterator findPrincipals(@Nullable String nameHint, i return in.iterator(); } }; - List out = ImmutableList.copyOf(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); + List out = CollectionUtils.toList(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); Collections.sort(in, Comparator.comparing(Principal::getName)); assertEquals(in, out); } @@ -597,7 +604,7 @@ public void testFindPrincipalsWithOffset() throws Exception { long offset = 2; long expectedSize = (all.size() <= offset) ? 0 : all.size()-offset; - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, offset, -1)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, offset, -1)); assertEquals(expectedSize, result.size()); } @@ -605,7 +612,7 @@ public void testFindPrincipalsWithOffset() throws Exception { public void testFindPrincipalsWithOffsetEqualsResultSize() throws Exception { Set all = getExpectedAllSearchResult(USER_ID); - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, all.size(), -1)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, all.size(), -1)); assertTrue(result.isEmpty()); } @@ -613,13 +620,13 @@ public void testFindPrincipalsWithOffsetEqualsResultSize() throws Exception { public void testFindPrincipalsWithOffsetExceedsResultSize() throws Exception { Set all = getExpectedAllSearchResult(USER_ID); - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, all.size()+1, -1)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, all.size()+1, -1)); assertTrue(result.isEmpty()); } @Test public void testFindPrincipalsWithLimit() { - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, 1)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, 1)); int expectedSize = (hasDynamicGroups()) ? 0 : 1; assertEquals(expectedSize, result.size()); } @@ -628,13 +635,13 @@ public void testFindPrincipalsWithLimit() { public void testFindPrincipalsWithLimitExceedsResultSize() throws Exception { Set all = getExpectedAllSearchResult(USER_ID); - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, all.size()+1)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, all.size()+1)); assertEquals(all, result); } @Test public void testFindPrincipalsWithZeroLimit() { - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, 0)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, 0, 0)); assertTrue(result.isEmpty()); } @@ -644,7 +651,7 @@ public void testFindPrincipalsWithOffsetAndLimit() throws Exception { long offset = all.size()-1; long limit = all.size(); - Set result = CollectionUtils.toSet(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, offset, limit)); + Set result = ImmutableSet.copyOf(principalProvider.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_GROUP, offset, limit)); int expectedSize = (hasDynamicGroups()) ? 0 : 1; assertEquals(expectedSize, result.size()); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderWithCacheTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderWithCacheTest.java index c58d4264457..c2388b1b13c 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderWithCacheTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderWithCacheTest.java @@ -33,18 +33,22 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import javax.jcr.RepositoryException; +import org.apache.jackrabbit.api.security.principal.GroupPrincipal; +import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig; +import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.security.user.cache.CacheConstants; @@ -120,7 +124,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { @NotNull Set getExternalGroupPrincipals(@NotNull String userId) throws Exception { if (syncConfig.user().getMembershipNestingDepth() == 1) { - return CollectionUtils.toSet(idp.getUser(userId).getDeclaredGroups()).stream().map(externalIdentityRef -> { + return ImmutableSet.copyOf(idp.getUser(userId).getDeclaredGroups()).stream().map(externalIdentityRef -> { try { return new PrincipalImpl(idp.getIdentity(externalIdentityRef).getPrincipalName()); } catch (ExternalIdentityException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java index 78e5bb6ac63..69cb1f25a5b 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; @@ -26,6 +25,7 @@ import org.apache.jackrabbit.oak.api.QueryEngine; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -38,7 +38,9 @@ import java.security.Principal; import java.text.ParseException; import java.util.Enumeration; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static org.apache.jackrabbit.oak.spi.security.authentication.external.TestIdentityProvider.ID_SECOND_USER; import static org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES; @@ -69,10 +71,10 @@ public void testNotIsMember() throws Exception { Authorizable notMember = getUserManager(root).getAuthorizable(ID_SECOND_USER); assertFalse(principal.isMember(notMember.getPrincipal())); - root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("secondGroup"), Type.STRINGS); + root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of("secondGroup"), Type.STRINGS); assertFalse(principal.isMember(notMember.getPrincipal())); - root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of(), Type.STRINGS); + root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of(), Type.STRINGS); assertFalse(principal.isMember(new PrincipalImpl(notMember.getPrincipal().getName()))); } @@ -80,7 +82,8 @@ public void testNotIsMember() throws Exception { public void testIsMemberExternalGroup() throws Exception { GroupPrincipal principal = getGroupPrincipal(); - Iterable exGroupPrincNames = Iterables.transform(ImmutableList.copyOf(idp.listGroups()), ExternalIdentity::getPrincipalName); + List exGroupPrincNames = CollectionUtils.toStream( + idp.listGroups()).map(ExternalIdentity::getPrincipalName).collect(Collectors.toList()); for (String principalName : exGroupPrincNames) { assertFalse(principal.isMember(new PrincipalImpl(principalName))); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java index 52963b03707..b45b21062b0 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java @@ -18,7 +18,6 @@ import javax.jcr.SimpleCredentials; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -85,7 +84,7 @@ protected boolean isDynamic() { public void testAddExternalPrincipalNames() throws Exception { Tree userTree = root.getTree(testUserPath); try { - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); root.commit(); fail("Creating rep:externalPrincipalNames must be detected."); } catch (CommitFailedException e) { @@ -101,7 +100,7 @@ public void testAddExternalPrincipalNamesAsSystemMissingExternalId() throws Exce Root systemRoot = getSystemRoot(); try { Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); fail("Creating rep:externalPrincipalNames without rep:externalId must be detected."); } catch (CommitFailedException e) { @@ -117,7 +116,7 @@ public void testAddExternalPrincipalNamesAsSystem() throws Exception { Root systemRoot = getSystemRoot(); Tree userTree = systemRoot.getTree(testUserPath); userTree.setProperty(REP_EXTERNAL_ID, "externalId"); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); } @@ -167,7 +166,7 @@ public void testModifyExternalPrincipalNamesAsSystem() throws Exception { Tree userTree = systemRoot.getTree(externalUserPath); // changing with system root must succeed - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalNames"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalNames"), Type.STRINGS); systemRoot.commit(); } @@ -233,7 +232,7 @@ public void testRepExternalIdMultiple() throws Exception { Root systemRoot = getSystemRoot(); try { Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS); + userTree.setProperty(REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS); systemRoot.commit(); fail("Creating rep:externalId as multiple STRING property must be detected."); } catch (CommitFailedException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java index 7d68a2ceb49..5b23190cc1a 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; @@ -39,7 +39,6 @@ import java.security.Principal; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -157,10 +156,10 @@ protected DefaultSyncConfig createSyncConfig() { @Override @NotNull Set getExpectedGroupPrincipals(@NotNull String userId) throws Exception { - Set builder = new HashSet<>(); - builder.addAll(super.getExpectedGroupPrincipals(userId)); - builder.add(userAutoMembershipGroup.getPrincipal()); - builder.add(groupAutoMembershipGroup.getPrincipal()); + ImmutableSet.Builder builder = ImmutableSet.builder() + .addAll(super.getExpectedGroupPrincipals(userId)) + .add(userAutoMembershipGroup.getPrincipal()) + .add(groupAutoMembershipGroup.getPrincipal()); if (nestedAutomembership) { builder.add(baseGroup.getPrincipal()); } @@ -170,7 +169,7 @@ Set getExpectedGroupPrincipals(@NotNull String userId) throws Excepti builder.add(baseGroup2.getPrincipal()); } } - return Set.copyOf(builder); + return builder.build(); } @Override @@ -300,7 +299,7 @@ public void testGetPrincipals() throws Exception { @Test public void testFindPrincipalsByHint() throws Exception { - List hints = ImmutableList.of( + List hints = List.of( USER_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME, GROUP_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME, USER_AUTO_MEMBERSHIP_GROUP_ID, diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderDeepNestingTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderDeepNestingTest.java index f4dfc848a79..5839699882c 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderDeepNestingTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderDeepNestingTest.java @@ -19,9 +19,10 @@ import java.security.Principal; import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; + import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -85,7 +86,7 @@ public void testGetPrincipalInheritedGroups() throws Exception { @Test public void testFindPrincipalsByHintTypeGroup() { Set expected = Set.of(new PrincipalImpl("a"), new PrincipalImpl("aa"), new PrincipalImpl("aaa")); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_GROUP)); + Set res = ImmutableSet.copyOf(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_GROUP)); assertEquals(expected, res); } @@ -97,7 +98,7 @@ public void testFindPrincipalsByHintTypeAll() { new PrincipalImpl("a"), new PrincipalImpl("aa"), new PrincipalImpl("aaa")); - Set res = CollectionUtils.toSet(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL)); + Set res = ImmutableSet.copyOf(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL)); assertEquals(expected, res); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncConfigTrackerTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncConfigTrackerTest.java index a9369d79653..a93b91e8559 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncConfigTrackerTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncConfigTrackerTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.ObjectArrays; import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler; import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.AutoMembershipAware; @@ -141,8 +142,8 @@ public void testGetAutoMembership() { Map automembership = tracker.getAutoMembership(); assertEquals(1, automembership.size()); - Set expected = Set.of(ObjectArrays.concat(uam, gam, String.class)); - assertEquals(expected, Set.of(automembership.get("idp"))); + Set expected = ImmutableSet.copyOf(ObjectArrays.concat(uam, gam, String.class)); + assertEquals(expected, ImmutableSet.copyOf(automembership.get("idp"))); } @Test @@ -201,8 +202,8 @@ public void testGetAutoMembershipMultipleHandlersAndIdps() { Map automembership = tracker.getAutoMembership(); assertEquals(2, automembership.size()); - Set expected = Set.of(ObjectArrays.concat(uam, gam, String.class)); - assertEquals(expected, Set.of(automembership.get("idp"))); + Set expected = ImmutableSet.copyOf(ObjectArrays.concat(uam, gam, String.class)); + assertEquals(expected, ImmutableSet.copyOf(automembership.get("idp"))); assertArrayEquals(uam, automembership.get("idp2")); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java index 9274ba15d8d..6cdbb380662 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java @@ -16,8 +16,8 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.SyncHandlerMapping; import org.junit.Before; import org.junit.Test; @@ -72,23 +72,23 @@ public void testAddingServiceWithProperties() { when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP"); tracker.addingService(ref); - assertEquals(Set.of("testIDP"), CollectionUtils.toSet(tracker.getIdpNames("testSH"))); + assertEquals(Set.of("testIDP"), ImmutableSet.copyOf(tracker.getIdpNames("testSH"))); ServiceReference ref2 = mock(ServiceReference.class); when(ref2.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH-2"); when(ref2.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP-2"); tracker.addingService(ref2); - assertEquals(Set.of("testIDP"), CollectionUtils.toSet(tracker.getIdpNames("testSH"))); - assertEquals(Set.of("testIDP-2"), CollectionUtils.toSet(tracker.getIdpNames("testSH-2"))); + assertEquals(Set.of("testIDP"), ImmutableSet.copyOf(tracker.getIdpNames("testSH"))); + assertEquals(Set.of("testIDP-2"), ImmutableSet.copyOf(tracker.getIdpNames("testSH-2"))); ServiceReference ref3 = mock(ServiceReference.class); when(ref3.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH"); when(ref3.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP-3"); tracker.addingService(ref3); - assertEquals(Set.of("testIDP", "testIDP-3"), CollectionUtils.toSet(tracker.getIdpNames("testSH"))); - assertEquals(Set.of("testIDP-2"), CollectionUtils.toSet(tracker.getIdpNames("testSH-2"))); + assertEquals(Set.of("testIDP", "testIDP-3"), ImmutableSet.copyOf(tracker.getIdpNames("testSH"))); + assertEquals(Set.of("testIDP-2"), ImmutableSet.copyOf(tracker.getIdpNames("testSH-2"))); } @Test @@ -121,13 +121,13 @@ public void testModifiedServiceWithProperties() { when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH"); when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP-2"); tracker.modifiedService(ref, service); - assertEquals(Set.of("testIDP-2"), CollectionUtils.toSet(tracker.getIdpNames("testSH"))); + assertEquals(Set.of("testIDP-2"), ImmutableSet.copyOf(tracker.getIdpNames("testSH"))); when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH-3"); when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP-3"); tracker.modifiedService(ref, service); assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH"))); - assertEquals(Set.of("testIDP-3"), CollectionUtils.toSet(tracker.getIdpNames("testSH-3"))); + assertEquals(Set.of("testIDP-3"), ImmutableSet.copyOf(tracker.getIdpNames("testSH-3"))); } @Test diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SystemPrincipalConfigTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SystemPrincipalConfigTest.java index 0efea39c5a8..34e19cf9546 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SystemPrincipalConfigTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SystemPrincipalConfigTest.java @@ -16,7 +16,9 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.oak.spi.commit.MoveTracker; import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider; @@ -59,7 +61,7 @@ public class SystemPrincipalConfigTest extends AbstractExternalAuthTest { private SystemPrincipalConfig systemPrincipalConfig; public SystemPrincipalConfigTest(String[] systemUserNames, String name) { - this.systemUserNames = (systemUserNames == null) ? null : Set.of(systemUserNames); + this.systemUserNames = (systemUserNames == null) ? null : ImmutableSet.copyOf(systemUserNames); } @Parameterized.Parameters(name = "name={1}") diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java index 0c894a35510..8866700c557 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java @@ -16,9 +16,9 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -41,7 +41,7 @@ public void before() throws Exception { public void testRepExternalIdMultiple() throws Exception { Root systemRoot = getSystemRoot(); Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS); systemRoot.commit(); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java index a6a9ab2d366..f63aef64502 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -24,6 +23,8 @@ import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants; import org.junit.Test; +import java.util.List; + import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT; import static org.junit.Assert.fail; @@ -41,7 +42,7 @@ protected boolean isDynamic() { private void setExternalPrincipalNames() throws Exception { Root systemRoot = getSystemRoot(); - systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); root.refresh(); diff --git a/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java b/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java index 39a2ebc2e87..749de755083 100644 --- a/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java +++ b/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java @@ -17,10 +17,10 @@ package org.apache.jackrabbit.oak.security.authentication.ldap.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.directory.api.util.Strings; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException; @@ -64,7 +64,7 @@ public void testListUsers() throws Exception { Iterator ids = Iterators.transform(users, externalUser -> externalUser.getId()); Set expectedIds = Set.of(TEST_USER0_UID, TEST_USER1_UID, TEST_USER5_UID, "hnelson", "thardy", "tquist", "fchristi", "wbush", "cbuckley", "jhallett", "mchrysta", "wbligh", "jfryer"); - assertEquals(expectedIds, CollectionUtils.toSet(ids)); + assertEquals(expectedIds, ImmutableSet.copyOf(ids)); } @Test @@ -74,7 +74,7 @@ public void testListUsersWithExtraFilter() throws Exception { Iterator ids = Iterators.transform(users, externalUser -> externalUser.getId()); Set expectedIds = Set.of(TEST_USER0_UID, TEST_USER1_UID, TEST_USER5_UID, "hnelson", "thardy", "tquist", "fchristi", "wbush", "cbuckley", "jhallett", "mchrysta", "wbligh", "jfryer"); - assertEquals(expectedIds, CollectionUtils.toSet(ids)); + assertEquals(expectedIds, ImmutableSet.copyOf(ids)); } /** @@ -202,8 +202,8 @@ public void testGetDeclaredMembers() throws Exception { Iterable memberrefs = gr.getDeclaredMembers(); Iterable memberIds = Iterables.transform(memberrefs, externalIdentityRef -> externalIdentityRef.getId()); - Set expected = Set.of(TEST_GROUP1_MEMBERS); - assertEquals(expected, CollectionUtils.toSet(memberIds)); + Set expected = ImmutableSet.copyOf(TEST_GROUP1_MEMBERS); + assertEquals(expected, ImmutableSet.copyOf(memberIds)); } @Test @@ -238,7 +238,7 @@ public void testGetDeclaredGroupMissingIdAttribute() throws Exception { ExternalUser user = idp.getUser(TEST_USER1_UID); Iterable groupRefs = user.getDeclaredGroups(); Iterable groupIds = Iterables.transform(groupRefs, externalIdentityRef -> externalIdentityRef.getId()); - assertEquals(Set.of(TEST_USER1_GROUPS), CollectionUtils.toSet(groupIds)); + assertEquals(ImmutableSet.copyOf(TEST_USER1_GROUPS), ImmutableSet.copyOf(groupIds)); } @Test @@ -297,7 +297,7 @@ public void testListGroups() throws Exception { Iterator ids = Iterators.transform(groups, externalGroup -> externalGroup.getId()); Set expectedIds = Set.of(TEST_GROUP1_NAME, TEST_GROUP2_NAME, TEST_GROUP3_NAME, "Administrators"); - assertEquals(expectedIds, CollectionUtils.toSet(ids)); + assertEquals(expectedIds, ImmutableSet.copyOf(ids)); } @Test @@ -308,6 +308,6 @@ public void testListGroupsWithEmptyExtraFilter() throws Exception { Iterator ids = Iterators.transform(groups, externalGroup -> externalGroup.getId()); Set expectedIds = Set.of(TEST_GROUP1_NAME, TEST_GROUP2_NAME, TEST_GROUP3_NAME, "Administrators"); - assertEquals(expectedIds, CollectionUtils.toSet(ids)); + assertEquals(expectedIds, ImmutableSet.copyOf(ids)); } } diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AbstractCugTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AbstractCugTest.java index a0f575f73fa..a80cfa3b7db 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AbstractCugTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AbstractCugTest.java @@ -28,6 +28,7 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.AccessControlPolicyIterator; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -39,7 +40,6 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.conditions.Validate; import org.apache.jackrabbit.oak.plugins.tree.RootProvider; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; @@ -149,7 +149,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { } CugPermissionProvider createCugPermissionProvider(@NotNull Set supportedPaths, @NotNull Principal... principals) { - return new CugPermissionProvider(root, root.getContentSession().getWorkspaceName(), Set.of(principals), supportedPaths, getConfig(AuthorizationConfiguration.class).getContext(), getRootProvider(), getTreeProvider()); + return new CugPermissionProvider(root, root.getContentSession().getWorkspaceName(), ImmutableSet.copyOf(principals), supportedPaths, getConfig(AuthorizationConfiguration.class).getContext(), getRootProvider(), getTreeProvider()); } void createTrees(@NotNull Tree tree, @NotNull String... names) throws AccessDeniedException { @@ -269,7 +269,7 @@ static void assertNestedCugs(@NotNull Root root, @NotNull RootProvider rootProvi assertFalse(tree.hasProperty(HIDDEN_NESTED_CUGS)); } else { assertTrue(tree.hasProperty(HIDDEN_NESTED_CUGS)); - assertEquals(Set.of(expectedNestedPaths), CollectionUtils.toSet(tree.getProperty(HIDDEN_NESTED_CUGS).getValue(Type.PATHS))); + assertEquals(ImmutableSet.copyOf(expectedNestedPaths), ImmutableSet.copyOf(tree.getProperty(HIDDEN_NESTED_CUGS).getValue(Type.PATHS))); assertTrue(tree.hasProperty(HIDDEN_TOP_CUG_CNT)); assertEquals(Long.valueOf(expectedNestedPaths.length), tree.getProperty(HIDDEN_TOP_CUG_CNT).getValue(Type.LONG)); @@ -282,7 +282,7 @@ static void assertNestedCugs(@NotNull Root root, @NotNull RootProvider rootProvi assertFalse(tree.hasProperty(HIDDEN_NESTED_CUGS)); } else { assertTrue(tree.hasProperty(HIDDEN_NESTED_CUGS)); - assertEquals(Set.of(expectedNestedPaths), CollectionUtils.toSet(tree.getProperty(HIDDEN_NESTED_CUGS).getValue(Type.PATHS))); + assertEquals(ImmutableSet.copyOf(expectedNestedPaths), ImmutableSet.copyOf(tree.getProperty(HIDDEN_NESTED_CUGS).getValue(Type.PATHS))); } } diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java index b157e1b404c..bef75f9debf 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java @@ -21,7 +21,6 @@ import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -73,7 +72,7 @@ public void before() throws Exception { * - /content2 : allow everyone, deny testGroup (isolated) * */ - acPaths = ImmutableList.of( + acPaths = List.of( "/content/rep:policy", PermissionConstants.PERMISSIONS_STORE_PATH, "/content/a/rep:cugPolicy", diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java index cdc445031c7..3f8a124b575 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java @@ -30,7 +30,7 @@ import javax.jcr.security.NamedAccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.JcrConstants; @@ -73,7 +73,7 @@ public class CugAccessControlManagerTest extends AbstractCugTest { public void before() throws Exception { super.before(); - cugAccessControlManager = new CugAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + cugAccessControlManager = new CugAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); } private CugPolicy createCug(@NotNull String path) { @@ -170,7 +170,7 @@ public void testGetPoliciesAfterManualCreation() throws Exception { CugPolicy cugPolicy = (CugPolicy) policies[0]; assertTrue(cugPolicy.getPrincipals().isEmpty()); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of("unknownPrincipalName", EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of("unknownPrincipalName", EveryonePrincipal.NAME), Type.STRINGS); policies = cugAccessControlManager.getPolicies(SUPPORTED_PATH); cugPolicy = (CugPolicy) policies[0]; @@ -237,7 +237,7 @@ public void testGetEffectivePoliciesNotEnabled() throws Exception { ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of( CugConstants.PARAM_CUG_SUPPORTED_PATHS, SUPPORTED_PATHS, CugConstants.PARAM_CUG_ENABLED, false)); - CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); AccessControlPolicy[] policies = acMgr.getEffectivePolicies(SUPPORTED_PATH); assertEquals(0, policies.length); @@ -253,7 +253,7 @@ public void testGetEffectivePoliciesNoReadAcPermission() throws Exception { // test-user only has read-access on /content (no read-ac permission) try (ContentSession cs = createTestSession()) { Root r = cs.getLatestRoot(); - CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); AccessControlPolicy[] effective = m.getEffectivePolicies("/content"); assertEquals(0, effective.length); } @@ -265,7 +265,7 @@ public void testGetEffectivePoliciesNoReadPermission() throws Exception { // test-user only has read-access on /content (no read-ac permission) try (ContentSession cs = createTestSession()) { Root r = cs.getLatestRoot(); - CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); m.getEffectivePolicies("/content2"); } } @@ -277,7 +277,7 @@ public void testGetEffectivePoliciesLimitedReadAcPermission() throws Exception { // test-user2 only has read-ac permission on /content but not on /content2 try (ContentSession cs = createTestSession2()) { Root r = cs.getLatestRoot(); - CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); AccessControlPolicy[] effective = m.getEffectivePolicies("/content/a/b/c"); // [/content/a, /content/a/b/c] assertEquals(2, effective.length); @@ -323,7 +323,7 @@ public void testSetPolicyPersisted() throws Exception { @Test public void testSetInvalidPolicy() throws Exception { - List invalidPolicies = ImmutableList.of( + List invalidPolicies = List.of( new AccessControlPolicy() {}, (NamedAccessControlPolicy) () -> "name", InvalidCug.INSTANCE @@ -453,7 +453,7 @@ public void testRemovePolicyMixinAlreadyRemoved() throws Exception { @Test public void testRemoveInvalidPolicy() throws Exception { - List invalidPolicies = ImmutableList.of( + List invalidPolicies = List.of( new AccessControlPolicy() {}, (NamedAccessControlPolicy) () -> "name", InvalidCug.INSTANCE @@ -585,7 +585,7 @@ public void testGetEffectivePrincipalDistributed() throws Exception { AccessControlPolicy[] testgroupEffective = cugAccessControlManager.getEffectivePolicies(Set.of(getTestGroupPrincipal())); assertEquals(2, testgroupEffective.length); - assertTrue(Sets.intersection(Set.of(everyoneEffective), Set.of(testgroupEffective)).isEmpty()); + assertTrue(Sets.intersection(ImmutableSet.copyOf(everyoneEffective), ImmutableSet.copyOf(testgroupEffective)).isEmpty()); } @Test @@ -595,7 +595,7 @@ public void testGetEffectivePrincipalNoReadAcPermission() throws Exception { try (ContentSession cs = createTestSession()) { Root r = cs.getLatestRoot(); CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), - Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); AccessControlPolicy[] effective = m.getEffectivePolicies(Set.of(getTestGroupPrincipal(), EveryonePrincipal.getInstance())); assertEquals(0, effective.length); } @@ -609,7 +609,7 @@ public void testGetEffectivePrincipalLimitedReadAcPermission() throws Exception try (ContentSession cs = createTestSession2()) { Root r = cs.getLatestRoot(); CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), - Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); AccessControlPolicy[] effective = m.getEffectivePolicies(Set.of(getTestGroupPrincipal(), EveryonePrincipal.getInstance())); // [/content/a, /content/a/b/c, /content/aa/bb] but not: /content2 assertEquals(3, effective.length); @@ -642,7 +642,7 @@ public void testGetEffectiveByPrincipalNotEnabled() throws Exception { ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of( CugConstants.PARAM_CUG_SUPPORTED_PATHS, SUPPORTED_PATHS, CugConstants.PARAM_CUG_ENABLED, false)); - CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); assertEquals(0, acMgr.getEffectivePolicies(Set.of(getTestGroupPrincipal(), EveryonePrincipal.getInstance())).length); } @@ -676,7 +676,7 @@ public void testGetEffectivePrincipalsPathsDisabled() throws Exception { ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of( CugConstants.PARAM_CUG_SUPPORTED_PATHS, SUPPORTED_PATHS, CugConstants.PARAM_CUG_ENABLED, false)); - CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager acMgr = new CugAccessControlManager(root, NamePathMapper.DEFAULT, CugSecurityProvider.newTestSecurityProvider(config), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); Iterator effective = acMgr.getEffectivePolicies(principalSet, "/content/a"); assertFalse(effective.hasNext()); @@ -729,7 +729,7 @@ public void testGetEffectivePrincipalsPathsMissingPermission() throws Exception // test-user only has read-access on /content (no read-ac permission) try (ContentSession cs = createTestSession()) { Root r = cs.getLatestRoot(); - CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), Set.of(SUPPORTED_PATHS), getExclude(), getRootProvider()); + CugAccessControlManager m = new CugAccessControlManager(r, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableSet.copyOf(SUPPORTED_PATHS), getExclude(), getRootProvider()); Iterator effective = m.getEffectivePolicies(Set.of(getTestGroupPrincipal()), "/content/a"); assertFalse(effective.hasNext()); } diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java index 8f92428a209..5023c9a6e61 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java @@ -23,7 +23,7 @@ import java.util.Set; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration; @@ -186,7 +186,7 @@ public void testExcludedPrincipals() { CugConstants.PARAM_CUG_SUPPORTED_PATHS, "/content"); CugConfiguration cc = createConfiguration(params); - List excluded = ImmutableList.of( + List excluded = List.of( SystemPrincipal.INSTANCE, (AdminPrincipal) () -> "admin", (SystemUserPrincipal) () -> "systemUser"); @@ -219,7 +219,7 @@ public void testModified() { } private static void assertSupportedPaths(@NotNull CugConfiguration configuration, @NotNull String... paths) { - Set expected = Set.of(paths); + Set expected = ImmutableSet.copyOf(paths); assertEquals(expected, configuration.getParameters().getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, Set.of())); } diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java index 63c323b78ec..5508bde0128 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java @@ -21,7 +21,6 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.PropertyState; @@ -41,7 +40,7 @@ public class CugContextTest extends AbstractCugTest implements NodeTypeConstants { private static String CUG_PATH = "/content/a/rep:cugPolicy"; - private static List NO_CUG_PATH = ImmutableList.of( + private static List NO_CUG_PATH = List.of( "/content", "/content/a", "/content/rep:policy", @@ -116,7 +115,7 @@ public void testDefinesLocation() { assertTrue(CugContext.INSTANCE.definesLocation(TreeLocation.create(root, CUG_PATH))); assertTrue(CugContext.INSTANCE.definesLocation(TreeLocation.create(root, CUG_PATH + "/" + CugConstants.REP_PRINCIPAL_NAMES))); - List existingNoCug = ImmutableList.of( + List existingNoCug = List.of( "/content", "/content/a", "/content/rep:policy" @@ -126,7 +125,7 @@ public void testDefinesLocation() { assertFalse(path, CugContext.INSTANCE.definesLocation(TreeLocation.create(root, path + "/" + CugConstants.REP_PRINCIPAL_NAMES))); } - List nonExistingCug = ImmutableList.of( + List nonExistingCug = List.of( "/content/rep:cugPolicy", UNSUPPORTED_PATH + "/rep:cugPolicy"); for (String path : nonExistingCug) { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java index e9c7b205214..a2ed9357c09 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java @@ -22,7 +22,7 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; @@ -99,12 +99,12 @@ private PermissionProvider createPermissionProvider(ContentSession cs) { } private PermissionProvider createPermissionProvider(Principal... principals) { - return getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getPermissionProvider(root, adminSession.getWorkspaceName(), Set.of(principals)); + return getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getPermissionProvider(root, adminSession.getWorkspaceName(), ImmutableSet.copyOf(principals)); } @Test public void testRead() { - List noAccess = ImmutableList.of( + List noAccess = List.of( "/", UNSUPPORTED_PATH, /* no access */ "/content/a", "/content/a/b", "/content/aa/bb", /* granted by ace, denied by cug */ "/content2" /* granted by cug only */ @@ -113,7 +113,7 @@ public void testRead() { assertFalse(p, testRoot.getTree(p).exists()); } - List readAccess = ImmutableList.of("/content", "/content/subtree", "/content/a/b/c", "/content/aa"); + List readAccess = List.of("/content", "/content/subtree", "/content/a/b/c", "/content/aa"); for (String p : readAccess) { assertTrue(p, testRoot.getTree(p).exists()); } @@ -135,7 +135,7 @@ public void testReadAcl2() throws Exception { @Test public void testReadCug() { - List noAccess = ImmutableList.of( + List noAccess = List.of( "/content/a/rep:cugPolicy", "/content/aa/bb/rep:cugPolicy", "/content2/rep:cugPolicy" ); for (String p : noAccess) { @@ -155,7 +155,7 @@ public void testReadCug2() throws Exception { @Test public void testWrite() throws Exception { - List readOnly = ImmutableList.of("/content", "/content/a/b/c"); + List readOnly = List.of("/content", "/content/a/b/c"); for (String p : readOnly) { try { Tree content = testRoot.getTree(p); @@ -179,7 +179,7 @@ public void testWrite2() throws Exception { assertTrue(pp.isGranted(root.getTree("/content/writeTest"), null, Permissions.ADD_NODE)); assertTrue(pp.isGranted(root.getTree("/content/a/b/c/writeTest"), null, Permissions.ADD_NODE)); - List paths = ImmutableList.of("/content", "/content/a/b/c"); + List paths = List.of("/content", "/content/a/b/c"); for (String p : paths) { Tree content = r.getTree(p); TreeUtil.addChild(content, "writeTest", NT_OAK_UNSTRUCTURED); @@ -197,7 +197,7 @@ public void testWriteAcl() throws Exception { Root r = cs.getLatestRoot(); try { Tree tree = r.getTree("/content/a/b/c"); - tree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN, AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + tree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN, AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); tree.addChild(AccessControlConstants.REP_POLICY).setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME); r.commit(); fail(); @@ -215,7 +215,7 @@ public void testWriteCug() throws Exception { try { // modify the existing cug Tree tree = r.getTree("/content/a/rep:cugPolicy"); - tree.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME, testGroupPrincipal.getName()), Type.STRINGS); + tree.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME, testGroupPrincipal.getName()), Type.STRINGS); r.commit(); fail(); } catch (CommitFailedException e) { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugImportBaseTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugImportBaseTest.java index 510843007e0..0c217d95387 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugImportBaseTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugImportBaseTest.java @@ -31,12 +31,12 @@ import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.security.AccessControlException; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.JackrabbitRepository; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.oak.api.CommitFailedException; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.query.QueryEngineSettings; @@ -191,7 +191,7 @@ private void doImport(Session importSession, String parentPath, String xml) thro static void assertPrincipalNames(@NotNull Set expectedPrincipalNames, @NotNull Value[] principalNames) { assertEquals(expectedPrincipalNames.size(), principalNames.length); - Set result = CollectionUtils.toSet(Iterables.transform(Set.of(principalNames), principalName -> { + Set result = ImmutableSet.copyOf(Iterables.transform(ImmutableSet.copyOf(principalNames), principalName -> { try { return principalName.getString(); } catch (RepositoryException e) { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java index be0551a2f93..9d26e422a25 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java @@ -25,7 +25,6 @@ import javax.jcr.GuestCredentials; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; @@ -88,11 +87,11 @@ public class CugPermissionProviderTest extends AbstractCugTest implements NodeTy PATH_INCUG_MAP.put(INVALID_PATH, false); } - private static final List READABLE_PATHS = ImmutableList.of( + private static final List READABLE_PATHS = List.of( "/content/a/b/c", "/content/a/b/c/jcr:primaryType", "/content/a/b/c/nonExisting", "/content/a/b/c/nonExisting/jcr:primaryType"); - private static final List NOT_READABLE_PATHS = ImmutableList.of( + private static final List NOT_READABLE_PATHS = List.of( "/", "/jcr:primaryType", UNSUPPORTED_PATH, UNSUPPORTED_PATH + "/jcr:primaryType", "/content", "/content/jcr:primaryType", diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugTreePermissionTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugTreePermissionTest.java index f830bbdc0aa..96afce352dc 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugTreePermissionTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugTreePermissionTest.java @@ -17,8 +17,7 @@ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; import java.security.Principal; -import java.util.Set; - +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -57,7 +56,7 @@ private CugTreePermission getCugTreePermission(@NotNull Principal... principals) } private CugTreePermission getCugTreePermission(@NotNull String path, @NotNull Principal... principals) { - CugPermissionProvider pp = createCugPermissionProvider(Set.of(SUPPORTED_PATHS), principals); + CugPermissionProvider pp = createCugPermissionProvider(ImmutableSet.copyOf(SUPPORTED_PATHS), principals); TreePermission targetTp = getTreePermission(root, path, pp); assertTrue(targetTp instanceof CugTreePermission); return (CugTreePermission) targetTp; diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java index 1831b7921d4..b5036c057f6 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; @@ -37,6 +36,8 @@ import javax.jcr.nodetype.NodeDefinitionTemplate; import javax.jcr.nodetype.NodeTypeTemplate; +import java.util.List; + import static java.util.Objects.requireNonNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -64,7 +65,7 @@ public void testChangePrimaryType() { node = root.getTree(SUPPORTED_PATH2); try { node.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_CUG_POLICY, Type.NAME); - node.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + node.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); fail(); } catch (CommitFailedException e) { @@ -118,9 +119,9 @@ public void testPropertyChangedNoCugInvolved() throws Exception { @Test(expected = CommitFailedException.class) public void testChangePrimaryTypeOfCug() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); try { @@ -136,7 +137,7 @@ public void testChangePrimaryTypeOfCug() throws Exception { @Test(expected = CommitFailedException.class) public void testInvalidPrimaryType() throws Exception { Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); @@ -152,7 +153,7 @@ public void testInvalidPrimaryType() throws Exception { @Test(expected = CommitFailedException.class) public void testMissingMixin() throws Exception { Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); @@ -167,9 +168,9 @@ public void testMissingMixin() throws Exception { @Test(expected = CommitFailedException.class) public void testRemoveMixin() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); try { @@ -186,9 +187,9 @@ public void testRemoveMixin() throws Exception { @Test(expected = CommitFailedException.class) public void testCugPolicyWithDifferentName() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, "anotherName", NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); } catch (CommitFailedException e) { @@ -228,7 +229,7 @@ protected Tree getTypes() { public void testJcrNodeTypesOutsideOfSystemIsValidated() throws Exception { Tree n = TreeUtil.addChild(node, JCR_NODE_TYPES, NT_OAK_UNSTRUCTURED); Tree cug = TreeUtil.addChild(n, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/MoveRenameTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/MoveRenameTest.java index 86fca43095d..d197a18991d 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/MoveRenameTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/MoveRenameTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.jetbrains.annotations.NotNull; @@ -28,7 +29,6 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.AccessControlPolicy; import java.security.Principal; -import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -68,7 +68,7 @@ public void before() throws Exception { } private void assertCugPrivileges(@NotNull Principal principal, boolean isGranted, String... paths) { - CugPermissionProvider pp = createCugPermissionProvider(Set.of(SUPPORTED_PATHS), principal); + CugPermissionProvider pp = createCugPermissionProvider(ImmutableSet.copyOf(SUPPORTED_PATHS), principal); for (String path : paths) { assertEquals(isGranted, pp.isGranted(path, Session.ACTION_READ)); } diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java index 462fef159ea..e5a8fef4bb0 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -36,6 +35,7 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.AccessControlPolicy; import java.util.Collections; +import java.util.List; import static org.apache.jackrabbit.oak.commons.PathUtils.ROOT_PATH; import static org.junit.Assert.assertEquals; @@ -421,7 +421,7 @@ public void testRemoveWithInvalidHiddenNestedCugEntry() throws Exception { // cannot be relativized during the reconnect-preparation NodeBuilder before = new MemoryNodeBuilder(getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = before.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of("/nested/out/of/hierarchy", "/content/subtree"), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of("/nested/out/of/hierarchy", "/content/subtree"), Type.STRINGS); NestedCugHook nch = new NestedCugHook(); nch.processCommit(before.getNodeState(), after, new CommitInfo("sid", null)); @@ -442,7 +442,7 @@ public void testRemoveWithMissingHiddenNestedCugEntry() throws Exception { // for that very cug) NodeBuilder after = new MemoryNodeBuilder(getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = after.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); NodeState before = getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH)); @@ -467,7 +467,7 @@ public void testRemoveWithMissingHiddenNestedCugEntry2() throws Exception { // the nested cug of the before-state (and thus cannot clean-up the hidden structure) NodeBuilder before = new MemoryNodeBuilder(getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = before.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); NestedCugHook nch = new NestedCugHook(); nch.processCommit(before.getNodeState(), after, new CommitInfo("sid", null)); @@ -510,7 +510,7 @@ public void testRemoveWithMissingHiddenNestedCugEntryAtRootNode() throws Excepti // the nested /content with the root node (and thus cannot clean-up the hidden structure, // which is already 'cleaned' for that very cug) NodeBuilder after = new MemoryNodeBuilder(getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH))); - after.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + after.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); after.setProperty(HIDDEN_TOP_CUG_CNT, 0); NodeState before = getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH)); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java index c0f0ca07764..586aa8e5d31 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java @@ -21,7 +21,6 @@ import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeLocation; @@ -40,7 +39,7 @@ public class NoCugTest extends AbstractCugTest { - private static final List PATHS = ImmutableList.of(PathUtils.ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); + private static final List PATHS = List.of(PathUtils.ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); private CugPermissionProvider cugPermProvider; diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java index 31ed92b7bf9..dad9f29bc67 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -79,7 +78,7 @@ public void testMayContainCug() { public void testRootPath() { SupportedPaths supportedPaths = new SupportedPaths(Set.of("/")); - List paths = ImmutableList.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); + List paths = List.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); for (String path : paths) { assertTrue(path, supportedPaths.includes(path)); @@ -91,7 +90,7 @@ public void testRootPath() { public void testEmpty() { SupportedPaths supportedPaths = new SupportedPaths(Set.of()); - List paths = ImmutableList.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); + List paths = List.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); for (String path : paths) { assertFalse(path, supportedPaths.includes(path)); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java index d3f534d4efc..caf119c3f68 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -39,7 +38,7 @@ public class TopLevelPathTest extends AbstractCugTest { - private static final List PATHS = ImmutableList.of(ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); + private static final List PATHS = List.of(ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); @Test public void testHasAnyNoCug() { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java index 5ae6789678b..0a90e552537 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.ContentSession; @@ -76,12 +75,12 @@ public void before() throws Exception { // - /content2 : allow everyone, deny testGroup (isolated) setupCugsAndAcls(); - readAccess = ImmutableList.of( + readAccess = List.of( SUPPORTED_PATH, "/content/subtree", "/content/aa"); - noReadAccess = ImmutableList.of( + noReadAccess = List.of( UNSUPPORTED_PATH, /* no access */ "/content2", /* granted by cug only */ "/content/a", /* granted by ace, denied by cug */ diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractEntryTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractEntryTest.java index b8979808fd4..c7daf722bde 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractEntryTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractEntryTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl; @@ -36,7 +37,6 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.security.Principal; -import java.util.Set; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; import static org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants.REP_GLOB; @@ -129,7 +129,7 @@ public void testEquals() throws Exception { private final class TestEntry extends AbstractEntry { TestEntry(@Nullable String oakPath, @NotNull Principal principal, @NotNull PrivilegeBits privilegeBits, @NotNull Restriction... restrictions) throws AccessControlException { - super(oakPath, principal, privilegeBits, Set.of(restrictions), AbstractEntryTest.this.getNamePathMapper()); + super(oakPath, principal, privilegeBits, ImmutableSet.copyOf(restrictions), AbstractEntryTest.this.getNamePathMapper()); } TestEntry(@NotNull AbstractEntry base) throws AccessControlException { diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractPrincipalBasedTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractPrincipalBasedTest.java index 931e4a4292e..b928786709c 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractPrincipalBasedTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AbstractPrincipalBasedTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.ObjectArrays; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -27,7 +28,6 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper; import org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; @@ -49,14 +49,16 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Collections; import java.util.Map; -import java.util.Set; import java.util.UUID; import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public abstract class AbstractPrincipalBasedTest extends AbstractSecurityTest { @@ -112,7 +114,7 @@ protected SecurityProvider initSecurityProvider() { @Override @NotNull protected Privilege[] privilegesFromNames(@NotNull String... privilegeNames) throws RepositoryException { - Iterable pn = Iterables.transform(CollectionUtils.toLinkedSet(privilegeNames), privName -> getNamePathMapper().getJcrName(privName)); + Iterable pn = Iterables.transform(ImmutableSet.copyOf(privilegeNames), privName -> getNamePathMapper().getJcrName(privName)); return super.privilegesFromNames(pn); } @@ -183,7 +185,7 @@ boolean addDefaultEntry(@Nullable String path, @NotNull Principal principal, @Nu @NotNull PrincipalBasedPermissionProvider createPermissionProvider(@NotNull Root root, @NotNull Principal... principals) { - PermissionProvider pp = principalBasedAuthorizationConfiguration.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Set.of(principals)); + PermissionProvider pp = principalBasedAuthorizationConfiguration.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), ImmutableSet.copyOf(principals)); if (pp instanceof PrincipalBasedPermissionProvider) { return (PrincipalBasedPermissionProvider) pp; } else { diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java index 642a6812ceb..ccb3d1977a1 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; @@ -47,7 +46,6 @@ import javax.jcr.security.Privilege; import java.security.Principal; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -561,7 +559,7 @@ public void testAddEntryTree() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } catch (CommitFailedException e) { assertEquals(CommitFailedException.ACCESS, e.getType()); @@ -581,7 +579,7 @@ public void testAddEntryTreeModAcOnSystemPrincipal() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } catch (CommitFailedException e) { assertEquals(CommitFailedException.ACCESS, e.getType()); @@ -612,7 +610,7 @@ public void testAddEntryTreeFullModAc() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/EffectivePolicyTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/EffectivePolicyTest.java index edb50a398ba..32f94958dd4 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/EffectivePolicyTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/EffectivePolicyTest.java @@ -16,13 +16,13 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; import org.apache.jackrabbit.util.Text; @@ -138,7 +138,7 @@ public void testEffectivePolicyByPath() throws Exception { // filter expected entries: only entries that take effect at the target path should be taken into consideration ImmutablePrincipalPolicy byPrincipal = (ImmutablePrincipalPolicy) acMgr.getEffectivePolicies(Set.of(effectivePolicy.getPrincipal()))[0]; - Set expected = CollectionUtils.toSet(Iterables.filter(byPrincipal.getEntries(), entry -> { + Set expected = ImmutableSet.copyOf(Iterables.filter(byPrincipal.getEntries(), entry -> { String effectivePath = ((PrincipalAccessControlList.Entry) entry).getEffectivePath(); return effectivePath != null && Text.isDescendantOrEqual(effectivePath, path); })); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java index 6d87333b096..ad7e90f0e1b 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -36,6 +35,7 @@ import org.jetbrains.annotations.Nullable; import org.mockito.Mockito; +import java.util.Arrays; import java.util.Set; import static org.mockito.ArgumentMatchers.any; @@ -98,7 +98,7 @@ static PropertyState createPrimaryTypeProperty(@NotNull String ntName) { } static PropertyState createMixinTypesProperty(@NotNull String... mixinTypes) { - return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.copyOf(mixinTypes), Type.NAMES); + return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, Arrays.asList(mixinTypes), Type.NAMES); } static FilterProvider mockFilterProvider(boolean canHandle) { diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorLimitedUserTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorLimitedUserTest.java index bcdced199da..257e67b2c8a 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorLimitedUserTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorLimitedUserTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; @@ -93,7 +94,7 @@ private Tree createPolicyEntryTree(@NotNull Root r, @NotNull String effectiveOak policy.setProperty(REP_PRINCIPAL_NAME, getTestSystemUser().getPrincipal().getName()); Tree entry = TreeUtil.addChild(policy, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, effectiveOakPath, Type.PATH); - entry.setProperty(REP_PRIVILEGES, Set.of(privNames), Type.NAMES); + entry.setProperty(REP_PRIVILEGES, ImmutableSet.copyOf(privNames), Type.NAMES); return entry; } diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java index 2205f984f70..66b46e64e0a 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -42,6 +40,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; +import java.util.List; import java.util.Map; import java.util.Set; @@ -525,7 +524,7 @@ public void testAddEntryPrivilegeLookupThrowsRepositoryException() throws Except try { NodeState entry = mockNodeState(NT_REP_PRINCIPAL_ENTRY); when(entry.getProperty(REP_EFFECTIVE_PATH)).thenReturn(PropertyStates.createProperty(REP_EFFECTIVE_PATH,"/path", Type.PATH)); - when(entry.getNames(REP_PRIVILEGES)).thenReturn(ImmutableList.of("privName")); + when(entry.getNames(REP_PRIVILEGES)).thenReturn(List.of("privName")); v.childNodeChanged("entryName", entry, entry); fail("CommitFailedException type OAK code 13 expected."); @@ -554,7 +553,7 @@ public void testAddEntryMissingEffectivePath() throws Exception { try { NodeState entry = mockNodeState(NT_REP_PRINCIPAL_ENTRY); when(entry.getProperty(REP_EFFECTIVE_PATH)).thenReturn(null); - when(entry.getNames(REP_PRIVILEGES)).thenReturn(ImmutableList.of(JCR_READ)); + when(entry.getNames(REP_PRIVILEGES)).thenReturn(List.of(JCR_READ)); v.childNodeChanged("entryName", entry, entry); fail("CommitFailedException type CONSTRAINT code 21 expected."); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java index c5a54cbf0f3..4d5ce01c01f 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList; @@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration; @@ -48,6 +49,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import static org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.Constants.MIX_REP_PRINCIPAL_BASED_MIXIN; import static org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.Constants.REP_PRINCIPAL_POLICY; @@ -518,7 +520,7 @@ public void testGetPrivilegesByPrincipals() throws Exception { } private void assertPrivileges(@NotNull Privilege[] privs, @NotNull String... expectedOakPrivNames) throws Exception { - assertEquals(Set.of(privilegesFromNames(expectedOakPrivNames)), Set.of(privs)); + assertEquals(ImmutableSet.copyOf(privilegesFromNames(expectedOakPrivNames)), ImmutableSet.copyOf(privs)); } @Test @@ -554,7 +556,7 @@ public void testGetEffectivePrincipalsEmptyPaths() throws Exception { Iterator effective = acMgr.getEffectivePolicies(principals, new String[0]); AccessControlPolicy[] expected = acMgr.getEffectivePolicies(principals); - assertArrayEquals(expected, ImmutableList.copyOf(effective).toArray(new AccessControlPolicy[0])); + assertArrayEquals(expected, (CollectionUtils.toList(effective).toArray())); } @Test @@ -567,7 +569,7 @@ public void testGetEffectivePrincipalsReadablePaths() throws Exception { String[] paths = readablePaths.stream().map(oakPath -> namePathMapper.getJcrPath(oakPath)).distinct().toArray(String[]::new); assertEquals(3, paths.length); - List effective = ImmutableList.copyOf(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths)); + List effective = CollectionUtils.toList(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths)); assertEquals(1, effective.size()); assertEquals(ReadPolicy.INSTANCE, effective.get(0)); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java index f27ed5f5565..c8f5bd7bd91 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; @@ -50,6 +49,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -140,7 +140,7 @@ private Tree createEntryTree(@NotNull String oakPath, @NotNull String... privile Tree t = mock(Tree.class); PropertyState path = PropertyStates.createProperty(REP_EFFECTIVE_PATH, oakPath); when(t.getProperty(REP_EFFECTIVE_PATH)).thenReturn(path); - PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES); + PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, Arrays.asList(privilegeNames), Type.NAMES); when(t.getProperty(REP_PRIVILEGES)).thenReturn(privs); Tree rTree = when(mock(Tree.class).getProperties()).thenReturn(Collections.emptySet()).getMock(); when(t.getChild(REP_RESTRICTIONS)).thenReturn(rTree); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java index b969900f80d..a6aabe51378 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.api.security.user.User; @@ -53,6 +52,7 @@ import javax.jcr.security.AccessControlPolicy; import java.security.Principal; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -148,10 +148,10 @@ private List mockPropInfos(@NotNull Map restrictions, } private List mockPropInfos(@NotNull Map restrictions) throws RepositoryException { - List propInfos = new ArrayList(); + List propInfos = new ArrayList<>(); for (Map.Entry r : restrictions.entrySet()) { String jcrName = r.getKey(); - List vs = ImmutableList.copyOf(r.getValue()); + List vs = Arrays.asList(r.getValue()); PropInfo propInfo = mockPropInfo(jcrName); if (!vs.isEmpty()) { TextValue first = when(mock(TextValue.class).getString()).thenReturn(vs.get(0).getString()).getMock(); @@ -574,7 +574,7 @@ public void testStartChildInfoWrongPrivilegesPropertyType() throws Exception { // rep:privileges with wrong type PropInfo propInfo = mockPropInfo(getJcrName(REP_PRIVILEGES)); TextValue tx = when(mock(TextValue.class).getString()).thenReturn(getJcrName(JCR_READ)).getMock(); - List values = ImmutableList.of(tx); + List values = List.of(tx); when(propInfo.getTextValues()).thenReturn(values); when(propInfo.getType()).thenReturn(PropertyType.STRING); propInfos.add(propInfo); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java index e3f84bed9c1..80e1caf9aa7 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; @@ -203,7 +204,7 @@ public void testGetEffectivePoliciesLimitedAccess2() throws Exception { // test-session can read-ac at readable path but cannot access principal-based policy try (ContentSession cs = Java23Subject.doAsPrivileged(getTestSubject(), (PrivilegedExceptionAction) () -> getContentRepository().login(null, null), null)) { PrincipalBasedAccessControlManager testAcMgr = new PrincipalBasedAccessControlManager(getMgrProvider(cs.getLatestRoot()), getFilterProvider()); - Set effective = Set.of(testAcMgr.getEffectivePolicies(path)); + Set effective = ImmutableSet.copyOf(testAcMgr.getEffectivePolicies(path)); assertEquals(1, effective.size()); assertTrue(effective.contains(ReadPolicy.INSTANCE)); diff --git a/oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackendTest.java b/oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackendTest.java index 788ca33e9e2..41acca88007 100644 --- a/oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackendTest.java +++ b/oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackendTest.java @@ -24,6 +24,7 @@ import com.microsoft.azure.storage.blob.SharedAccessBlobPolicy; import org.apache.jackrabbit.core.data.DataRecord; import org.apache.jackrabbit.core.data.DataStoreException; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.ClassRule; @@ -37,8 +38,6 @@ import java.util.EnumSet; import java.util.Properties; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import java.util.stream.StreamSupport; import static com.microsoft.azure.storage.blob.SharedAccessBlobPermissions.ADD; @@ -100,8 +99,7 @@ public void initWithSharedAccessSignature_readWrite() throws Exception { azureBlobStoreBackend.init(); assertWriteAccessGranted(azureBlobStoreBackend, "file"); - assertReadAccessGranted(azureBlobStoreBackend, - concat(BLOBS, "file")); + assertReadAccessGranted(azureBlobStoreBackend, concat(BLOBS, "file")); } @Test @@ -292,7 +290,7 @@ private static Instant yesterday() { } private static Set concat(Set set, String element) { - return Stream.concat(set.stream(), Stream.of(element)).collect(Collectors.toSet()); + return ImmutableSet.builder().addAll(set).add(element).build(); } private static String getConnectionString() { diff --git a/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java b/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java index 7b4a9afa1c2..b0e0c15fb44 100644 --- a/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java +++ b/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java @@ -41,7 +41,6 @@ import com.amazonaws.services.s3.transfer.TransferManager; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.core.data.DataStore; @@ -66,7 +65,7 @@ public class S3DataStoreUtils extends DataStoreUtils { protected static Class S3 = S3DataStore.class; public static List getFixtures() { - return ImmutableList.of(S3.getName()); + return List.of(S3.getName()); } public static boolean isS3DataStore() { diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java index e0f922771d2..8ceaa979b2b 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java @@ -27,7 +27,6 @@ import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.oak.api.jmx.CheckpointMBean; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils; import org.apache.jackrabbit.oak.stats.Clock; @@ -60,7 +59,7 @@ public void gcCheckpointHeld() throws Exception { checkpointMBean.createCheckpoint(100); Set afterCheckpointBlobs = createBlobs(cluster.blobStore, 2, 100); - Set present = CollectionUtils.union(cluster.blobStoreState.blobsPresent, afterCheckpointBlobs); + Set present = Sets.union(cluster.blobStoreState.blobsPresent, afterCheckpointBlobs); long maxGcAge = checkpointMBean.getOldestCheckpointCreationTimestamp() - afterSetupTime; log.info("{} blobs remaining : {}", present.size(), present); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java index 9b2e89767f3..03f71af3596 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java @@ -52,6 +52,7 @@ import ch.qos.logback.classic.Level; import org.apache.jackrabbit.guava.common.collect.Iterators; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.guava.common.io.Closer; import org.apache.jackrabbit.oak.api.Blob; @@ -60,7 +61,6 @@ import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider; import org.apache.jackrabbit.oak.api.blob.BlobUpload; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; import org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector.NotAllRepositoryMarkedException; @@ -214,8 +214,10 @@ public void sharedGC() throws Exception { Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); - Set totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); - Set totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); + Sets.SetView totalPresent = + Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); + Sets.SetView totalAdded = + Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); // Execute mark on the default cluster executeGarbageCollection(cluster, cluster.getCollector(0), true); @@ -236,7 +238,8 @@ public void noSharedGC() throws Exception { Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); - Set totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); + Sets.SetView totalAdded = + Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); Set existingAfterGC = executeGarbageCollection(secondCluster, secondCluster.getCollector(0), false); @@ -257,7 +260,8 @@ public void sharedGCRepositoryCloned() throws Exception { ((SharedDataStore) secondCluster.blobStore).deleteMetadataRecord(REPOSITORY.getNameFromId(secondCluster.repoId)); secondCluster.setRepoId(cluster.repoId); - Set totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); + Sets.SetView totalPresent = + Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); // Execute mark on the default cluster executeGarbageCollection(cluster, cluster.getCollector(0), true); @@ -275,8 +279,10 @@ public void sharedGCRefsOld() throws Exception { Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); - Set totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); - Set totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); + Sets.SetView totalPresent = + Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); + Sets.SetView totalAdded = + Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); clock.waitUntil(clock.getTime() + 5); @@ -303,8 +309,10 @@ public void sharedGCRefsNotOld() throws Exception { Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); - Set totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); - Set totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); + Sets.SetView totalPresent = + Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent); + Sets.SetView totalAdded = + Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded); // Execute mark on the default cluster executeGarbageCollection(cluster, cluster.getCollector(5), true); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java index 1d577b893b2..e36a5695799 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.blob; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.core.data.DataIdentifier; import org.apache.jackrabbit.core.data.DataRecord; import org.apache.jackrabbit.core.data.DataStoreException; @@ -79,7 +77,7 @@ public class SharedDataStoreMarkSweepGarbageCollectorTest { @Before public void setUp() throws IOException { when(whiteboard.track(CheckpointMBean.class)).thenReturn(tracker); - when(tracker.getServices()).thenReturn(ImmutableList.of(checkpointMBean)); + when(tracker.getServices()).thenReturn(List.of(checkpointMBean)); when(blobStore.getType()).thenReturn(SHARED); @@ -116,7 +114,7 @@ public void markAndSweepShouldFailIfNotAllRepositoriesHaveMarkedReferencesAvaila @Test public void markAndSweepShouldSucceedWhenAllRepositoriesAreAvailable() throws Exception { setupSharedDataRecords("REPO1", "REPO1"); - when(blobStore.getAllChunkIds(0L)).thenReturn(ImmutableList.of().iterator()); + when(blobStore.getAllChunkIds(0L)).thenReturn(List.of().iterator()); collector.markAndSweep(false, true); @@ -133,8 +131,8 @@ private void setupSharedDataRecords(final String refRepoId, final String repoRep DataRecord repoDataRecord = mock(DataRecord.class); when(repoDataRecord.getIdentifier()).thenReturn(new DataIdentifier("repository-" + repoRepoId)); - List refs = ImmutableList.of(refDataRecord); - List repos = ImmutableList.of(repoDataRecord); + List refs = List.of(refDataRecord); + List repos = List.of(repoDataRecord); when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REFERENCES.getType())).thenReturn(refs); when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REPOSITORY.getType())).thenReturn(repos); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java index a797063affa..028a88b6502 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java @@ -29,9 +29,7 @@ import java.util.Set; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.core.data.DataIdentifier; @@ -170,7 +168,7 @@ public void testGetAllChunks() throws Exception{ DataIdentifier d10 = new DataIdentifier("d-10"); DataIdentifier d20 = new DataIdentifier("d-20"); DataIdentifier d30 = new DataIdentifier("d-30"); - List dis = ImmutableList.of(d10, d20, d30); + List dis = List.of(d10, d20, d30); List recs = CollectionUtils.toList( Iterables.transform(dis, input -> new TimeDataRecord(input))); OakFileDataStore mockedDS = mock(OakFileDataStore.class); diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java index 9094c55a173..275602a01d8 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.commons; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.jackrabbit.guava.common.collect.Sets.union; import static org.apache.jackrabbit.oak.commons.FileIOUtils.append; import static org.apache.jackrabbit.oak.commons.FileIOUtils.copy; import static org.apache.jackrabbit.oak.commons.FileIOUtils.lexComparator; @@ -60,6 +61,7 @@ import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.guava.common.base.Splitter; +import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.sort.EscapeUtils; import org.jetbrains.annotations.Nullable; @@ -236,7 +238,7 @@ public void appendTest() throws IOException { File f3 = assertWrite(added3.iterator(), false, added3.size()); append(List.of(f2, f3), f1, true); - assertEquals(CollectionUtils.union(CollectionUtils.union(added1, added2), added3), + assertEquals(union(union(added1, added2), added3), readStringsAsSet(new FileInputStream(f1), false)); assertTrue(!f2.exists()); assertTrue(!f3.exists()); @@ -256,7 +258,7 @@ public void appendTestNoDelete() throws IOException { append(List.of(f2, f3), f1, false); - assertEquals(CollectionUtils.union(CollectionUtils.union(added1, added2), added3), + assertEquals(union(union(added1, added2), added3), readStringsAsSet(new FileInputStream(f1), false)); assertTrue(f2.exists()); assertTrue(f3.exists()); @@ -292,7 +294,7 @@ public void appendRandomizedTest() throws Exception { append(List.of(f2), f1, true); - assertEquals(CollectionUtils.union(added1, added2), + assertEquals(union(added1, added2), readStringsAsSet(new FileInputStream(f1), true)); } @@ -306,7 +308,7 @@ public void appendWithLineBreaksTest() throws IOException { append(List.of(f1), f2, true); - assertEquals(CollectionUtils.union(added1, added2), readStringsAsSet(new FileInputStream(f2), true)); + assertEquals(union(added1, added2), readStringsAsSet(new FileInputStream(f2), true)); } @Test diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java index 8011eb15b6d..1cb0ecf497a 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java @@ -37,7 +37,7 @@ import org.apache.commons.io.LineIterator; import org.apache.jackrabbit.guava.common.base.Splitter; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.io.FileLineDifferenceIterator; import org.jetbrains.annotations.Nullable; import org.junit.Test; @@ -159,12 +159,12 @@ private static List escape(List list) { private static void assertReverseDiff(String marked, String all, List diff) throws IOException { Iterator itr = createItr(all, marked); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } private static void assertDiff(String marked, String all, List diff) throws IOException { Iterator itr = createItr(marked, all); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } private static Iterator createItr(String marked, String all) throws IOException { @@ -189,6 +189,6 @@ public String apply(@Nullable String input) { } }); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } } diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java index 9508e4e4321..018a3fcc433 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java @@ -188,75 +188,6 @@ public void nullArrayToSet() { CollectionUtils.toSet((String[])null); } - @Test - public void arrayToLinkedSet() { - final Set s = CollectionUtils.toLinkedSet(data); - Assert.assertEquals(s, CollectionUtils.toLinkedSet(data.toArray())); - } - - @Test - public void arrayContainingNullToLinkedSet() { - final Set expected = Collections.singleton(null); - final Set result = CollectionUtils.toLinkedSet((String)null); - Assert.assertEquals(expected, result); - } - - @Test(expected = NullPointerException.class) - public void nullArrayToLinkedSet() { - CollectionUtils.toLinkedSet((String[])null); - } - - @Test - public void testUnionWithNonEmptySets() { - final Set set1 = Set.of("a", "b", "c"); - final Set set2 = Set.of("d", "e", "f"); - - final Set expected = Set.of("a", "b", "c", "d", "e", "f"); - Assert.assertEquals(expected, CollectionUtils.union(set1, set2)); - } - - @Test - public void testUnionWithEmptySet() { - final Set set1 = Set.of("a", "b", "c"); - final Set set2 = new HashSet<>(); - - final Set expected = Set.of("a", "b", "c"); - Assert.assertEquals(expected, CollectionUtils.union(set1, set2)); - } - - @Test - public void testUnionWithBothEmptySets() { - final Set set1 = new HashSet<>(); - final Set set2 = new HashSet<>(); - - Assert.assertEquals(new HashSet<>(), CollectionUtils.union(set1, set2)); - } - - @Test(expected = NullPointerException.class) - public void testUnionWithNullFirstSet() { - Set set1 = null; - Set set2 = Set.of("a", "b", "c"); - - CollectionUtils.union(set1, set2); - } - - @Test(expected = NullPointerException.class) - public void testUnionWithNullSecondSet() { - Set set1 = Set.of("a", "b", "c"); - Set set2 = null; - - CollectionUtils.union(set1, set2); - } - - @Test - public void testUnionWithOverlappingSets() { - final Set set1 = Set.of("a", "b", "c"); - final Set set2 = Set.of("b", "c", "d"); - - final Set expected = Set.of("a", "b", "c", "d"); - Assert.assertEquals(expected, CollectionUtils.union(set1, set2)); - } - @Test public void iteratorToIIteratable() { Iterator iterator = List.of("a", "b", "c").iterator(); diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java index cf8423038a9..1006d190acf 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java @@ -28,8 +28,7 @@ import java.util.List; import java.util.Set; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -106,7 +105,7 @@ private void assertConstraints(List paths) throws IOException { Collections.sort(paths, comparator); collector.sort(); - List sortedPaths = ImmutableList.copyOf(collector.getIds()); + List sortedPaths = CollectionUtils.toList(collector.getIds()); assertEquals(paths.size(), sortedPaths.size()); assertEquals(paths, sortedPaths); } @@ -123,7 +122,7 @@ private static List createTestPaths(int depth, boolean permutation){ if (permutation) { List newRoots = new ArrayList<>(); - CollectionUtils.permutations(rootPaths). + org.apache.commons.collections4.CollectionUtils.permutations(rootPaths). stream(). sorted((a, b) -> Arrays.compare(a.toArray(new String[0]), b.toArray(new String[0]))). forEach(permuts -> newRoots.add(String.join("", permuts))); diff --git a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java index d8763fc186a..33817431de3 100644 --- a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java +++ b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.spi.mount; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -27,12 +25,13 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; public class MountInfoTest { @Test public void testIsMounted() throws Exception{ - MountInfo md = new MountInfo("foo", false, of("/x/y"), of("/a", "/b")); + MountInfo md = new MountInfo("foo", false, List.of("/x/y"), List.of("/a", "/b")); assertTrue(md.isMounted("/a")); assertTrue(md.isMounted("/b")); assertTrue(md.isMounted("/b/c/d")); @@ -45,7 +44,7 @@ public void testIsMounted() throws Exception{ @Test public void testIsUnder() { - MountInfo md = new MountInfo("foo", false, Collections.emptyList(), of("/apps", "/etc/config", "/content/my/site", "/var")); + MountInfo md = new MountInfo("foo", false, Collections.emptyList(), List.of("/apps", "/etc/config", "/content/my/site", "/var")); assertTrue(md.isUnder("/etc")); assertTrue(md.isUnder("/content")); assertTrue(md.isUnder("/content/my")); @@ -56,7 +55,7 @@ public void testIsUnder() { @Test public void testIsDirectlyUnder() { - MountInfo md = new MountInfo("foo", false, Collections.emptyList(), of("/apps", "/etc/my/config", "/var")); + MountInfo md = new MountInfo("foo", false, Collections.emptyList(), List.of("/apps", "/etc/my/config", "/var")); assertFalse(md.isDirectlyUnder("/etc")); assertTrue(md.isDirectlyUnder("/etc/my")); assertFalse(md.isDirectlyUnder("/etc/my/config")); @@ -65,7 +64,7 @@ public void testIsDirectlyUnder() { @Test public void testSupportFragment() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertFalse(md.isSupportFragment("/")); assertTrue(md.isSupportFragment("/apps")); @@ -86,7 +85,7 @@ public void testSupportFragment() { @Test public void testSupportFragmentUnder() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertTrue(md.isSupportFragmentUnder("/")); assertTrue(md.isSupportFragmentUnder("/apps")); @@ -107,7 +106,7 @@ public void testSupportFragmentUnder() { @Test public void testIsMountedWithFragments() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertFalse(md.isMounted("/oak:mount-foo")); assertTrue(md.isMounted("/apps/oak:mount-foo")); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java index 3eb02946fe9..76b232d885a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.core; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.LazyValue; @@ -31,6 +30,8 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; + import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_ACCESSIBLE; import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_NON_ACCESSIBLE; import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_NON_EXISTING; @@ -266,7 +267,7 @@ public void testGetPropertiesCanReadProperties() { @Test public void testGetPropertiesAfterSet() { - secureNodeBuilder.setProperty(PropertyStates.createProperty("another", ImmutableList.of("v", "v2"), Type.STRINGS)); + secureNodeBuilder.setProperty(PropertyStates.createProperty("another", List.of("v", "v2"), Type.STRINGS)); assertEquals(2, Iterables.size(secureNodeBuilder.getProperties())); } @@ -291,7 +292,7 @@ public void testGetBooleanTypeBoolean() { @Test public void testGetBooleanTypeBooleans() { - secureNodeBuilder.setProperty("booleans", ImmutableList.of(true, false), Type.BOOLEANS); + secureNodeBuilder.setProperty("booleans", List.of(true, false), Type.BOOLEANS); assertFalse(secureNodeBuilder.getBoolean("booleans")); } @@ -304,7 +305,7 @@ public void testGetString() { @Test public void testGetStringTypeStrings() { - secureNodeBuilder.setProperty("strings", ImmutableList.of("a", "b"), Type.STRINGS); + secureNodeBuilder.setProperty("strings", List.of("a", "b"), Type.STRINGS); assertNull(secureNodeBuilder.getString("strings")); } @@ -323,7 +324,7 @@ public void testGetName() { @Test public void testGetNameTypeNames() { - secureNodeBuilder.setProperty("names", ImmutableList.of("a", "b"), Type.NAMES); + secureNodeBuilder.setProperty("names", List.of("a", "b"), Type.NAMES); assertNull(secureNodeBuilder.getName("names")); } @@ -342,7 +343,7 @@ public void testGetNames() { @Test public void testGetNamesTypeNames() { - Iterable names = ImmutableList.of("a", "b"); + Iterable names = List.of("a", "b"); secureNodeBuilder.setProperty("names", names, Type.NAMES); assertTrue(Iterables.elementsEqual(names, secureNodeBuilder.getNames("names"))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java index a68a3d08474..0c4f1df13f5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.plugins.atomic; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; + import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.oak.api.Type.LONG; import static org.apache.jackrabbit.oak.api.Type.NAMES; @@ -213,7 +213,7 @@ private static void assertTotalCountersValue(@NotNull final Iterable names = CollectionUtils.toSet(service.getAsyncLanes()); + Set names = ImmutableSet.copyOf(service.getAsyncLanes()); assertThat(names, containsInAnyOrder("async", "foo-async")); service.bindStatsMBeans(async.getIndexStats()); @@ -61,7 +64,7 @@ public void info() throws Exception{ AsyncIndexUpdate async = new AsyncIndexUpdate("foo-async", store, provider); async.run(); - Set names = CollectionUtils.toSet(service.getAsyncLanes()); + Set names = ImmutableSet.copyOf(service.getAsyncLanes()); assertThat(names, containsInAnyOrder("foo-async")); service.bindStatsMBeans(async.getIndexStats()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java index 4ccea8d9fe3..39a0e126e60 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java @@ -97,7 +97,8 @@ import org.junit.Ignore; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Maps; import ch.qos.logback.classic.Level; @@ -209,10 +210,10 @@ public void testAsyncDouble() throws Exception { PropertyIndexLookup lookup = new PropertyIndexLookup(root); assertEquals(Set.of("testRoot"), find(lookup, "foo", "abc")); - assertEquals(Set. of(), find(lookup, "foo", "def")); - assertEquals(Set. of(), find(lookup, "foo", "ghi")); + assertEquals(ImmutableSet. of(), find(lookup, "foo", "def")); + assertEquals(ImmutableSet. of(), find(lookup, "foo", "ghi")); - assertEquals(Set. of(), find(lookup, "bar", "abc")); + assertEquals(ImmutableSet. of(), find(lookup, "bar", "abc")); assertEquals(Set.of("testRoot"), find(lookup, "bar", "def")); assertEquals(Set.of("testSecond"), find(lookup, "bar", "ghi")); @@ -266,7 +267,7 @@ public void testAsyncDoubleSubtree() throws Exception { .getChildNode("newchild").getChildNode("other")); assertEquals(Set.of("testChild"), find(lookupChild, "foo", "xyz")); - assertEquals(Set. of(), + assertEquals(ImmutableSet. of(), find(lookupChild, "foo", "abc")); } @@ -1880,7 +1881,7 @@ public void validatorProviderInvocation() throws Exception{ AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider); CollectingValidatorProvider v = new CollectingValidatorProvider(); - async.setValidatorProviders(ImmutableList.of(v)); + async.setValidatorProviders(List.of(v)); async.run(); assertFalse(v.visitedPaths.isEmpty()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java index cb2e87faaf8..30931b342c0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java @@ -44,12 +44,12 @@ import java.util.Calendar; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; @@ -554,15 +554,15 @@ public void testMissingProviderWithAsyncDef() throws Exception { // create async defs with nrt and sync mixed in createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "nrtIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "nrt"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run", "nrt"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncSyncIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "sync"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run", "sync"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); // node states to run hook on diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java index 2ace0da3ade..dac5aa14990 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.importer; import java.io.File; @@ -27,12 +26,12 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.felix.inventory.Format; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.inventory.IndexDefinitionPrinter; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory; @@ -144,7 +143,7 @@ public void newIndexAndOrderableChildren() throws Exception{ NodeBuilder idxBuilder = updater.apply(builder, "/oak:index/barIndex"); PropertyState childOrder = builder.getChildNode("oak:index").getProperty(":childOrder"); - List names = ImmutableList.copyOf(childOrder.getValue(Type.NAMES)); + List names = CollectionUtils.toList(childOrder.getValue(Type.NAMES)); assertEquals(asList("fooIndex", "barIndex"), names); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java index b641d3bb322..750c36ae2f3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.nodetype; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition; @@ -62,7 +61,7 @@ private static Tree child(Tree t, String n, String type) { private static void mixLanguage(Tree t, String n) { Tree c = t.addChild(n); c.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME); - c.setProperty(JCR_MIXINTYPES, of("mix:language"), Type.NAMES); + c.setProperty(JCR_MIXINTYPES, List.of("mix:language"), Type.NAMES); } @Test @@ -86,8 +85,8 @@ public void query() throws Exception { assertQuery("select [jcr:path] from [nt:unstructured] ", new ArrayList()); - assertQuery("select [jcr:path] from [nt:folder] ", of("/c", "/d")); - assertQuery("select [jcr:path] from [mix:language] ", of("/e", "/f")); + assertQuery("select [jcr:path] from [nt:folder] ", List.of("/c", "/d")); + assertQuery("select [jcr:path] from [mix:language] ", List.of("/e", "/f")); setTraversalEnabled(true); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java index b10262c6a2a..31df7419fe3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java @@ -30,7 +30,6 @@ import javax.jcr.query.Query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -61,7 +60,7 @@ public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); IndexUtils.createIndexDefinition( index, "xyz", true, false, - ImmutableList.of("x", "y", "z", "w"), null); + List.of("x", "y", "z", "w"), null); } }) .with(new OpenSecurityProvider()) @@ -79,7 +78,7 @@ public void query() throws Exception { root.commit(); setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [x] is not null", - ImmutableList.of("/a")); + List.of("/a")); List lines = executeQuery( "explain select [jcr:path] from [nt:base] where [x] is not null", @@ -105,13 +104,13 @@ public void query() throws Exception { assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [y] = 'foo'", - ImmutableList.of("/a")); + List.of("/a")); assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [z] = 'foo'", - ImmutableList.of("/a", "/c")); + List.of("/a", "/c")); assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [y] = 'bar'", - ImmutableList.of("/a", "/b")); + List.of("/a", "/b")); setTraversalEnabled(false); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java index baac33ba97f..58cd459cad9 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java @@ -20,6 +20,7 @@ import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getOrCreateOakIndex; import java.util.ArrayList; +import java.util.List; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -33,8 +34,6 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class MultipleIndicesTest extends AbstractQueryTest { @Override @@ -46,10 +45,10 @@ protected ContentRepository createRepository() { public void initialize(@NotNull NodeBuilder builder) { createIndexDefinition( getOrCreateOakIndex(builder), "pid", - true, false, ImmutableList.of("pid"), null); + true, false, List.of("pid"), null); createIndexDefinition( getOrCreateOakIndex(builder.child("content")), - "pid", true, false, ImmutableList.of("pid"), + "pid", true, false, List.of("pid"), null); } }) @@ -80,13 +79,13 @@ public void query() throws Exception { new ArrayList()); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'foo'", - ImmutableList.of("/", "/a", "/c", "/content/x")); + List.of("/", "/a", "/c", "/content/x")); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'bar'", - ImmutableList.of("/b", "/content/z")); + List.of("/b", "/content/z")); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'baz'", - ImmutableList.of("/content/y")); + List.of("/content/y")); setTraversalEnabled(true); } @@ -109,11 +108,11 @@ public void emptyStringValue() throws CommitFailedException { setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'value'", - ImmutableList.of("/node-1")); + List.of("/node-1")); assertQuery("select [jcr:path] from [nt:base] where [pid] = ''", - ImmutableList.of("/node-2")); + List.of("/node-2")); assertQuery("select [jcr:path] from [nt:base] where [pid] = ':'", - ImmutableList.of("/node-3")); + List.of("/node-3")); setTraversalEnabled(true); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java index 7e64b603aff..e594b0d9cef 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java @@ -30,7 +30,6 @@ import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; @@ -60,7 +59,7 @@ public class OrderedPropertyIndexEditorProviderTest { private NodeBuilder createIndexDef(NodeBuilder root) throws RepositoryException { return IndexUtils.createIndexDefinition( root.child(IndexConstants.INDEX_DEFINITIONS_NAME), indexName, false, - ImmutableList.of(indexedProperty), null, OrderedIndex.TYPE, null); + List.of(indexedProperty), null, OrderedIndex.TYPE, null); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java index aa1269a518d..d977728e409 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java @@ -23,7 +23,6 @@ import javax.jcr.query.Query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; import org.apache.jackrabbit.oak.api.Tree; @@ -49,7 +48,7 @@ protected ContentRepository createRepository() { public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); IndexUtils.createIndexDefinition(index, "myProp", true, - false, ImmutableList.of("myProp"), null); + false, List.of("myProp"), null); } }) .with(new OpenSecurityProvider()) @@ -68,7 +67,7 @@ public void query() throws Exception { root.commit(); setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [n/myProp] is not null", - ImmutableList.of("/a", "/b")); + List.of("/a", "/b")); List lines = executeQuery( "explain select [jcr:path] from [nt:base] where [n/myProp] is not null", @@ -79,7 +78,7 @@ public void query() throws Exception { assertQuery( "select [jcr:path] from [nt:base] where [n/myProp] = 'foo'", - ImmutableList.of("/a")); + List.of("/a")); setTraversalEnabled(false); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java index 9086156f8c7..3e55d5d2d34 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.property; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.Type.NAMES; import static org.apache.jackrabbit.oak.api.Type.STRINGS; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.PROPERTY_NAMES; @@ -49,7 +48,7 @@ protected ContentRepository createRepository() { @Override protected void createTestIndexNode() throws Exception { Tree index = super.createTestIndexNode(root.getTree("/"), TYPE); - index.setProperty(PROPERTY_NAMES, of(INDEXED_PROPERTY), NAMES); + index.setProperty(PROPERTY_NAMES, List.of(INDEXED_PROPERTY), NAMES); index.setProperty(REINDEX_PROPERTY_NAME, true); root.commit(); } @@ -66,19 +65,19 @@ public void oak2146() throws Exception { // adding /content/node1 { a, b } Tree node = content.addChild("node1"); - node.setProperty(INDEXED_PROPERTY, of("a", "b"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("a", "b"), STRINGS); expected.add(node.getPath()); // adding /content/node2 { c, d } node = content.addChild("node2"); - node.setProperty(INDEXED_PROPERTY, of("c", "d"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("c", "d"), STRINGS); expected.add(node.getPath()); // adding nodes with {a, x} and {c, x} these should not be returned node = content.addChild("node3"); - node.setProperty(INDEXED_PROPERTY, of("a", "x"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("a", "x"), STRINGS); node = content.addChild("node4"); - node.setProperty(INDEXED_PROPERTY, of("c", "x"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("c", "x"), STRINGS); root.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java index bf86b4d5ba9..49eb50bd37d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.property; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.Type.NAMES; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.PROPERTY_NAMES; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; @@ -34,6 +33,8 @@ import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.junit.Test; +import java.util.List; + public class ValuePatternPropertyIndexTests extends AbstractQueryTest { private static final String INDEXED_PROPERTY = "indexedProperty"; @@ -57,7 +58,7 @@ public void valuePattern() throws Exception { private void valuePattern(String middle, String plan) throws Exception { Tree index = super.createTestIndexNode(root.getTree("/"), TYPE); - index.setProperty(PROPERTY_NAMES, of(INDEXED_PROPERTY), NAMES); + index.setProperty(PROPERTY_NAMES, List.of(INDEXED_PROPERTY), NAMES); index.setProperty(IndexConstants.VALUE_INCLUDED_PREFIXES, "hello" + middle + "world"); index.setProperty(REINDEX_PROPERTY_NAME, true); root.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java index f00db7a58bd..97ad3cce87d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java @@ -16,9 +16,9 @@ */ package org.apache.jackrabbit.oak.plugins.index.property.strategy; -import static org.apache.jackrabbit.guava.common.base.Suppliers.memoize; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Arrays.asList; + +import static org.apache.jackrabbit.guava.common.base.Suppliers.memoize; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.ENTRY_COUNT_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.KEY_COUNT_PROPERTY_NAME; @@ -31,12 +31,14 @@ import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.function.Supplier; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.spi.query.Filter; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -306,21 +308,21 @@ public void nonRootStorage() throws Exception{ indexMeta.setChildNode(INDEX_CONTENT_NODE_NAME, builder.getNodeState()); Iterable paths = store.query(filter, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("a", "a/c", "b")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("a", "a/c", "b")); FilterImpl filter2 = FilterImpl.newTestInstance(); filter2.restrictPath("/content/a", Filter.PathRestriction.ALL_CHILDREN); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("a", "a/c")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("a", "a/c")); store = new ContentMirrorStoreStrategy(INDEX_CONTENT_NODE_NAME, "/content", true); paths = store.query(filter, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b")); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a", "/content/a/c")); } private static void assertInRange(String msg, double expected, double actual) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java index c68b1caf3ac..4179578b1e3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java @@ -47,7 +47,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_UUID; import static org.apache.jackrabbit.JcrConstants.NT_BASE; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; @@ -80,11 +79,11 @@ public void basicReferenceHandling() throws Exception{ FilterImpl f = createFilter(indexed, NT_BASE); f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE); - assertFilter(f, new ReferenceIndex(), indexed, of("/a", "/b")); + assertFilter(f, new ReferenceIndex(), indexed, List.of("/a", "/b")); FilterImpl f2 = createFilter(indexed, NT_BASE); f2.restrictProperty("*", Operator.EQUAL, newReference("u2"), PropertyType.WEAKREFERENCE); - assertFilter(f2, new ReferenceIndex(), indexed, of("/c")); + assertFilter(f2, new ReferenceIndex(), indexed, List.of("/c")); } @Test @@ -117,11 +116,11 @@ public void referenceHandlingWithMounts() throws Exception{ f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE); // System.out.println(NodeStateUtils.toString(NodeStateUtils.getNode(indexed, "/oak:index/reference"))); - assertFilter(f, referenceIndex, indexed, of("/a/x", "/b")); + assertFilter(f, referenceIndex, indexed, List.of("/a/x", "/b")); FilterImpl f2 = createFilter(indexed, NT_BASE); f2.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.WEAKREFERENCE); - assertFilter(f2, referenceIndex, indexed, of("/c", "/a/y")); + assertFilter(f2, referenceIndex, indexed, List.of("/c", "/a/y")); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java index 1a1102c218d..55bd4b463b4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java @@ -30,8 +30,8 @@ import static org.junit.Assert.fail; import java.util.Collections; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -129,7 +129,7 @@ public void addNamedPropertyWithBadRequiredType() { NodeBuilder testNode = builder.child("testNode"); testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); - testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES); + testNode.setProperty(JCR_MIXINTYPES, List.of("mix:title"), Type.NAMES); testNode.setProperty("jcr:title", true); try { @@ -148,7 +148,7 @@ public void changeNamedPropertyToBadRequiredType() { NodeBuilder builder = root.builder(); NodeBuilder testNode = builder.child("testNode"); testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); - testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES); + testNode.setProperty(JCR_MIXINTYPES, List.of("mix:title"), Type.NAMES); testNode.setProperty("jcr:title", "title"); NodeState before = builder.getNodeState(); @@ -177,7 +177,7 @@ public void addMandatoryPropertyWithBadRequiredType() { NodeBuilder ace = acl.child("first"); ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME); ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.STRINGS); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); @@ -199,12 +199,12 @@ public void changeMandatoryPropertyToBadRequiredType() { NodeBuilder ace = acl.child("first"); ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME); ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.NAMES); NodeState before = builder.getNodeState(); // change to invalid type - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.STRINGS); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); @@ -316,7 +316,7 @@ public void malformedUUID() throws CommitFailedException { builder = root.builder(); before = builder.getNodeState(); - builder.child("testcontent").setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REFERENCEABLE), Type.NAMES); + builder.child("testcontent").setProperty(JCR_MIXINTYPES, List.of(MIX_REFERENCEABLE), Type.NAMES); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); fail("should not be able to change mixin due to illegal uuid format"); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java index ee0cde6907a..2f878c65dae 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java @@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_BASE; @@ -143,7 +142,7 @@ public void oakIndexableSuccessful() throws IOException, CommitFailedException { Tree test = root.getTree("/").addChild("test"); test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME); - test.setProperty(JCR_MIXINTYPES, of(MIX_INDEXABLE), Type.NAMES); + test.setProperty(JCR_MIXINTYPES, List.of(MIX_INDEXABLE), Type.NAMES); test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); root.commit(); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java index 8aecb03eca3..5d6f4ff9fdf 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -64,10 +62,10 @@ public void inexistence() throws Exception { root.commit(); String query1 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [z] IS NULL"; - List expected1 = ImmutableList.of("/a/x", "/a/x/y"); + List expected1 = List.of("/a/x", "/a/x/y"); String query2 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x') AND [z] IS NULL"; - List expected2 = ImmutableList.of("/a/x/y"); + List expected2 = List.of("/a/x/y"); assertQuery(query1, expected1); assertQuery(query2, expected2); @@ -88,12 +86,12 @@ public void relativeInexistence() throws Exception { root.commit(); String query1 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [y/z] IS NULL"; - List expected1 = ImmutableList.of("/a/x", "/a/x/y", "/a/x1"); - List expectedOld1 = ImmutableList.of("/a/x"); + List expected1 = List.of("/a/x", "/a/x/y", "/a/x1"); + List expectedOld1 = List.of("/a/x"); String query2 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x') AND [y/z] IS NULL"; - List expected2 = ImmutableList.of("/a/x/y"); - List expectedOld2 = ImmutableList.of(); + List expected2 = List.of("/a/x/y"); + List expectedOld2 = List.of(); assertQuery(query1, expected1); assertQuery(query2, expected2); @@ -112,8 +110,8 @@ public void relativeInexistence() throws Exception { System.setProperty("oak.useOldInexistenceCheck", "false"); String query3 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x2') AND [y/z] IS NULL"; - List expected3 = ImmutableList.of("/a/x2/z", "/a/x2/z1/y"); - List expectedOld3 = ImmutableList.of(); + List expected3 = List.of("/a/x2/z", "/a/x2/z1/y"); + List expectedOld3 = List.of(); assertQuery(query3, expected3); @@ -131,8 +129,8 @@ public void deeperRelativeInexistence() throws Exception { root.commit(); String query = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [w/y/z] IS NULL"; - List expected = ImmutableList.of("/a/x", "/a/x1", "/a/x1/w", "/a/x2", "/a/x2/w", "/a/x2/w/y"); - List expectedOld = ImmutableList.of("/a/x2"); + List expected = List.of("/a/x", "/a/x1", "/a/x1/w", "/a/x2", "/a/x2/w", "/a/x2/w/y"); + List expectedOld = List.of("/a/x2"); assertQuery(query, expected); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java index 24d437e115e..77298990ed1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.query; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -29,6 +28,8 @@ import org.apache.jackrabbit.oak.query.ast.OrImpl; import org.junit.Test; +import java.util.List; + public class QueryCostOverheadTest { @Test public void getCostOverhead() { @@ -54,14 +55,14 @@ public void getCostOverhead() { c1 = new ComparisonImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new OrImpl(of(c1, c2, c3)); + c = new OrImpl(List.of(c1, c2, c3)); query = createQuery(c); assertTrue(query.containsUnfilteredFullTextCondition()); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); c4 = new ComparisonImpl(null, null, null); - c1 = new OrImpl(of(c2, c3, c4)); + c1 = new OrImpl(List.of(c2, c3, c4)); c5 = mock(DescendantNodeImpl.class); c = new AndImpl(c1, c5); query = createQuery(c); @@ -74,20 +75,20 @@ public void getCostOverhead() { c1 = new FullTextSearchImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new OrImpl(of(c1, c2, c3)); + c = new OrImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); c1 = new ComparisonImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new AndImpl(of(c1, c2, c3)); + c = new AndImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); c1 = new ComparisonImpl(null, null, null); c2 = new ComparisonImpl(null, null, null); - c = new AndImpl(of(c1, c2, c3)); + c = new AndImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java index f8685022ec9..8092a1f1913 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.query; -import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; -import static javax.jcr.query.Query.JCR_SQL2; +import static java.util.Objects.requireNonNull;import static javax.jcr.query.Query.JCR_SQL2; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.api.Type.NAME; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; @@ -125,7 +123,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format("SELECT * FROM [%s] WHERE p = 'a' OR p = 'b'", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b", "/test2/a"); + expected = List.of("/test/a", "/test/b", "/test2/a"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -137,7 +135,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE p = 'a' OR p = 'b' OR p = 'c' OR p = 'd' OR p = 'e' ", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b", "/test/c", "/test/d", "/test/e", "/test2/a"); + expected = List.of("/test/a", "/test/b", "/test/c", "/test/d", "/test/e", "/test2/a"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -149,7 +147,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE (p = 'a' OR p = 'b') AND (p1 = 'a1' OR p1 = 'b1')", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -161,7 +159,8 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE (p = 'a' AND p1 = 'a1') OR (p = 'b' AND p1 = 'b1')", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -176,7 +175,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { + "OR c.[p3] = 'a') " + "AND ISDESCENDANTNODE(c, '/test') " + "ORDER BY added DESC"; - expected = of("/test/a", "/test/b", "/test/c"); + expected = List.of("/test/a", "/test/b", "/test/c"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java index fc39b400575..f3e02547dca 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java @@ -44,8 +44,6 @@ import org.junit.Before; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class TraversalAvoidanceTest extends AbstractQueryTest { Whiteboard wb; @@ -192,7 +190,7 @@ void restPlans() { @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(queryIndex); + return List.of(queryIndex); } } @@ -248,7 +246,7 @@ public String getIndexName() { @Override public List getPlans(Filter filter, List sortOrder, NodeState rootState) { - return ImmutableList.copyOf(plans); + return List.copyOf(plans); } @Override diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java index a6afdcbb304..ca77a4f17a0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java @@ -16,13 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.query.index; import java.util.List; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -64,7 +62,7 @@ public void uuidIndexQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] = '"+uuid+"' ", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should not be invoked", 0, testIndexProvider.index.invocationCount); } @@ -77,7 +75,7 @@ public void uuidIndexNotNullQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] is not null", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should be invoked", 1, testIndexProvider.index.invocationCount); } @@ -91,7 +89,7 @@ public void uuidIndexInListQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] in('" + uuid + "', '" + uuid2 + "')", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should be invoked", 1, testIndexProvider.index.invocationCount); } @@ -101,7 +99,7 @@ private static class TestIndexProvider implements QueryIndexProvider { @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java index 69f5973a6d0..07f17b34199 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java @@ -14,7 +14,7 @@ package org.apache.jackrabbit.oak.query.index; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; + import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; import static org.apache.jackrabbit.oak.api.Type.LONG; @@ -37,8 +37,6 @@ import org.junit.Ignore; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Tests the query engine using the default index implementation: the * {@link TraversingIndex} @@ -71,7 +69,7 @@ public void testFullTextTerm() throws Exception { node.setProperty("jcr:mimeType", "text/plain"); root.commit(); assertQuery("//*[jcr:contains(., 'text/plain')]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); } @Test @@ -83,10 +81,10 @@ public void testFullTextTermName() throws Exception { root.commit(); assertQuery("//*[jcr:contains(., 'testFullTextTermNameSimple')]", "xpath", - ImmutableList.of("/content/testFullTextTermNameSimple")); + List.of("/content/testFullTextTermNameSimple")); assertQuery("//*[jcr:contains(., 'testFullTextTermNameFile.txt')]", "xpath", - ImmutableList.of("/content/testFullTextTermNameFile.txt")); + List.of("/content/testFullTextTermNameFile.txt")); } @Test @@ -95,13 +93,13 @@ public void testMultiNotEqual() throws Exception { c.addChild("one").setProperty("prop", "value"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaa", "value", "bbb"), Type.STRINGS); + List.of("aaa", "value", "bbb"), Type.STRINGS); c.addChild("three").setProperty("prop", - ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); + List.of("aaa", "bbb", "ccc"), Type.STRINGS); root.commit(); assertQuery("//*[@prop != 'value']", "xpath", - ImmutableList.of("/content/two", "/content/three")); + List.of("/content/two", "/content/three")); } @Test @@ -110,13 +108,13 @@ public void testMultiAndEquals() throws Exception { c.addChild("one").setProperty("prop", "aaa"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); - c.addChild("three").setProperty("prop", ImmutableList.of("aaa", "bbb"), + List.of("aaa", "bbb", "ccc"), Type.STRINGS); + c.addChild("three").setProperty("prop", List.of("aaa", "bbb"), Type.STRINGS); root.commit(); assertQuery("//*[(@prop = 'aaa' and @prop = 'bbb' and @prop = 'ccc')]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -125,13 +123,13 @@ public void testMultiAndLike() throws Exception { c.addChild("one").setProperty("prop", "aaaBoom"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); - c.addChild("three").setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"), + List.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); + c.addChild("three").setProperty("prop", List.of("aaaBoom", "bbbBoom"), Type.STRINGS); root.commit(); assertQuery("//*[(jcr:like(@prop, 'aaa%') and jcr:like(@prop, 'bbb%') and jcr:like(@prop, 'ccc%'))]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -141,17 +139,17 @@ public void testSubPropertyMultiAndEquals() throws Exception { c.addChild("one").addChild("child").setProperty("prop", "aaa"); c.addChild("two") .addChild("child") - .setProperty("prop", ImmutableList.of("aaa", "bbb", "ccc"), + .setProperty("prop", List.of("aaa", "bbb", "ccc"), Type.STRINGS); c.addChild("three") .addChild("child") - .setProperty("prop", ImmutableList.of("aaa", "bbb"), + .setProperty("prop", List.of("aaa", "bbb"), Type.STRINGS); root.commit(); assertQuery( "//*[(child/@prop = 'aaa' and child/@prop = 'bbb' and child/@prop = 'ccc')]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -161,17 +159,17 @@ public void testSubPropertyMultiAndLike() throws Exception { c.addChild("one").addChild("child").setProperty("prop", "aaaBoom"); c.addChild("two") .addChild("child") - .setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), + .setProperty("prop", List.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); c.addChild("three") .addChild("child") - .setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"), + .setProperty("prop", List.of("aaaBoom", "bbbBoom"), Type.STRINGS); root.commit(); assertQuery( "//*[(jcr:like(child/@prop, 'aaa%') and jcr:like(child/@prop, 'bbb%') and jcr:like(child/@prop, 'ccc%'))]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -204,8 +202,7 @@ public void testOak1301() throws Exception { assertQuery( "/jcr:root/home//*[@id='socialgraph_test_group']", "xpath", - ImmutableList - .of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); + List.of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); // sql2 select c.[jcr:path] as [jcr:path], c.[jcr:score] as [jcr:score], // c.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, @@ -217,8 +214,7 @@ public void testOak1301() throws Exception { assertQuery( "/jcr:root/home//social/relationships//*[@id='socialgraph_test_group']", "xpath", - ImmutableList - .of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); + List.of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); } @@ -229,22 +225,22 @@ public void testRelativeProperties() throws Exception { root.commit(); assertQuery("//*[(@prop > 1)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 2)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 20)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 100)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 200)]", "xpath", new ArrayList()); assertQuery("//*[(@prop > 1000)]", "xpath", new ArrayList()); - assertQuery("//*[(*/@prop > 1)]", "xpath", ImmutableList.of("/content")); - assertQuery("//*[(*/@prop > 2)]", "xpath", ImmutableList.of("/content")); + assertQuery("//*[(*/@prop > 1)]", "xpath", List.of("/content")); + assertQuery("//*[(*/@prop > 2)]", "xpath", List.of("/content")); assertQuery("//*[(*/@prop > 20)]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); assertQuery("//*[(*/@prop > 100)]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); assertQuery("//*[(*/@prop > 200)]", "xpath", new ArrayList()); assertQuery("//*[(*/@prop > 1000)]", "xpath", new ArrayList()); } @@ -271,35 +267,35 @@ public void testRelativeProperties2() throws Exception { root.commit(); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 9)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 9)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 10)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 10)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 15)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 15)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 20)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 20)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 30)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 30)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); } /** @@ -377,53 +373,53 @@ public void testRangeRelativeProperties() throws CommitFailedException { root.commit(); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 9)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 10)]", "xpath", - of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); + List.of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 20)]", "xpath", - of("/content/nodes/a20", "/content/nodes/a30")); + List.of("/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 30)]", "xpath", - of("/content/nodes/a30")); + List.of("/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 40)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 8)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 9)]", "xpath", - of("/content/nodes/a9")); + List.of("/content/nodes/a9")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 10)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10")); + List.of("/content/nodes/a9", "/content/nodes/a10")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 20)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 30)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 9)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 10)]", - "xpath", of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); + "xpath", List.of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 20)]", - "xpath", of("/content/nodes/a20", "/content/nodes/a30")); + "xpath", List.of("/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 30)]", - "xpath", of("/content/nodes/a30")); + "xpath", List.of("/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 40)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 8)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 9)]", - "xpath", of("/content/nodes/a9")); + "xpath", List.of("/content/nodes/a9")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 10)]", - "xpath", of("/content/nodes/a9", "/content/nodes/a10")); + "xpath", List.of("/content/nodes/a9", "/content/nodes/a10")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 20)]", - "xpath", of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); + "xpath", List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 30)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java index 63eb9fc195a..8a479a197a4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java @@ -46,8 +46,6 @@ import org.junit.Test; import org.slf4j.event.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Tests for cases where two or more indices return a similar cost estimation for the same query */ @@ -101,7 +99,7 @@ private static class TestIndexProvider implements QueryIndexProvider { @Override public @NotNull List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/Jackrabbit2ConfigurationTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/Jackrabbit2ConfigurationTest.java index 345232b8646..38ab5410d73 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/Jackrabbit2ConfigurationTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/Jackrabbit2ConfigurationTest.java @@ -24,6 +24,7 @@ import javax.security.auth.login.Configuration; import javax.security.auth.login.LoginException; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.authentication.token.TokenCredentials; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -243,7 +244,7 @@ public void testTokenCreationWithAttributes() throws Exception { cs = login(sc); AuthInfo ai = cs.getAuthInfo(); - Set attrNames = Set.of(ai.getAttributeNames()); + Set attrNames = ImmutableSet.copyOf(ai.getAttributeNames()); assertTrue(attrNames.contains("attr")); assertFalse(attrNames.contains(".token")); assertFalse(attrNames.contains(".token.mandatory")); @@ -267,7 +268,7 @@ public void testTokenCreationWithImpersonationAttributes() throws Exception { cs = login(ic); AuthInfo ai = cs.getAuthInfo(); - Set attrNames = Set.of(ai.getAttributeNames()); + Set attrNames = ImmutableSet.copyOf(ai.getAttributeNames()); assertTrue(attrNames.contains("attr")); assertFalse(attrNames.contains(".token")); assertFalse(attrNames.contains(".token.mandatory")); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImplTest.java index 076ef15f63e..504f891cbff 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImplTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authentication.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; @@ -71,8 +72,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule.SHARED_KEY_CREDENTIALS; import static org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule.SHARED_KEY_PRE_AUTH_LOGIN; @@ -377,7 +376,7 @@ public void testLoginPreAuthenticated() throws Exception { assertTrue(lm.commit()); // verify subject has been updated with test-user principals - Set expected = Stream.concat(Stream.of(foreignPrincipal), principals.stream()).collect(Collectors.toSet()); + Set expected = new ImmutableSet.Builder().add(foreignPrincipal).addAll(principals).build(); assertEquals(expected, subject.getPrincipals()); // no other public credentials than the AuthInfo assertEquals(1, subject.getPublicCredentials().size()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java index ea224f0c092..c7308ec5607 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.security.authorization.accesscontrol.AccessControlImporter; @@ -101,13 +100,13 @@ public void testGetWorkspaceInitializer() { @Test public void testGetCommitHooks() { - List expected = ImmutableList.of(VersionablePathHook.class, PermissionHook.class); + List expected = List.of(VersionablePathHook.class, PermissionHook.class); assertTrue(Iterables.elementsEqual(expected, Iterables.transform(authorizationConfiguration.getCommitHooks(adminSession.getWorkspaceName()), commitHook -> commitHook.getClass()))); } @Test public void testGetValidators() { - List expected = ImmutableList.of(PermissionStoreValidatorProvider.class, PermissionValidatorProvider.class, AccessControlValidatorProvider.class); + List expected = List.of(PermissionStoreValidatorProvider.class, PermissionValidatorProvider.class, AccessControlValidatorProvider.class); assertTrue(Iterables.elementsEqual(expected, Iterables.transform(authorizationConfiguration.getValidators(adminSession.getWorkspaceName(), Set.of(), new MoveTracker()), commitHook -> commitHook.getClass()))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java index 306938e67f9..526b88a0872 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java @@ -22,7 +22,6 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -127,7 +126,7 @@ public void testLocation() throws Exception { assertTrue(ctx.definesLocation(TreeLocation.create(root, policyPath + "/allow/" + AccessControlConstants.REP_PRINCIPAL_NAME))); assertTrue(ctx.definesLocation(TreeLocation.create(root, policyPath + "/allow/" + AccessControlConstants.REP_PRIVILEGES))); - List existingRegular = ImmutableList.of( + List existingRegular = List.of( "/", "/jcr:system" ); @@ -136,7 +135,7 @@ public void testLocation() throws Exception { assertFalse(path, ctx.definesLocation(TreeLocation.create(root, PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE)))); } - List nonExistingItem = ImmutableList.of( + List nonExistingItem = List.of( '/' + AccessControlConstants.REP_REPO_POLICY, "/content/" + AccessControlConstants.REP_POLICY, "/content/" + AccessControlConstants.REP_PRIVILEGES, diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java index 2bf3ceea6a3..d0799150de6 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java @@ -34,7 +34,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -114,7 +114,7 @@ private List createTestEntries() throws RepositoryException { @Test public void testGetNamePathMapper() { assertSame(getNamePathMapper(), acl.getNamePathMapper()); - assertSame(NamePathMapper.DEFAULT, createACL(TEST_PATH, ImmutableList.of(), NamePathMapper.DEFAULT).getNamePathMapper()); + assertSame(NamePathMapper.DEFAULT, createACL(TEST_PATH, List.of(), NamePathMapper.DEFAULT).getNamePathMapper()); } @Test @@ -586,7 +586,7 @@ public void testAllowWriteDenyRemoveGroupEntries() throws Exception { Privilege[] expected = privilegesFromNames(JCR_ADD_CHILD_NODES, JCR_REMOVE_NODE, JCR_MODIFY_PROPERTIES, JCR_NODE_TYPE_MANAGEMENT); assertEquals(expected.length, allows.size()); - assertEquals(Set.of(expected), allows); + assertEquals(ImmutableSet.copyOf(expected), allows); assertEquals(1, denies.size()); assertArrayEquals(privilegesFromNames(JCR_REMOVE_CHILD_NODES), denies.toArray(new Privilege[0])); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java index d4d689b80b6..0d05bff559b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java @@ -18,7 +18,8 @@ import javax.jcr.security.AccessControlException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.junit.Test; @@ -33,6 +34,6 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java index 02dfc26fdcd..39380380d81 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; @@ -71,9 +70,9 @@ public abstract class AccessControlImporterBaseTest extends AbstractSecurityTest implements AccessControlConstants { - final NodeInfo aceGrantInfo = new NodeInfo("grantAceName", NT_REP_GRANT_ACE, ImmutableList.of(), null); - private final NodeInfo aceDenyInfo = new NodeInfo("denyAceName", NT_REP_DENY_ACE, ImmutableList.of(), null); - private final NodeInfo restrInfo = new NodeInfo("anyRestrName", NT_REP_RESTRICTIONS, ImmutableList.of(), null); + final NodeInfo aceGrantInfo = new NodeInfo("grantAceName", NT_REP_GRANT_ACE, List.of(), null); + private final NodeInfo aceDenyInfo = new NodeInfo("denyAceName", NT_REP_DENY_ACE, List.of(), null); + private final NodeInfo restrInfo = new NodeInfo("anyRestrName", NT_REP_RESTRICTIONS, List.of(), null); final PropInfo unknownPrincipalInfo = new PropInfo(REP_PRINCIPAL_NAME, PropertyType.STRING, createTextValue("unknownPrincipal")); private Tree accessControlledTree; @@ -327,38 +326,38 @@ public void testProcessReferencesIsNoOp() { @Test(expected = IllegalStateException.class) public void testStartChildInfoNotInitialized() throws Exception { - importer.startChildInfo(mock(NodeInfo.class), ImmutableList.of()); + importer.startChildInfo(mock(NodeInfo.class), List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartChildInfoUnknownType() throws Exception { - NodeInfo invalidChildInfo = new NodeInfo("anyName", NT_OAK_UNSTRUCTURED, ImmutableList.of(), null); + NodeInfo invalidChildInfo = new NodeInfo("anyName", NT_OAK_UNSTRUCTURED, List.of(), null); init(); importer.start(aclTree); - importer.startChildInfo(invalidChildInfo, ImmutableList.of()); + importer.startChildInfo(invalidChildInfo, List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartNestedAceChildInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); - importer.startChildInfo(aceDenyInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); + importer.startChildInfo(aceDenyInfo, List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartRestrictionChildInfoWithoutAce() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(restrInfo, ImmutableList.of()); + importer.startChildInfo(restrInfo, List.of()); } @Test public void testStartAceAndRestrictionChildInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); - importer.startChildInfo(restrInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); + importer.startChildInfo(restrInfo, List.of()); } @Test(expected = AccessControlException.class) @@ -366,7 +365,7 @@ public void testStartAceChildInfoInvalidPrivilege() throws Exception { init(); importer.start(aclTree); PropInfo invalidPrivInfo = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues("jcr:invalidPrivilege"), PropInfo.MultipleStatus.MULTIPLE); - importer.startChildInfo(aceDenyInfo, ImmutableList.of(invalidPrivInfo)); + importer.startChildInfo(aceDenyInfo, List.of(invalidPrivInfo)); } //-------------------------------------------------------< endChildInfo >--- @@ -387,7 +386,7 @@ public void testEndChildInfoWithoutStart() throws Exception { public void testEndChildInfoIncompleteAce() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); importer.endChildInfo(); } @@ -418,10 +417,10 @@ public void testEndWithoutChildInfo() throws Exception { public void testInvalidRestriction() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); PropInfo invalidRestrProp = new PropInfo(REP_GLOB, PropertyType.NAME, createTextValues("glob1", "glob2"), PropInfo.MultipleStatus.MULTIPLE); - importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp)); + importer.startChildInfo(restrInfo, List.of(invalidRestrProp)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); @@ -431,10 +430,10 @@ public void testInvalidRestriction() throws Exception { public void testUnknownRestriction() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); PropInfo invalidRestrProp = new PropInfo("unknown", PropertyType.STRING, createTextValue("val")); - importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp)); + importer.startChildInfo(restrInfo, List.of(invalidRestrProp)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); @@ -444,7 +443,7 @@ public void testUnknownRestriction() throws Exception { public void testImportSimple() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); importer.endChildInfo(); importer.end(aclTree); @@ -454,7 +453,7 @@ public void testImportSimple() throws Exception { assertEquals(principalName, TreeUtil.getString(aceTree, REP_PRINCIPAL_NAME)); assertEquals( Set.of(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES), - CollectionUtils.toSet(TreeUtil.getNames(aceTree, REP_PRIVILEGES))); + ImmutableSet.copyOf(TreeUtil.getNames(aceTree, REP_PRIVILEGES))); assertFalse(aceTree.hasChild(REP_RESTRICTIONS)); } @@ -469,7 +468,7 @@ public void testImportWithRestrictions() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo, globInfo, ntNamesInfo, itemNamesInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo, globInfo, ntNamesInfo, itemNamesInfo)); importer.endChildInfo(); importer.end(aclTree); @@ -487,8 +486,8 @@ public void testImportWithRestrictionNodeInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); - importer.startChildInfo(restrInfo, ImmutableList.of(globInfo, ntNamesInfo, itemNamesInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); + importer.startChildInfo(restrInfo, List.of(globInfo, ntNamesInfo, itemNamesInfo)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); @@ -503,7 +502,7 @@ private static void assertImport(@NotNull Tree aclTree, @NotNull String principa assertEquals(principalName, TreeUtil.getString(aceTree, REP_PRINCIPAL_NAME)); assertEquals( Set.of(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES), - CollectionUtils.toSet(TreeUtil.getNames(aceTree, REP_PRIVILEGES))); + ImmutableSet.copyOf(TreeUtil.getNames(aceTree, REP_PRIVILEGES))); assertTrue(aceTree.hasChild(REP_RESTRICTIONS)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java index cf08ac1038f..77a725d1697 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java @@ -18,7 +18,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; @@ -26,6 +25,8 @@ import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertEquals; public class AccessControlImporterBesteffortTest extends AccessControlImporterBaseTest{ @@ -39,7 +40,7 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } @Test @@ -48,7 +49,7 @@ public void testImportWithUnknownPrincipal() throws Exception { importer.start(aclTree); PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ)); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo, privs)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo, privs)); importer.endChildInfo(); importer.end(aclTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java index 3075ef731ae..37cc4c5d928 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java @@ -18,12 +18,13 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.apache.jackrabbit.oak.spi.xml.PropInfo; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertFalse; public class AccessControlImporterIgnoreTest extends AccessControlImporterBaseTest{ @@ -37,7 +38,7 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } @Test @@ -46,7 +47,7 @@ public void testImportWithUnknownPrincipal() throws Exception { importer.start(aclTree); PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ)); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo, privs)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo, privs)); importer.endChildInfo(); importer.end(aclTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java index 3d4a7e05b3f..8db506f5bad 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; @@ -614,8 +614,8 @@ public void testGetPrivilegesForPrincipals() throws Exception { assertArrayEquals(new Privilege[0], acMgr.getPrivileges(null, testPrincipals)); assertArrayEquals(new Privilege[0], acMgr.getPrivileges("/", testPrincipals)); assertEquals( - Set.of(testPrivileges), - Set.of(acMgr.getPrivileges(testPath, testPrincipals))); + ImmutableSet.copyOf(testPrivileges), + ImmutableSet.copyOf(acMgr.getPrivileges(testPath, testPrincipals))); } //--------------------------------------< getApplicablePolicies(String) >--- @@ -641,7 +641,7 @@ public void testGetApplicablePolicies() throws Exception { @Test public void testGetApplicablePoliciesOnAccessControllable() throws Exception { Tree node = root.getTree(testPath); - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath); @@ -784,7 +784,7 @@ public void testGetPolicyWithInvalidPrincipal() throws Exception { Tree aclNode = root.getTree(testPath + '/' + REP_POLICY); Tree aceNode = TreeUtil.addChild(aclNode, "testACE", NT_REP_DENY_ACE); aceNode.setProperty(REP_PRINCIPAL_NAME, "invalidPrincipal"); - aceNode.setProperty(REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES); + aceNode.setProperty(REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.NAMES); // reading policies with unknown principal name should not fail. AccessControlPolicy[] policies = acMgr.getPolicies(testPath); @@ -1371,7 +1371,7 @@ public void testSetPolicyWithExistingMixins() throws Exception { root.commit(); assertEquals(Set.of(JcrConstants.MIX_LOCKABLE, MIX_REP_ACCESS_CONTROLLABLE), - CollectionUtils.toSet(TreeUtil.getNames(root.getTree(testPath), JcrConstants.JCR_MIXINTYPES))); + ImmutableSet.copyOf(TreeUtil.getNames(root.getTree(testPath), JcrConstants.JCR_MIXINTYPES))); } //--------------------------< removePolicy(String, AccessControlPolicy) >--- @@ -1485,7 +1485,7 @@ public void testGetApplicablePoliciesNullPrincipal() throws Exception { @Test public void testGetApplicablePoliciesByPrincipal() throws Exception { - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { AccessControlPolicy[] applicable = acMgr.getApplicablePolicies(principal); assertPolicies(applicable, 1); @@ -1515,7 +1515,7 @@ public void testGetPoliciesNullPrincipal() throws Exception { @Test public void testGetPoliciesByPrincipal() throws Exception { - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { assertPolicies(acMgr.getPolicies(principal), 0); } @@ -1718,7 +1718,7 @@ public void testEffectivePoliciesFiltering() throws Exception { // different ways to create the principal-set to make sure the filtering // doesn't rely on principal equality but rather on the name. - List principals = ImmutableList.of( + List principals = List.of( testPrincipal, new PrincipalImpl(testPrincipal.getName()), () -> testPrincipal.getName()); @@ -1745,7 +1745,7 @@ public void testEffectivePolicyIsolatedAce() throws Exception { Tree testTree = r.getTree(testPath); Tree ace = TreeUtil.addChild(testTree, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mockQueryEngine(ace); when(r.getQueryEngine()).thenReturn(qe); @@ -1765,7 +1765,7 @@ public void testEffectivePolicyWrongPrimaryType() throws Exception { Tree aclWithWrongType = TreeUtil.addChild(testTree, REP_POLICY, NT_OAK_UNSTRUCTURED); Tree ace = TreeUtil.addChild(aclWithWrongType, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mockQueryEngine(ace); when(r.getQueryEngine()).thenReturn(qe); @@ -1777,7 +1777,7 @@ public void testEffectivePolicyWrongPrimaryType() throws Exception { private static QueryEngine mockQueryEngine(@NotNull Tree aceTree) throws Exception { ResultRow row = when(mock(ResultRow.class).getTree(null)).thenReturn(aceTree).getMock(); - Iterable rows = ImmutableList.of(row); + Iterable rows = List.of(row); Result res = mock(Result.class); when(res.getRows()).thenReturn(rows).getMock(); QueryEngine qe = mock(QueryEngine.class); @@ -1794,7 +1794,7 @@ public void testEffectivePolicyFailingQuery() throws Exception { Tree testTree = r.getTree(testPath); Tree ace = TreeUtil.addChild(testTree, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mock(QueryEngine.class); when(qe.executeQuery(anyString(), anyString(), any(Map.class), any(Map.class))).thenThrow(new ParseException("test", 0)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java index 55c3ea3d92f..075ea823aad 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.principal.PrincipalManager; @@ -318,10 +318,10 @@ public void testGetPrivileges() throws Exception { assertArrayEquals(new Privilege[0], testAcMgr.getPrivileges(null, testPrincipals)); Privilege[] privs = testAcMgr.getPrivileges(testPath); - assertEquals(Set.of(testPrivileges), Set.of(privs)); + assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs)); privs = testAcMgr.getPrivileges(testPath, testPrincipals); - assertEquals(Set.of(testPrivileges), Set.of(privs)); + assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs)); // but for 'admin' the test-session doesn't have sufficient privileges try { @@ -338,7 +338,7 @@ public void testGetApplicablePolicies() throws Exception { root.commit(); testRoot.refresh(); - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { // testRoot can't read access control content -> doesn't see // the existing policies and creates a new applicable policy. @@ -358,7 +358,7 @@ public void testGetPolicies() throws Exception { testRoot.refresh(); PrincipalManager testPrincipalMgr = getPrincipalManager(testRoot); - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { if (testPrincipalMgr.hasPrincipal(principal.getName())) { // testRoot can't read access control content -> doesn't see @@ -418,7 +418,7 @@ public void testGetEffectivePoliciesWithoutPrivilege() throws Exception { testRoot.refresh(); - List paths = ImmutableList.of(testPath, NodeTypeConstants.NODE_TYPES_PATH); + List paths = List.of(testPath, NodeTypeConstants.NODE_TYPES_PATH); for (String path : paths) { assertFalse(testAcMgr.hasPrivileges(path, privilegesFromNames(PrivilegeConstants.JCR_READ_ACCESS_CONTROL))); try { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java index 221488a86cd..50d72c9016b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -63,7 +61,9 @@ import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -148,7 +148,7 @@ private Validator createRootValidator(@NotNull Tree rootTree) { @NotNull private Tree createPolicy(@NotNull Tree tree, boolean createRestrictionNode) throws AccessDeniedException { - tree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + tree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); Tree acl = TreeUtil.addChild(tree, REP_POLICY, NT_REP_ACL); acl.setOrderableChildren(true); @@ -163,7 +163,7 @@ private Tree createPolicy(@NotNull Tree tree, boolean createRestrictionNode) thr private static Tree createACE(@NotNull Tree acl, @NotNull String aceName, @NotNull String ntName, @NotNull String principalName, @NotNull String... privilegeNames) throws AccessDeniedException { Tree ace = TreeUtil.addChild(acl, aceName, ntName); ace.setProperty(REP_PRINCIPAL_NAME, principalName); - ace.setProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, Arrays.asList(privilegeNames), Type.NAMES); return ace; } @@ -176,7 +176,7 @@ private static CommitFailedException assertCommitFailedException(@NotNull Commit @Test(expected = CommitFailedException.class) public void testPolicyWithOutChildOrder() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(testRoot, REP_POLICY, NT_REP_ACL); try { @@ -189,7 +189,7 @@ public void testPolicyWithOutChildOrder() throws Exception { @Test(expected = CommitFailedException.class) public void testOnlyRootIsRepoAccessControllable() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_REPO_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_REPO_ACCESS_CONTROLLABLE), Type.NAMES); try { root.commit(); @@ -201,7 +201,7 @@ public void testOnlyRootIsRepoAccessControllable() throws Exception { @Test(expected = CommitFailedException.class) public void testAddInvalidRepoPolicy() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(testRoot, REP_REPO_POLICY, NT_REP_ACL); try { root.commit(); @@ -439,7 +439,7 @@ public void testDuplicateAceWithRestrictions() throws Exception { Tree ace = createDuplicateAceTree(); Tree rest = TreeUtil.addChild(ace, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); rest.setProperty(AccessControlConstants.REP_GLOB, "some/glob", Type.STRING); - rest.setProperty(AccessControlConstants.REP_GLOBS, ImmutableList.of("glob1", "glob2"), Type.STRINGS); + rest.setProperty(AccessControlConstants.REP_GLOBS, List.of("glob1", "glob2"), Type.STRINGS); try { root.commit(); @@ -455,7 +455,7 @@ public void testDuplicateAceWithRestrictions() throws Exception { Tree policy = root.getTree(testPath + "/rep:policy"); Tree ace = TreeUtil.addChild(policy, "duplicateAce", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_ADD_CHILD_NODES), Type.NAMES); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_ADD_CHILD_NODES), Type.NAMES); return ace; } @@ -606,7 +606,7 @@ public void testRestrictionsUsedByOtherModule2() throws Exception { @Test(expected = CommitFailedException.class) public void testAddPolicyTreeWithInvalidName() throws Exception { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); - rootTree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + rootTree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(rootTree, "invalidName", NT_REP_ACL); Validator v = createRootValidator(rootTree); @@ -622,7 +622,7 @@ public void testAddEntyWithEmptyPrivileges() throws Exception { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); Tree policy = createPolicy(rootTree, false); Tree entry = policy.getChild(aceName); - entry.setProperty(REP_PRIVILEGES, ImmutableList.of(), Type.NAMES); + entry.setProperty(REP_PRIVILEGES, List.of(), Type.NAMES); Validator v = createRootValidator(rootTree); try { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/EntryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/EntryTest.java index e5bbeddb924..bddd70eed59 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/EntryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/EntryTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -165,7 +166,7 @@ public void testGetPrivileges() throws RepositoryException { Privilege[] expected = AccessControlUtils.privilegesFromNames(acMgr, PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES); - assertEquals(Set.of(expected), Set.of(privs)); + assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(privs)); } @Test @@ -388,8 +389,8 @@ public void testGetRestrictionsNone() throws Exception { @Test public void testGetPrivilegeCollection() throws Exception { PrivilegeCollection pc = createEntry(Privilege.JCR_READ, Privilege.JCR_WRITE).getPrivilegeCollection(); - Set expected = Set.of(AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ, Privilege.JCR_WRITE)); - assertEquals(expected, Set.of(pc.getPrivileges())); + Set expected = ImmutableSet.copyOf(AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ, Privilege.JCR_WRITE)); + assertEquals(expected, ImmutableSet.copyOf(pc.getPrivileges())); assertEquals(pc, createEntry(JCR_READ, JCR_WRITE).getPrivilegeCollection()); assertEquals(pc, createEntry(JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_MODIFY_PROPERTIES, diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java index b65918f9750..ea60f63ddfa 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -90,6 +89,6 @@ public void testWriteEntryWithJcrPrivilegeName() throws Exception { getAccessControlManager(root).setPolicy(acl.getPath(), acl); Tree aceTree = root.getTree(acl.getPath()).getChild(REP_POLICY).getChildren().iterator().next(); Iterable privNames = TreeUtil.getNames(aceTree, PrivilegeConstants.REP_PRIVILEGES); - assertTrue(Iterables.elementsEqual(ImmutableList.of(PrivilegeConstants.JCR_READ), privNames)); + assertTrue(Iterables.elementsEqual(List.of(PrivilegeConstants.JCR_READ), privNames)); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java index d3a49d87312..b0a34290e6f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -46,6 +46,7 @@ import javax.jcr.Session; import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -69,8 +70,8 @@ public abstract class AbstractCompositeProviderTest extends AbstractSecurityTest static final String TEST_PATH_2 = "/test2"; - static final List NODE_PATHS = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_PATH_2, TEST_CHILD_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B2_PATH); - static final List TP_PATHS = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B_C_PATH + "/nonexisting"); + static final List NODE_PATHS = List.of(ROOT_PATH, TEST_PATH, TEST_PATH_2, TEST_CHILD_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B2_PATH); + static final List TP_PATHS = List.of(ROOT_PATH, TEST_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B_C_PATH + "/nonexisting"); static final PropertyState PROPERTY_STATE = PropertyStates.createProperty("propName", "val"); @@ -238,18 +239,17 @@ boolean reverseOrder() { List getAggregatedProviders(@NotNull String workspaceName, @NotNull AuthorizationConfiguration config, @NotNull Set principals) { - ImmutableList l = ImmutableList.of( + List l = new ArrayList<>(List.of( (AggregatedPermissionProvider) config.getPermissionProvider(root, workspaceName, principals), - getTestPermissionProvider()); + getTestPermissionProvider())); if (reverseOrder()) { - return l.reverse(); - } else { - return l; + Collections.reverse(l); } + return l; } CompositePermissionProvider createPermissionProvider(Principal... principals) { - return createPermissionProvider(Set.of(principals)); + return createPermissionProvider(ImmutableSet.copyOf(principals)); } CompositePermissionProvider createPermissionProvider(Set principals) { @@ -260,7 +260,7 @@ CompositePermissionProvider createPermissionProvider(Set principals) } CompositePermissionProvider createPermissionProviderOR(Principal... principals) { - return createPermissionProviderOR(Set.of(principals)); + return createPermissionProviderOR(ImmutableSet.copyOf(principals)); } CompositePermissionProvider createPermissionProviderOR(Set principals) { @@ -572,7 +572,7 @@ public void testGetTreePermissionInstanceOR() throws Exception { @Test public void testTreePermissionGetChild() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -587,7 +587,7 @@ public void testTreePermissionGetChild() throws Exception { @Test public void testTreePermissionGetChildOR() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java index 3b90bdb869b..58db5f7f823 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -44,6 +44,7 @@ import javax.jcr.security.AccessControlPolicyIterator; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.Set; @@ -100,13 +101,13 @@ private CompositeAccessControlManager createComposite(@NotNull AccessControlMana @NotNull private CompositeAccessControlManager createComposite(@NotNull AggregationFilter aggregationFilter, @NotNull AccessControlManager... acMgrs) { - return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableList.copyOf(acMgrs), aggregationFilter); + return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), Arrays.asList(acMgrs), aggregationFilter); } @Test public void testGetSupportedPrivileges() throws Exception { - Set expected = Set.of(getPrivilegeManager(root).getRegisteredPrivileges()); - Set result = Set.of(acMgr.getSupportedPrivileges("/")); + Set expected = ImmutableSet.copyOf(getPrivilegeManager(root).getRegisteredPrivileges()); + Set result = ImmutableSet.copyOf(acMgr.getSupportedPrivileges("/")); assertEquals(expected, result); result = CollectionUtils.toSet(acMgr.getSupportedPrivileges(TEST_PATH)); @@ -123,7 +124,7 @@ public void testGetApplicablePolicies() throws Exception { } } - Set applicable = CollectionUtils.toSet(acMgr.getApplicablePolicies(TEST_PATH)); + Set applicable = ImmutableSet.copyOf(acMgr.getApplicablePolicies(TEST_PATH)); assertEquals(2, applicable.size()); assertTrue(applicable.contains(TestPolicy.INSTANCE)); } @@ -163,7 +164,7 @@ public void testGetPolicies() throws Exception { acMgr.setPolicy(TEST_PATH, plc); len++; - Set policySet = Set.of(acMgr.getPolicies(TEST_PATH)); + Set policySet = ImmutableSet.copyOf(acMgr.getPolicies(TEST_PATH)); assertEquals(len, policySet.size()); assertTrue(policySet.contains(TestPolicy.INSTANCE)); assertTrue(policySet.contains(plc)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java index 28951c63d4a..11fbf672a5a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -98,7 +97,7 @@ private CompositePermissionProvider createPermissionProviderOR(Set pr String workspaceName = root.getContentSession().getWorkspaceName(); AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class); - ImmutableList l = ImmutableList.of( + List l = List.of( (AggregatedPermissionProvider) config.getPermissionProvider(root, workspaceName, principals), new ReadNodeGrantedInSupportedTree()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java index 601deece305..6883858d48f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java @@ -21,7 +21,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.PropertyState; @@ -79,7 +78,7 @@ AggregatedPermissionProvider getTestPermissionProvider() { @Override List getAggregatedProviders(@NotNull String workspaceName, @NotNull AuthorizationConfiguration config, @NotNull Set principals) { - return ImmutableList.of(getTestPermissionProvider()); + return List.of(getTestPermissionProvider()); } @Override @@ -111,7 +110,7 @@ public void testGetTreePermissionInstanceOR() throws Exception { @Override @Test public void testTreePermissionGetChild() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -127,7 +126,7 @@ public void testTreePermissionGetChild() throws Exception { @Override @Test public void testTreePermissionGetChildOR() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java index 6407a516777..68ecb4d0f01 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -59,7 +59,7 @@ public class CompositeProviderCustomMixTest extends AbstractSecurityTest { public void hasPrivilegesTest() throws Exception { Set supp1 = Set.of(JCR_READ, JCR_NAMESPACE_MANAGEMENT); Set supp2 = Set.of(JCR_READ, JCR_WRITE); - Set all = CollectionUtils.union(supp1, supp2); + Set all = Sets.union(supp1, supp2); // tests all possible 256 shuffles for (CompositionType type : CompositionType.values()) { @@ -84,7 +84,7 @@ public void hasPrivilegesTest() throws Exception { public void isGrantedTest() throws Exception { Set supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT); Set supp2 = Set.of(JCR_READ, JCR_WRITE); - Set all = CollectionUtils.union(supp1, supp2); + Set all = Sets.union(supp1, supp2); Map grantMap = new HashMap<>(); grantMap.put(JCR_READ, Permissions.READ); @@ -131,7 +131,7 @@ public void isGrantedTest() throws Exception { public void getRepositoryPermissionTest() throws Exception { Set supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT); Set supp2 = Set.of(JCR_READ, JCR_WRITE); - Set all = CollectionUtils.union(supp1, supp2); + Set all = Sets.union(supp1, supp2); Map grantMap = new HashMap<>(); grantMap.put(JCR_READ, Permissions.READ); @@ -161,7 +161,7 @@ public void getRepositoryPermissionTest() throws Exception { public void getTreePermissionTest() throws Exception { Set supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT); Set supp2 = Set.of(JCR_READ, JCR_WRITE); - Set all = CollectionUtils.union(supp1, supp2); + Set all = Sets.union(supp1, supp2); Map grantMap = new HashMap<>(); grantMap.put(JCR_READ, Permissions.READ); @@ -232,7 +232,7 @@ private CompositePermissionProvider buildCpp(Set supported1, Set AggregatedPermissionProvider a2 = new CustomProvider(root, supported2, granted2, grantMap); AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class); - List composite = ImmutableList.of(a1, a2); + List composite = List.of(a1, a2); return CompositePermissionProvider.create(root, composite, config.getContext(), type, getRootProvider(), getTreeProvider()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java index ead95d6ab8b..a47cd60d615 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java @@ -16,13 +16,13 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -226,7 +226,7 @@ public void testIsGrantedAction() throws Exception { for (String p : defActionsGranted.keySet()) { String[] actions = defActionsGranted.get(p); - if (ImmutableList.copyOf(actions).contains(Session.ACTION_READ)) { + if (Arrays.asList(actions).contains(Session.ACTION_READ)) { TreeLocation tl = TreeLocation.create(readOnlyRoot, p); assertEquals(p, tl.getTree() != null, cppTestUser.isGranted(p, Session.ACTION_READ)); } else { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java index 001bc1993b9..e326e7486d3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -31,6 +30,8 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.Arrays; + import static org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration.CompositionType.AND; import static org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration.CompositionType.OR; import static org.junit.Assert.assertSame; @@ -47,7 +48,7 @@ public class CompositeProviderGetTreePermissionTest extends AbstractSecurityTest private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType, @NotNull AggregatedPermissionProvider... providers) { - return CompositePermissionProvider.create(root, ImmutableList.copyOf(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); + return CompositePermissionProvider.create(root, Arrays.asList(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java index 5e71f87e761..def4c75b671 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java @@ -24,7 +24,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Tree; @@ -119,7 +118,7 @@ public void testGetTreePermissionInstanceOR() { @Override @Test public void testTreePermissionGetChild() { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -136,7 +135,7 @@ public void testTreePermissionGetChild() { @Override @Test public void testTreePermissionGetChildOR() { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -453,7 +452,7 @@ public void testTreePermissionSize() throws Exception { TreePermission tp = cppTestUser.getTreePermission(rootTree, TreePermission.EMPTY); assertEquals(2, ((TreePermission[]) tpField.get(tp)).length); - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); for (String cName : childNames) { ns = ns.getChildNode(cName); tp = tp.getChildPermission(cName, ns); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java index 69f1518d3a9..1cdb7c7800d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -72,7 +71,7 @@ */ public class CompositeProviderScopeTest extends AbstractCompositeProviderTest { - private static List PATH_OUTSIDE_SCOPE = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_CHILD_PATH); + private static List PATH_OUTSIDE_SCOPE = List.of(ROOT_PATH, TEST_PATH, TEST_CHILD_PATH); private CompositePermissionProvider cppTestUser; private CompositePermissionProvider cppAdminUser; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java index e3db40fd88c..4100e4ecc98 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.Arrays; + import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -89,7 +90,7 @@ public void before() throws Exception { } private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType, @NotNull AggregatedPermissionProvider... aggregated) { - return CompositePermissionProvider.create(root, ImmutableList.copyOf(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); + return CompositePermissionProvider.create(root, Arrays.asList(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java index f017dcf4d04..d53620e243b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; @@ -98,7 +97,7 @@ public void testChildOrderWithoutPropertyReadAccess() throws Exception { // verify that properties cannot be read: assertFalse(aTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)); - List expected = ImmutableList.of("/a/bb", "/a/b"); + List expected = List.of("/a/bb", "/a/b"); Iterable childPaths = Iterables.transform(aTree.getChildren(), input -> input.getPath()); assertTrue(childPaths.toString(), Iterables.elementsEqual(expected, childPaths)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RepoLevelPolicyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RepoLevelPolicyTest.java index d16be3a76a4..e866b4c3a91 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RepoLevelPolicyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RepoLevelPolicyTest.java @@ -22,6 +22,7 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; @@ -118,9 +119,9 @@ public void testHasPrivilege() throws Exception { public void testGetPrivileges() throws Exception { setupPermission(null, getTestUser().getPrincipal(), true, JCR_READ_ACCESS_CONTROL, JCR_NAMESPACE_MANAGEMENT); - Set expected = Set.of(privilegesFromNames(JCR_READ_ACCESS_CONTROL, JCR_NAMESPACE_MANAGEMENT)); + Set expected = ImmutableSet.copyOf(privilegesFromNames(JCR_READ_ACCESS_CONTROL, JCR_NAMESPACE_MANAGEMENT)); AccessControlManager testAcMgr = getAccessControlManager(getTestRoot()); - assertEquals(expected, Set.of(testAcMgr.getPrivileges(null))); + assertEquals(expected, ImmutableSet.copyOf(testAcMgr.getPrivileges(null))); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java index 3b2cb05b146..fee48b3b4cc 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java @@ -18,7 +18,6 @@ import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -44,7 +43,7 @@ public void testGetTree() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/b/c"); for (String path : accessible) { assertTrue(testRoot.getTree(path).exists()); } @@ -60,12 +59,12 @@ public void testGetTree2() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a/b"); + List notAccessible = List.of("/", "/a/b"); for (String path : notAccessible) { assertFalse(path, testRoot.getTree(path).exists()); } - List accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c"); + List accessible = List.of("/a", "/a/bb", "/a/b/c"); for (String path : accessible) { assertTrue(path, testRoot.getTree(path).exists()); } @@ -79,7 +78,7 @@ public void testGetNodeLocation() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/b/c"); for (String path : accessible) { Tree tree = testRoot.getTree(path); assertNotNull(tree); @@ -99,14 +98,14 @@ public void testGetNodeLocation2() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a/b"); + List notAccessible = List.of("/", "/a/b"); for (String path : notAccessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); assertFalse(tree.exists()); } - List accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c"); + List accessible = List.of("/a", "/a/bb", "/a/b/c"); for (String path : accessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); @@ -121,7 +120,7 @@ public void testGetNodeLocation3() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List notAccessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : notAccessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); @@ -135,14 +134,14 @@ public void testGetPropertyLocation() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : accessible) { String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE); PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE); assertNotNull(propertyPath, property); } - List propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List propPaths = List.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : propPaths) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); @@ -155,14 +154,14 @@ public void testGetPropertyLocation2() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : accessible) { String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE); PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE); assertNotNull(propertyPath, property); } - List propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List propPaths = List.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : propPaths) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); @@ -177,13 +176,13 @@ public void testGetPropertyLocation3() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/a/aProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List accessible = List.of("/a/aProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : accessible) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); } - List notAccessible = ImmutableList.of("/jcr:primaryType", "/a/b/bProp"); + List notAccessible = List.of("/jcr:primaryType", "/a/b/bProp"); for (String path : notAccessible) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNull(path, property); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java index b7e2b7a03f7..893eef1b536 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java @@ -25,7 +25,6 @@ import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -101,7 +100,7 @@ public void testGetChildrenCount() throws Exception { assertEquals(cntA - 1, testRoot.getTree("/a").getChildrenCount(Long.MAX_VALUE)); // for the following nodes the cnt must not differ - List paths = ImmutableList.of("/a/b", "/a/b/c"); + List paths = List.of("/a/b", "/a/b/c"); for (String path : paths) { assertEquals( root.getTree(path).getChildrenCount(Long.MAX_VALUE), diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java index 0db13cbfbb3..c83a1871647 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java @@ -16,13 +16,14 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.Arrays; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -30,7 +31,7 @@ public class ChildOrderDiffTest { @NotNull private static PropertyState createPropertyState(@NotNull String... names) { - return PropertyStates.createProperty("any", ImmutableList.copyOf(names), Type.NAMES); + return PropertyStates.createProperty("any", Arrays.asList(names), Type.NAMES); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java index 1f575b3284d..2fc474635a6 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -455,7 +456,7 @@ public void testDynamicJcrAll() throws Exception { // verify that the permission provider still exposes the correct privilege // (jcr:all) for the given childPath irrespective of the dynamic nature of // the privilege bits in the persisted permission entry. - Set principalSet = Set.of(EveryonePrincipal.getInstance()); + Set principalSet = ImmutableSet.of(EveryonePrincipal.getInstance()); PermissionProvider permissionProvider = getConfig(AuthorizationConfiguration.class).getPermissionProvider(root, root.getContentSession().getWorkspaceName(), principalSet); Tree childTree = root.getTree(childPath); assertTrue(permissionProvider.hasPrivileges(childTree, PrivilegeConstants.JCR_ALL)); @@ -797,7 +798,7 @@ public void testInvalidPolicyNodeBecomesTypeRepACL() throws Exception { assertEquals(2, principalPermissionStore.getChildrenCount(10)); Iterable paths = Iterables.transform(principalPermissionStore.getChildren(), tree -> tree.getProperty(REP_ACCESS_CONTROLLED_PATH).getValue(Type.STRING)); - assertEquals(Set.of(testPath, t.getPath()), CollectionUtils.toSet(paths)); + assertEquals(Set.of(testPath, t.getPath()), ImmutableSet.copyOf(paths)); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java index ab97d1076d7..77e3316bf9c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -47,6 +46,7 @@ import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.List; import java.util.Set; import static org.apache.jackrabbit.JcrConstants.JCR_CREATED; @@ -276,7 +276,7 @@ public void testChangePrimaryTypeToPolicyNode() throws Exception { Root testRoot = testSession.getLatestRoot(); Tree testChild = testRoot.getTree(TEST_CHILD_PATH); - testChild.setProperty(PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES)); + testChild.setProperty(PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, List.of(AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES)); Tree testPolicy = testChild.getChild(AccessControlConstants.REP_POLICY); testPolicy.setOrderableChildren(true); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java index 22ad256a77d..92f68bbfec5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -36,6 +35,7 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; import static org.apache.jackrabbit.JcrConstants.JCR_UUID; import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONHISTORY; @@ -76,7 +76,7 @@ public boolean exists() { @Override public @NotNull Iterable getProperties() { - return ImmutableList.of(PropertyStates.createProperty(JCR_VERSIONHISTORY, "someValue")); + return List.of(PropertyStates.createProperty(JCR_VERSIONHISTORY, "someValue")); } @Override diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/AbstractRestrictionProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/AbstractRestrictionProviderTest.java index 7558c2e14b8..7601461a0b1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/AbstractRestrictionProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/AbstractRestrictionProviderTest.java @@ -23,6 +23,7 @@ import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlException; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; @@ -93,7 +94,7 @@ private Tree getAceTree(Restriction... restrictions) throws Exception { Tree tmp = TreeUtil.addChild(rootNode, "testRoot", JcrConstants.NT_UNSTRUCTURED); Tree policy = TreeUtil.addChild(tmp, REP_POLICY, NT_REP_ACL); Tree ace = TreeUtil.addChild(policy, "ace0", NT_REP_GRANT_ACE); - restrictionProvider.writeRestrictions(tmp.getPath(), ace, Set.of(restrictions)); + restrictionProvider.writeRestrictions(tmp.getPath(), ace, ImmutableSet.copyOf(restrictions)); return ace; } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java index 1ad0fa9ae45..4d09827ea2c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositePattern; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction; +import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinitionImpl; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider; @@ -37,6 +38,7 @@ import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -92,11 +94,11 @@ public void after() throws Exception { public void testReadRestrictions() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); aceNode.setProperty("boolean", true); - aceNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + aceNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); aceNode.setProperty(REP_GLOB, "*"); aceNode.setProperty(REP_NT_NAMES, Set.of(), Type.NAMES); // empty array aceNode.setProperty("invalid", "val"); - aceNode.setProperty("invalid2", ImmutableList.of("val1", "val2", "val3"), Type.STRINGS); + aceNode.setProperty("invalid2", List.of("val1", "val2", "val3"), Type.STRINGS); Set restrictions = provider.readRestrictions("/test", aceNode); assertEquals(4, restrictions.size()); @@ -124,7 +126,7 @@ public void testWriteUnsupportedRestrictions() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); Restriction invalid = new RestrictionImpl(PropertyStates.createProperty("invalid", vf.createValue(true)), false); try { - provider.writeRestrictions("/test", aceNode, Set.of(invalid)); + provider.writeRestrictions("/test", aceNode, ImmutableSet.of(invalid)); fail("AccessControlException expected"); } catch (AccessControlException e) { // success @@ -136,9 +138,9 @@ public void testValidateRestrictions() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); Tree rNode = TreeUtil.addChild(aceNode, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); rNode.setProperty("boolean", true); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); rNode.setProperty(REP_GLOB, "*"); - rNode.setProperty(REP_NT_NAMES, ImmutableList.of(), Type.NAMES); // empty array + rNode.setProperty(REP_NT_NAMES, List.of(), Type.NAMES); // empty array provider.validateRestrictions("/test", aceNode); @@ -162,7 +164,7 @@ public void testValidateRestrictions() throws Exception { rNode.setProperty("boolean", true); } - rNode.setProperty(REP_GLOB, ImmutableList.of("*", "/jcr:content"), Type.STRINGS); + rNode.setProperty(REP_GLOB, List.of("*", "/jcr:content"), Type.STRINGS); try { provider.validateRestrictions("/test", aceNode); fail("validation should detect wrong restriction type (multi vs single valued)"); @@ -175,9 +177,9 @@ public void testValidateRestrictions() throws Exception { public void testValidateRestrictionsAtEntryNode() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); aceNode.setProperty("boolean", true); - aceNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + aceNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); aceNode.setProperty(REP_GLOB, "*"); - aceNode.setProperty(REP_NT_NAMES, ImmutableList.of(), Type.NAMES); // empty array + aceNode.setProperty(REP_NT_NAMES, List.of(), Type.NAMES); // empty array provider.validateRestrictions("/test", aceNode); } @@ -188,7 +190,7 @@ public void testValidateInvalidRestrictionDef() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); Tree rNode = TreeUtil.addChild(aceNode, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); try { rp.validateRestrictions("/test", aceNode); @@ -223,7 +225,7 @@ public void testGetRestrictionPattern() throws Exception { assertFalse(provider.getPattern("/test", aceNode) instanceof CompositePattern); rNode.setProperty("boolean", true); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); assertTrue(provider.getPattern("/test", rNode) instanceof CompositePattern); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java index 93606f012f6..141885ca658 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -148,7 +147,7 @@ public void testMatchesTreePropertyPropertyNames() { @Test public void testMatchesPath() { - List propNames = ImmutableList.of(new String[0], new String[]{RESIDUAL_NAME}, new String[] {PROP_NAME}); + List propNames = List.of(new String[0], new String[]{RESIDUAL_NAME}, new String[] {PROP_NAME}); for (String[] pn : propNames) { RestrictionPattern rp = createPattern(pn); assertTrue(rp.matches(TEST_PATH)); @@ -172,7 +171,7 @@ public void testMatchesPathPointsToKnownProperty() { } // pattern with * or all propnames will match - List propNames = ImmutableList.of(new String[]{RESIDUAL_NAME}, knownPropertyNames); + List propNames = List.of(new String[]{RESIDUAL_NAME}, knownPropertyNames); for (String[] names : propNames) { rp = createPattern(names); for (String pn : knownPropertyNames) { @@ -205,7 +204,7 @@ public void testMatchesPathPointsToKnownNode() { } // pattern with * or all node-names will NOT match because they point to items that are known to be nodes - List propNames = ImmutableList.of(new String[]{RESIDUAL_NAME}, knownNodeNames); + List propNames = List.of(new String[]{RESIDUAL_NAME}, knownNodeNames); for (String[] names : propNames) { rp = createPattern(names); for (String pn : knownNodeNames) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java index e7211674d94..cc3e4fd0e87 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -53,7 +52,7 @@ private static Tree addTree(@NotNull Tree parent, @NotNull String relPath) throw public void testMatchesItem() throws Exception { Tree rootTree = root.getTree("/"); - List matching = ImmutableList.of("a", "b", "c", "d/e/a", "a/b/c/d/b", "test/c"); + List matching = List.of("a", "b", "c", "d/e/a", "a/b/c/d/b", "test/c"); for (String relPath : matching) { Tree testTree = addTree(rootTree, relPath); @@ -64,7 +63,7 @@ public void testMatchesItem() throws Exception { testTree.remove(); } - List notMatching = ImmutableList.of("d", "b/d", "d/e/f", "c/b/abc"); + List notMatching = List.of("d", "b/d", "d/e/f", "c/b/abc"); for (String relPath : notMatching) { Tree testTree = addTree(rootTree, relPath); @@ -78,12 +77,12 @@ public void testMatchesItem() throws Exception { @Test public void testMatchesPath() { - List matching = ImmutableList.of("/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c"); + List matching = List.of("/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c"); for (String p : matching) { assertTrue(pattern.matches(p)); } - List notMatching = ImmutableList.of("/", "/d", "/b/d", "/d/e/f", "/c/b/abc"); + List notMatching = List.of("/", "/d", "/b/d", "/d/e/f", "/c/b/abc"); for (String p : notMatching) { assertFalse(pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java index 95478f462c8..5837faa6723 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Group; @@ -71,12 +70,12 @@ boolean addEntry(@NotNull JackrabbitAccessControlList acl) throws RepositoryExce public void testRead() { Root testRoot = testSession.getLatestRoot(); - List visible = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List visible = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : visible) { assertTrue(testRoot.getTree(p).exists()); } - List invisible = ImmutableList.of("/", "/a/d", "/a/d/b/e", "/a/d/b/e/c/f"); + List invisible = List.of("/", "/a/d", "/a/d/b/e", "/a/d/b/e/c/f"); for (String p : invisible) { assertFalse(testRoot.getTree(p).exists()); } @@ -91,7 +90,7 @@ public void testRead() { public void testAddProperty() throws Exception { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List paths = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : paths) { Tree t = testRoot.getTree(p); t.setProperty("b", "anyvalue"); @@ -132,7 +131,7 @@ public void testModifyProperty() throws Exception { public void testAddChild() throws Exception { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List paths = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : paths) { Tree t = testRoot.getTree(p); TreeUtil.addChild(t, "c", NodeTypeConstants.NT_OAK_UNSTRUCTURED); @@ -143,7 +142,7 @@ public void testAddChild() throws Exception { @Test public void testRemoveTree() { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a/d/b/e/c", "/a/d/b", "/a"); + List paths = List.of("/a/d/b/e/c", "/a/d/b", "/a"); for (String p : paths) { try { testRoot.getTree(p).remove(); @@ -169,7 +168,7 @@ public void testRemoveTree2() throws Exception { root.commit(); Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a/d/b/e/c", "/a/d/b"); + List paths = List.of("/a/d/b/e/c", "/a/d/b"); for (String p : paths) { testRoot.getTree(p).remove(); testRoot.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java index 5d2ef62d1d8..5144efa7f04 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -58,7 +57,7 @@ public void testMatchesItem() throws Exception { public void testNotMatchesItem() throws Exception { Tree rootTree = root.getTree("/"); - List notMatching = ImmutableList.of(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, JcrConstants.NT_VERSION); + List notMatching = List.of(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, JcrConstants.NT_VERSION); for (String ntName : notMatching) { Tree testTree = TreeUtil.addChild(rootTree, "name", ntName); @@ -72,7 +71,7 @@ public void testNotMatchesItem() throws Exception { @Test public void testMatchesPath() { - List notMatching = ImmutableList.of("/", "/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c", "/d", "/b/d", "/d/e/f", "/c/b/abc"); + List notMatching = List.of("/", "/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c", "/d", "/b/d", "/d/e/f", "/c/b/abc"); for (String p : notMatching) { assertFalse(pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java index 06f5074dc4b..a1c38d0e9a4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java @@ -20,7 +20,6 @@ import java.util.Set; import javax.jcr.NamespaceRegistry; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -55,7 +54,7 @@ public void testMatchesItem() throws Exception { testTree.remove(); } - List notMatching = ImmutableList.of(NamespaceRegistry.PREFIX_EMPTY, NamespaceRegistry.PREFIX_MIX, "any"); + List notMatching = List.of(NamespaceRegistry.PREFIX_EMPTY, NamespaceRegistry.PREFIX_MIX, "any"); for (String prefix : notMatching) { String name = (prefix.isEmpty()) ? "name" : prefix + ":name"; Tree testTree = TreeUtil.addChild(rootTree, name, NodeTypeConstants.NT_OAK_UNSTRUCTURED); @@ -71,7 +70,7 @@ public void testMatchesItem() throws Exception { @Test public void testMatchesPath() { - List notMatching = ImmutableList.of("/", "/a", "/d/jcr:e/a"); + List notMatching = List.of("/", "/a", "/d/jcr:e/a"); for (String p : notMatching) { assertFalse(p, pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java index 021bc46d969..4221ac4b921 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -132,7 +131,7 @@ public void testGetSupportedDefinitions() { public void testGetRestrictionPattern() throws Exception { Map map = new HashMap<>(); map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content")); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -161,17 +160,17 @@ public void testGetPatternForAllSupported() throws Exception { Map map = new HashMap<>(); String globRestriction = "/*/jcr:content"; map.put(PropertyStates.createProperty(REP_GLOB, globRestriction), GlobPattern.create("/testPath", globRestriction)); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); - List prefixes = ImmutableList.of("rep", "jcr"); + List prefixes = List.of("rep", "jcr"); map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes)); - List itemNames = ImmutableList.of("abc", "jcr:primaryType"); + List itemNames = List.of("abc", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_ITEM_NAMES, prefixes, Type.NAMES), new ItemNamePattern(itemNames)); - List propNames = ImmutableList.of("jcr:mixinTypes", "jcr:primaryType"); + List propNames = List.of("jcr:mixinTypes", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_CURRENT, propNames, Type.STRINGS), new CurrentPattern("/testPath", propNames)); List globs = Collections.singletonList(globRestriction); map.put(PropertyStates.createProperty(REP_GLOBS, globs, Type.STRINGS), new GlobsPattern("/testPath", globs)); - List subtrees = ImmutableList.of("/sub/tree", "/a/b/c/"); + List subtrees = List.of("/sub/tree", "/a/b/c/"); map.put(PropertyStates.createProperty(REP_SUBTREES, subtrees, Type.STRINGS), new SubtreePattern("/testPath", subtrees)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -191,22 +190,22 @@ public void testGetPatternFromRestrictions() throws Exception { Map map = new HashMap<>(); map.put(PropertyStates.createProperty(REP_GLOB, globRestriction), GlobPattern.create("/testPath", globRestriction)); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); - List prefixes = ImmutableList.of("rep", "jcr"); + List prefixes = List.of("rep", "jcr"); map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes)); - List itemNames = ImmutableList.of("abc", "jcr:primaryType"); + List itemNames = List.of("abc", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_ITEM_NAMES, itemNames, Type.NAMES), new ItemNamePattern(itemNames)); - List propNames = ImmutableList.of("*"); + List propNames = List.of("*"); map.put(PropertyStates.createProperty(REP_CURRENT, propNames, Type.STRINGS), new CurrentPattern("/testPath", propNames)); List globs = Collections.singletonList(globRestriction); map.put(PropertyStates.createProperty(REP_GLOBS, globs, Type.STRINGS), new GlobsPattern("/testPath", globs)); - List subtrees = ImmutableList.of("/sub/tree", "/a/b/c/"); + List subtrees = List.of("/sub/tree", "/a/b/c/"); map.put(PropertyStates.createProperty(REP_SUBTREES, subtrees, Type.STRINGS), new SubtreePattern("/testPath", subtrees)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -259,7 +258,7 @@ public void testValidateGlobRestriction() throws Exception { AccessControlManager acMgr = getAccessControlManager(root); - List globs = ImmutableList.of( + List globs = List.of( "/1*/2*/3*/4*/5*/6*/7*/8*/9*/10*/11*/12*/13*/14*/15*/16*/17*/18*/19*/20*/21*", "*********************"); for (String glob : globs) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java index 723c552a005..0d3b5b2282f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.internal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -887,7 +886,7 @@ private void testMultipleServiceWithRanking(@NotNull String fieldName, @NotNull SortedMap m = (SortedMap) f.get(registration); assertEquals(3, m.size()); Collection c = m.values(); - assertTrue(Iterables.elementsEqual(ImmutableList.of(service2, service3, service1), c)); + assertTrue(Iterables.elementsEqual(List.of(service2, service3, service1), c)); } @Test @@ -1105,7 +1104,7 @@ public void testRegisterWithMonitors() { assertNull(context.getService(SecurityProvider.class)); AuthorizationConfiguration mockConfiguration = mockConfiguration(AuthorizationConfiguration.class); - when(mockConfiguration.getMonitors(any(StatisticsProvider.class))).thenReturn(ImmutableList.of(new TestMonitor())); + when(mockConfiguration.getMonitors(any(StatisticsProvider.class))).thenReturn(List.of(new TestMonitor())); registration.bindAuthorizationConfiguration(mockConfiguration, Collections.singletonMap(SERVICE_PID, "customAuthorizationConfig")); SecurityProvider service = context.getService(SecurityProvider.class); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java index f983f8cacc9..5115a6b24c1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -128,7 +129,7 @@ public ConfigurationParameters getParameters(@Nullable String name) { @NotNull @Override public Iterable getConfigurations() { - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java index 54cba9ac032..2e5ad92e9f3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java @@ -23,7 +23,10 @@ import java.util.List; import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; + import org.apache.jackrabbit.guava.common.collect.Iterators; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -76,7 +79,7 @@ public void testEveryoneMembers() throws Exception { root.commit(); Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME); - Set everyoneMembers = Set.copyOf(Collections.list(((GroupPrincipal) ep).members())); + Set everyoneMembers = ImmutableSet.copyOf(Collections.list(((GroupPrincipal) ep).members())); Iterator all = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL); while (all.hasNext()) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java index 42dd60c8f54..21170954a85 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.security.privilege; +import java.util.List; import java.util.Set; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -107,7 +107,7 @@ public void testJcrAllNodeAlreadyContainsNewName() { Root r = adminSession.getLatestRoot(); Tree t = r.getTree(PRIVILEGES_PATH); Tree jcrAll = t.getChild(JCR_ALL); - jcrAll.setProperty(REP_AGGREGATES, ImmutableList.of("newPriv"), Type.NAMES); + jcrAll.setProperty(REP_AGGREGATES, List.of("newPriv"), Type.NAMES); t.addChild("newPriv"); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProviderTest.java index e320c591924..d9f6800a7d7 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeBitsProviderTest.java @@ -20,9 +20,9 @@ import java.util.Set; import javax.jcr.RepositoryException; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; @@ -106,12 +106,12 @@ public void testGetAggregatedNamesUnknown() throws Exception { @Test public void testGetAggregatedNamesJcrAll() throws Exception { - assertEquals(NON_AGGREGATE_PRIVILEGES, CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); + assertEquals(NON_AGGREGATE_PRIVILEGES, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); } @Test public void testGetAggregatedNamesIncludingJcrAll() throws Exception { - assertEquals(NON_AGGREGATE_PRIVILEGES, CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_READ, JCR_WRITE, JCR_ALL))); + assertEquals(NON_AGGREGATE_PRIVILEGES, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_READ, JCR_WRITE, JCR_ALL))); } @Test @@ -119,12 +119,12 @@ public void getAggregatedNamesWithCustom() throws Exception { PrivilegeManager pMgr = getPrivilegeManager(root); pMgr.registerPrivilege("test1", true, null); - assertEquals(Set.of("test1"), CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames("test1"))); + assertEquals(Set.of("test1"), ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames("test1"))); Set expected = new HashSet<>(NON_AGGREGATE_PRIVILEGES); expected.add("test1"); - assertEquals(expected, CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); - assertEquals(expected, CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); + assertEquals(expected, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); + assertEquals(expected, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL))); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImplTest.java index 92eb28ff05e..2a64b88e0cd 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImplTest.java @@ -16,9 +16,10 @@ */ package org.apache.jackrabbit.oak.security.privilege; +import java.security.Principal; import java.util.List; -import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -71,7 +72,7 @@ public void testGetCommitHooks() { @Test public void testGetValidators() { - List l = configuration.getValidators("wspName", Set.of(), new MoveTracker()); + List l = configuration.getValidators("wspName", ImmutableSet.of(), new MoveTracker()); assertEquals(1, l.size()); assertTrue(l.get(0) instanceof PrivilegeValidatorProvider); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java index 746b3f9c21e..1fbeb1bcc8a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.security.privilege; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -123,7 +123,7 @@ public void testNotDefinesTree() { @Test public void testDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PrivilegeConstants.PRIVILEGES_PATH, PrivilegeConstants.PRIVILEGES_PATH + "/child", PrivilegeConstants.PRIVILEGES_PATH + "/another/child" @@ -139,7 +139,7 @@ public void testDefinesLocation() { @Test public void testNotDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PathUtils.ROOT_PATH, PrivilegeConstants.PRIVILEGES_PATH + "sibling", "/some/other/path", diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java index 4b6f2babb27..4d171217758 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java @@ -16,10 +16,11 @@ */ package org.apache.jackrabbit.oak.security.privilege; +import java.util.List; import java.util.Set; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -66,7 +67,7 @@ private static void assertAggregation(@NotNull Privilege[] aggr, @NotNull String assertEquals(expectedNames.length, aggr.length); Set expected = CollectionUtils.toSet(expectedNames); - Set result = CollectionUtils.toSet(Iterables.transform(Set.of(aggr), Privilege::getName)); + Set result = CollectionUtils.toSet(Iterables.transform(ImmutableSet.copyOf(aggr), Privilege::getName)); assertEquals(expected, result); } @@ -163,7 +164,7 @@ public void testToString() { public void testInvalidDeclaredAggregate() throws Exception { Tree privilegeDefs = root.getTree(PRIVILEGES_PATH); Tree privDef = TreeUtil.addChild(privilegeDefs, "test", NT_REP_PRIVILEGE); - privDef.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, "invalid"), Type.NAMES); + privDef.setProperty(REP_AGGREGATES, List.of(JCR_READ, "invalid"), Type.NAMES); Privilege p = getPrivilegeManager(root).getPrivilege("test"); assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ); @@ -173,7 +174,7 @@ public void testInvalidDeclaredAggregate() throws Exception { public void testCyclicDeclaredAggregate() throws Exception { Tree privilegeDefs = root.getTree(PRIVILEGES_PATH); Tree privDef = TreeUtil.addChild(privilegeDefs, "test", NT_REP_PRIVILEGE); - privDef.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, "test"), Type.NAMES); + privDef.setProperty(REP_AGGREGATES, List.of(JCR_READ, "test"), Type.NAMES); Privilege p = getPrivilegeManager(root).getPrivilege("test"); assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeManagerImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeManagerImplTest.java index 4fd5a8a982c..689b5f38c41 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeManagerImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeManagerImplTest.java @@ -23,11 +23,11 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper; import org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -217,7 +217,7 @@ protected Root getWriteRoot() { Iterable aggr = TreeUtil.getStrings(privTree, PrivilegeConstants.REP_AGGREGATES); assertNotNull(aggr); - assertEquals(Set.of("jcr:read", "jcr:write"), CollectionUtils.toSet(aggr)); + assertEquals(Set.of("jcr:read", "jcr:write"), ImmutableSet.copyOf(aggr)); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java index fcb7eadaa5c..73ab423ce8c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java @@ -17,9 +17,9 @@ package org.apache.jackrabbit.oak.security.privilege; import java.util.Collections; -import java.util.Set; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; @@ -79,7 +79,7 @@ public void after() throws Exception { private Tree createPrivilegeTree(@NotNull String privName, @NotNull String... aggr) { Tree privTree = privilegesTree.addChild(privName); privTree.setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE, Type.NAME); - privTree.setProperty(REP_AGGREGATES, Set.of(aggr), Type.NAMES); + privTree.setProperty(REP_AGGREGATES, ImmutableSet.copyOf(aggr), Type.NAMES); return privTree; } @@ -129,7 +129,7 @@ public void testBitsConflictWithAggregation() throws Exception { try { Tree privTree = createPrivilegeTree("test"); privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, - ImmutableList.of(JCR_READ, JCR_MODIFY_PROPERTIES), Type.NAMES)); + List.of(JCR_READ, JCR_MODIFY_PROPERTIES), Type.NAMES)); setPrivilegeBits(privTree, REP_BITS, 340); root.commit(); @@ -211,7 +211,7 @@ public void testChildNodeChangedWithoutChanges() throws CommitFailedException { public void testAggregatesIncludesJcrAll() throws Exception { try { Tree privTree = createPrivilegeTree("test"); - privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(JCR_ALL, JCR_READ, JCR_WRITE), Type.NAMES)); + privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, List.of(JCR_ALL, JCR_READ, JCR_WRITE), Type.NAMES)); PrivilegeBits.getInstance(bitsProvider.getBits(JCR_ALL, JCR_READ, JCR_WRITE)).writeTo(privTree); root.commit(); @@ -224,7 +224,7 @@ public void testAggregatesIncludesJcrAll() throws Exception { public void testAggregatesMatchesExisting() throws Exception { try { Tree privTree = createPrivilegeTree("test"); - privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES)); + privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES)); PrivilegeBits.getInstance(bitsProvider.getBits(REP_READ_NODES, REP_READ_PROPERTIES)).writeTo(privTree); root.commit(); @@ -236,8 +236,8 @@ public void testAggregatesMatchesExisting() throws Exception { @Test(expected = CommitFailedException.class) public void testPropertyChanged() throws Exception { try { - PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); - PropertyState after = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES), Type.NAMES); + PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); + PropertyState after = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES), Type.NAMES); PrivilegeValidator validator = new PrivilegeValidator(root, root, getTreeProvider()); validator.propertyChanged(before, after); @@ -249,7 +249,7 @@ public void testPropertyChanged() throws Exception { @Test(expected = CommitFailedException.class) public void testPropertyDeleted() throws Exception { try { - PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); + PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); PrivilegeValidator validator = new PrivilegeValidator(root, root, getTreeProvider()); validator.propertyDeleted(before); @@ -288,7 +288,7 @@ public void testUnknownAggregate() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("unknown", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("unknown", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -306,7 +306,7 @@ public void testCircularAggregate() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("test", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("test", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -325,7 +325,7 @@ public void testCircularAggregate2() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("test2", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("test2", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -344,7 +344,7 @@ public void testInvalidAggregation() throws Exception { Tree privDefs = root.getTree(PRIVILEGES_PATH); Tree newPriv = TreeUtil.addChild(privDefs, "newPriv", NT_REP_PRIVILEGE); PrivilegeBits.getInstance(PrivilegeBits.BUILT_IN.get(JCR_READ), PrivilegeBits.BUILT_IN.get(JCR_ADD_CHILD_NODES)).writeTo(newPriv); - newPriv.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, JCR_ADD_CHILD_NODES), Type.NAMES); + newPriv.setProperty(REP_AGGREGATES, List.of(JCR_READ, JCR_ADD_CHILD_NODES), Type.NAMES); TreeProvider tp = mock(TreeProvider.class); when(tp.createReadOnlyTree(any(Tree.class), anyString(), any(NodeState.class))).thenReturn(newPriv); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java index fa6b8123f33..b07ed1eee0c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -87,7 +86,7 @@ public void testIsMemberOf() throws Exception { @Test public void testIsMemberMissingAuthorizable() { - List principals = ImmutableList.of( + List principals = List.of( new PrincipalImpl("name"), () -> "name" ); @@ -108,7 +107,7 @@ public void testIsMemberOfEveryone() throws Exception { @Test public void testIsMemberOfEveryoneMissingAuthorizable() { - List principals = ImmutableList.of( + List principals = List.of( new PrincipalImpl("name"), () -> "name" ); @@ -188,7 +187,7 @@ boolean isMember(@NotNull Authorizable authorizable) throws RepositoryException @NotNull @Override Iterator getMembers() throws RepositoryException { - return ImmutableList.of(member).iterator(); + return List.of(member).iterator(); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java index c4c16a85137..df8b6b14bcd 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java @@ -17,11 +17,11 @@ package org.apache.jackrabbit.oak.security.user; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -110,7 +110,7 @@ public void testNonExistingMember() throws Exception { assertTrue(failed.isEmpty()); Iterable memberIds = getMemberIds(testGroup); - Iterables.elementsEqual(ImmutableList.copyOf(NON_EXISTING_IDS), memberIds); + Iterables.elementsEqual(Arrays.asList(NON_EXISTING_IDS), memberIds); Iterator members = testGroup.getDeclaredMembers(); assertFalse(members.hasNext()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdIgnoreTest.java index 6bc4f44e5e8..fcce1a541c1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdIgnoreTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; @@ -40,7 +41,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { @Test public void testNonExistingMember() throws Exception { Set failed = addNonExistingMember(); - assertEquals(Set.of(NON_EXISTING_IDS), failed); + assertEquals(ImmutableSet.copyOf(NON_EXISTING_IDS), failed); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java index 0484a939a4d..ac965482b11 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.User; @@ -100,7 +99,7 @@ public void testInvalidPath() { @Test public void testFilterDuplicates() throws Exception { - List l = ImmutableList.of(getTestUser()); + List l = List.of(getTestUser()); assertEquals(1, Iterators.size(AuthorizableIterator.create(true, l.iterator(), l.iterator()))); assertEquals(2, Iterators.size(AuthorizableIterator.create(false, l.iterator(), l.iterator()))); @@ -119,7 +118,7 @@ public void testFilterDuplicatesHandlesNull() throws Exception { public void testFilterDuplicatesGetIdFails() throws Exception { Authorizable a = when(mock(Authorizable.class).getID()).thenThrow(new RepositoryException()).getMock(); - List l = ImmutableList.of(getTestUser(), a); + List l = List.of(getTestUser(), a); assertEquals(1, Iterators.size(AuthorizableIterator.create(true, l.iterator(), Collections.emptyIterator()))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImplTest.java index 664659b8a03..071ee17fd0e 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImplTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -26,7 +27,6 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.apache.jackrabbit.oak.plugins.value.jcr.PartialValueFactory; @@ -156,7 +156,7 @@ public void testGetNamesCurrent2() throws Exception { Iterator names = properties.getNames("."); Set expected = Set.of("prop", "mvProp"); - assertEquals(expected, CollectionUtils.toSet(names)); + assertEquals(expected, ImmutableSet.copyOf(names)); } @Test(expected = RepositoryException.class) @@ -169,7 +169,7 @@ public void testGetNamesRelPath() throws Exception { Iterator names = properties.getNames("relPath"); Set expected = Set.of("prop", "mvProp"); - assertEquals(expected, CollectionUtils.toSet(names)); + assertEquals(expected, ImmutableSet.copyOf(names)); } //--------------------------------------------------------< getProperty >--- diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/EveryoneGroupTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/EveryoneGroupTest.java index 99b3e9752cd..1950e881950 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/EveryoneGroupTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/EveryoneGroupTest.java @@ -20,12 +20,12 @@ import java.util.Iterator; import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.junit.Test; @@ -104,7 +104,7 @@ public void testIsDeclaredMember() throws Exception { @Test public void testGetMembers() throws Exception { - Set members = CollectionUtils.toSet(everyoneGroup.getMembers()); + Set members = ImmutableSet.copyOf(everyoneGroup.getMembers()); assertFalse(members.contains(everyoneGroup)); for (Authorizable a : authorizables) { @@ -114,7 +114,7 @@ public void testGetMembers() throws Exception { @Test public void testGetDeclaredMembers() throws Exception { - Set members = CollectionUtils.toSet(everyoneGroup.getDeclaredMembers()); + Set members = ImmutableSet.copyOf(everyoneGroup.getDeclaredMembers()); assertFalse(members.contains(everyoneGroup)); for (Authorizable a : authorizables) { @@ -176,7 +176,7 @@ public void testEveryoneDeclaredMemberOf() throws Exception { @Test public void testMemberOfIncludesEveryone() throws Exception { for (Authorizable a : authorizables) { - Set groups = CollectionUtils.toSet(a.memberOf()); + Set groups = ImmutableSet.copyOf(a.memberOf()); assertTrue(groups.contains(everyoneGroup)); } } @@ -184,7 +184,7 @@ public void testMemberOfIncludesEveryone() throws Exception { @Test public void testDeclaredMemberOfIncludesEveryone() throws Exception { for (Authorizable a : authorizables) { - Set groups = CollectionUtils.toSet(a.declaredMemberOf()); + Set groups = ImmutableSet.copyOf(a.declaredMemberOf()); assertTrue(groups.contains(everyoneGroup)); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java index daa120d8fe7..e88bc84bc4f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -31,6 +30,7 @@ import javax.jcr.nodetype.ConstraintViolationException; import java.security.Principal; import java.util.Iterator; +import java.util.List; import java.util.UUID; import static org.apache.jackrabbit.oak.spi.security.user.UserConstants.REP_MEMBERS; @@ -165,7 +165,7 @@ public void testGroupPrincipalMembers() throws Exception { @Test public void testImpactOfOak8054AddingMembers() throws Exception { Tree groupTree = root.getTree(group.getPath()); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(getTestUser().getID())), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(getTestUser().getID())), Type.STRINGS); root.commit(); group.addMember(uMgr.createUser("userid", null)); @@ -182,7 +182,7 @@ public void testImpactOfOak8054RemovingMembers() throws Exception { User user = uMgr.createUser("userid", null); UserProvider up = new UserProvider(root, ConfigurationParameters.EMPTY); Tree groupTree = root.getTree(group.getPath()); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(up.getContentID(getTestUser().getID()), up.getContentID(user.getID())), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(up.getContentID(getTestUser().getID()), up.getContentID(user.getID())), Type.STRINGS); root.commit(); group.removeMembers(user.getID()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplEmptyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplEmptyTest.java index b87d8d41dd6..d8ee65e2dae 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplEmptyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplEmptyTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -94,7 +95,7 @@ private Principal getAdminPrincipal() throws Exception { @NotNull static Subject createSubject(@NotNull Principal... principals) { - return new Subject(true, Set.of(principals), Set.of(), Set.of()); + return new Subject(true, ImmutableSet.copyOf(principals), Set.of(), Set.of()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java index 1b244b09d47..8cc770d5d86 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java @@ -18,13 +18,14 @@ import java.security.Principal; import java.util.Enumeration; +import java.util.List; import java.util.Set; import java.util.UUID; import javax.jcr.RepositoryException; import javax.security.auth.Subject; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.principal.PrincipalIterator; import org.apache.jackrabbit.api.security.user.Group; @@ -32,7 +33,6 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; import org.jetbrains.annotations.NotNull; @@ -93,7 +93,7 @@ public void testContentRepresentation() throws Exception { PropertyState property = tree.getProperty(UserConstants.REP_IMPERSONATORS); assertNotNull(property); - assertEquals(ImmutableList.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); + assertEquals(List.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); } @Test @@ -172,7 +172,7 @@ public void testContentRepresentationAfterModification() throws Exception { assertNotNull(property); Set expected = Set.of(impersonator.getPrincipal().getName(), principal2.getName()); - assertEquals(expected, CollectionUtils.toSet(property.getValue(Type.STRINGS))); + assertEquals(expected, ImmutableSet.copyOf(property.getValue(Type.STRINGS))); impersonation.revokeImpersonation(impersonator.getPrincipal()); @@ -180,7 +180,7 @@ public void testContentRepresentationAfterModification() throws Exception { assertNotNull(property); expected = Set.of(principal2.getName()); - assertEquals(expected, CollectionUtils.toSet(property.getValue(Type.STRINGS))); + assertEquals(expected, ImmutableSet.copyOf(property.getValue(Type.STRINGS))); impersonation.revokeImpersonation(principal2); assertNull(tree.getProperty(UserConstants.REP_IMPERSONATORS)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/InheritedMembersIteratorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/InheritedMembersIteratorTest.java index 2709dfde220..c34f8ee213f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/InheritedMembersIteratorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/InheritedMembersIteratorTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -23,7 +24,6 @@ import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.user.DynamicMembershipProvider; import org.jetbrains.annotations.NotNull; import org.junit.Before; @@ -134,7 +134,7 @@ public void testDynamicMembersFails() throws Exception { } private static @NotNull Set getMembersIds(@NotNull InheritedMembersIterator it) { - return CollectionUtils.toSet(Iterators.transform(it, authorizable -> { + return ImmutableSet.copyOf(Iterators.transform(it, authorizable -> { try { return authorizable.getID(); } catch (RepositoryException repositoryException) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java index e6685bc4b2a..69fb4b94fa3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java @@ -22,7 +22,6 @@ import javax.jcr.RepositoryException; import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -139,7 +138,7 @@ public void testGroupWrongRoot() throws Exception { @Test public void testInvalidAbsolutePaths() throws Exception { TreeUtil.addChild(root.getTree(PathUtils.ROOT_PATH), "testNode", NodeTypeConstants.NT_OAK_UNSTRUCTURED); - List invalidPaths = ImmutableList.of( + List invalidPaths = List.of( "/", PathUtils.getAncestorPath(UserConstants.DEFAULT_GROUP_PATH, 1), PathUtils.getAncestorPath(UserConstants.DEFAULT_GROUP_PATH, 2), @@ -183,7 +182,7 @@ public void testAbsolutePathsWithInvalidParentElements() throws Exception { @Test public void testRelativePaths() throws Exception { TreeUtil.addChild(root.getTree(PathUtils.ROOT_PATH), "testNode", NodeTypeConstants.NT_OAK_UNSTRUCTURED); - List invalidPaths = ImmutableList.of("..", "../..", "../../..", "../../../testNode","a/b/../../../c"); + List invalidPaths = List.of("..", "../..", "../../..", "../../../testNode","a/b/../../../c"); for (String relPath : invalidPaths) { try { createAuthorizable(false, relPath); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java index f7698b6835c..2001c249145 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; @@ -36,6 +35,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; +import java.util.List; import java.util.Map; /** @@ -57,7 +57,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { pwAction.init(null, ConfigurationParameters.of( PasswordValidationAction.CONSTRAINT, "^.*(?=.{4,}).*" )); - final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(pwAction); + final AuthorizableActionProvider actionProvider = securityProvider -> List.of(pwAction); ConfigurationParameters userConfig = ConfigurationParameters.of( Map.of( diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java index d2c31065a10..08139e751bf 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java @@ -24,11 +24,11 @@ import javax.jcr.RepositoryException; import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; @@ -62,7 +62,9 @@ protected ConfigurationParameters getSecurityConfigParameters() { @NotNull private List getHistory(@NotNull User user) throws RepositoryException { Iterable history = TreeUtil.getStrings(root.getTree(user.getPath()).getChild(REP_PWD), REP_PWD_HISTORY); - return (history == null) ? Collections.emptyList() : ImmutableList.copyOf(history).reverse(); + List result = history == null ? Collections.emptyList() : CollectionUtils.toList(history); + Collections.reverse(result); + return result; } /** @@ -217,7 +219,7 @@ public void testDisabledPasswordHistory() throws Exception { User user = getTestUser(); Tree userTree = root.getTree(user.getPath()); - List configs = ImmutableList.of( + List configs = List.of( ConfigurationParameters.EMPTY, ConfigurationParameters.of(PARAM_PASSWORD_HISTORY_SIZE, PASSWORD_HISTORY_DISABLED_SIZE), ConfigurationParameters.of(PARAM_PASSWORD_HISTORY_SIZE, -1), diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdBestEffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdBestEffortTest.java index f517e4e45c5..e0dfefd3cbe 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdBestEffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdBestEffortTest.java @@ -18,6 +18,7 @@ import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; @@ -41,7 +42,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { @Test public void testNonExistingMember() throws Exception { Set failed = removeNonExistingMember(); - assertEquals(Set.of(NON_EXISTING_IDS), failed); + assertEquals(ImmutableSet.copyOf(NON_EXISTING_IDS), failed); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdIgnoreTest.java index 9eba0f3e7b8..0c5ef1b0d17 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RemoveMembersByIdIgnoreTest.java @@ -18,6 +18,7 @@ import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; @@ -40,7 +41,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { @Test public void testNonExistingMember() throws Exception { Set failed = removeNonExistingMember(); - assertEquals(Set.of(NON_EXISTING_IDS), failed); + assertEquals(ImmutableSet.copyOf(NON_EXISTING_IDS), failed); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RepMembersConflictHandlerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RepMembersConflictHandlerTest.java index f473a376e3c..ab75b267b73 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RepMembersConflictHandlerTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/RepMembersConflictHandlerTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java index dc7aea0c5f1..b268e6bc350 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; @@ -49,6 +48,7 @@ import javax.jcr.nodetype.ConstraintViolationException; import javax.security.auth.login.LoginException; import java.util.Iterator; +import java.util.List; import java.util.UUID; import static org.junit.Assert.assertEquals; @@ -95,7 +95,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, (AuthorizableActionProvider) securityProvider -> { AuthorizableAction action = new AccessControlAction(); action.init(securityProvider, ConfigurationParameters.of(AccessControlAction.USER_PRIVILEGE_NAMES, new String[]{PrivilegeConstants.JCR_ALL})); - return ImmutableList.of(action); + return List.of(action); })); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java index 1b9aa5da037..4afdd01266b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; @@ -225,7 +224,7 @@ public void testPropertyDefinesLocation() { NT_REP_GROUP, GROUP_PROPERTY_NAMES, NT_REP_USER, USER_PROPERTY_NAMES, NT_REP_PASSWORD, PWD_PROPERTY_NAMES, - NT_REP_MEMBER_REFERENCES, ImmutableList.of(REP_MEMBERS) + NT_REP_MEMBER_REFERENCES, List.of(REP_MEMBERS) ); m.forEach((key, value) -> { @@ -302,7 +301,7 @@ public void testNoTreeDefinesLocationIntermediate() { @Test public void testNotDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PathUtils.ROOT_PATH, NodeTypeConstants.NODE_TYPES_PATH, "/content", diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java index 15a22c7c20c..b91b5a75b92 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.User; @@ -65,7 +64,7 @@ public abstract class UserImporterBaseTest extends AbstractSecurityTest implemen @NotNull @Override public List getAuthorizableActions(@NotNull SecurityProvider securityProvider) { - return (testAction == null) ? ImmutableList.of() : ImmutableList.of(testAction); + return (testAction == null) ? List.of() : List.of(testAction); } }; @@ -206,6 +205,6 @@ PropertyDefinition mockPropertyDefinition(@NotNull String declaringNt, boolean m @NotNull NodeInfo createNodeInfo(@NotNull String name, @NotNull String primaryTypeName) { - return new NodeInfo(name, primaryTypeName, ImmutableList.of(), null); + return new NodeInfo(name, primaryTypeName, List.of(), null); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationBestEffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationBestEffortTest.java index 6e1b057e579..38e47e967e5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationBestEffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationBestEffortTest.java @@ -16,9 +16,9 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -43,7 +43,7 @@ public void testUnknownImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(Set.of("impersonator1", "impersonator2"), CollectionUtils.toSet(impersonators.getValue(Type.STRINGS))); + assertEquals(Set.of("impersonator1", "impersonator2"), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS))); } @Test @@ -53,6 +53,6 @@ public void testMixedImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(Set.of("impersonator1", testUser.getPrincipal().getName()), CollectionUtils.toSet(impersonators.getValue(Type.STRINGS))); + assertEquals(Set.of("impersonator1", testUser.getPrincipal().getName()), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS))); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java index 9a0ac481438..20e16325f86 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java @@ -16,14 +16,13 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; @@ -34,6 +33,7 @@ import javax.jcr.RepositoryException; import java.security.Principal; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -73,7 +73,7 @@ public void testKnownImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test @@ -83,7 +83,7 @@ public void testMixedImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test(expected = RepositoryException.class) @@ -102,26 +102,26 @@ public void testUserConvertedGroupBeforeProcessing() throws Exception { @Test public void testReplaceExistingProperty() throws Exception { - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test public void testReplaceExistingProperty2() throws Exception { - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(Set.of("impersonator1", testUser.getPrincipal().getName()), CollectionUtils.toSet(impersonators.getValue(Type.STRINGS))); + assertEquals(Set.of("impersonator1", testUser.getPrincipal().getName()), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS))); } @Test @@ -138,7 +138,7 @@ public void testNewImpersonator() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of("impersonator1"), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of("impersonator1"), impersonators.getValue(Type.STRINGS)); } @Test @@ -156,7 +156,7 @@ public void testNewImpersonator2() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of("impersonator1"), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of("impersonator1"), impersonators.getValue(Type.STRINGS)); } @Test @@ -176,7 +176,7 @@ public void testRevokeImpersonationAlreadyRemoved() throws Exception { return null; }).when(ua).onRevokeImpersonation(any(User.class), any(Principal.class), any(Root.class), any(NamePathMapper.class)); - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java index 8d8d22faec5..c4e44304fb8 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java @@ -18,7 +18,6 @@ import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; @@ -26,6 +25,8 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertTrue; public class UserImporterMembershipAbortTest extends UserImporterMembershipIgnoreTest { @@ -38,13 +39,13 @@ String getImportBehavior() { @Test(expected = ConstraintViolationException.class) public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); } @Test(expected = ConstraintViolationException.class) public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); } @@ -59,7 +60,7 @@ public void testAddSameAsMember() throws Exception { @Test(expected = ConstraintViolationException.class) public void testNewMembersToEveryone() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); groupTree.setProperty(REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); Tree userTree = createUserTree(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java index 324f1f0fa8b..5d7ec9d2795 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java @@ -16,11 +16,12 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertTrue; public class UserImporterMembershipBesteffortTest extends UserImporterMembershipIgnoreTest { @@ -33,7 +34,7 @@ String getImportBehavior() { @Test public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); @@ -41,7 +42,7 @@ public void testUnknownMember() throws Exception { @Test public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java index 87c0e70ddf3..2d062572c1e 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java @@ -21,7 +21,7 @@ import java.util.Set; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.oak.api.PropertyState; @@ -68,13 +68,13 @@ public void before() throws Exception { @Test(expected = IllegalArgumentException.class) public void testInvalidMemberContentId() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "memberId"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "memberId"))); importer.processReferences(); } @Test public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); // default importbehavior == IGNORE @@ -83,7 +83,7 @@ public void testUnknownMember() throws Exception { @Test public void testKnownMemberThresholdNotReached() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); @@ -97,7 +97,7 @@ public void testKnownMemberThresholdReached() throws Exception { } groupTree.setProperty(REP_MEMBERS, memberIds, Type.STRINGS); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertEquals(1, memberRefList.getChildrenCount(100)); @@ -106,7 +106,7 @@ public void testKnownMemberThresholdReached() throws Exception { @Test public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); assertFalse(memberRefList.hasChild("memberRef")); @@ -114,7 +114,7 @@ public void testMixedMembers() throws Exception { @Test(expected = RepositoryException.class) public void testGroupRemovedBeforeProcessing() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); groupTree.remove(); importer.processReferences(); @@ -122,21 +122,21 @@ public void testGroupRemovedBeforeProcessing() throws Exception { @Test(expected = RepositoryException.class) public void testUserConvertedGroupBeforeProcessing() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); groupTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_USER); importer.processReferences(); } @Test public void testAddMemberToNonExistingMember() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(unknownContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(unknownContentId), Type.STRINGS); assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, knownMemberContentId), mockPropertyDefinition(NT_REP_GROUP, true))); importer.processReferences(); PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(Set.of(unknownContentId, knownMemberContentId), CollectionUtils.toSet(members.getValue(Type.STRINGS))); + assertEquals(Set.of(unknownContentId, knownMemberContentId), ImmutableSet.copyOf(members.getValue(Type.STRINGS))); } @Test @@ -145,13 +145,13 @@ public void testAddReplacesExistingMember() throws Exception { String contentId = userProvider.getContentID(userTree); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_AUTHORIZABLE_ID, TEST_USER_ID), mockPropertyDefinition(NT_REP_AUTHORIZABLE, false))); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, contentId), mockPropertyDefinition(NT_REP_GROUP, true))); importer.processReferences(); PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(Set.of(contentId), CollectionUtils.toSet(members.getValue(Type.STRINGS))); + assertEquals(Set.of(contentId), ImmutableSet.copyOf(members.getValue(Type.STRINGS))); } @Test @@ -165,7 +165,7 @@ public void testNewMembers() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList(members.getValue(Type.STRINGS))); } @Test @@ -180,7 +180,7 @@ public void testNewMembers2() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } @Test @@ -197,7 +197,7 @@ public void testAddSameAsMember() throws Exception { @Test public void testNewMembersToEveryone() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); groupTree.setProperty(REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); Tree userTree = createUserTree(); @@ -209,7 +209,7 @@ public void testNewMembersToEveryone() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(knownMemberContentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(knownMemberContentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } @Test @@ -227,6 +227,6 @@ public void testAddExistingMembers() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java index abe4b03f790..a8782755da7 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; @@ -52,6 +51,7 @@ import javax.jcr.nodetype.PropertyDefinition; import java.lang.reflect.Field; import java.util.Collections; +import java.util.List; import java.util.Map; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; @@ -625,7 +625,7 @@ public void testStartNonExistingTree() throws Exception { @Test(expected = IllegalStateException.class) public void testStartChildInfoIllegalState() { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test(expected = IllegalStateException.class) @@ -635,7 +635,7 @@ public void testStartChildInfoWithoutValidStart() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); importer.start(memberRefList); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test @@ -646,7 +646,7 @@ public void testStartChildInfoWithoutRepMembersProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of()); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of()); } @Test @@ -657,7 +657,7 @@ public void testStartChildInfoWithRepMembersProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test @@ -668,7 +668,7 @@ public void testStartChildInfoWithOtherProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); importer.start(memberRefList); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo("otherName", "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo("otherName", "member1"))); importer.processReferences(); // no members should have been added to the group node @@ -684,7 +684,7 @@ public void testStartRepMembersChildInfo() throws Exception { Tree repMembers = groupTree.addChild("memberTree"); repMembers.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBERS); assertTrue(importer.start(repMembers)); - importer.startChildInfo(createNodeInfo("memberTree", NT_REP_MEMBERS), ImmutableList.of(createPropInfo("anyProp", "memberValue"))); + importer.startChildInfo(createNodeInfo("memberTree", NT_REP_MEMBERS), List.of(createPropInfo("anyProp", "memberValue"))); } @Test @@ -695,7 +695,7 @@ public void testStartOtherChildInfo() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_OAK_UNSTRUCTURED), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_OAK_UNSTRUCTURED), List.of(createPropInfo(REP_MEMBERS, "member1"))); } //-------------------------------------------------------< endChildInfo >--- diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserPrincipalProviderWithCacheTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserPrincipalProviderWithCacheTest.java index 9eab5f5b6d0..9ffab3c9a14 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserPrincipalProviderWithCacheTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserPrincipalProviderWithCacheTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.principal.PrincipalIterator; import org.apache.jackrabbit.api.security.principal.PrincipalManager; @@ -28,7 +29,6 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.jdkcompat.Java23Subject; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.apache.jackrabbit.oak.security.principal.AbstractPrincipalProviderTest; @@ -183,7 +183,7 @@ public void testPrincipalManagerGetGroupMembershipPopulatesCache() throws Except PrincipalManager principalManager = getPrincipalManager(systemRoot); PrincipalIterator principalIterator = principalManager.getGroupMembership(getTestUser().getPrincipal()); - assertPrincipals(CollectionUtils.toSet(principalIterator), EveryonePrincipal.getInstance(), testGroup.getPrincipal()); + assertPrincipals(ImmutableSet.copyOf(principalIterator), EveryonePrincipal.getInstance(), testGroup.getPrincipal()); root.refresh(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java index d4c8cd6fd44..302926740e0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -33,6 +32,7 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.mockito.Mockito.mock; @@ -45,7 +45,7 @@ public class GroupActionTest extends AbstractSecurityTest { private static final String TEST_USER_PREFIX = "testUser"; final GroupAction groupAction = mock(GroupAction.class); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(groupAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(groupAction); private User testUser01; private User testUser02; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java index 0b910ad496b..abba077269e 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Type; @@ -44,7 +45,7 @@ public class PasswordValidationActionTest extends AbstractSecurityTest { private final PasswordValidationAction pwAction = new PasswordValidationAction(); private final AuthorizableAction testAction = mock(AuthorizableAction.class); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(pwAction, testAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(pwAction, testAction); @Before public void before() throws Exception { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java index bbff8dda1e0..db0b8e61339 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -35,6 +34,7 @@ import javax.jcr.RepositoryException; import javax.jcr.ValueFactory; import java.security.Principal; +import java.util.List; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -50,7 +50,7 @@ public class UserActionTest extends AbstractSecurityTest { private UserAction userAction = mock(UserAction.class); private ClearProfileAction clearProfileAction = new ClearProfileAction(); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(userAction, clearProfileAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(userAction, clearProfileAction); @Override protected ConfigurationParameters getSecurityConfigParameters() { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java index f95c8d01890..00b7ed2b0f6 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java @@ -24,7 +24,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.QueryBuilder; @@ -159,7 +158,7 @@ public void testNodeTypeName() { @Test public void testEscapeNodeName() { - List names = ImmutableList.of("name", JcrConstants.JCR_CREATED, "%name", "a%name", "name%"); + List names = List.of("name", JcrConstants.JCR_CREATED, "%name", "a%name", "name%"); for (String name : names) { assertEquals(QueryUtils.escapeNodeName(name), QueryUtil.escapeNodeName(name)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java index 6f6c3b4dfdc..0b4b916decc 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java @@ -18,9 +18,9 @@ import java.util.Collections; import java.util.Iterator; +import java.util.List; import java.util.NoSuchElementException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.junit.Test; @@ -37,7 +37,7 @@ public void createWithNegativeOffset() { @Test public void testCreateWithoutLimitation() { - Iterator it = ImmutableList.of("str").iterator(); + Iterator it = List.of("str").iterator(); assertSame(it, ResultIterator.create(ResultIterator.OFFSET_NONE, ResultIterator.MAX_ALL, it)); } @@ -58,22 +58,22 @@ public void testCreateOffsetGtSize() { @Test public void testCreateOffsetLtSize() { - assertEquals(1, Iterators.size(ResultIterator.create(1, ResultIterator.MAX_ALL, ImmutableList.of("str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(1, ResultIterator.MAX_ALL, List.of("str", "str").iterator()))); } @Test public void testCreateOffsetEqualsMax() { - assertEquals(1, Iterators.size(ResultIterator.create(1, 1, ImmutableList.of("str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(1, 1, List.of("str", "str").iterator()))); } @Test public void testCreateOffsetGtMax() { - assertEquals(1, Iterators.size(ResultIterator.create(2, 1, ImmutableList.of("str", "str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(2, 1, List.of("str", "str", "str").iterator()))); } @Test public void testCreateOffsetLtMax() { - Iterator resultIt = ResultIterator.create(1, 3, ImmutableList.of("str", "str", "str", "str").iterator()); + Iterator resultIt = ResultIterator.create(1, 3, List.of("str", "str", "str", "str").iterator()); assertEquals(3, Iterators.size(resultIt)); } @@ -85,7 +85,7 @@ public void testNextNoElements() { @Test public void testNextWithOffset() { - Iterator it = ResultIterator.create(1, ResultIterator.MAX_ALL, ImmutableList.of("str", "str2").iterator()); + Iterator it = ResultIterator.create(1, ResultIterator.MAX_ALL, List.of("str", "str2").iterator()); assertEquals("str2", it.next()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java index a3c476adae7..1c350b76039 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.security.user.query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -53,7 +53,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Set; import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants.JCR_READ; @@ -145,7 +144,7 @@ private static void assertResultContainsAuthorizables(@NotNull Iterator void build(@NotNull QueryBuilder builder) { }; Iterator result = queryMgr.findAuthorizables(q); - assertEquals(ImmutableList.of(user, g2, g), ImmutableList.copyOf(result)); + assertEquals(List.of(user, g2, g), CollectionUtils.toList(result)); } @Test @@ -517,7 +516,7 @@ public void build(@NotNull QueryBuilder builder) { }; Iterator result = queryMgr.findAuthorizables(q); - assertEquals(ImmutableList.of(user, g, g2), ImmutableList.copyOf(result)); + assertEquals(List.of(user, g, g2), CollectionUtils.toList(result)); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java index e46fb2bd27c..e7be81e0e5b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; import org.apache.jackrabbit.oak.spi.security.user.action.AbstractAuthorizableAction; import org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableAction; @@ -64,7 +63,7 @@ public void testStarted() { public void testRegisteredImplementation() { actionProvider.start(whiteboard); - AuthorizableActionProvider registered = securityProvider -> ImmutableList.of(new TestAction()); + AuthorizableActionProvider registered = securityProvider -> List.of(new TestAction()); whiteboard.register(AuthorizableActionProvider.class, registered, Map.of()); List actions = actionProvider.getAuthorizableActions(Mockito.mock(SecurityProvider.class)); diff --git a/oak-doc/src/site/markdown/query/property-index.md b/oak-doc/src/site/markdown/query/property-index.md index 940f7c93458..ebd6b3113fd 100644 --- a/oak-doc/src/site/markdown/query/property-index.md +++ b/oak-doc/src/site/markdown/query/property-index.md @@ -115,7 +115,7 @@ or to simplify you can use one of the existing `IndexUtils#createIndexDefinition { NodeBuilder index = IndexUtils.getOrCreateOakIndex(root); - IndexUtils.createIndexDefinition(index, "myProp", true, false, ImmutableList.of("myProp"), null); + IndexUtils.createIndexDefinition(index, "myProp", true, false, List.of("myProp"), null); } #### Reindexing diff --git a/oak-doc/src/site/markdown/security/authentication/externalloginmodule.md b/oak-doc/src/site/markdown/security/authentication/externalloginmodule.md index 7364fd77e5e..5a5a1a646b7 100644 --- a/oak-doc/src/site/markdown/security/authentication/externalloginmodule.md +++ b/oak-doc/src/site/markdown/security/authentication/externalloginmodule.md @@ -203,7 +203,7 @@ handles the same set of supported credentials! @Nonnull @Override public Set getCredentialClasses() { - return Set.of(MyCredentials.class); + return ImmutableSet.of(MyCredentials.class); } @CheckForNull diff --git a/oak-doc/src/site/markdown/security/authentication/token/default.md b/oak-doc/src/site/markdown/security/authentication/token/default.md index f04ef4f9056..99965e10abc 100644 --- a/oak-doc/src/site/markdown/security/authentication/token/default.md +++ b/oak-doc/src/site/markdown/security/authentication/token/default.md @@ -261,7 +261,7 @@ in order to enable a custom `CredentialsSupport`. @Nonnull @Override public Set getCredentialClasses() { - return Set.of(MyCredentials.class); + return ImmutableSet.of(MyCredentials.class); } @CheckForNull diff --git a/oak-doc/src/site/markdown/security/user/default.md b/oak-doc/src/site/markdown/security/user/default.md index fe269004d6f..3bb9817370d 100644 --- a/oak-doc/src/site/markdown/security/user/default.md +++ b/oak-doc/src/site/markdown/security/user/default.md @@ -326,7 +326,7 @@ implementation. //------------------------------------------------< SCR Integration >--- @Activate private void activate(Map properties) { - ids = CollectionUtils.toSet(PropertiesUtil.toStringArray(properties.get("ids"), new String[0])); + ids = ImmutableSet.copyOf(PropertiesUtil.toStringArray(properties.get("ids"), new String[0])); } } diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java index d443f0d9247..9583db37a3b 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java @@ -27,7 +27,6 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; @@ -270,7 +269,7 @@ public void testSessionGetEffectivePoliciesWithoutPrivilege() throws Exception { testSession = getTestSession(); AccessControlManager testAcMgr = testSession.getAccessControlManager(); - List paths = ImmutableList.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); + List paths = List.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); for (String path : paths) { // EXERCISE : complete or fix the test case AccessControlPolicy[] effectivePolicies = testAcMgr.getEffectivePolicies(path); diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java index d4d274e9836..46fc6ed6260 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java @@ -17,6 +17,7 @@ package org.apache.jackrabbit.oak.exercise.security.authorization.accesscontrol; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.List; import javax.jcr.RepositoryException; @@ -27,7 +28,6 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.JackrabbitWorkspace; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; @@ -186,15 +186,16 @@ public void testUpdateAndComplementary() throws Exception { public void testAddEntryWithInvalidPrincipals() throws Exception { // EXERCISE: explain for each principal in the list why using it for an ACE fails - List invalidPrincipals = ImmutableList.of( + List invalidPrincipals = Arrays.asList( new InvalidTestPrincipal("unknown"), null, - new PrincipalImpl(""), new Principal() { - @Override - public String getName() { - return "unknown"; - } - }); + new PrincipalImpl(""), + new Principal() { + @Override + public String getName() { + return "unknown"; + } + }); for (Principal principal : invalidPrincipals) { try { @@ -227,7 +228,7 @@ public void testAddEntryWithInvalidPrivilege() throws Exception { Privilege customPriv = ((JackrabbitWorkspace) superuser.getWorkspace()).getPrivilegeManager().registerPrivilege(privilegeName, true, new String[0]); // EXERCISE : walks through this test and explain why adding those ACEs fails. - List invalidPrivileges = ImmutableList.of( + List invalidPrivileges = Arrays.asList( new Privilege[0], null, new Privilege[] {customPriv} diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java index 656aef48e05..314cb402c9e 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java @@ -19,13 +19,11 @@ import java.security.Principal; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.jcr.GuestCredentials; import javax.jcr.Session; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -204,8 +202,7 @@ public void before() throws Exception { root.commit(); - trees = ImmutableList.builder().add(root.getTree("/")).add(testTree).add(aTree).add(aaTree).add(bTree).add(bbTree).add(cTree).add(ccTree).build(); - + trees = List.of(root.getTree("/"), testTree, aTree, aaTree, bTree, bbTree, cTree, ccTree); } private PermissionProvider getPermissionProvider(@NotNull Set principals) { @@ -270,11 +267,11 @@ public void testGuestAccess() throws Exception { @Test public void testWriteAccess() throws Exception { - List> editors = ImmutableList.>of( - Set.of(new Editor("ida")), - Set.of(EveryonePrincipal.getInstance(), new Editor("amanda")), - Set.of(getTestUser().getPrincipal(),new Editor("susi")), - Stream.concat(getGuestPrincipals().stream(), Stream.of(new Editor("naima"))).collect(Collectors.toUnmodifiableSet()) + List> editors = List.of( + ImmutableSet.of(new Editor("ida")), + ImmutableSet.of(EveryonePrincipal.getInstance(), new Editor("amanda")), + ImmutableSet.of(getTestUser().getPrincipal(),new Editor("susi")), + ImmutableSet.builder().addAll(getGuestPrincipals()).add(new Editor("naima")).build() ); for (Set principals : editors) { @@ -310,11 +307,11 @@ public void testWriteAccess() throws Exception { @Test public void testReadAccess() throws Exception { - List> readers = ImmutableList.>of( - Set.of(new Reader("ida")), - Set.of(EveryonePrincipal.getInstance(), new Reader("fairuz")), - Set.of(getTestUser().getPrincipal(),new Editor("juni")), - Stream.concat(getGuestPrincipals().stream(), Stream.of(new Editor("ale"))).collect(Collectors.toUnmodifiableSet()) + List> readers = List.of( + ImmutableSet.of(new Reader("ida")), + ImmutableSet.of(EveryonePrincipal.getInstance(), new Reader("fairuz")), + ImmutableSet.of(getTestUser().getPrincipal(),new Editor("juni")), + ImmutableSet.builder().addAll(getGuestPrincipals()).add(new Editor("ale")).build() ); PrivilegeManager privilegeManager = getPrivilegeManager(root); diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/principalbased/AbstractPrincipalBasedTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/principalbased/AbstractPrincipalBasedTest.java index 5276820ba9f..0c6ed8a58ce 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/principalbased/AbstractPrincipalBasedTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/principalbased/AbstractPrincipalBasedTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.principalbased; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; @@ -159,14 +160,14 @@ PrincipalBasedAuthorizationConfiguration getPrincipalBasedAuthorizationConfigura @Nullable static PrincipalAccessControlList getApplicablePrincipalAccessControlList(@NotNull JackrabbitAccessControlManager acMgr, @NotNull Principal principal) throws Exception { - Set applicable = Set.of(acMgr.getApplicablePolicies(principal)); + Set applicable = ImmutableSet.copyOf(acMgr.getApplicablePolicies(principal)); PrincipalAccessControlList acl = (PrincipalAccessControlList) Iterables.find(applicable, accessControlPolicy -> accessControlPolicy instanceof PrincipalAccessControlList, null); return acl; } @NotNull ContentSession getTestSession(@NotNull Principal... principals) throws Exception { - Subject subject = new Subject(true, Set.of(principals), Set.of(), Set.of()); + Subject subject = new Subject(true, ImmutableSet.copyOf(principals), Set.of(), Set.of()); return Java23Subject.doAsPrivileged(subject, (PrivilegedExceptionAction) () -> getContentRepository().login(null, null), null); } } \ No newline at end of file diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java index ffedf62fa52..b0c980ea456 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.exercise.security.privilege; +import java.util.Arrays; import java.util.Map; import java.util.Set; import javax.jcr.RepositoryException; @@ -23,7 +24,7 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -133,12 +134,12 @@ public void testAggregation() throws RepositoryException { ); Iterable aggregated = Iterables.filter( - ImmutableList.copyOf(privilegeManager.getRegisteredPrivileges()), + Arrays.asList(privilegeManager.getRegisteredPrivileges()), input -> input != null && input.isAggregate()); for (Privilege aggrPrivilege : aggregated) { Set expected = expectedResults.get(aggrPrivilege.getName()); - assertEquals(expected, Set.of(aggrPrivilege.getDeclaredAggregatePrivileges())); + assertEquals(expected, ImmutableSet.copyOf(aggrPrivilege.getDeclaredAggregatePrivileges())); } } diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java index a26a37a1a24..68776e651be 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java @@ -26,6 +26,7 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -239,15 +240,15 @@ public void testGetPrivileges() throws Exception { Set expected = null; // EXERCISE Privilege[] testRootPrivs = acMgr.getPrivileges(testRoot); - assertEquals(expected, Set.of(testRootPrivs)); + assertEquals(expected, ImmutableSet.copyOf(testRootPrivs)); expected = null; // EXERCISE Privilege[] privs = acMgr.getPrivileges(testPath); - assertEquals(expected, Set.of(privs)); + assertEquals(expected, ImmutableSet.copyOf(privs)); expected = null; // EXERCISE Privilege[] childPrivs = acMgr.getPrivileges(childPath); - assertEquals(expected, Set.of(childPrivs)); + assertEquals(expected, ImmutableSet.copyOf(childPrivs)); } public void testGetPrivilegesForPrincipals() throws Exception { @@ -263,7 +264,7 @@ public void testGetPrivilegesForPrincipals() throws Exception { for (String path : expected.keySet()) { Set expectedPrivs = expected.get(path); Privilege[] privs = acMgr.getPrivileges(path, principals); - assertEquals(expectedPrivs, Set.of(privs)); + assertEquals(expectedPrivs, ImmutableSet.copyOf(privs)); } // 2. EXERCISE: expected privileges for the 'gPrincipal' only @@ -276,7 +277,7 @@ public void testGetPrivilegesForPrincipals() throws Exception { for (String path : expected.keySet()) { Set expectedPrivs = expected.get(path); Privilege[] privs = acMgr.getPrivileges(path, principals); - assertEquals(expectedPrivs, Set.of(privs)); + assertEquals(expectedPrivs, ImmutableSet.copyOf(privs)); } // 3. EXERCISE: expected privileges for the 'uPrincipal' and 'gPrincipal' @@ -289,7 +290,7 @@ public void testGetPrivilegesForPrincipals() throws Exception { for (String path : expected.keySet()) { Set expectedPrivs = expected.get(path); Privilege[] privs = acMgr.getPrivileges(path, principals); - assertEquals(expectedPrivs, Set.of(privs)); + assertEquals(expectedPrivs, ImmutableSet.copyOf(privs)); } // 4. EXERCISE: expected privileges for the 'uPrincipal', 'gPrincipal' + everyone @@ -302,7 +303,7 @@ public void testGetPrivilegesForPrincipals() throws Exception { for (String path : expected.keySet()) { Set expectedPrivs = expected.get(path); Privilege[] privs = acMgr.getPrivileges(path, principals); - assertEquals(expectedPrivs, Set.of(privs)); + assertEquals(expectedPrivs, ImmutableSet.copyOf(privs)); } } @@ -313,7 +314,7 @@ public void testGetPrivilegesForPrincipalsUserSession() throws Exception { Privilege[] privs = acMgr.getPrivileges(testPath, Set.of(gPrincipal)); Set expectedPrivs = null; - assertEquals(expectedPrivs, Set.of(privs)); + assertEquals(expectedPrivs, ImmutableSet.copyOf(privs)); } public void testHasPermissionVsHasPrivilege() throws Exception { diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java index 5366a5315de..7724b2f1ecd 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java @@ -20,7 +20,6 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -149,7 +148,7 @@ public void testUserNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } @@ -174,7 +173,7 @@ public void testGroupNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java index 1b8ea63c0f5..c1e9f2d2137 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java @@ -22,7 +22,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -125,7 +124,7 @@ public void testArbitraryProperties() throws RepositoryException { Node node = getAuthorizableNode(testUser); // EXERCISE: build the list of existing user properties rel paths - List userPropertiesPath = ImmutableList.of(); + List userPropertiesPath = List.of(); for (String relPath : userPropertiesPath) { assertTrue(testUser.hasProperty(relPath)); } @@ -139,13 +138,13 @@ public void testArbitraryProperties() throws RepositoryException { assertArrayEquals(petsExpected, node.getProperty(expectedRelPath).getValues()); // EXERCISE: build a list of protected JCR properties that cannot be accessed using the Authorizable interface - List protectedJcrPropertyNames = ImmutableList.of(); + List protectedJcrPropertyNames = List.of(); for (String relPath : protectedJcrPropertyNames) { assertFalse(testUser.hasProperty(relPath)); } // EXERCISE: build a list of protected properties defined by the authorizable or user node type definitions that cannot be accessed using the Authorizable interface - List protectedAuthorizablePropertyNames = ImmutableList.of(); + List protectedAuthorizablePropertyNames = List.of(); for (String relPath : protectedAuthorizablePropertyNames) { assertFalse(testUser.hasProperty(relPath)); } diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java index c4e44bd8585..e4a63f1f9f4 100644 --- a/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java +++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; @@ -60,7 +58,7 @@ public TreeTest(NodeStoreFixture fixture) { public void setUp() { repository = new Oak(store) .with(new OpenSecurityProvider()) - .with(new CompositeConflictHandler(ImmutableList.of( + .with(new CompositeConflictHandler(List.of( ConflictHandlers.wrap(new ChildOrderConflictHandler() { /** * Allow deleting changed node. diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java index 30b83bcb022..3f66fed90ba 100644 --- a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java +++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java @@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledFuture; import ch.qos.logback.classic.Level; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.api.Blob; @@ -61,6 +62,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; +import static org.apache.jackrabbit.guava.common.collect.Sets.union; import static java.lang.String.valueOf; import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; @@ -468,9 +470,12 @@ private void clusterGCInternal(Cluster cluster1, Cluster cluster2, boolean same) Set existingAfterGC = iterate(s1); // Check the state of the blob store after gc - assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), existingAfterGC); + assertEquals( + union(state1.blobsPresent, state2.blobsPresent), existingAfterGC); // Tracked blobs should reflect deletions after gc - assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), retrieveTracked(tracker1)); + assertEquals( + union(state1.blobsPresent, state2.blobsPresent), + retrieveTracked(tracker1)); // Again create snapshots at both cluster nodes to synchronize the latest state of // local references with datastore at each node @@ -501,7 +506,8 @@ private void clusterGCInternal(Cluster cluster1, Cluster cluster2, boolean same) customLogs.finished(); // Check the state of the blob store after gc - assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), existingAfterGC); + assertEquals( + union(state1.blobsPresent, state2.blobsPresent), existingAfterGC); } /** diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java index 285dca71927..69908e95b12 100644 --- a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java +++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java @@ -53,7 +53,6 @@ import org.junit.Before; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.io.Closer; public class AsyncIndexUpdateClusterTestIT { @@ -65,8 +64,7 @@ public class AsyncIndexUpdateClusterTestIT { private MemoryBlobStore bs; private Random random = new Random(); - private final List values = ImmutableList.of("a", "b", "c", "d", - "e"); + private final List values = List.of("a", "b", "c", "d", "e"); private Closer closer = Closer.create(); private final AtomicBoolean illegalReindex = new AtomicBoolean(false); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java index c0f43e5b50e..f09e2eb21ba 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java @@ -17,7 +17,6 @@ package org.apache.jackrabbit.oak; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitRepository; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; @@ -113,7 +112,7 @@ private class TestIndexProvider implements QueryIndexProvider { @Override public @NotNull List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java index 6224f87d432..38f6fd39d37 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java @@ -32,8 +32,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver; import org.junit.After; @@ -62,7 +60,7 @@ public void teardown() throws RepositoryException { @Test public void testSlashInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "//jcr:content", "//content" ); @@ -71,7 +69,7 @@ public void testSlashInPath() throws RepositoryException { @Test public void testSlashInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "/jcr:content", "/content", "jcr:con/ent", @@ -83,7 +81,7 @@ public void testSlashInName() throws RepositoryException { @Test public void testColonInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con:ent" ); testPaths(paths); @@ -91,7 +89,7 @@ public void testColonInPath() throws RepositoryException { @Test public void testColonInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:con:ent" ); testNames(names); @@ -99,7 +97,7 @@ public void testColonInName() throws RepositoryException { @Test public void testSquareBracketsInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "//jcr:content", "/jcr:con]ent", "/con]ent" @@ -109,7 +107,7 @@ public void testSquareBracketsInPath() throws RepositoryException { @Test public void testSquareBracketsInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:content[1]", "content[1]", "jcr:conten[t]", @@ -135,7 +133,7 @@ public void testSquareBracketsInName() throws RepositoryException { @Test public void testAsteriskInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con*ent", "/jcr:*ontent", "/jcr:conten*", @@ -148,7 +146,7 @@ public void testAsteriskInPath() throws RepositoryException { @Test public void testAsteriskInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:con*ent", "jcr:*ontent", "jcr:conten*", @@ -161,7 +159,7 @@ public void testAsteriskInName() throws RepositoryException { @Test public void testVerticalLineInPath() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con|ent", "/jcr:|ontent", "/jcr:conten|", @@ -174,7 +172,7 @@ public void testVerticalLineInPath() throws Exception { @Test public void testVerticalLineInName() throws Exception { - List names = ImmutableList.of( + List names = List.of( "jcr:con|ent", "jcr:|ontent", "jcr:conten|", @@ -187,7 +185,7 @@ public void testVerticalLineInName() throws Exception { @Test public void testWhitespaceInPath() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/content ", "/ content", "/content\t", @@ -201,7 +199,7 @@ public void testWhitespaceInPath() throws Exception { @Test public void testWhitespaceInName() throws Exception { - List names = ImmutableList.of( + List names = List.of( "jcr:content ", "content ", " content", diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java index a8dad6686b9..8fa0aff6761 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java @@ -22,7 +22,6 @@ import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions; @@ -32,7 +31,7 @@ public class HasPermissionTest extends AbstractEvaluationTest { public void testEmpty() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/", path, childPPath, path + "/rep:policy", "/nonExisting", path + "/nonExisting"); @@ -82,7 +81,7 @@ public void testDuplicate() throws Exception { } public void testMultiple() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/", path, childPPath, path + "/rep:policy", "/nonExisting", path + "/nonExisting"); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/JackrabbitAccessControlManagerTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/JackrabbitAccessControlManagerTest.java index f617c752a67..d1005470b78 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/JackrabbitAccessControlManagerTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/JackrabbitAccessControlManagerTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.jcr.security.authorization; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; @@ -94,8 +95,8 @@ public void testPrivilegeCollectionFromNames() throws Exception { PrivilegeCollection pc = jrAcMgr.privilegeCollectionFromNames(Privilege.JCR_READ, Privilege.JCR_WRITE); assertFalse(pc instanceof PrivilegeCollection.Default); - Set expected = Set.of(privilegesFromNames(new String[] {Privilege.JCR_READ, Privilege.JCR_WRITE})); - assertEquals(expected, Set.of(pc.getPrivileges())); + Set expected = ImmutableSet.copyOf(privilegesFromNames(new String[] {Privilege.JCR_READ, Privilege.JCR_WRITE})); + assertEquals(expected, ImmutableSet.copyOf(pc.getPrivileges())); } public void testPrivilegeCollectionFromInvalidNames() throws Exception { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeRegistrationTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeRegistrationTest.java index 77957a8bad5..0a08f937831 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeRegistrationTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeRegistrationTest.java @@ -34,6 +34,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -430,7 +431,7 @@ public void testJcrAllWithCustomPrivileges() throws Exception { JackrabbitAccessControlManager acMgr = (JackrabbitAccessControlManager) session.getAccessControlManager(); Privilege[] allPrivileges = AccessControlUtils.privilegesFromNames(session, Privilege.JCR_ALL); - Set principalSet = Set.of(EveryonePrincipal.getInstance()); + Set principalSet = ImmutableSet.of(EveryonePrincipal.getInstance()); assertTrue(acMgr.hasPrivileges(testPath, principalSet, allPrivileges)); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsBestEffortTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsBestEffortTest.java index cb1d1c7e26e..4cf4b565fef 100755 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsBestEffortTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsBestEffortTest.java @@ -16,11 +16,11 @@ */ package org.apache.jackrabbit.oak.jcr.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.Root; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; @@ -140,16 +140,16 @@ public void onMemberAdded(@NotNull Group group, @NotNull Authorizable member, @N @Override public void onMembersAdded(@NotNull Group group, @NotNull Iterable memberIds, @NotNull Iterable failedIds, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { this.group = group; - this.memberIds.addAll(CollectionUtils.toSet(memberIds)); - this.failedIds.addAll(CollectionUtils.toSet(failedIds)); + this.memberIds.addAll(ImmutableSet.copyOf(memberIds)); + this.failedIds.addAll(ImmutableSet.copyOf(failedIds)); onMembersAddedCalled = true; } @Override public void onMembersAddedContentId(@NotNull Group group, @NotNull Iterable memberContentIds, @NotNull Iterable failedIds, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { this.group = group; - this.memberContentIds.addAll(CollectionUtils.toSet(memberContentIds)); - this.failedIds.addAll(CollectionUtils.toSet(failedIds)); + this.memberContentIds.addAll(ImmutableSet.copyOf(memberContentIds)); + this.failedIds.addAll(ImmutableSet.copyOf(failedIds)); onMembersAddedContentIdCalled = true; } } diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsTest.java index 5ee9f91f243..ad541f344cf 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImportWithActionsTest.java @@ -16,11 +16,11 @@ */ package org.apache.jackrabbit.oak.jcr.security.user; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.Root; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; @@ -132,7 +132,7 @@ private class TestGroupAction extends AbstractGroupAction { @Override public void onMembersAdded(@NotNull Group group, @NotNull Iterable memberIds, @NotNull Iterable failedIds, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { this.group = group; - this.memberIds.addAll(CollectionUtils.toSet(memberIds)); + this.memberIds.addAll(ImmutableSet.copyOf(memberIds)); onMembersAddedCalled = true; } diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java index 2cd275ae809..22586f1ad03 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java @@ -24,7 +24,6 @@ import javax.jcr.Session; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Query; import org.apache.jackrabbit.api.security.user.QueryBuilder; @@ -43,8 +42,8 @@ public class RemappingTest extends AbstractUserTest { private Session session; private Authorizable authorizable; - private List unmappedPaths = ImmutableList.of("uTest:property", "uTest:node/uTest:property2"); - private List mappedPaths = ImmutableList.of("my:property", "my:node/my:property2"); + private List unmappedPaths = List.of("uTest:property", "uTest:node/uTest:property2"); + private List mappedPaths = List.of("my:property", "my:node/my:property2"); private Value nameValue; @Override diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java index f2c697cfd10..7cf06c8f02b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java @@ -27,9 +27,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.Query; @@ -755,7 +753,7 @@ public void build(@NotNull QueryBuilder builder) { } }); - Iterator continents = ImmutableList.of("africa", "america", "australia").iterator(); + Iterator continents = List.of("africa", "america", "australia").iterator(); String expected = continents.next(); while (result.hasNext()) { Authorizable a = result.next(); @@ -779,7 +777,7 @@ public void build(@NotNull QueryBuilder builder) { } }); - Iterator continents = ImmutableList.of("Africa", "America", "africa", "australia").iterator(); + Iterator continents = List.of("Africa", "America", "africa", "australia").iterator(); String expected = continents.next(); while (result.hasNext()) { Authorizable a = result.next(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java index ec590a5e8a4..bfe6c5ed8ff 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java @@ -18,6 +18,7 @@ */ package org.apache.jackrabbit.oak.jcr; +import java.util.List; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -47,7 +48,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.oak.api.Type.BOOLEAN; import static org.apache.jackrabbit.oak.api.Type.LONG; @@ -74,7 +74,7 @@ public void setup() throws Exception { NodeBuilder builder = ns.getRoot().builder(); NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); NodeBuilder lucene = newLuceneIndexDefinition(index, "lucene", Set.of("String"), null, "async"); - lucene.setProperty("async", of("async", "nrt"), STRINGS); + lucene.setProperty("async", List.of("async", "nrt"), STRINGS); IndexDefinition.updateDefinition(index.child("lucene")); ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); @@ -111,7 +111,7 @@ public void consolidate() throws Exception { Root root = session.getLatestRoot(); Tree t = root.getTree("/"); Tree counter = t.addChild("counter"); - counter.setProperty(JCR_MIXINTYPES, of(MIX_ATOMIC_COUNTER), NAMES); + counter.setProperty(JCR_MIXINTYPES, List.of(MIX_ATOMIC_COUNTER), NAMES); root.commit(); root = session.getLatestRoot(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java index 5e6d3ae44bd..937b78af2e4 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakDirectory; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory; @@ -140,7 +139,7 @@ public void lockAndRefreshPolicy() throws Exception { @Test public void indexOpenedBeforeFistCycle() throws Exception { NodeState nrtIndex = createNRTIndex(); - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); @@ -193,7 +192,7 @@ public void indexWithIndexedDataOpenedBeforeFistCycle() throws Exception { directory.close(); nrtIndex = indexBuilder.getNodeState(); } - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); @@ -218,7 +217,7 @@ public void indexWithIndexedDataOpenedBeforeFistCycle() throws Exception { @Test public void hasIndexingRun() { NodeState nrtIndex = createNRTIndex(); - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java index bea73fc3c51..45efad61685 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import static java.util.Objects.requireNonNull; @@ -103,8 +102,6 @@ import org.junit.After; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class IndexPlannerTest { private NodeState root = INITIAL_CONTENT; @@ -121,7 +118,7 @@ public void planForSortField() throws Exception{ defn.setProperty(createProperty(ORDERED_PROP_NAMES, Set.of("foo"), STRINGS)); LuceneIndexNode node = createIndexNode(new LuceneIndexDefinition(root, defn.getNodeState(), "/foo")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertTrue(pr(planner.getPlan()).isUniquePathsRequired()); } @@ -131,7 +128,7 @@ public void noPlanForSortOnlyByScore() throws Exception{ NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", Set.of("foo"), "async"); LuceneIndexNode node = createIndexNode(new LuceneIndexDefinition(root, defn.getNodeState(), "/foo")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", createFilter("nt:file"), - ImmutableList.of(new OrderEntry("jcr:score", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("jcr:score", Type.LONG, OrderEntry.Order.ASCENDING))); assertNull(planner.getPlan()); } @@ -1127,7 +1124,7 @@ public void syncIndex_NotUsedWithSort() throws Exception{ filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, - ImmutableList.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1151,7 +1148,7 @@ public void syncIndex_NotUsedWithFulltext() throws Exception{ filter.setFullTextConstraint(FullTextParser.parse("bar", "mountain")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, - ImmutableList.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1297,7 +1294,7 @@ public void noRestrictionWithSingleSortableField() throws Exception{ LuceneIndexDefinition definition = new LuceneIndexDefinition(root, defn.getNodeState(), "/test"); LuceneIndexNode node = createIndexNode(definition); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/test", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); @@ -1312,7 +1309,7 @@ public void noRestrictionWithTwoSortableFields() throws Exception{ LuceneIndexDefinition definition = new LuceneIndexDefinition(root, defn.getNodeState(), "/test"); LuceneIndexNode node = createIndexNode(definition); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/test", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java index 14c1e55fc23..870c3ef503e 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.index.lucene; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -131,8 +130,8 @@ public void repositoryTraversalIfLaneIsPresent() throws Exception { Tree test1 = root.getTree("/").addChild(INDEX_DEFINITIONS_NAME).addChild("mynodetype"); test1.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME); test1.setProperty("type", "property"); - test1.setProperty("propertyNames", ImmutableList.of("jcr:primaryType", "jcr:mixinTypes"), Type.NAMES); - test1.setProperty("declaringNodeTypes", ImmutableList.of("oak:QueryIndexDefinition"), Type.NAMES); + test1.setProperty("propertyNames", List.of("jcr:primaryType", "jcr:mixinTypes"), Type.NAMES); + test1.setProperty("declaringNodeTypes", List.of("oak:QueryIndexDefinition"), Type.NAMES); test1.setProperty("nodeTypeListDefined", true); test1.setProperty("reindex", true); root.commit(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java index 0d9766b3880..a4abb51327a 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.util.Collections; @@ -25,7 +24,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; @@ -312,7 +310,7 @@ public void indexRuleInheritanceDisabled() throws Exception{ @Test public void indexRuleInheritanceOrdering() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); - rules.setProperty(OAK_CHILD_ORDER, ImmutableList.of("nt:hierarchyNode", "nt:base"),NAMES); + rules.setProperty(OAK_CHILD_ORDER, List.of("nt:hierarchyNode", "nt:base"),NAMES); rules.child("nt:hierarchyNode").setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); rules.child("nt:base").setProperty(FulltextIndexConstants.FIELD_BOOST, 3.0); @@ -325,7 +323,7 @@ public void indexRuleInheritanceOrdering() throws Exception{ @Test public void indexRuleInheritanceOrdering2() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); - rules.setProperty(OAK_CHILD_ORDER, ImmutableList.of("nt:base", "nt:hierarchyNode"),NAMES); + rules.setProperty(OAK_CHILD_ORDER, List.of("nt:base", "nt:hierarchyNode"),NAMES); rules.child("nt:hierarchyNode").setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); rules.child("nt:base").setProperty(FulltextIndexConstants.FIELD_BOOST, 3.0); @@ -400,7 +398,7 @@ public void indexRuleWithPropertyOrdering() throws Exception{ .setProperty(FulltextIndexConstants.PROP_IS_REGEX, true) .setProperty(FulltextIndexConstants.FIELD_BOOST, 4.0); - rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, ImmutableList.of("prop2", "prop1"), NAMES); + rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, List.of("prop2", "prop1"), NAMES); LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); @@ -416,7 +414,7 @@ public void indexRuleWithPropertyOrdering() throws Exception{ assertEquals(4.0f, rule1.getConfig("fooProp").boost, 0); //Order it correctly to get expected result - rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, ImmutableList.of("prop1", "prop2"), NAMES); + rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, List.of("prop1", "prop2"), NAMES); defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder"))); assertEquals(3.0f, rule1.getConfig("fooProp").boost, 0); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java index a54da2e9620..92ef77eff93 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.File; @@ -29,7 +28,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.CIHelper; import org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore; @@ -118,7 +116,7 @@ public class LuceneIndexEditorTest { @Parameterized.Parameters(name = "{index}: useBlobStore ({0})") public static List fixtures() { - return ImmutableList.of(new Boolean[] {true}, new Boolean[] {false}); + return List.of(new Boolean[] {true}, new Boolean[] {false}); } @Before diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java index 69c093c81c5..1b998419cb7 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.guava.common.collect.Iterators.transform; import static org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static java.util.Arrays.asList; @@ -69,6 +68,7 @@ import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; import org.apache.jackrabbit.oak.plugins.index.IndexUpdate; @@ -116,8 +116,6 @@ import org.junit.Assert; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - @SuppressWarnings("ConstantConditions") public class LuceneIndexTest { @@ -218,7 +216,7 @@ public void testLuceneLazyCursor() throws Exception { List plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); - List paths = copyOf(transform(cursor, IndexRow::getPath)); + List paths = CollectionUtils.toList(transform(cursor, IndexRow::getPath)); assertFalse(paths.isEmpty()); assertEquals(LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 1, paths.size()); } @@ -400,7 +398,7 @@ public void testPropertyNonExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("foo", Operator.EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/c")); + assertFilter(filter, queryIndex, indexed, List.of("/c")); } @Test @@ -431,7 +429,7 @@ public void testPropertyExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("foo", Operator.NOT_EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a","/b")); + assertFilter(filter, queryIndex, indexed, List.of("/a","/b")); } @@ -467,7 +465,7 @@ public void testRelativePropertyNonExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("jcr:content/bar", Operator.EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/b1")); + assertFilter(filter, queryIndex, indexed, List.of("/b1")); builder.child("b1").child("jcr:content").setProperty("bar", "foo"); after = builder.getNodeState(); @@ -502,19 +500,19 @@ public void testPathRestrictions() throws Exception { FilterImpl filter = createTestFilter(); filter.restrictPath("/", Filter.PathRestriction.EXACT); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); filter = createTestFilter(); filter.restrictPath("/", Filter.PathRestriction.DIRECT_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a", "/a1")); + assertFilter(filter, queryIndex, indexed, List.of("/a", "/a1")); filter = createTestFilter(); filter.restrictPath("/a", Filter.PathRestriction.DIRECT_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a/b")); + assertFilter(filter, queryIndex, indexed, List.of("/a/b")); filter = createTestFilter(); filter.restrictPath("/a", Filter.PathRestriction.ALL_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a/b", "/a/b/c")); + assertFilter(filter, queryIndex, indexed, List.of("/a/b", "/a/b/c")); } @Test @@ -538,15 +536,15 @@ public void nodeNameIndex() throws Exception{ FilterImpl filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.EQUAL, PropertyValues.newString("foo")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/foo")); + assertFilter(filter, queryIndex, indexed, List.of("/foo")); filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.LIKE, PropertyValues.newString("camelCase")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/camelCase")); + assertFilter(filter, queryIndex, indexed, List.of("/camelCase")); filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.LIKE, PropertyValues.newString("camel%")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/camelCase")); + assertFilter(filter, queryIndex, indexed, List.of("/camelCase")); } private FilterImpl createTestFilter(){ @@ -573,7 +571,7 @@ public void analyzerWithStopWords() throws Exception{ FilterImpl filter = createFilter("nt:base"); filter.setFullTextConstraint(new FullTextTerm(null, "fox jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); //No stop word configured so default analyzer would also check for 'was' filter.setFullTextConstraint(new FullTextTerm(null, "fox was jumping", false, false, null)); @@ -594,36 +592,36 @@ public void analyzerWithStopWords() throws Exception{ queryIndex = new LucenePropertyIndex(tracker); filter.setFullTextConstraint(new FullTextTerm(null, "fox jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); //Now this should get passed as the analyzer would ignore 'was' filter.setFullTextConstraint(new FullTextTerm(null, "fox was jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); } @Test public void testTokens() { Analyzer analyzer = LuceneIndexConstants.ANALYZER; - assertEquals(ImmutableList.of("parent", "child"), + assertEquals(List.of("parent", "child"), LuceneIndex.tokenize("/parent/child", analyzer)); - assertEquals(ImmutableList.of("p1234", "p5678"), + assertEquals(List.of("p1234", "p5678"), LuceneIndex.tokenize("/p1234/p5678", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first_second", analyzer)); - assertEquals(ImmutableList.of("first1", "second2"), + assertEquals(List.of("first1", "second2"), LuceneIndex.tokenize("first1_second2", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first. second", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first.second", analyzer)); - assertEquals(ImmutableList.of("hello", "world"), + assertEquals(List.of("hello", "world"), LuceneIndex.tokenize("hello-world", analyzer)); - assertEquals(ImmutableList.of("hello", "wor*"), + assertEquals(List.of("hello", "wor*"), LuceneIndex.tokenize("hello-wor*", analyzer)); - assertEquals(ImmutableList.of("*llo", "world"), + assertEquals(List.of("*llo", "world"), LuceneIndex.tokenize("*llo-world", analyzer)); - assertEquals(ImmutableList.of("*llo", "wor*"), + assertEquals(List.of("*llo", "wor*"), LuceneIndex.tokenize("*llo-wor*", analyzer)); } @@ -843,7 +841,7 @@ public void testConfigErrorInIndexDefintion() throws Exception { newLucenePropertyIndexDefinition(index, "luceneTest", Set.of("foo"), null); newLucenePropertyIndexDefinition(index, "luceneTest2", Set.of("foo2"), null); - builder.child(INDEX_DEFINITIONS_NAME).child("luceneTest").setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, ImmutableList.of(2L), Type.LONGS); + builder.child(INDEX_DEFINITIONS_NAME).child("luceneTest").setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, List.of(2L), Type.LONGS); NodeState before = builder.getNodeState(); // Add some content that qualifies to be indexed by both of the above indexes (separately) diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java index 2864cff8ee8..d4a70dd1ef1 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.QueryEngine.NO_BINDINGS; import static org.apache.jackrabbit.oak.api.Type.STRINGS; import static org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndexTest.createIndex; @@ -44,7 +42,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; @@ -213,13 +210,13 @@ public void propertyIndex() throws Exception{ assertEquals(2, getIndexDirNames(idxName).size()); String barQuery = "select [jcr:path] from [nt:base] where [foo] = 'bar'"; - assertQuery(barQuery, of("/libs/a", "/content/a")); + assertQuery(barQuery, List.of("/libs/a", "/content/a")); Result result = executeQuery(barQuery, SQL2, NO_BINDINGS); assertTrue(result.getRows().iterator().hasNext()); assertEquals(2, result.getSize(Result.SizePrecision.FAST_APPROXIMATION, 100)); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar2'", of("/libs/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar2'", List.of("/libs/b")); } @Test diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java index c4ead1c3b16..e9a4f1365c9 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java @@ -16,16 +16,15 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.io.Reader; import java.lang.reflect.Field; +import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.plugins.index.lucene.NodeStateAnalyzerFactory.NodeStateResourceLoader; @@ -109,7 +108,7 @@ public void analyzerByComposition_TokenFilter() throws Exception{ nb.child(ANL_TOKENIZER).setProperty(ANL_NAME, "whitespace"); NodeBuilder filters = nb.child(ANL_FILTERS); - filters.setProperty(OAK_CHILD_ORDER, ImmutableList.of("stop", "LowerCase"),NAMES); + filters.setProperty(OAK_CHILD_ORDER, List.of("stop", "LowerCase"),NAMES); filters.child("LowerCase").setProperty(ANL_NAME, "LowerCase"); filters.child("LowerCase").setProperty(JCR_PRIMARYTYPE, "nt:unstructured"); //name is optional. Derived from nodeName @@ -131,7 +130,7 @@ public void analyzerByComposition_CharFilter() throws Exception{ nb.child(ANL_TOKENIZER).setProperty(ANL_NAME, "whitespace"); NodeBuilder filters = nb.child(ANL_CHAR_FILTERS); - filters.setProperty(OAK_CHILD_ORDER, ImmutableList.of("htmlStrip", "mapping"),NAMES); + filters.setProperty(OAK_CHILD_ORDER, List.of("htmlStrip", "mapping"),NAMES); filters.child("mapping").setProperty(ANL_NAME, "mapping"); filters.child("htmlStrip"); //name is optional. Derived from nodeName diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java index 05c4f129183..d588ad353f0 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java @@ -38,7 +38,6 @@ import javax.management.ObjectName; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; @@ -99,7 +98,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.apache.jackrabbit.oak.api.QueryEngine.NO_BINDINGS; import static org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider; @@ -194,25 +192,25 @@ public void hybridIndex() throws Exception{ runAsyncIndex(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This would not be reflected in result as local index would not be updated createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Now let some time elapse such that readers can be refreshed clock.waitUntil(clock.getTime() + refreshDelta + 1); //Now recently added stuff should be visible without async indexing run - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); createPath("/c").setProperty("foo", "bar"); root.commit(); //Post async index it should still be upto date runAsyncIndex(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b", "/c")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b", "/c")); } @Test @@ -262,7 +260,7 @@ public void noTextExtractionForSyncCommit() throws Exception{ runAsyncIndex(); assertEquals(1, testBlob.accessCount); - assertQuery("select * from [nt:base] where CONTAINS(*, 'sky')", of("/test/msg/jcr:content")); + assertQuery("select * from [nt:base] where CONTAINS(*, 'sky')", List.of("/test/msg/jcr:content")); } @@ -281,12 +279,12 @@ public void hybridIndexSync() throws Exception{ runAsyncIndex(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This should get immediately reelected as its a sync index createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); } @Test @@ -299,19 +297,19 @@ public void usageBeforeFirstIndex() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This should get immediately reelected as its a sync index createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); runAsyncIndex(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); createPath("/c").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b", "/c")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b", "/c")); } @Test @@ -325,7 +323,7 @@ public void newNodeTypesFoundLater() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); optionalEditorProvider.delegate = new TypeEditorProvider(false); NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType"); @@ -335,7 +333,7 @@ public void newNodeTypesFoundLater() throws Exception{ b.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:TestNode", Type.NAME); b.setProperty("bar", "foo"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [bar] = 'foo'", of("/b")); + assertQuery("select [jcr:path] from [nt:base] where [bar] = 'foo'", List.of("/b")); } @Test @@ -354,7 +352,7 @@ public void newNodeTypesFoundLater2() throws Exception{ //such that it does not indexes test nodetype Tree nodeType = root.getTree("/oak:index/nodetype"); if (!nodeType.hasProperty(IndexConstants.DECLARING_NODE_TYPES)){ - nodeType.setProperty(IndexConstants.DECLARING_NODE_TYPES, ImmutableList.of("nt:file"), Type.NAMES); + nodeType.setProperty(IndexConstants.DECLARING_NODE_TYPES, List.of("nt:file"), Type.NAMES); nodeType.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true); } @@ -364,7 +362,7 @@ public void newNodeTypesFoundLater2() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); optionalEditorProvider.delegate = new TypeEditorProvider(false); NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType"); @@ -380,7 +378,7 @@ public void newNodeTypesFoundLater2() throws Exception{ String query = "select [jcr:path] from [oak:TestNode] "; assertThat(explain(query), containsString("/oak:index/hybridtest")); - assertQuery(query, of("/b", "/c")); + assertQuery(query, List.of("/b", "/c")); } @Test diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java index 3ddf24a5e3a..d44271dba2c 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java @@ -16,15 +16,14 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.EqualsDiff; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_HEAD_BUCKET; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_PREVIOUS_BUCKET; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -43,7 +42,7 @@ public class BucketSwitcherTest { @Test public void basic() throws Exception { bs.switchBucket(100); - assertThat(copyOf(bs.getOldBuckets()), empty()); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), empty()); } @Test @@ -52,7 +51,7 @@ public void singleUnusedBucket() throws Exception { builder.setProperty(PROP_HEAD_BUCKET, "1"); bs.switchBucket(100); - assertThat(copyOf(bs.getOldBuckets()), empty()); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), empty()); } @Test @@ -65,7 +64,7 @@ public void twoBucket_HeadUnused() throws Exception { bs.switchBucket(100); assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET)); assertEquals("2", builder.getString(PROP_HEAD_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); } @Test @@ -81,7 +80,7 @@ public void twoBuckets_BothUsed() throws Exception { assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertTrue(builder.hasChildNode("3")); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); } @Test @@ -96,7 +95,7 @@ public void twoBuckets_2Switches() throws Exception{ bs.switchBucket(150); assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET)); assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); } /** @@ -117,7 +116,7 @@ public void twoBuckets_NoChange() throws Exception{ assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state1 = builder.getNodeState(); assertFalse(bs.switchBucket(100)); @@ -126,7 +125,7 @@ public void twoBuckets_NoChange() throws Exception{ //as previous assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state2 = builder.getNodeState(); assertFalse(bs.switchBucket(100)); @@ -134,7 +133,7 @@ public void twoBuckets_NoChange() throws Exception{ //Async indexer time still not changed. So head bucket remains same assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state3 = builder.getNodeState(); @@ -159,7 +158,7 @@ public void twoBucket_IndexedToTimeChange() throws Exception{ assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state1 = builder.getNodeState(); assertTrue(bs.switchBucket(150)); @@ -167,14 +166,14 @@ public void twoBucket_IndexedToTimeChange() throws Exception{ //This time previous bucket should be discarded assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertNull(builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); NodeState state2 = builder.getNodeState(); assertTrue(bs.switchBucket(200)); assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertNull(builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); //assert no change done after previous is removed //not even change of asyncIndexedTo diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java index 1ee37ff43fd..99f4f8adab9 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; @@ -108,7 +107,7 @@ public void pathResultAbsolutePath() throws Exception{ Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/a")); } @Test @@ -128,14 +127,14 @@ public void nonRootIndex() throws Exception{ Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/a")); lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState(), "/content", true); paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/content/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a")); } private void propertyUpdated(String nodePath, String propertyRelativeName, String value){ @@ -157,7 +156,7 @@ private List query(Filter filter, String propertyName, String propertyRe HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState()); Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyRestrictionName)); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private PropertyDefinition pd(String propName){ diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java index e292ac1aa28..dc6640ea048 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyValue; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; @@ -205,7 +204,7 @@ private List query(String propertyName, PropertyValue value) { HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState()); FilterImpl filter = createFilter(root, "nt:base"); Iterable paths = lookup.query(filter, propertyName, value); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private PropertyIndexUpdateCallback newCallback(){ diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java index b8b89933bbd..4ebc69def36 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.HashMap; @@ -24,9 +23,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService; import org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner.CleanupStats; @@ -332,7 +331,7 @@ private List query(String indexPath, String propertyName, String value) HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, getNode(root, indexPath)); FilterImpl filter = FilterImpl.newTestInstance(); Iterable paths = lookup.query(filter, propertyName, PropertyValues.newString(value)); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private static class SimpleAsyncInfoService implements AsyncIndexInfoService { diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java index 9b33ff2e4fd..fce3c814201 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java @@ -16,14 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; - +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_CREATED; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -42,7 +40,7 @@ public void nothingCleaned() throws Exception{ UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 1); cleaner.clean(builder, 10); - assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("a", "b")); + assertThat(CollectionUtils.toList(builder.getChildNodeNames()), containsInAnyOrder("a", "b")); } @Test @@ -53,7 +51,7 @@ public void cleanWithMargin() throws Exception{ refresh(); UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 100); cleaner.clean(builder, 200); - assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("b")); + assertThat(CollectionUtils.toList(builder.getChildNodeNames()), containsInAnyOrder("b")); } private void refresh(){ diff --git a/oak-parent/pom.xml b/oak-parent/pom.xml index b30d7c29d85..66843c46e9d 100644 --- a/oak-parent/pom.xml +++ b/oak-parent/pom.xml @@ -142,6 +142,23 @@ 5.1.9 true true + + + org.apache.felix + org.apache.felix.scr.bnd + 1.9.6 + + + + biz.aQute.bnd + bnd + + + + true NONE @@ -154,6 +171,8 @@ <_nodefaultversion>true + + <_plugin>org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory} @@ -521,6 +540,11 @@ org.osgi.annotation.versioning 1.1.2 + + org.apache.felix + org.apache.felix.scr.annotations + 1.12.0 + org.jetbrains annotations diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java index 59f829c4a54..d558622065d 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java @@ -26,11 +26,11 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -60,17 +60,17 @@ public void children() { CountingIterable citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/e", preferred); - assertEquals(singletonList("f"), copyOf(childNames(p.children()))); + assertEquals(singletonList("f"), CollectionUtils.toList(childNames(p.children()))); assertEquals(7, citr.getCount()); p = new ChildNodeStateProvider(citr, "/g", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); } @Test @@ -79,22 +79,22 @@ public void children2() { CountingIterable citr = createList(preferred, asList("/a", "/a/b", "/a/b/c", "/a/b/c/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(singletonList("b"), copyOf(childNames(p.children()))); + assertEquals(singletonList("b"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/a/b", preferred); - assertEquals(singletonList("c"), copyOf(childNames(p.children()))); + assertEquals(singletonList("c"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); p = new ChildNodeStateProvider(citr, "/a/b/c", preferred); - assertEquals(singletonList("d"), copyOf(childNames(p.children()))); + assertEquals(singletonList("d"), CollectionUtils.toList(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/a/b/c/d", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/h", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); } @Test @@ -152,7 +152,7 @@ public void childNames() { CountingIterable citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); } @@ -163,7 +163,7 @@ public void childNames2() { "/a/c", "/a/c/status","/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(7, citr.getCount()); } diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java index ddfc6b1f1d2..6b7c4e8fc37 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.index.indexer.document.flatfile; import java.util.Arrays; import java.util.List; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder; import org.apache.jackrabbit.oak.spi.blob.BlobStore; @@ -32,7 +32,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import static org.apache.jackrabbit.oak.index.indexer.document.flatfile.NodeStateEntryWriter.getPath; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -112,7 +111,7 @@ public void pathElements(){ NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/a/b/c/d").build(); String json = nw.asJson(e1.getNodeState()); - List pathElements = copyOf(elements(e1.getPath())); + List pathElements = CollectionUtils.toList(elements(e1.getPath())); String line = nw.toString(pathElements, json); @@ -132,7 +131,7 @@ public void pathElements_root(){ NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/").build(); String json = nw.asJson(e1.getNodeState()); - List pathElements = copyOf(elements(e1.getPath())); + List pathElements = CollectionUtils.toList(elements(e1.getPath())); String line = nw.toString(pathElements, json); @@ -154,9 +153,9 @@ public void memUsage() { b.setProperty("foo1", "bar1"); String json2 = nw.asJson(b.getNodeState()); - String line1 = nw.toString(copyOf(elements("/")), json1); - String line2 = nw.toString(copyOf(elements("/sub-node")), json1); - String line3 = nw.toString(copyOf(elements("/sub-node")), json2); + String line1 = nw.toString(CollectionUtils.toList(elements("/")), json1); + String line2 = nw.toString(CollectionUtils.toList(elements("/sub-node")), json1); + String line3 = nw.toString(CollectionUtils.toList(elements("/sub-node")), json2); NodeStateEntryReader nr = new NodeStateEntryReader(blobStore); diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java index e9d5b483b5e..66d831e8c63 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.index.indexer.document.flatfile; import org.apache.jackrabbit.guava.common.collect.Iterables; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -29,7 +30,6 @@ import java.util.Set; import java.util.function.Predicate; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Collections.emptySet; import static java.util.stream.Collectors.toList; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; @@ -51,7 +51,7 @@ static List extractPredicatePaths(List paths, Predicate static List sortPaths(List paths, Comparator> comparator) { List> copy = paths.stream() - .map(p -> copyOf(elements(p))) + .map(p -> CollectionUtils.toList(elements(p))) .sorted(comparator) .collect(toList()); return copy.stream().map(e -> "/" + String.join("/", e)).collect(toList()); diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java index 3f2aad0865b..30dd2c07500 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java @@ -20,10 +20,12 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection; import org.apache.jackrabbit.oak.run.RevisionsCommand; import org.junit.Before; @@ -409,11 +411,13 @@ private DocumentNodeStore createDocumentNodeStore(boolean fullGCEnabled) { private static class RevisionsCmd implements Runnable { - private final ImmutableList args; + private final List args; public RevisionsCmd(String... args) { - this.args = ImmutableList.builder().add(MongoUtils.URL) - .add(args).build(); + List builder = new ArrayList<>(); + builder.add(MongoUtils.URL); + builder.addAll(Arrays.asList(args)); + this.args = Collections.unmodifiableList(builder); } @Override diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java index dd4d8d5b90a..6871a440215 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java @@ -40,9 +40,10 @@ import java.util.Random; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; +import org.apache.jackrabbit.guava.common.collect.Maps; +import org.apache.jackrabbit.guava.common.collect.Sets; import joptsimple.internal.Strings; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; @@ -201,14 +202,14 @@ public void testConsistency() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); testAllParams(dump, repoHome); assertFileEquals(dump, "[id]", blobsAdded); - assertFileEquals(dump, "[ref]", CollectionUtils.union(blobsAdded, Set.of(deletedBlobId))); + assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Set.of(deletedBlobId))); assertFileEquals(dump, "[consistency]", Set.of(deletedBlobId)); } @@ -222,7 +223,7 @@ public void testConsistencyVerbose() throws Exception { blobsAdded.remove(deletedBlobId); long count = setupDataStore - .countDeleteChunks(ImmutableList.of(deletedBlobId), + .countDeleteChunks(List.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); @@ -231,7 +232,7 @@ public void testConsistencyVerbose() throws Exception { assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption)); assertFileEquals(dump, "[ref]", - encodedIdsAndPath(CollectionUtils.union(blobsAdded, Set.of(deletedBlobId)), dsOption, blobsAddedWithNodes)); + encodedIdsAndPath(Sets.union(blobsAdded, Set.of(deletedBlobId)), dsOption, blobsAddedWithNodes)); assertFileEquals(dump, "[consistency]", encodedIdsAndPath(Set.of(deletedBlobId), dsOption, blobsAddedWithNodes)); } @@ -248,11 +249,11 @@ public void testConsistencyWithDeleteTracker() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); - count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); + count += setupDataStore.countDeleteChunks(List.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file @@ -263,7 +264,7 @@ public void testConsistencyWithDeleteTracker() throws Exception { testAllParams(dump, repoHome); assertFileEquals(dump, "[id]", blobsAdded); - assertFileEquals(dump, "[ref]", CollectionUtils.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId))); + assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId))); assertFileEquals(dump, "[consistency]", Set.of(deletedBlobId)); } @@ -279,11 +280,11 @@ public void testConsistencyVerboseWithDeleteTracker() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); - count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); + count += setupDataStore.countDeleteChunks(List.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file @@ -295,7 +296,7 @@ public void testConsistencyVerboseWithDeleteTracker() throws Exception { assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption)); assertFileEquals(dump, "[ref]", - encodedIdsAndPath(CollectionUtils.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)), dsOption, + encodedIdsAndPath(Sets.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)), dsOption, blobsAddedWithNodes)); assertFileEquals(dump, "[consistency]", encodedIdsAndPath(Set.of(deletedBlobId), dsOption, blobsAddedWithNodes)); diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java index f0cc1d8d1fd..f2d0fdda85b 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java @@ -42,7 +42,6 @@ import ch.qos.logback.classic.Level; import org.apache.jackrabbit.guava.common.base.Splitter; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Maps; @@ -258,7 +257,7 @@ private static Data prepareData(StoreFixture storeFixture, DataStoreFixture blob } for (String id : data.missingDataStore) { - long count = blobStore.countDeleteChunks(ImmutableList.of(id), 0); + long count = blobStore.countDeleteChunks(List.of(id), 0); assertEquals(1, count); } @@ -1341,11 +1340,11 @@ class FileDataStoreFixture implements DataStoreFixture { static class FixtureHelper { static List getStoreFixtures() { - return ImmutableList.of(StoreFixture.MONGO, StoreFixture.SEGMENT, StoreFixture.SEGMENT_AZURE); + return List.of(StoreFixture.MONGO, StoreFixture.SEGMENT, StoreFixture.SEGMENT_AZURE); } static List getDataStoreFixtures() { - return ImmutableList.of(DataStoreFixture.S3, DataStoreFixture.AZURE, DataStoreFixture.FDS); + return List.of(DataStoreFixture.S3, DataStoreFixture.AZURE, DataStoreFixture.FDS); } static List get() { diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java index 5083b29be6b..c2963ec7517 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java @@ -21,8 +21,6 @@ import java.util.List; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider; @@ -237,7 +235,7 @@ private void merge(NodeBuilder builder, boolean withIndexUpdate) CommitHook hook = EmptyHook.INSTANCE; if (withIndexUpdate) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); - IndexUtils.createIndexDefinition(index, "uuid", true, true, ImmutableList.of("jcr:uuid"), null); + IndexUtils.createIndexDefinition(index, "uuid", true, true, List.of("jcr:uuid"), null); hook = new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider())); } ns.merge(builder, hook, CommitInfo.EMPTY); diff --git a/oak-search-elastic/pom.xml b/oak-search-elastic/pom.xml index c1d022395b9..99f4f163f5b 100644 --- a/oak-search-elastic/pom.xml +++ b/oak-search-elastic/pom.xml @@ -99,6 +99,11 @@ org.osgi.service.component provided + + org.apache.felix + org.apache.felix.scr.annotations + provided + org.osgi org.osgi.annotation.versioning diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java index 0b86a878cf4..c3f871ba078 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder; import org.apache.jackrabbit.oak.query.AbstractQueryTest; @@ -78,14 +77,14 @@ protected Tree setIndex(IndexDefinitionBuilder builder, String idxName) { * - The queries that have different results between traversal and the indexes, for the most part also produce * different results between Elastic and Lucene. */ - protected List queriesWithSameResults = ImmutableList.of( + protected List queriesWithSameResults = List.of( // Full-text queries "/jcr:root//*[jcr:contains(@propa, '*')]", "/jcr:root//*[jcr:contains(@propa, '123*')]", "/jcr:root//*[jcr:contains(@propa, 'fal*')]" ); - protected List queriesWithDifferentResults = ImmutableList.of( + protected List queriesWithDifferentResults = List.of( "/jcr:root//*[@propa]", "/jcr:root//*[@propa > 0]", "/jcr:root//*[@propa > '0']", diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java index a813ebe4c94..82c40abcd19 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java @@ -22,7 +22,6 @@ import java.util.List; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static javax.jcr.PropertyType.TYPENAME_BINARY; import static javax.jcr.PropertyType.TYPENAME_STRING; import static org.apache.jackrabbit.JcrConstants.JCR_LASTMODIFIED; @@ -47,8 +46,8 @@ public abstract class IndexExclusionQueryCommonTest extends AbstractQueryTest { protected void createTestIndexNode() throws Exception { Tree index = createTestIndexNode(root.getTree("/"), indexOptions.getIndexType()); index.setProperty(INCLUDE_PROPERTY_TYPES, - of(TYPENAME_BINARY, TYPENAME_STRING), STRINGS); - index.setProperty(EXCLUDE_PROPERTY_NAMES, of(NOT_IN), STRINGS); + List.of(TYPENAME_BINARY, TYPENAME_STRING), STRINGS); + index.setProperty(EXCLUDE_PROPERTY_NAMES, List.of(NOT_IN), STRINGS); TestUtil.useV2(index); root.commit(); } @@ -72,12 +71,12 @@ public void ignoreByType() throws Exception { + " and (@" + JCR_LASTMODIFIED + " > xs:dateTime('2014-04-01T08:58:03.231Z')) ]"; - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/two")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/two")), 3000 * 3); } @Test public void ignoreByName() throws Exception { - final List expected = of("/content/two"); + final List expected = List.of("/content/two"); Tree content = root.getTree("/").addChild("content"); Tree one = content.addChild("one"); @@ -117,7 +116,7 @@ public void ignoreByName2() throws Exception { // Should not return /content/two since there, querty value is set for notincluded property which // is part of excluded properties in the index definition - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/one")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/one")), 3000 * 3); } @Test @@ -138,7 +137,7 @@ public void ignoreByType2() throws Exception { // Assert /content/two is not returned since it matches 2014 from DATE type property field which is not part of // includePropertyTypes in the index definition String query = "/jcr:root/content//*[jcr:contains(., '2014')]"; - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/one")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/one")), 3000 * 3); } } diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java index ebba33eca46..e8a557e923c 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.index; import org.apache.commons.lang3.RandomStringUtils; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; @@ -104,7 +103,7 @@ public void planForSortField() throws Exception { defn.setProperty(createProperty(ORDERED_PROP_NAMES, Set.of("foo"), STRINGS)); IndexNode node = createIndexNode(getIndexDefinition(root, defn.getNodeState(), "/oak:index/" + indexName)); FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertTrue(pr(planner.getPlan()).isUniquePathsRequired()); } @@ -114,7 +113,7 @@ public void noPlanForSortOnlyByScore() throws Exception { NodeBuilder defn = getPropertyIndexDefinitionNodeBuilder(builder, indexName, Set.of("foo"), "async"); IndexNode node = createIndexNode(getIndexDefinition(root, defn.getNodeState(), "/oak:index/" + indexName)); FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:file"), - ImmutableList.of(new QueryIndex.OrderEntry("jcr:score", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("jcr:score", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNull(planner.getPlan()); } @@ -1158,7 +1157,7 @@ public void syncIndex_NotUsedWithSort() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, filter, - ImmutableList.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1184,7 +1183,7 @@ public void syncIndex_NotUsedWithFulltext() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, filter, - ImmutableList.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1338,7 +1337,7 @@ public void noRestrictionWithSingleSortableField() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertEquals(1, planner.getPlan().getEstimatedEntryCount()); @@ -1356,7 +1355,7 @@ public void noRestrictionWithTwoSortableFields() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java index 38ac728f152..ab4936ef038 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.search; import java.util.ArrayList; @@ -42,7 +41,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; @@ -71,7 +69,7 @@ public class AggregateTest { @Test public void oneLevelAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -83,7 +81,7 @@ public void oneLevelAll() { @Test public void oneLevelNamed() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"))); NodeBuilder nb = newNode("nt:base"); nb.child("a"); nb.child("b"); @@ -95,7 +93,7 @@ public void oneLevelNamed() { @Test public void noOfChildNodeRead() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"))); NodeBuilder nb = newNode("nt:base"); nb.child("a"); for (int i = 0; i < 10; i++) { @@ -119,7 +117,7 @@ public void noOfChildNodeRead() { @Test public void oneLevelTyped() { - Aggregate ag = new Aggregate("nt:base", of(ni("nt:resource","*", false))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("nt:resource","*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").setProperty(JCR_PRIMARYTYPE,"nt:resource"); nb.child("b"); @@ -131,7 +129,7 @@ public void oneLevelTyped() { @Test public void oneLevelTypedMixin() { - Aggregate ag = new Aggregate("nt:base", of(ni("mix:title","*", false))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("mix:title","*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton("mix:title"), Type.NAMES); nb.child("b"); @@ -143,7 +141,7 @@ public void oneLevelTypedMixin() { @Test public void multiLevelAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"), ni("*/*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"), ni("*/*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -156,7 +154,7 @@ public void multiLevelAll() { @Test public void multiLevelNamed() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), ni("d/e"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("d/e"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -169,7 +167,7 @@ public void multiLevelNamed() { @Test public void multiLevelTyped() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("nt:resource", "d/*/*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); @@ -185,7 +183,7 @@ public void multiLevelTyped() { @Test public void multiLevelNamedSubAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), ni("d/*/*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("d/*/*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -202,9 +200,9 @@ public void multiLevelNamedSubAll() { @Test public void multiAggregateMapping() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"))); - Aggregate agFile = new Aggregate("nt:file", of(ni("*"), ni("*/*"))); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*"), ni("*/*"))); mapper.add("nt:file", agFile); NodeBuilder nb = newNode("nt:base"); @@ -220,7 +218,7 @@ public void multiAggregateMapping() { @Test public void recursionEnabled() { - Aggregate agFile = new Aggregate("nt:file", of(ni("*")), 5); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*")), 5); mapper.add("nt:file", agFile); NodeBuilder nb = newNode("nt:file"); @@ -237,7 +235,7 @@ public void recursionEnabled() { @Test public void recursionEnabledWithLimitCheck() { int limit = 5; - Aggregate agFile = new Aggregate("nt:file", of(ni("*")), limit); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*")), limit); mapper.add("nt:file", agFile); List expectedPaths = new ArrayList<>(); @@ -265,12 +263,12 @@ public void recursionEnabledWithLimitCheck() { @Test public void includeMatches() { - Aggregate ag = new Aggregate("nt:base", of(ni(null, "*", true), ni(null, "*/*", true))); + Aggregate ag = new Aggregate("nt:base", List.of(ni(null, "*", true), ni(null, "*/*", true))); assertTrue(ag.hasRelativeNodeInclude("foo")); assertTrue(ag.hasRelativeNodeInclude("foo/bar")); assertFalse(ag.hasRelativeNodeInclude("foo/bar/baz")); - Aggregate ag2 = new Aggregate("nt:base", of(ni(null, "foo", true), ni(null, "foo/*", true))); + Aggregate ag2 = new Aggregate("nt:base", List.of(ni(null, "foo", true), ni(null, "foo/*", true))); assertTrue(ag2.hasRelativeNodeInclude("foo")); assertFalse(ag2.hasRelativeNodeInclude("bar")); assertTrue(ag2.hasRelativeNodeInclude("foo/bar")); @@ -281,9 +279,9 @@ public void includeMatches() { public void testReaggregate() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agFolder = new Aggregate("nt:folder", of(ni("nt:file", "*", true))); + Aggregate agFolder = new Aggregate("nt:folder", List.of(ni("nt:file", "*", true))); - Aggregate agFile = new Aggregate("nt:file", of(ni(null, "jcr:content", true))); + Aggregate agFile = new Aggregate("nt:file", List.of(ni(null, "jcr:content", true))); mapper.add("nt:file", agFile); mapper.add("nt:folder", agFolder); @@ -312,9 +310,9 @@ public void testReaggregateMixin() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agFolder = new Aggregate("nt:folder", of(ni("mix:title", "*", true))); + Aggregate agFolder = new Aggregate("nt:folder", List.of(ni("mix:title", "*", true))); - Aggregate agFile = new Aggregate("mix:title", of(ni(null, "jcr:content", true))); + Aggregate agFile = new Aggregate("mix:title", List.of(ni(null, "jcr:content", true))); mapper.add("mix:title", agFile); mapper.add("nt:folder", agFolder); @@ -338,7 +336,7 @@ public void testReaggregateMixin() { public void testRelativeNodeInclude() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agContent = new Aggregate("app:Page", of(ni(null, "jcr:content", true))); + Aggregate agContent = new Aggregate("app:Page", List.of(ni(null, "jcr:content", true))); mapper.add("app:Page", agContent); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java index 79f9ce11c5d..d84e973f252 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.plugins.tree; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -310,7 +308,7 @@ public void testAddChildWithOrderableChildren() throws Exception { Tree parent = when(mockTree("/some/tree", true).addChild("name")).thenReturn(t).getMock(); when(ntDef.getProperty(JCR_HASORDERABLECHILDNODES)).thenReturn(PropertyStates.createProperty(JCR_HASORDERABLECHILDNODES, true, Type.BOOLEAN)); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); @@ -328,10 +326,10 @@ public void testAddChildWithDefaultChildType() throws Exception { Tree defWithChild = mock(Tree.class); when(defWithChild.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_OAK_UNSTRUCTURED, Type.NAME)); when(defWithChild.getChild("name")).thenReturn(defWithChild); - when(defWithChild.getChildren()).thenReturn(ImmutableList.of(defWithChild)); + when(defWithChild.getChildren()).thenReturn(List.of(defWithChild)); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(ntDef.getProperty(JCR_IS_ABSTRACT)).thenReturn(PropertyStates.createProperty(JCR_IS_ABSTRACT, true, Type.BOOLEAN)); @@ -418,7 +416,7 @@ public void testAddMixinAlreadyContainedNoPrimary() throws Exception { @Test public void testAddMixinSuPrimary() throws Exception { when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); - when(ntDef.getProperty(REP_PRIMARY_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_PRIMARY_SUBTYPES, ImmutableList.of(NT_OAK_UNSTRUCTURED), Type.NAMES)); + when(ntDef.getProperty(REP_PRIMARY_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_PRIMARY_SUBTYPES, List.of(NT_OAK_UNSTRUCTURED), Type.NAMES)); when(typeRoot.getChild("containsSubPrimary")).thenReturn(ntDef); TreeUtil.addMixin(child, "containsSubPrimary", typeRoot, "userId"); @@ -430,7 +428,7 @@ public void testAddMixinSuPrimary() throws Exception { @Test public void testAddMixinSubMixin() throws Exception { when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); - when(ntDef.getProperty(REP_MIXIN_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_MIXIN_SUBTYPES, ImmutableList.of(MIX_VERSIONABLE), Type.NAMES)); + when(ntDef.getProperty(REP_MIXIN_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_MIXIN_SUBTYPES, List.of(MIX_VERSIONABLE), Type.NAMES)); when(typeRoot.getChild("containsSubMixin")).thenReturn(ntDef); TreeUtil.addMixin(child, "containsSubMixin", typeRoot, "userId"); @@ -441,7 +439,7 @@ public void testAddMixinSubMixin() throws Exception { @Test public void testAddMixin() throws Exception { - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); @@ -457,8 +455,8 @@ public void testAddMixin() throws Exception { @Test public void testAutoCreateItemsNoAutoCreateDefs() throws Exception { Tree noAutoCreate = when(mockTree("/definitions/definition/notAutoCreate", true).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, false)).getMock(); - Tree defWithChildren = when(mockTree("/definitions/definition", true).getChildren()).thenReturn(ImmutableList.of(noAutoCreate)).getMock(); - Tree definitions = when(mockTree("/definitions", true).getChildren()).thenReturn(ImmutableList.of(defWithChildren)).getMock(); + Tree defWithChildren = when(mockTree("/definitions/definition", true).getChildren()).thenReturn(List.of(noAutoCreate)).getMock(); + Tree definitions = when(mockTree("/definitions", true).getChildren()).thenReturn(List.of(defWithChildren)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(definitions); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); @@ -471,13 +469,13 @@ public void testAutoCreateItemsNoAutoCreateDefs() throws Exception { @Test public void testAutoCreateItemsExcludedProperties() throws Exception { - List list = ImmutableList.of( + List list = List.of( mockTree("/some/path/"+ REP_PRIMARY_TYPE, true), mockTree("/some/path/" + REP_MIXIN_TYPES, true)); Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(list).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); TreeUtil.autoCreateItems(child, ntDef, typeRoot, "userId"); @@ -490,11 +488,11 @@ public void testAutoCreateItemsExcludedProperties() throws Exception { public void testAutoCreateItemsExistingUuid() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/"+ REP_UUID, true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty(JCR_UUID)).thenReturn(true); @@ -509,11 +507,11 @@ public void testAutoCreateItemsExistingUuid() throws Exception { public void testAutoCreateItemsMissingUuid() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/"+ REP_UUID, true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty(JCR_UUID)).thenReturn(false); @@ -528,11 +526,11 @@ public void testAutoCreateItemsMissingUuid() throws Exception { public void testAutoCreateItemsMissingDefaultValue() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/unknownProperty", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty("unknownProperty")).thenReturn(false); @@ -543,12 +541,12 @@ public void testAutoCreateItemsMissingDefaultValue() throws Exception { public void testAutoCreateItemsExistingChild() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/autoChild", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); + when(definitions.getChildren()).thenReturn(List.of(definition)); - Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithAutoChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasChild("autoChild")).thenReturn(true); @@ -565,12 +563,12 @@ public void testAutoCreateItemsNonExistingChild() throws Exception { when(definition.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_OAK_UNSTRUCTURED, Type.NAME)); Tree definitions = mockTree("/some/path/autoChild", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); + when(definitions.getChildren()).thenReturn(List.of(definition)); - Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithAutoChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); Tree newChild = mock(Tree.class); @@ -606,7 +604,7 @@ public void testAutoCreatePropertyBuiltIn() { @Test public void testAutoCreatePropertyFromDefaultValues() { - PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(34L), Type.LONGS); + PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(34L), Type.LONGS); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultSingleValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, false)); @@ -619,7 +617,7 @@ public void testAutoCreatePropertyFromDefaultValues() { @Test public void testAutoCreatePropertyFromEmptyDefaultValues() { - PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(), Type.DATES); + PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(), Type.DATES); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultSingleValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, false)); @@ -629,7 +627,7 @@ public void testAutoCreatePropertyFromEmptyDefaultValues() { @Test public void testAutoCreatePropertyFromMvDefaultValues() { - PropertyState defaultMvValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(true, false, true), Type.BOOLEANS); + PropertyState defaultMvValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(true, false, true), Type.BOOLEANS); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultMvValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, true)); @@ -643,7 +641,7 @@ public void testAutoCreatePropertyFromMvDefaultValues() { @Test public void testGetDefaultChildTypeFromNamed() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); PropertyState ps = PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_RESOURCE, Type.NAME); when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, false, Type.BOOLEAN); @@ -652,7 +650,7 @@ public void testGetDefaultChildTypeFromNamed() { Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(definitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(emptyDefinitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -662,7 +660,7 @@ public void testGetDefaultChildTypeFromNamed() { @Test public void testGetDefaultChildTypeFromNamedWithSns() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); PropertyState ps = PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_RESOURCE, Type.NAME); when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, true, Type.BOOLEAN); @@ -677,7 +675,7 @@ public void testGetDefaultChildTypeFromNamedWithSns() { @Test public void testGetDefaultChildTypeFromResidual() { - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(emptyDefinitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); @@ -686,7 +684,7 @@ public void testGetDefaultChildTypeFromResidual() { when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, false, Type.BOOLEAN); when(def.getProperty(JCR_SAMENAMESIBLINGS)).thenReturn(sns); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -695,7 +693,7 @@ public void testGetDefaultChildTypeFromResidual() { @Test public void testGetDefaultChildTypeFromResidualSns() { - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(emptyDefinitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); @@ -704,7 +702,7 @@ public void testGetDefaultChildTypeFromResidualSns() { when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, true, Type.BOOLEAN); when(def.getProperty(JCR_SAMENAMESIBLINGS)).thenReturn(sns); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -718,25 +716,25 @@ public void testGetEffectiveTypeNoPrimary() { @Test public void testGetEffectiveTypeNoMixins() { - assertEquals(ImmutableList.of(ntDef), TreeUtil.getEffectiveType(z, typeRoot)); + assertEquals(List.of(ntDef), TreeUtil.getEffectiveType(z, typeRoot)); } @Test public void testGetEffectiveType() { - assertEquals(ImmutableList.of(ntDef, ntDef, ntDef), TreeUtil.getEffectiveType(child, typeRoot)); + assertEquals(List.of(ntDef, ntDef, ntDef), TreeUtil.getEffectiveType(child, typeRoot)); } @Test public void testGetEffectiveTypeNonExistingPrimaryDef() { - assertEquals(ImmutableList.of(), TreeUtil.getEffectiveType(mockTree("/anotherTree", rootTree, false, "rep:NonExistingType"), typeRoot)); + assertEquals(List.of(), TreeUtil.getEffectiveType(mockTree("/anotherTree", rootTree, false, "rep:NonExistingType"), typeRoot)); } @Test public void testGetEffectiveTypeNonExistingMixinDef() { Tree tree = mockTree("/anotherTree", rootTree, false); - when(tree.getProperty(JCR_MIXINTYPES)).thenReturn(PropertyStates.createProperty(JCR_MIXINTYPES, ImmutableList.of("rep:NonExistingType"), Type.NAMES)); + when(tree.getProperty(JCR_MIXINTYPES)).thenReturn(PropertyStates.createProperty(JCR_MIXINTYPES, List.of("rep:NonExistingType"), Type.NAMES)); - assertEquals(ImmutableList.of(), TreeUtil.getEffectiveType(tree, typeRoot)); + assertEquals(List.of(), TreeUtil.getEffectiveType(tree, typeRoot)); } @Test @@ -748,7 +746,7 @@ public void testFindDefaultPrimaryTypeUnknownDefinition() { @Test public void testFindDefaultPrimaryType() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); assertNull(TreeUtil.findDefaultPrimaryType(definitions, false)); assertNull(TreeUtil.findDefaultPrimaryType(definitions, true)); @@ -782,7 +780,7 @@ public void testIsNodeTypeMissingTypeProperties() { @Test public void testIsNodeTypeContainedInSupertypes() { - PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, ImmutableList.of(NT_BASE), Type.NAMES); + PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, List.of(NT_BASE), Type.NAMES); when(ntDef.getProperty(REP_SUPERTYPES)).thenReturn(supertypes); assertTrue(TreeUtil.isNodeType(child, NT_BASE, typeRoot)); @@ -797,7 +795,7 @@ public void testIsNodeTypeMixin() { @Test public void testIsNodeTypeMixinContainedInSupertypes() { - PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, ImmutableList.of(MIX_REFERENCEABLE), Type.NAMES); + PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, List.of(MIX_REFERENCEABLE), Type.NAMES); when(ntDef.getProperty(REP_SUPERTYPES)).thenReturn(supertypes); PropertyState mixinNames = PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, List.of(JcrConstants.MIX_VERSIONABLE), Type.NAMES); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java index 20e0a06213d..90c19baed09 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.plugins.tree.RootProvider; import org.apache.jackrabbit.oak.plugins.tree.TreeProvider; @@ -251,7 +251,7 @@ public void testGetProtectedItemImporters() { @NotNull @Override public List getProtectedItemImporters() { - return ImmutableList.of(mock(ProtectedItemImporter.class)); + return List.of(mock(ProtectedItemImporter.class)); } }; addConfiguration(withImporter); @@ -270,7 +270,7 @@ public void testGetConflictHandlers() { @NotNull @Override public List getConflictHandlers() { - return ImmutableList.of(mock(ThreeWayConflictHandler.class)); + return List.of(mock(ThreeWayConflictHandler.class)); } }; addConfiguration(withConflictHandler); @@ -289,7 +289,7 @@ public void testGetCommitHooks() { @NotNull @Override public List getCommitHooks(@NotNull String workspaceName) { - return ImmutableList.of(mock(CommitHook.class)); + return List.of(mock(CommitHook.class)); } }; addConfiguration(withCommitHook); @@ -308,7 +308,7 @@ public void testGetValidators() { @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(mock(ValidatorProvider.class)); + return List.of(mock(ValidatorProvider.class)); } }; addConfiguration(withValidator); @@ -371,7 +371,7 @@ public ConfigurationParameters getParameters() { }; addConfiguration(withParams); - assertEquals(Set.copyOf(params.keySet()), Set.copyOf(compositeConfiguration.getParameters().keySet())); + assertEquals(ImmutableSet.copyOf(params.keySet()), ImmutableSet.copyOf(compositeConfiguration.getParameters().keySet())); ConfigurationParameters params2 = ConfigurationParameters.of("a", "valueA2", "c", "valueC"); SecurityConfiguration withParams2 = new SecurityConfiguration.Default() { @@ -385,7 +385,7 @@ public ConfigurationParameters getParameters() { ConfigurationParameters compositeParams = compositeConfiguration.getParameters(); assertEquals(3, compositeParams.size()); - assertEquals(Set.copyOf(ConfigurationParameters.of(params, params2).keySet()), Set.copyOf(compositeParams.keySet())); + assertEquals(ImmutableSet.copyOf(ConfigurationParameters.of(params, params2).keySet()), ImmutableSet.copyOf(compositeParams.keySet())); assertEquals("valueA2", compositeParams.getConfigValue("a", "def")); } @@ -402,7 +402,7 @@ public void testGetMonitors() { @NotNull @Override public Iterable> getMonitors(@NotNull StatisticsProvider statisticsProvider) { - return ImmutableList.of(monitor); + return List.of(monitor); } }; addConfiguration(withMonitors); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java index 63d0c9078d0..32cfc1bf0a7 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java @@ -27,8 +27,9 @@ import java.util.Properties; import java.util.Set; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.guava.common.collect.Sets; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -91,8 +92,8 @@ public void testCreationFromProperties() { properties.put("a", "b"); ConfigurationParameters cp = ConfigurationParameters.of(properties); - assertEquals(Set.copyOf(properties.keySet()), Set.copyOf(cp.keySet())); - assertEquals(Set.copyOf(properties.values()), Set.copyOf(cp.values())); + assertEquals(ImmutableSet.copyOf(properties.keySet()), ImmutableSet.copyOf(cp.keySet())); + assertEquals(ImmutableSet.copyOf(properties.values()), ImmutableSet.copyOf(cp.values())); } @@ -109,8 +110,8 @@ public void testCreationFromDictionary() { dict.put("a", "b"); ConfigurationParameters cp = ConfigurationParameters.of(dict); - assertEquals(CollectionUtils.toSet(Iterators.forEnumeration(dict.keys())), Set.copyOf(cp.keySet())); - assertEquals(CollectionUtils.toSet(Iterators.forEnumeration(dict.elements())), Set.copyOf(cp.values())); + assertEquals(ImmutableSet.copyOf(Iterators.forEnumeration(dict.keys())), ImmutableSet.copyOf(cp.keySet())); + assertEquals(ImmutableSet.copyOf(Iterators.forEnumeration(dict.elements())), ImmutableSet.copyOf(cp.values())); } @@ -321,10 +322,10 @@ public void testImpossibleConversion() { @Test public void testConversionToSet() { String[] stringArray = new String[] {"a", "b"}; - Set stringSet = Set.of(stringArray); + Set stringSet = ImmutableSet.copyOf(stringArray); TestObject[] testObjectArray = new TestObject[] {new TestObject("a"), new TestObject("b")}; - Set testObjectSet = Set.of(testObjectArray); + Set testObjectSet = ImmutableSet.copyOf(testObjectArray); // map of config value (key) and expected result set. Map> configValues = new HashMap<>(); @@ -463,10 +464,10 @@ public void testInvalidConversionToBoolean() { @Test public void testConversionToStringArray() { String[] stringArray = new String[] {"a", "b"}; - Set stringSet = CollectionUtils.toSet(stringArray); + Set stringSet = ImmutableSet.copyOf(stringArray); TestObject[] testObjectArray = new TestObject[] {new TestObject("a"), new TestObject("b")}; - Set testObjectSet = CollectionUtils.toSet(testObjectArray); + Set testObjectSet = ImmutableSet.copyOf(testObjectArray); String[] defaultStrings = new String[]{"abc", "def", "ghi"}; diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModuleTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModuleTest.java index f8677cd2400..98646e9ebd4 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModuleTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModuleTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.authentication.token.TokenCredentials; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.api.security.user.UserManager; @@ -62,8 +63,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule.SHARED_KEY_CREDENTIALS; import static org.junit.Assert.assertEquals; @@ -147,7 +146,7 @@ public void testLogout() throws Exception { @Test public void testLogoutSuccessClearsSubject() throws Exception { - Subject subject = new Subject(false, Set.of(new PrincipalImpl("pName")), Set.of(new TestCredentials()), Set.of()); + Subject subject = new Subject(false, ImmutableSet.of(new PrincipalImpl("pName")), Set.of(new TestCredentials()), Set.of()); AbstractLoginModule loginModule = initLoginModule(subject); assertTrue(loginModule.logout()); @@ -158,7 +157,7 @@ public void testLogoutSuccessClearsSubject() throws Exception { @Test public void testLogoutSuccessReadOnlySubject() throws Exception { - Subject subject = new Subject(true, Set.of(new PrincipalImpl("pName")), Set.of(new TestCredentials()), Set.of()); + Subject subject = new Subject(true, ImmutableSet.of(new PrincipalImpl("pName")), Set.of(new TestCredentials()), Set.of()); AbstractLoginModule loginModule = initLoginModule(subject); assertTrue(loginModule.logout()); @@ -169,14 +168,14 @@ public void testLogoutSuccessReadOnlySubject() throws Exception { @Test public void testLogoutSubjectWithoutCredentials() throws Exception { - Subject subject = new Subject(false, Set.of(new PrincipalImpl("pName")), Set.of("stringNotCredentials"), Set.of()); + Subject subject = new Subject(false, ImmutableSet.of(new PrincipalImpl("pName")), Set.of("stringNotCredentials"), Set.of()); AbstractLoginModule loginModule = initLoginModule(subject); loginModule.logout(); assertFalse(subject.getPublicCredentials().isEmpty()); assertFalse(subject.getPrincipals().isEmpty()); - subject = new Subject(false, Set.of(new PrincipalImpl("pName")), Set.of(), Set.of()); + subject = new Subject(false, ImmutableSet.of(new PrincipalImpl("pName")), Set.of(), Set.of()); loginModule = initLoginModule(subject); loginModule.logout(); @@ -209,7 +208,7 @@ public void testLogoutCPSuccess() throws LoginException { String userId = TestPrincipalProvider.getIDFromPrincipal(p); Set principals = pp.getPrincipals(userId); - Set all = Stream.concat(Stream.of(p, foreignPrincipal), principals.stream()).collect(Collectors.toUnmodifiableSet()); + Set all = ImmutableSet.builder().add(p).add(foreignPrincipal).addAll(principals).build(); AuthInfo authInfo = new AuthInfoImpl(userId, null, all); @@ -243,7 +242,7 @@ public void testLogoutCPDestroyable() throws Exception { Credentials foreign2 = new TokenCredentials("token"); Subject subject = new Subject(true, - Set.of(new PrincipalImpl("pName")), + ImmutableSet.of(new PrincipalImpl("pName")), Set.of(creds, foreign1, foreign2), Set.of()); AbstractLoginModule loginModule = initLoginModule(subject); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthInfoImplTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthInfoImplTest.java index a8fb7711fd5..4d3fce193e5 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthInfoImplTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthInfoImplTest.java @@ -25,6 +25,7 @@ import javax.jcr.SimpleCredentials; import javax.security.auth.Subject; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.AuthInfo; import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl; @@ -40,7 +41,7 @@ public class AuthInfoImplTest { private static final String USER_ID = "userId"; private static final Map ATTRIBUTES = Map.of("attr", "value"); - private static final Set PRINCIPALS = Set.of(new PrincipalImpl("principalName")); + private static final Set PRINCIPALS = ImmutableSet.of(new PrincipalImpl("principalName")); private final AuthInfoImpl authInfo = new AuthInfoImpl(USER_ID, ATTRIBUTES, PRINCIPALS); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java index 16c53ce070e..7b2830201eb 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.token; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Before; @@ -26,6 +24,7 @@ import javax.jcr.Credentials; import javax.jcr.GuestCredentials; import javax.jcr.SimpleCredentials; +import java.util.List; import java.util.Map; import static org.junit.Assert.assertFalse; @@ -58,7 +57,7 @@ public void before() { public void testNullProvider() { TokenProvider tp = CompositeTokenProvider.newInstance(); - assertSame(tp, CompositeTokenProvider.newInstance(ImmutableList.of())); + assertSame(tp, CompositeTokenProvider.newInstance(List.of())); Credentials creds = new Credentials() {}; @@ -82,7 +81,7 @@ public void testSingleProvider() { TokenProvider tp = CompositeTokenProvider.newInstance(base); assertSame(base, tp); - assertSame(base, CompositeTokenProvider.newInstance(ImmutableList.of(base))); + assertSame(base, CompositeTokenProvider.newInstance(List.of(base))); } @Test @@ -93,7 +92,7 @@ public void testCreateCompositeProvider() { @Test public void testCreateCompositeProviderFromList() { TokenProvider base = mock(TokenProvider.class); - TokenProvider tp = CompositeTokenProvider.newInstance(ImmutableList.of(base, base)); + TokenProvider tp = CompositeTokenProvider.newInstance(List.of(base, base)); assertTrue(tp instanceof CompositeTokenProvider); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/OpenAuthorizationConfigurationTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/OpenAuthorizationConfigurationTest.java index bf43d7cc670..741b24a75c3 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/OpenAuthorizationConfigurationTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/OpenAuthorizationConfigurationTest.java @@ -16,8 +16,9 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization; -import java.util.Set; +import java.security.Principal; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.authorization.permission.OpenPermissionProvider; @@ -42,6 +43,6 @@ public void testGetRestrictionProvider() { @Test public void testGetPermissionProvider() { - assertSame(OpenPermissionProvider.getInstance(), config.getPermissionProvider(Mockito.mock(Root.class), "default", Set.of())); + assertSame(OpenPermissionProvider.getInstance(), config.getPermissionProvider(Mockito.mock(Root.class), "default", ImmutableSet.of())); } } \ No newline at end of file diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java index bf051f79d4a..356f1567e41 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; @@ -43,7 +42,9 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants.JCR_READ; @@ -105,7 +106,7 @@ private Restriction createRestriction(String name, Value value) throws Exception } private Restriction createRestriction(String name, Value[] values) throws Exception { - return new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.copyOf(values)), false); + return new RestrictionImpl(PropertyStates.createProperty(name, Arrays.asList(values)), false); } @Test @@ -216,7 +217,7 @@ public void testNullRestrictions() { @Test public void testRestrictions() { Restriction r = new RestrictionImpl(PropertyStates.createProperty("r", "v"), false); - Restriction r2 = new RestrictionImpl(PropertyStates.createProperty("r2", ImmutableList.of("v"), Type.STRINGS), false); + Restriction r2 = new RestrictionImpl(PropertyStates.createProperty("r2", List.of("v"), Type.STRINGS), false); Set restrictions = Set.of(r, r2); ACE ace = mockACE(testPrincipal, PrivilegeBits.BUILT_IN.get(JCR_READ), true, restrictions); assertFalse(ace.getRestrictions().isEmpty()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java index 39c60303c06..fa2aa9b85b3 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java @@ -28,7 +28,6 @@ import javax.jcr.Value; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -134,7 +133,7 @@ protected List createTestEntries() throws Reposito @Test public void testGetNamePathMapper() { assertSame(getNamePathMapper(), createEmptyACL().getNamePathMapper()); - assertSame(NamePathMapper.DEFAULT, createACL(getTestPath(), ImmutableList.of(), NamePathMapper.DEFAULT).getNamePathMapper()); + assertSame(NamePathMapper.DEFAULT, createACL(getTestPath(), List.of(), NamePathMapper.DEFAULT).getNamePathMapper()); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlTest.java index 5fb9bbdc4a0..2f4793bcc3e 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction; @@ -61,7 +62,7 @@ ACE createEntry(boolean isAllow, String... privilegeName) ACE createEntry(Principal principal, PrivilegeBits privilegeBits, boolean isAllow, Restriction... restrictions) throws RepositoryException { - return new TestACE(principal, privilegeBits, isAllow, Set.of(restrictions)); + return new TestACE(principal, privilegeBits, isAllow, ImmutableSet.copyOf(restrictions)); } private final class TestACE extends ACE { diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java index 063c78f9d9d..87fdd866d0d 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java @@ -24,7 +24,7 @@ import javax.jcr.Session; import org.apache.jackrabbit.guava.common.base.Splitter; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; @@ -208,7 +208,7 @@ public void testGetStringAggregates() { @Test public void testIsAggregate() { - List aggregates = ImmutableList.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE); + List aggregates = List.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE); for (long permission : Permissions.PERMISSION_NAMES.keySet()) { if (aggregates.contains(permission)) { assertTrue(Permissions.getString(permission), Permissions.isAggregate(permission)); @@ -230,7 +230,7 @@ public void testAggregates() { Permissions.SET_PROPERTY, Set.of(Permissions.ADD_PROPERTY, Permissions.MODIFY_PROPERTY, Permissions.REMOVE_PROPERTY), Permissions.WRITE, Set.of(Permissions.ADD_NODE, Permissions.REMOVE_NODE, Permissions.ADD_PROPERTY, Permissions.REMOVE_PROPERTY,Permissions.MODIFY_PROPERTY) ); - aggregation.forEach((key, value) -> assertEquals(value, CollectionUtils.toSet(Permissions.aggregates(key)))); + aggregation.forEach((key, value) -> assertEquals(value, ImmutableSet.copyOf(Permissions.aggregates(key)))); } @Test @@ -245,7 +245,7 @@ public void testAggregatesAllPermission() { assertFalse(Iterables.contains(aggregates, Permissions.ALL)); Set expected = new HashSet<>(Permissions.PERMISSION_NAMES.keySet()); - expected.removeAll(ImmutableList.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE)); + expected.removeAll(List.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE)); assertEquals(expected, CollectionUtils.toSet(aggregates)); } @@ -260,7 +260,7 @@ public void testIsRepositoryPermission() { @Test public void testRespectParentPermissions() { - List permissions = ImmutableList.of( + List permissions = List.of( Permissions.ALL, Permissions.ADD_NODE, Permissions.ADD_NODE|Permissions.ADD_PROPERTY, @@ -278,7 +278,7 @@ public void testRespectParentPermissions() { @Test public void testNotRespectParentPermissions() { - List permissions = ImmutableList.of( + List permissions = List.of( Permissions.READ, Permissions.ADD_PROPERTY, Permissions.REMOVE_PROPERTY, @@ -357,7 +357,7 @@ public void testGetPermissionsFromPermissionNameActions() { @Test public void testGetPermissionsFromInvalidActions() { TreeLocation tl = TreeLocation.create(existingTree); - List l = ImmutableList.of( + List l = List.of( Session.ACTION_READ + ",invalid", "invalid", "invalid," + Session.ACTION_REMOVE ); @@ -555,7 +555,7 @@ public void testGetPermissionsForVersionPaths() { @Test public void testGetPermissionsForRegularPaths() { - for (String path : ImmutableList.of("/", "/a/b/c", "/myfile/jcr:content")) { + for (String path : List.of("/", "/a/b/c", "/myfile/jcr:content")) { for (long defaultPermission : Permissions.PERMISSION_NAMES.keySet()) { assertEquals(defaultPermission, Permissions.getPermission(path, defaultPermission)); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java index 2a808817a42..86a54e99136 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -32,24 +32,24 @@ public class CompositePatternTest { - private final RestrictionPattern alwaysMatching = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_TRUE)); - private final RestrictionPattern neverMatching = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); + private final RestrictionPattern alwaysMatching = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_TRUE)); + private final RestrictionPattern neverMatching = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); @Test public void testCreateFromEmptyList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of()); + RestrictionPattern rp = CompositePattern.create(List.of()); assertSame(RestrictionPattern.EMPTY, rp); } @Test public void testCreateFromSingletonList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE)); + RestrictionPattern rp = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE)); assertSame(TestRestrictionPatter.INSTANCE_TRUE, rp); } @Test public void testCreateFromList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); + RestrictionPattern rp = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); assertTrue(rp instanceof CompositePattern); } @@ -61,7 +61,7 @@ public void testMatches() { @Test public void testMatchesPath() { - List paths = ImmutableList.of("/", "/a", "/a/b/c", ""); + List paths = List.of("/", "/a", "/a/b/c", ""); for (String path : paths) { assertTrue(alwaysMatching.matches(path)); @@ -71,7 +71,7 @@ public void testMatchesPath() { @Test public void testMatchesPathIsProperty() { - List paths = ImmutableList.of("/", "/a", "/a/b/c", ""); + List paths = List.of("/", "/a", "/a/b/c", ""); for (String path : paths) { assertTrue(alwaysMatching.matches(path, true)); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java index f4c1ad1b622..a7091a01acb 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -66,9 +65,9 @@ public class CompositeRestrictionProviderTest implements AccessControlConstants private static final String NAME_BOOLEAN = "boolean"; private static final Restriction GLOB_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, "*"), false); - private static final Restriction NT_PREFIXES_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_PREFIXES, ImmutableList.of(), Type.STRINGS), false); + private static final Restriction NT_PREFIXES_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_PREFIXES, List.of(), Type.STRINGS), false); private static final Restriction MANDATORY_BOOLEAN_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_BOOLEAN, true, Type.BOOLEAN), true); - private static final Restriction LONGS_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_LONGS, ImmutableList.of(Long.MAX_VALUE), Type.LONGS), false); + private static final Restriction LONGS_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_LONGS, List.of(Long.MAX_VALUE), Type.LONGS), false); private static final Restriction UNKNOWN_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty("unknown", "string"), false); private final AbstractRestrictionProvider rp1 = spy(createRestrictionProvider(GLOB_RESTRICTION.getDefinition(), NT_PREFIXES_RESTRICTION.getDefinition())); @@ -300,7 +299,7 @@ public void testValidateRestrictionsWrongType() throws Exception { @Test(expected = AccessControlException.class) public void testValidateRestrictionsInvalidDefinition() throws Exception { - Restriction rWithInvalidDefinition = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, ImmutableList.of("str", "str2"), Type.STRINGS), false); + Restriction rWithInvalidDefinition = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, List.of("str", "str2"), Type.STRINGS), false); Tree aceTree = getAceTree(rWithInvalidDefinition, MANDATORY_BOOLEAN_RESTRICTION); RestrictionProvider rp = createRestrictionProvider(null, rWithInvalidDefinition, GLOB_RESTRICTION.getDefinition()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java index bc099e5f0cb..cbc4f716bd7 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -112,7 +111,7 @@ public void testNotEqual() { // - different type rs.add(new RestrictionImpl(PropertyStates.createProperty(name, value, Type.STRING), isMandatory)); // - different multi-value status - rs.add(new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.of(value), Type.NAMES), isMandatory)); + rs.add(new RestrictionImpl(PropertyStates.createProperty(name, List.of(value), Type.NAMES), isMandatory)); // - different name rs.add(new RestrictionImpl(createProperty("otherName", value, type), isMandatory)); // - different value @@ -151,7 +150,7 @@ public void testNotSameHashCode() { // - different type rs.add(new RestrictionImpl(PropertyStates.createProperty(name, value, Type.STRING), isMandatory)); // - different multi-value status - rs.add(new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.of(value), Type.NAMES), isMandatory)); + rs.add(new RestrictionImpl(PropertyStates.createProperty(name, List.of(value), Type.NAMES), isMandatory)); // - different name rs.add(new RestrictionImpl(createProperty("otherName", value, type), isMandatory)); // - different value diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java index df88787fb7c..9a5d95ba86e 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java @@ -27,13 +27,12 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Test; @@ -53,25 +52,25 @@ public class CompositePrincipalProviderTest { private final TestPrincipalProvider pp1 = new TestPrincipalProvider(); private final TestPrincipalProvider pp2 = new TestPrincipalProvider("p1", "p2"); - private final PrincipalProvider cpp = CompositePrincipalProvider.of(ImmutableList.of(pp1, pp2)); + private final PrincipalProvider cpp = CompositePrincipalProvider.of(List.of(pp1, pp2)); private Iterable testPrincipals() { return Iterables.concat(pp1.getTestPrincipals(), pp2.getTestPrincipals()); } private static void assertIterator(@NotNull Iterable expected, @NotNull Iterator result) { - assertEquals(CollectionUtils.toSet(expected), CollectionUtils.toSet(result)); + assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(result)); } @Test public void testOfEmptyList() { - assertSame(EmptyPrincipalProvider.INSTANCE, CompositePrincipalProvider.of(ImmutableList.of())); + assertSame(EmptyPrincipalProvider.INSTANCE, CompositePrincipalProvider.of(List.of())); } @Test public void testOfSingletonList() { PrincipalProvider pp = new TestPrincipalProvider(true); - assertSame(pp, CompositePrincipalProvider.of(ImmutableList.of(pp))); + assertSame(pp, CompositePrincipalProvider.of(List.of(pp))); } @Test @@ -107,7 +106,7 @@ public void testGetItemBasedPrincipal() throws Exception { ItemBasedPrincipal p = mock(ItemBasedPrincipal.class); PrincipalProvider pp = when(mock(PrincipalProvider.class).getItemBasedPrincipal(anyString())).thenReturn(p).getMock(); - assertEquals(p, CompositePrincipalProvider.of(ImmutableList.of(pp, pp2)).getItemBasedPrincipal("/any/path")); + assertEquals(p, CompositePrincipalProvider.of(List.of(pp, pp2)).getItemBasedPrincipal("/any/path")); } @Test @@ -165,7 +164,7 @@ public void findPrincipalsByTypeAll() { */ @Test public void testRangeDefault() { - List pps = ImmutableList.of(new PrincipalImpl("p0"), new PrincipalImpl("p1"), + List pps = List.of(new PrincipalImpl("p0"), new PrincipalImpl("p1"), new PrincipalImpl("p2")); PrincipalProvider pp = new PrincipalProvider() { @@ -271,7 +270,7 @@ public void testFindWithOffsetLimit() { // NOTE: CompositePrincipalProvider passes 0 offset to the aggregated provider! when(pp.findPrincipals("p", false, PrincipalManager.SEARCH_TYPE_ALL, 0, 3)).thenReturn(principals); - PrincipalProvider cpp = CompositePrincipalProvider.of(ImmutableList.of(pp, EmptyPrincipalProvider.INSTANCE)); + PrincipalProvider cpp = CompositePrincipalProvider.of(List.of(pp, EmptyPrincipalProvider.INSTANCE)); Iterator it = cpp.findPrincipals("p", false, PrincipalManager.SEARCH_TYPE_ALL, 2, 1); assertTrue(it.hasNext()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalManagerImplTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalManagerImplTest.java index 9012de45676..9bc41a56ff8 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalManagerImplTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalManagerImplTest.java @@ -20,12 +20,12 @@ import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalIterator; import org.apache.jackrabbit.api.security.principal.PrincipalManager; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -54,7 +54,7 @@ private static boolean isGroup(Principal p) { } private static void assertIterator(@NotNull Iterator expected, @NotNull Iterator result) { - assertEquals(CollectionUtils.toSet(expected), CollectionUtils.toSet(result)); + assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(result)); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/TestPrincipalProvider.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/TestPrincipalProvider.java index 6e5d5fcb574..1e4b97fab54 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/TestPrincipalProvider.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/TestPrincipalProvider.java @@ -17,7 +17,6 @@ package org.apache.jackrabbit.oak.spi.security.principal; import java.security.Principal; -import java.util.Arrays; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; @@ -26,6 +25,7 @@ import java.util.Set; import java.util.function.Predicate; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Maps; @@ -33,7 +33,6 @@ import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,7 +54,7 @@ public TestPrincipalProvider(boolean exposesEveryone) { public TestPrincipalProvider(String... principalNames) { this.exposesEveryone = true; - this.principals = Maps.toMap(CollectionUtils.toLinkedSet(Arrays.asList(principalNames)), input -> new ItemBasedPrincipal() { + this.principals = Maps.toMap(ImmutableSet.copyOf(principalNames), input -> new ItemBasedPrincipal() { @NotNull @Override public String getPath() { @@ -174,7 +173,7 @@ private static final class TestGroup extends PrincipalImpl implements GroupPrinc public TestGroup(String name, Principal... members) { super(name); - Set mset = Set.of(members); + Set mset = ImmutableSet.copyOf(members); this.members = Iterators.asEnumeration(mset.iterator()); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java index 06c9126bde8..dc09be37d44 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.spi.security.privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; import org.mockito.Mockito; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -29,7 +29,7 @@ public class ImmutablePrivilegeDefinitionTest { - private final ImmutablePrivilegeDefinition def = new ImmutablePrivilegeDefinition("name", true, ImmutableList.of("aggrName")); + private final ImmutablePrivilegeDefinition def = new ImmutablePrivilegeDefinition("name", true, List.of("aggrName")); @Test public void testGetName() { @@ -72,17 +72,17 @@ public void testNotEquals() { assertNotEquals(def, otherDef); assertNotEquals(def, null); - assertNotEquals(def, new ImmutablePrivilegeDefinition("othername", true, ImmutableList.of("aggrName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", false, ImmutableList.of("aggrName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, ImmutableList.of("anotherName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, ImmutableList.of())); - assertNotEquals(def, new ImmutablePrivilegeDefinition("otherName", false, ImmutableList.of("aggrName","aggrName2"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("othername", true, List.of("aggrName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", false, List.of("aggrName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, List.of("anotherName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, List.of())); + assertNotEquals(def, new ImmutablePrivilegeDefinition("otherName", false, List.of("aggrName","aggrName2"))); } @Test public void testToString() { assertEquals(def.toString(), def.toString()); assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), def.getDeclaredAggregateNames()).toString()); - assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), ImmutableList.of()).toString()); + assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), List.of()).toString()); } } \ No newline at end of file diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java index 048a25e0b74..66a0c72b7cc 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java @@ -16,13 +16,12 @@ */ package org.apache.jackrabbit.oak.spi.security.privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.jetbrains.annotations.NotNull; @@ -34,6 +33,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -111,7 +111,7 @@ public void testGetBitsEmptyString() { @Test public void testGetBitsEmptyIterable() { - assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(ImmutableList.of())); + assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(List.of())); } @Test @@ -124,7 +124,7 @@ public void testGetBitsBuiltInSingleName() { @Test public void testGetBitsBuiltInSingleton() { - PrivilegeBits bits = bitsProvider.getBits(ImmutableList.of(JCR_LOCK_MANAGEMENT)); + PrivilegeBits bits = bitsProvider.getBits(List.of(JCR_LOCK_MANAGEMENT)); assertFalse(bits.isEmpty()); assertEquals(PrivilegeBits.BUILT_IN.get(JCR_LOCK_MANAGEMENT), bits); @@ -141,7 +141,7 @@ public void testGetBitsBuiltInNames() { @Test public void testGetBitsBuiltInIterable() { - PrivilegeBits bits = bitsProvider.getBits(ImmutableList.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES)); + PrivilegeBits bits = bitsProvider.getBits(List.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES)); assertFalse(bits.isEmpty()); PrivilegeBits mod = PrivilegeBits.getInstance(bitsProvider.getBits(JCR_ADD_CHILD_NODES)).add(bitsProvider.getBits(JCR_REMOVE_CHILD_NODES)); @@ -167,7 +167,7 @@ public void testGetBitsKnownPrivName() { @Test public void testGetBitsTwiceSingleBuiltIn() { - Iterable names = ImmutableList.of(JCR_ADD_CHILD_NODES); + Iterable names = List.of(JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -180,7 +180,7 @@ public void testGetBitsTwiceSingleBuiltIn() { @Test public void testGetBitsTwiceMultipleBuiltIn() { - Iterable names = ImmutableList.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES); + Iterable names = List.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -193,7 +193,7 @@ public void testGetBitsTwiceMultipleBuiltIn() { @Test public void testGetBitsTwiceKnown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME); + Iterable names = List.of(KNOWN_PRIV_NAME); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -206,7 +206,7 @@ public void testGetBitsTwiceKnown() { @Test public void testGetBitsTwiceBuitInKnown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -219,7 +219,7 @@ public void testGetBitsTwiceBuitInKnown() { @Test public void testGetBitsTwiceKnownUnknown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, "unknown"); + Iterable names = List.of(KNOWN_PRIV_NAME, "unknown"); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -245,7 +245,7 @@ public void testBitsValidateEmpty() throws Exception { @Test public void testGetBitsValidateTwiceBuitInKnown() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names, true); PrivilegeBits bits2 = bitsProvider.getBits(names, false); @@ -258,7 +258,7 @@ public void testGetBitsValidateTwiceBuitInKnown() throws Exception { @Test(expected = AccessControlException.class) public void testBitsValidateNonExistingTree() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); when(privTree.exists()).thenReturn(true); when(privTree.hasChild(KNOWN_PRIV_NAME)).thenReturn(false); @@ -267,7 +267,7 @@ public void testBitsValidateNonExistingTree() throws Exception { } public void testBitsValidateFalseNonExistingTree() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); when(privTree.exists()).thenReturn(true); when(privTree.hasChild(KNOWN_PRIV_NAME)).thenReturn(false); @@ -354,7 +354,7 @@ public void testGetPrivilegeNamesWithAggregation() { when(anotherPriv.exists()).thenReturn(true); when(anotherPriv.getName()).thenReturn("name2"); when(anotherPriv.hasProperty(REP_AGGREGATES)).thenReturn(true); - when(anotherPriv.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(KNOWN_PRIV_NAME), Type.NAMES)); + when(anotherPriv.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, List.of(KNOWN_PRIV_NAME), Type.NAMES)); PropertyState bits2 = PropertyStates.createProperty(REP_BITS, 7500L); when(anotherPriv.getProperty(REP_BITS)).thenReturn(bits2); @@ -392,20 +392,20 @@ public void testGetAggregatedPrivilegeNamesNonAggregates() { @Test public void testGetAggregatedPrivilegeNamesJcrRead() { - assertEquals(Set.of(AGGREGATE_PRIVILEGES.get(JCR_READ)), CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_READ))); + assertEquals(ImmutableSet.copyOf(AGGREGATE_PRIVILEGES.get(JCR_READ)), ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_READ))); } @Test public void testGetAggregatedPrivilegeNamesJcrWrite() { // nested aggregated privileges in this case - Set result = CollectionUtils.toSet(bitsProvider.getAggregatedPrivilegeNames(JCR_WRITE)); - assertNotEquals(Set.of(AGGREGATE_PRIVILEGES.get(JCR_WRITE)), result); + Set result = ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_WRITE)); + assertNotEquals(ImmutableSet.copyOf(AGGREGATE_PRIVILEGES.get(JCR_WRITE)), result); String[] expected = new String[] { JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES, JCR_REMOVE_NODE, REP_ADD_PROPERTIES, REP_ALTER_PROPERTIES, REP_REMOVE_PROPERTIES }; - assertEquals(Set.of(expected), result); + assertEquals(ImmutableSet.copyOf(expected), result); } @Test @@ -416,35 +416,35 @@ public void testGetAggregatedPrivilegeNamesBuiltInTwice() { @Test public void testGetAggregatedPrivilegeNamesMultipleBuiltIn() { - Iterable expected = CollectionUtils.toSet(Iterables.concat( + Iterable expected = ImmutableSet.copyOf(Iterables.concat( bitsProvider.getAggregatedPrivilegeNames(JCR_READ), bitsProvider.getAggregatedPrivilegeNames(JCR_WRITE))); // create new to avoid reading from cache PrivilegeBitsProvider bp = new PrivilegeBitsProvider(root); Iterable result = bp.getAggregatedPrivilegeNames(JCR_READ, JCR_WRITE); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } @Test public void testGetAggregatedPrivilegeNamesMultipleBuiltIn2() { - Iterable expected = CollectionUtils.toSet(Iterables.concat( + Iterable expected = ImmutableSet.copyOf(Iterables.concat( bitsProvider.getAggregatedPrivilegeNames(JCR_READ), bitsProvider.getAggregatedPrivilegeNames(JCR_WRITE))); // read with same provider (i.e. reading from cache) Iterable result = bitsProvider.getAggregatedPrivilegeNames(JCR_READ, JCR_WRITE); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } @Test public void testGetAggregatedPrivilegeNamesMixedBuiltIn() { - Iterable expected = CollectionUtils.toSet(Iterables.concat( + Iterable expected = ImmutableSet.copyOf(Iterables.concat( Set.of(JCR_LOCK_MANAGEMENT), bitsProvider.getAggregatedPrivilegeNames(JCR_WRITE))); Iterable result = bitsProvider.getAggregatedPrivilegeNames(JCR_LOCK_MANAGEMENT, JCR_WRITE); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } @Test @@ -463,7 +463,7 @@ public void testGetAggregatedPrivilegeNamesMissingAggProperty() { when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); - assertTrue(Iterables.elementsEqual(ImmutableList.of(KNOWN_PRIV_NAME), result)); + assertTrue(Iterables.elementsEqual(List.of(KNOWN_PRIV_NAME), result)); } @Test @@ -474,7 +474,7 @@ public void testGetAggregatedPrivilegeNames() { when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } @Test @@ -486,7 +486,7 @@ public void testGetAggregatedPrivilegeNamesNested() { Iterable result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); Set expected = Set.of(REP_READ_NODES, REP_READ_PROPERTIES, JCR_ADD_CHILD_NODES); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } @Test @@ -497,10 +497,10 @@ public void testGetAggregatedPrivilegeNamesNestedWithCache() { when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); - Set expected = CollectionUtils.toSet(Iterables.concat( + Set expected = ImmutableSet.copyOf(Iterables.concat( Set.of(JCR_ADD_CHILD_NODES), bitsProvider.getAggregatedPrivilegeNames(JCR_READ))); - assertEquals(expected, CollectionUtils.toSet(result)); + assertEquals(expected, ImmutableSet.copyOf(result)); } } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java index 2bd45f5a43b..e66b58abb0d 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.spi.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -36,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.Test; + import javax.jcr.RepositoryException; import javax.jcr.security.AccessControlManager; import javax.jcr.security.AccessControlPolicy; @@ -84,14 +86,13 @@ private AccessControlManager mockAccessControlManager(boolean addEntrySuccess) t AccessControlManager acMgr = mock(AccessControlManager.class); when(acMgr.getApplicablePolicies("/none")).thenReturn(AccessControlPolicyIteratorAdapter.EMPTY); AccessControlPolicy policy = mock(AccessControlPolicy.class); - when(acMgr.getApplicablePolicies("/nonACL")).thenReturn(new AccessControlPolicyIteratorAdapter(ImmutableList.of(policy))); + when(acMgr.getApplicablePolicies("/nonACL")).thenReturn(new AccessControlPolicyIteratorAdapter(List.of(policy))); JackrabbitAccessControlList acl = mock(JackrabbitAccessControlList.class); if (addEntrySuccess) { when(acl.addAccessControlEntry(any(Principal.class), any(Privilege[].class))).thenReturn(true); } - when(acMgr.getApplicablePolicies("/acl")).thenReturn(new AccessControlPolicyIteratorAdapter(ImmutableList.of(acl))); + when(acMgr.getApplicablePolicies("/acl")).thenReturn(new AccessControlPolicyIteratorAdapter(List.of(acl))); return acMgr; - } private AccessControlAction createAction(@NotNull String... privNames) { diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java index 853fd718d8d..8c1898fb368 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.spi.security.user.action; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.oak.spi.security.SecurityProvider; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -47,7 +47,7 @@ public void testMultiple() { AuthorizableActionProvider aap = new TestAuthorizableActionProvider(); AuthorizableActionProvider aap2 = new TestAuthorizableActionProvider(); - assertEquals(ImmutableList.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(aap, aap2).getAuthorizableActions(securityProvider)); + assertEquals(List.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(aap, aap2).getAuthorizableActions(securityProvider)); } @Test @@ -55,7 +55,7 @@ public void testMultiple2() { AuthorizableActionProvider aap = new TestAuthorizableActionProvider(); AuthorizableActionProvider aap2 = new TestAuthorizableActionProvider(); - assertEquals(ImmutableList.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(ImmutableList.of(aap, aap2)).getAuthorizableActions(securityProvider)); + assertEquals(List.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(List.of(aap, aap2)).getAuthorizableActions(securityProvider)); } @@ -64,7 +64,7 @@ private static final class TestAuthorizableActionProvider implements Authorizabl @NotNull @Override public List getAuthorizableActions(@NotNull SecurityProvider securityProvider) { - return ImmutableList.of(TestAction.INSTANCE); + return List.of(TestAction.INSTANCE); } } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java index ebb36429861..6da7e4125ff 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; import org.apache.jackrabbit.util.Text; @@ -45,7 +44,7 @@ public class PasswordUtilTest { @Before public void before() throws Exception { - plainPasswords = ImmutableList.of( + plainPasswords = List.of( "pw", "PassWord123", "_", @@ -235,7 +234,7 @@ public void testIsSameInvalidIterations() throws Exception { @Test public void testIsSameMisplacedAlgorithm() { - List broken = ImmutableList.of("}{pw", "{pw", "{pw}"); + List broken = List.of("}{pw", "{pw", "{pw}"); for (String hash : broken) { assertFalse(PasswordUtil.isSame(hash, "pw")); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java index 33c0e9b7e49..60b0711ffa0 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.user.util; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.AuthorizableTypeException; @@ -170,7 +169,7 @@ public void testGetTypeFromTree() { @Test public void testGetTypeFromTree2() { - List test = ImmutableList.of( + List test = List.of( UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_FILE ); @@ -252,7 +251,7 @@ public void testGetAuthorizableIdNullTree() { @Test public void testGetAuthorizableId() { - List test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); + List test = List.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("id", UserUtil.getAuthorizableId(createTree(ntName, "id"))); } @@ -260,7 +259,7 @@ public void testGetAuthorizableId() { @Test public void testGetAuthorizableIdFallback() { - List test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); + List test = List.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("nName", UserUtil.getAuthorizableId(createTree(ntName, null, "nName"))); } @@ -268,7 +267,7 @@ public void testGetAuthorizableIdFallback() { @Test public void testGetAuthorizableIdNoAuthorizableType() { - List test = ImmutableList.of(UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_UNSTRUCTURED); + List test = List.of(UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_UNSTRUCTURED); for (String ntName : test) { assertNull(UserUtil.getAuthorizableId(createTree(ntName, "id"))); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java index f87c326efbb..eeb5c3b54c3 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java @@ -16,15 +16,16 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; public class NodeInfoTest { - private final NodeInfo nodeInfo = new NodeInfo("name", "primaryType", ImmutableList.of("mixin1", "mixin2"), "uuid"); + private final NodeInfo nodeInfo = new NodeInfo("name", "primaryType", List.of("mixin1", "mixin2"), "uuid"); @Test public void testGetName() { @@ -38,7 +39,7 @@ public void testGetPrimaryTypeName() { @Test public void testGetMixinTypeName() { - assertEquals(ImmutableList.of("mixin1", "mixin2"), nodeInfo.getMixinTypeNames()); + assertEquals(List.of("mixin1", "mixin2"), nodeInfo.getMixinTypeNames()); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java index f9b15ad8a88..1e97ff5b5d0 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; @@ -76,14 +75,14 @@ public void testDisposeThrowing() throws Exception { @Test(expected = DisposeException.class) public void testDisposeMultipleThrowing() throws Exception { - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(mockTextValue("value", PropertyType.STRING, true))); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(mockTextValue("value", PropertyType.STRING, true))); propInfo.dispose(); } @Test public void testDisposeMultiple() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING, false); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); propInfo.dispose(); verify(tv, times(1)).dispose(); } @@ -121,10 +120,10 @@ public void testGetType() throws Exception { @Test public void testIsUnknownMultiple() throws Exception { - PropInfo propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, ImmutableList.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.UNKNOWN); + PropInfo propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, List.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.UNKNOWN); assertTrue(propInfo.isUnknownMultiple()); - propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, ImmutableList.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.MULTIPLE); + propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, List.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.MULTIPLE); assertFalse(propInfo.isUnknownMultiple()); } @@ -136,25 +135,25 @@ public void testIsUnknownMultipleSingle() throws Exception { @Test public void testIsUnknownMultipleSingleList() throws Exception { - PropInfo propInfo = new PropInfo("long", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG))); + PropInfo propInfo = new PropInfo("long", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG))); assertTrue(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleSingleList2() throws Exception { - PropInfo propInfo = new PropInfo("long", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG)), PropInfo.MultipleStatus.MULTIPLE); + PropInfo propInfo = new PropInfo("long", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG)), PropInfo.MultipleStatus.MULTIPLE); assertFalse(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleEmpty() { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of()); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of()); assertFalse(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleMultiple() throws Exception { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("44", PropertyType.LONG))); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("44", PropertyType.LONG))); assertFalse(propInfo.isUnknownMultiple()); } @@ -169,14 +168,14 @@ public void testGetTextValueSingle() throws Exception { @Test public void testGetTextValueSingleList() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); assertEquals(tv, propInfo.getTextValue()); } @Test(expected = RepositoryException.class) public void testGetTextValueMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); propInfo.getTextValue(); @@ -187,12 +186,12 @@ public void testGetTextValuesSingle() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); PropInfo propInfo = new PropInfo("string", PropertyType.STRING, tv); - assertEquals(ImmutableList.of(tv), propInfo.getTextValues()); + assertEquals(List.of(tv), propInfo.getTextValues()); } @Test public void testGetTextValuesMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); assertEquals(tvs, propInfo.getTextValues()); @@ -209,14 +208,14 @@ public void testGetValueSingle() throws Exception { @Test public void testGetValueSingleList() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); assertEquals(tv.getValue(PropertyType.STRING), propInfo.getValue(PropertyType.STRING)); } @Test(expected = RepositoryException.class) public void testGetValueMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); propInfo.getValue(PropertyType.LONG); @@ -227,19 +226,19 @@ public void testGetValuesSingle() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); PropInfo propInfo = new PropInfo("string", PropertyType.STRING, tv); - assertEquals(ImmutableList.of(tv.getValue(PropertyType.STRING)), propInfo.getValues(PropertyType.STRING)); + assertEquals(List.of(tv.getValue(PropertyType.STRING)), propInfo.getValues(PropertyType.STRING)); } @Test public void testGetValuesEmpty() throws Exception { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of()); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of()); assertTrue(propInfo.getValues(PropertyType.LONG).isEmpty()); } @Test public void testGetValuesMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); assertEquals(Lists.transform(tvs, input -> { @@ -263,7 +262,7 @@ public void testAsPropertyStateSingle() throws Exception { @Test public void testAsPropertyStateEmptyList() throws Exception { - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of()); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of()); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); @@ -272,7 +271,7 @@ public void testAsPropertyStateEmptyList() throws Exception { @Test public void testAsPropertyStateSingleList() throws Exception { - PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, ImmutableList.of(mockTextValue("a", PropertyType.STRING)), PropInfo.MultipleStatus.MULTIPLE); + PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, List.of(mockTextValue("a", PropertyType.STRING)), PropInfo.MultipleStatus.MULTIPLE); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); @@ -281,7 +280,7 @@ public void testAsPropertyStateSingleList() throws Exception { @Test public void testAsPropertyStateMultiples() throws Exception { - PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, ImmutableList.of(mockTextValue("a", PropertyType.STRING), mockTextValue("b", PropertyType.STRING))); + PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, List.of(mockTextValue("a", PropertyType.STRING), mockTextValue("b", PropertyType.STRING))); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java index fa0b1ace5c8..f3042da9da7 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.junit.Test; @@ -53,7 +52,7 @@ public void testReferenceProcessing() { assertTrue(Iterators.elementsEqual(List.of("ref", "ref2").iterator(), rct.getProcessedReferences())); - rct.removeReferences(ImmutableList.of("ref")); + rct.removeReferences(List.of("ref")); assertTrue(Iterators.elementsEqual(List.of("ref2").iterator(), rct.getProcessedReferences())); } diff --git a/oak-segment-azure/src/test/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreServiceTest.java b/oak-segment-azure/src/test/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreServiceTest.java index 8a9b35faed1..a4531c3b5c3 100644 --- a/oak-segment-azure/src/test/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreServiceTest.java +++ b/oak-segment-azure/src/test/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreServiceTest.java @@ -16,10 +16,9 @@ */ package org.apache.jackrabbit.oak.segment.azure; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import com.microsoft.azure.storage.StorageException; -import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; -import com.microsoft.azure.storage.blob.SharedAccessBlobPolicy; -import com.microsoft.azure.storage.blob.CloudBlobContainer; +import com.microsoft.azure.storage.blob.*; import java.io.IOException; import java.net.URISyntaxException; import java.time.Duration; @@ -28,7 +27,6 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Set; -import java.util.stream.Stream; import java.util.stream.StreamSupport; import org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzuriteDockerRule; @@ -245,7 +243,7 @@ private static Instant yesterday() { } private static Set concat(Set blobs, String element) { - return Stream.concat(blobs.stream(), Stream.of(element)).collect(toSet()); + return ImmutableSet.builder().addAll(blobs).add(element).build(); } private static Configuration getConfigurationWithSharedAccessSignature(String sasToken) { diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java index dc2fa923114..b214bac8e8b 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java @@ -43,8 +43,6 @@ import ch.qos.logback.classic.Level; import org.apache.jackrabbit.guava.common.base.Stopwatch; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; @@ -345,7 +343,7 @@ public void consistencyCheckWithRenegadeDelete() throws Exception { Random rand = new Random(87); List existing = new ArrayList<>(state.blobsPresent); - long count = blobStore.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0); + long count = blobStore.countDeleteChunks(List.of(existing.get(rand.nextInt(existing.size()))), 0); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); MarkSweepGarbageCollector gcObj = init(86400, executor); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java index 2ea0bc251c6..d9789d14d01 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java @@ -46,7 +46,6 @@ import java.util.Map; import java.util.Random; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; @@ -229,7 +228,7 @@ public void template() throws IOException { builder.setChildNode("n"); builder.setProperty("p", 1); builder.setProperty("jcr:primaryType", "type", NAME); - builder.setProperty("jcr:mixinTypes", ImmutableList.of("type1", "type2"), NAMES); + builder.setProperty("jcr:mixinTypes", List.of("type1", "type2"), NAMES); SegmentNodeState node = new SegmentNodeState(store.getReader(), writer, store.getBlobStore(), writer.writeNode(builder.getNodeState())); NodeInfo nodeInfo = new TestParser(store.getReader(), "template") { @Override @@ -320,7 +319,7 @@ protected void onProperty(RecordId parentId, RecordId propertyId, PropertyTempla @Test public void multiValueProperty() throws IOException { NodeBuilder builder = EMPTY_NODE.builder(); - builder.setProperty("p", ImmutableList.of(1L, 2L, 3L, 4L), LONGS); + builder.setProperty("p", List.of(1L, 2L, 3L, 4L), LONGS); SegmentNodeState node = new SegmentNodeState(store.getReader(), writer, store.getBlobStore(), writer.writeNode(builder.getNodeState())); NodeInfo nodeInfo = new TestParser(store.getReader(), "multiValueProperty") { @Override diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java index eaa91f98c88..7d8100061ef 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java @@ -15,14 +15,13 @@ * limitations under the License. * */ - package org.apache.jackrabbit.oak.segment.spi.monitor; import static org.junit.Assert.assertEquals; import java.io.File; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.whiteboard.Registration; import org.junit.Test; @@ -31,8 +30,8 @@ public class CompositeIOMonitorTest { @Test public void testComposition() { - ImmutableList ioMonitors = - ImmutableList.of(new IOMonitorAssertion(), new IOMonitorAssertion()); + List ioMonitors = + List.of(new IOMonitorAssertion(), new IOMonitorAssertion()); IOMonitor ioMonitor = new CompositeIOMonitor(ioMonitors); ioMonitor.beforeSegmentRead(FILE, 0, 0, 0); @@ -50,8 +49,8 @@ public void testComposition() { @Test public void testUnregisterComposition() { - ImmutableList ioMonitors = - ImmutableList.of(new IOMonitorAssertion(), new IOMonitorAssertion()); + List ioMonitors = + List.of(new IOMonitorAssertion(), new IOMonitorAssertion()); CompositeIOMonitor ioMonitor = new CompositeIOMonitor(); ioMonitor.registerIOMonitor(ioMonitors.get(0)); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java index b64deaf958e..e46f0235097 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,7 @@ public void testTraverseEmptyTree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(0)); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); + assertEquals(List.of("0", "1"), trace.get(0)); } @Test @@ -54,8 +53,8 @@ public void testTraverseDepth1Tree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(1)); assertEquals(2, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); } @Test @@ -63,9 +62,9 @@ public void testTraverseDepth2Tree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(2)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3"), trace.get(2)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); + assertEquals(List.of("2", "3"), trace.get(2)); } @Test @@ -73,9 +72,9 @@ public void testTraverseDepth3TreeWithLimit2() { List> trace = new ArrayList<>(); new BreadthFirstTrace(2, "/", trace::add).run(createTree(3)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3"), trace.get(2)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); + assertEquals(List.of("2", "3"), trace.get(2)); } } diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java index 5f3ef1902a1..079b4d5413f 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,7 @@ public void testTraverseEmptyTree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(0)); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); } @Test @@ -54,8 +53,8 @@ public void testTraverseDepth1Tree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(1)); assertEquals(2, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); } @Test @@ -63,9 +62,9 @@ public void testTraverseDepth2Tree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(2)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3", "/node-0/node-1"), trace.get(2)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("2", "3", "/node-0/node-1"), trace.get(2)); } @Test @@ -73,9 +72,9 @@ public void testTraverseDepth3TreeWithLimit2() { List> trace = new ArrayList<>(); new DepthFirstTrace(2, "/", trace::add).run(createTree(3)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3", "/node-0/node-1"), trace.get(2)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("2", "3", "/node-0/node-1"), trace.get(2)); } } diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java index c088d724e62..e5b05ec0ab5 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java @@ -39,7 +39,6 @@ import java.util.Set; import java.util.function.Function; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.segment.SegmentNodeBuilder; import org.apache.jackrabbit.oak.segment.SegmentNodeState; import org.apache.jackrabbit.oak.segment.file.FileStore; @@ -176,7 +175,7 @@ public void collectRandomAccessTrace() throws IOException { Function factory = this::createFileStore; IOTracer ioTracer = newIOTracer(factory, out, RandomAccessTrace.CONTEXT_SPEC); - ImmutableList paths = ImmutableList.of("/1a", "/1b", "/foo"); + List paths = List.of("/1a", "/1b", "/foo"); ioTracer.collectTrace( new RandomAccessTrace(paths, 0, 10, ioTracer::setContext)); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java index e2e6b04ed69..170c78c7a6d 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -61,16 +60,16 @@ public void testTraverseEmptyTree() { @Test public void testTraverseNonExistingPath() { List> trace = new ArrayList<>(); - new RandomAccessTrace(ImmutableList.of("/not/here"), 0, 1, trace::add) + new RandomAccessTrace(List.of("/not/here"), 0, 1, trace::add) .run(createTree(emptyList())); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("/not/here"), trace.get(0)); + assertEquals(List.of("/not/here"), trace.get(0)); } @Test public void testTraverse() { List> trace = new ArrayList<>(); - ImmutableList paths = ImmutableList.of("/a/b/c", "/d/e/f"); + List paths = List.of("/a/b/c", "/d/e/f"); new RandomAccessTrace(paths, 0, 2, trace::add) .run(createTree(paths)); assertEquals(2, trace.size()); diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java index a1a57ba78a7..442093b54c8 100644 --- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java +++ b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -322,7 +322,7 @@ public void testTokenizeCN() throws Exception { Tree one = t.addChild("one"); one.setProperty("t", "美女衬衫"); root.commit(); - assertQuery("//*[jcr:contains(., '美女')]", "xpath", ImmutableList.of(one.getPath())); + assertQuery("//*[jcr:contains(., '美女')]", "xpath", List.of(one.getPath())); } @Test @@ -364,13 +364,13 @@ public void contains() throws Exception { stmt.append("/jcr:root//*[jcr:contains(., '").append(h); stmt.append("')]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); // query 'world' stmt = new StringBuffer(); stmt.append("/jcr:root//*[jcr:contains(., '").append(w); stmt.append("')]"); - assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a")); + assertQuery(stmt.toString(), "xpath", List.of("/test/a")); } @@ -384,9 +384,9 @@ public void containsDash() throws Exception { root.commit(); assertQuery("/jcr:root//*[jcr:contains(., 'hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); assertQuery("/jcr:root//*[jcr:contains(., '*hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); } @@ -398,7 +398,7 @@ public void multiPhraseQuery() throws Exception { assertQuery( "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]", - "xpath", ImmutableList.of("/test/a")); + "xpath", List.of("/test/a")); } @@ -411,19 +411,19 @@ public void testFulltextOperators() throws Exception { assertQuery( "/jcr:root//*[jcr:contains(., 'lazy AND brown')]", - "xpath", ImmutableList.of("/test/a")); + "xpath", List.of("/test/a")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy OR eat')]", - "xpath", ImmutableList.of("/test/a", "/test/b")); + "xpath", List.of("/test/a", "/test/b")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy AND bones')]", - "xpath", ImmutableList.of("/test/b")); + "xpath", List.of("/test/b")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy OR dog')]", - "xpath", ImmutableList.of("/test/a", "/test/b")); + "xpath", List.of("/test/a", "/test/b")); } @Test @@ -433,7 +433,7 @@ public void containsPath() throws Exception { test.addChild("a").setProperty("name", "/parent/child/node"); root.commit(); - assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", ImmutableList.of("/test/a")); + assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", List.of("/test/a")); } @@ -445,7 +445,7 @@ public void containsPathNum() throws Exception { a.setProperty("name", "/segment1/segment2/segment3"); root.commit(); - assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", ImmutableList.of("/test/a")); + assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", List.of("/test/a")); } @@ -470,7 +470,7 @@ public void testOAK1208() throws Exception { root.commit(); assertQuery("//*[jcr:contains(., 'media') and (@p = 'dam/smartcollection' or @p = 'dam/collection') ]", "xpath", - ImmutableList.of(one.getPath(), two.getPath())); + List.of(one.getPath(), two.getPath())); } @Test diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java index d52f8c07e53..aab0f42e482 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import java.util.List; import java.util.Map; @@ -72,8 +71,8 @@ public void bootstrapMultiMount() throws CommitFailedException { nodeStoreLibs.merge(libsRoot, EmptyHook.INSTANCE, CommitInfo.EMPTY); // Define read-only mounts - registerActivateMountInfoConfig("libs", ImmutableList.of("/libs")); - registerActivateMountInfoConfig("apps", ImmutableList.of("/apps")); + registerActivateMountInfoConfig("libs", List.of("/libs")); + registerActivateMountInfoConfig("apps", List.of("/apps")); registerMountInfoProviderService("libs", "apps"); diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/BackwardCompatibleMountCompositeIT.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/BackwardCompatibleMountCompositeIT.java index 86255e79eba..9d501f89bc9 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/BackwardCompatibleMountCompositeIT.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/BackwardCompatibleMountCompositeIT.java @@ -18,12 +18,11 @@ */ package org.apache.jackrabbit.oak.composite.it; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Set; import javax.inject.Inject; - -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.junit.Test; @@ -68,7 +67,7 @@ public void compositeNodeStoreCreatedFromDeprecatedConfiguration() { NodeState root = store.getRoot(); Set expectedNodes = Set.of("content", "apps", "libs"); - Set actualNodes = CollectionUtils.toSet(root.getChildNodeNames()); + Set actualNodes = ImmutableSet.copyOf(root.getChildNodeNames()); assertTrue("Expected nodes " + expectedNodes + ", but was " + actualNodes, actualNodes.containsAll(expectedNodes)); assertTrue("'libs' path should be mounted", root.getChildNode("libs").getChildNode("libsMount").exists()); diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/MultiMountCompositeIT.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/MultiMountCompositeIT.java index 947ffff8121..e2d65446e13 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/MultiMountCompositeIT.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/MultiMountCompositeIT.java @@ -18,12 +18,11 @@ */ package org.apache.jackrabbit.oak.composite.it; +import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Set; import javax.inject.Inject; - -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.junit.Test; @@ -65,7 +64,7 @@ public void compositeNodeStoreWithMultipleReadOnlyMounts() { NodeState root = store.getRoot(); Set expectedNodes = Set.of("content", "apps", "libs"); - Set actualNodes = CollectionUtils.toSet(root.getChildNodeNames()); + Set actualNodes = ImmutableSet.copyOf(root.getChildNodeNames()); assertTrue("Expected nodes " + expectedNodes + ", but was " + actualNodes, actualNodes.containsAll(expectedNodes)); assertTrue("'apps' mount should be mounted", root.getChildNode("apps").getChildNode("appsMount").exists()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java index 55731e41abc..3d16e380f65 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document; import java.util.ArrayList; @@ -24,10 +23,10 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import com.mongodb.ReadPreference; import org.apache.jackrabbit.oak.api.Blob; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.blob.ReferencedBlob; import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats; import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils; @@ -133,7 +132,7 @@ public void testBlobIterator() throws Exception { store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); } - List collectedBlobs = ImmutableList.copyOf(store.getReferencedBlobsIterator()); + List collectedBlobs = CollectionUtils.toList(store.getReferencedBlobsIterator()); assertEquals(blobs.size(), collectedBlobs.size()); assertEquals(new HashSet<>(blobs), new HashSet<>(collectedBlobs)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java index fefae7a7615..3fc45f2b934 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java @@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.jackrabbit.oak.api.CommitFailedException; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.apache.jackrabbit.oak.spi.commit.Observer; @@ -41,6 +40,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.jackrabbit.guava.common.collect.Sets.union; import static java.util.Collections.synchronizedList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -229,7 +229,7 @@ public RevisionVector getHeadRevision() { Thread t = new Thread(new Runnable() { @Override public void run() { - queue.suspendUntilAll(CollectionUtils.union(Set.of(newHeadRev), revisions)); + queue.suspendUntilAll(union(Set.of(newHeadRev), revisions)); } }); t.start(); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java index 7dafb539bb3..9a95ae55416 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.document; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.util.Collections.emptyList; import static java.util.Collections.synchronizedList; import static java.util.concurrent.TimeUnit.SECONDS; @@ -3920,28 +3919,28 @@ public void getChildNodeCountTest() throws Exception { final long UL = Long.MAX_VALUE; // unknown // childNodeCount = none getChildNodeCountTest(0, - of(0L, 1L), - of(0L, 0L) + List.of(0L, 1L), + List.of(0L, 0L) ); // childNodeCount = less than initial fetch size 42 getChildNodeCountTest(42, - of( 0L, 1L, 41L, 42L, 43L, 100L), - of(42L, 42L, 42L, 42L, 42L, 42L) + List.of( 0L, 1L, 41L, 42L, 43L, 100L), + List.of(42L, 42L, 42L, 42L, 42L, 42L) ); // childNodeCount = initial fetch size (100) getChildNodeCountTest(100, - of( 0L, 1L, 99L, 100L, 101L, 200L), - of(100L, 100L, 100L, 100L, 100L, 100L) + List.of( 0L, 1L, 99L, 100L, 101L, 200L), + List.of(100L, 100L, 100L, 100L, 100L, 100L) ); // childNodeCount = initial fetch size + 1 (100 + 1) getChildNodeCountTest(101, - of(0L, 1L, 99L, 100L, 101L, 200L), - of(UL, UL, UL, UL, 101L, 101L) + List.of(0L, 1L, 99L, 100L, 101L, 200L), + List.of(UL, UL, UL, UL, 101L, 101L) ); // childNodeCount = first two fetches (100 + 200) getChildNodeCountTest(300, - of(0L, 1L, 99L, 100L, 101L, 200L, 299L, 300L, 301L, 400L), - of(UL, UL, UL, UL, 300L, 300L, 300L, 300L, 300L, 300L) + List.of(0L, 1L, 99L, 100L, 101L, 200L, 299L, 300L, 301L, 400L), + List.of(UL, UL, UL, UL, 300L, 300L, 300L, 300L, 300L, 300L) ); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java index 8b8e72b5da0..9cfe93c690c 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java @@ -26,7 +26,6 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -49,7 +48,6 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.MongoBlobGCTest.randomStream; import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.DOC_SIZE_THRESHOLD; @@ -353,7 +351,7 @@ public void testSplitDocNoChild() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_LEAF, prevDocs.get(0).getSplitDocType()); } @@ -376,7 +374,7 @@ public void testSplitPropAndCommitOnly() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.COMMIT_ROOT_ONLY, prevDocs.get(0).getSplitDocType()); } @@ -398,7 +396,7 @@ public void splitDocWithHasBinary() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); //Check for hasBinary @@ -451,7 +449,7 @@ private void cascadingSplit(String path) { assertNotNull(doc); assertEquals(2, doc.getPreviousRanges().size()); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); //1 intermediate and 11 previous doc assertEquals(1 + 11, prevDocs.size()); assertTrue(prevDocs.stream().anyMatch(input -> input.getSplitDocType() == SplitDocType.INTERMEDIATE)); @@ -916,7 +914,7 @@ public void splitDocumentWithBinary() throws Exception { NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); // all but most recent value are moved to individual previous docs assertEquals(9, prevDocs.size()); } @@ -950,7 +948,7 @@ public void noBinarySplitWhenRemoved() throws Exception { // now the old binary value must be moved to a previous document foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); } @@ -973,7 +971,7 @@ public void noSplitForSmallBinary() throws Exception { NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); // must not create split documents for small binaries less 4k assertEquals(0, prevDocs.size()); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java index 8a3071fbd4d..6a7ad6ce40e 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document; import java.lang.management.ManagementFactory; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -35,7 +35,6 @@ import org.junit.Test; import org.slf4j.LoggerFactory; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.DocumentStoreStats.JOURNAL_CREATE; @@ -116,11 +115,11 @@ public void doneQuery_Journal() throws Exception{ @Test public void doneCreate_Journal() throws Exception{ - stats.doneCreate(100, Collection.JOURNAL, of("a", "b"), true); + stats.doneCreate(100, Collection.JOURNAL, List.of("a", "b"), true); assertEquals(2, getMeter(DocumentStoreStats.JOURNAL_CREATE).getCount()); assertEquals(100, getTimer(DocumentStoreStats.JOURNAL_CREATE_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, JOURNAL, of("c", "d"), false); + stats.doneCreate(100, JOURNAL, List.of("c", "d"), false); assertEquals(4, getMeter(JOURNAL_CREATE).getCount()); assertEquals(100, getTimer(JOURNAL_CREATE_TIMER).getSnapshot().getMax()); } @@ -129,24 +128,24 @@ public void doneCreate_Journal() throws Exception{ public void doneCreate_Nodes() { // empty list of ids - stats.doneCreate(100, NODES, of(), true); + stats.doneCreate(100, NODES, List.of(), true); assertEquals(0, getMeter(NODES_CREATE).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(0, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, NODES, of("a", "b"), true); + stats.doneCreate(100, NODES, List.of("a", "b"), true); assertEquals(2, getMeter(NODES_CREATE).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(50, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); // adding an Id with previous doc - stats.doneCreate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); + stats.doneCreate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); assertEquals(3, getMeter(NODES_CREATE).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); // if insert is not successful - stats.doneCreate(200, NODES, of("c"), false); + stats.doneCreate(200, NODES, List.of("c"), false); assertEquals(3, getMeter(NODES_CREATE).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); @@ -160,24 +159,24 @@ public void doneCreate_Nodes() { public void doneCreateOrUpdate() { // empty list of ids - stats.doneCreateOrUpdate(100, NODES, of()); + stats.doneCreateOrUpdate(100, NODES, List.of()); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); - stats.doneCreateOrUpdate(100, NODES, of("a", "b")); + stats.doneCreateOrUpdate(100, NODES, List.of("a", "b")); assertEquals(2, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(50, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreateOrUpdate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); + stats.doneCreateOrUpdate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); assertEquals(3, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); // insert is done for journal collection - stats.doneCreateOrUpdate(200, JOURNAL, of("c")); + stats.doneCreateOrUpdate(200, JOURNAL, List.of("c")); assertEquals(3, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); @@ -199,21 +198,21 @@ public void doneFindAndModify() throws Exception{ public void doneBulkFindAndModify() { // no node had been updated i.e. empty list of Ids - stats.doneFindAndModify(100, NODES, of(), true, 0); + stats.doneFindAndModify(100, NODES, List.of(), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(0, getMeter(NODES_UPDATE).getCount()); assertEquals(0, getTimer(NODES_UPDATE_TIMER).getSnapshot().getMax()); // 2 nodes had been updated - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); assertEquals(50, getTimer(NODES_UPDATE_TIMER).getSnapshot().getMax()); // fails to update 2 nodes without retrying - stats.doneFindAndModify(100, NODES, of("foo", "bar"), false, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), false, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); @@ -222,7 +221,7 @@ public void doneBulkFindAndModify() { assertEquals(1, getMeter(NODES_UPDATE_FAILURE).getCount()); // update is done on Journal collection - stats.doneFindAndModify(100, JOURNAL, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, JOURNAL, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java index dcf2ea492ed..e94038e9344 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java @@ -19,8 +19,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.junit.Test; @@ -102,7 +100,7 @@ public void writeTo() throws Exception { // must not write dummy version assertFalse(V0.writeTo(store)); // upgrade - for (FormatVersion v : ImmutableList.of(V1_0, V1_2, V1_4, V1_6, V1_8)) { + for (FormatVersion v : List.of(V1_0, V1_2, V1_4, V1_6, V1_8)) { assertTrue(v.writeTo(store)); assertSame(v, FormatVersion.versionOf(store)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java index 274769ecffe..b5fbbea014c 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java @@ -36,8 +36,6 @@ import org.apache.jackrabbit.guava.common.base.Splitter; import org.apache.jackrabbit.guava.common.base.Stopwatch; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.guava.common.io.Closeables; import com.mongodb.BasicDBObject; @@ -320,8 +318,8 @@ public void consistencyCheckWithRenegadeDelete() throws Exception { GarbageCollectableBlobStore store = (GarbageCollectableBlobStore) mk.getNodeStore().getBlobStore(); - long count = store.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0); - + long count = store.countDeleteChunks(List.of(existing.get(rand.nextInt(existing.size()))), 0); + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); MarkSweepGarbageCollector gcObj = init(86400, executor); long candidates = gcObj.checkConsistency(); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java index 4fe695ef11e..0c8542556fc 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java @@ -29,6 +29,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; +import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors; import org.apache.jackrabbit.core.data.DataStore; @@ -127,7 +128,7 @@ public void testGC() throws Exception { cluster1.gc.collectGarbage(false); assertTrue(Sets.symmetricDifference( - CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), + Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), cluster1.getExistingBlobIds()).isEmpty()); } @@ -144,7 +145,7 @@ public void testGCWithNodeSpecialChars() throws Exception { cluster1.gc.collectGarbage(false); assertTrue(Sets.symmetricDifference( - CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), + Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), cluster1.getExistingBlobIds()).isEmpty()); } @@ -210,7 +211,7 @@ public void testRepeatedMarkWithSweep() throws Exception { cluster2.gc.collectGarbage(false); assertTrue(Sets.symmetricDifference( - CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), + Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()), cluster1.getExistingBlobIds()).isEmpty()); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java index 6bd4c02838d..ea7a75b17d6 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java @@ -25,9 +25,9 @@ import org.junit.After; import org.junit.Test; +import java.util.List; import java.util.concurrent.ScheduledExecutorService; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.lang.management.ManagementFactory.getPlatformMBeanServer; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; @@ -65,16 +65,16 @@ public void shutDown(){ @Test public void doneCreateJournal() { - stats.doneCreate(100, JOURNAL, of("a", "b"), true); + stats.doneCreate(100, JOURNAL, List.of("a", "b"), true); assertEquals(2, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(100, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreate(200, JOURNAL, of("c", "d"), true); + stats.doneCreate(200, JOURNAL, List.of("c", "d"), true); assertEquals(4, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(200, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // journal metrics updated even if insert is not successful - stats.doneCreate(200, JOURNAL, of("e", "f"), false); + stats.doneCreate(200, JOURNAL, List.of("e", "f"), false); assertEquals(6, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(200, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); @@ -88,24 +88,24 @@ public void doneCreateJournal() { public void doneCreateNodes() { // empty list of ids - stats.doneCreate(100, NODES, of(), true); + stats.doneCreate(100, NODES, List.of(), true); assertEquals(0, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, NODES, of("a", "b"), true); + stats.doneCreate(100, NODES, List.of("a", "b"), true); assertEquals(2, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); + stats.doneCreate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); assertEquals(3, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // insert is not successful - stats.doneCreate(200, NODES, of("c"), false); + stats.doneCreate(200, NODES, List.of("c"), false); assertEquals(3, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); @@ -119,24 +119,24 @@ public void doneCreateNodes() { public void doneCreateOrUpdate() { // empty list of ids - stats.doneCreateOrUpdate(100, NODES, of()); + stats.doneCreateOrUpdate(100, NODES, List.of()); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreateOrUpdate(100, NODES, of("a", "b")); + stats.doneCreateOrUpdate(100, NODES, List.of("a", "b")); assertEquals(2, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreateOrUpdate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); + stats.doneCreateOrUpdate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); assertEquals(3, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); // insert is done for journal collection - stats.doneCreateOrUpdate(200, JOURNAL, of("c")); + stats.doneCreateOrUpdate(200, JOURNAL, List.of("c")); assertEquals(3, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); @@ -178,7 +178,7 @@ public void doneFindAndModify() { public void doneBulkFindAndModify() { // no node had been updated i.e. empty list of Ids - stats.doneFindAndModify(100, NODES, of(), true, 0); + stats.doneFindAndModify(100, NODES, List.of(), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(0, getMeter(NODES_UPDATE_THROTTLING).getCount()); @@ -186,14 +186,14 @@ public void doneBulkFindAndModify() { assertEquals(0, getMeter(NODES_UPDATE_RETRY_COUNT_THROTTLING).getCount()); // 2 nodes had been updated - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_UPDATE_THROTTLING_TIMER).getSnapshot().getMax()); // fails to update 2 nodes without retrying - stats.doneFindAndModify(100, NODES, of("foo", "bar"), false, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), false, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE_THROTTLING).getCount()); @@ -202,14 +202,14 @@ public void doneBulkFindAndModify() { assertEquals(1, getMeter(NODES_UPDATE_FAILURE_THROTTLING).getCount()); // entry updated after 3 retries - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 3); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 3); assertEquals(4, getMeter(NODES_UPDATE_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_UPDATE_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(3, getMeter(NODES_UPDATE_RETRY_COUNT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_UPDATE_FAILURE_THROTTLING).getCount()); // update is done on Journal collection - stats.doneFindAndModify(100, JOURNAL, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, JOURNAL, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(4, getMeter(NODES_UPDATE_THROTTLING).getCount()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java index 9fc0a3a8c63..a6f1020b67b 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java @@ -103,9 +103,7 @@ import org.apache.jackrabbit.guava.common.cache.Cache; import org.apache.jackrabbit.guava.common.collect.AbstractIterator; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Queues; import com.mongodb.ReadPreference; @@ -3070,11 +3068,11 @@ private void gcSplitDocsInternal(String subNodeName) throws Exception { store1.runBackgroundOperations(); List previousDocTestFoo = - ImmutableList.copyOf(getDoc("/test/" + subNodeName).getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/test/" + subNodeName).getAllPreviousDocs()); List previousDocTestFoo2 = - ImmutableList.copyOf(getDoc("/test2/" + subNodeName).getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/test2/" + subNodeName).getAllPreviousDocs()); List previousDocRoot = - ImmutableList.copyOf(getDoc("/").getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/").getAllPreviousDocs()); assertEquals(1, previousDocTestFoo.size()); assertEquals(1, previousDocTestFoo2.size()); @@ -3096,7 +3094,7 @@ private void gcSplitDocsInternal(String subNodeName) throws Exception { //Following would not work for Mongo as the delete happened on the server side //And entries from cache are not evicted - //assertTrue(ImmutableList.copyOf(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty()); + //assertTrue(List.copyOf(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty()); } /** @@ -3813,7 +3811,7 @@ public void gcDefaultNoBranchSplitDoc() throws Exception { NodeDocument doc = getDoc("/foo"); assertNotNull(doc); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType()); @@ -3824,7 +3822,7 @@ public void gcDefaultNoBranchSplitDoc() throws Exception { doc = getDoc("/foo"); assertNotNull(doc); - prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(0, prevDocs.size()); assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop")); @@ -3851,7 +3849,7 @@ public void gcWithOldSweepRev() throws Exception { // now /foo must have previous docs NodeDocument doc = getDoc("/foo"); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType()); @@ -3877,7 +3875,7 @@ public void gcWithOldSweepRev() throws Exception { doc = getDoc("/foo"); assertNotNull(doc); - prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(0, prevDocs.size()); // check value assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop")); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java index 06dd7dcec38..9dc5f19cf25 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java @@ -47,9 +47,6 @@ import org.slf4j.LoggerFactory; import org.slf4j.event.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; - /** * Tests the RDBBlobStore implementation. */ @@ -199,7 +196,7 @@ public void testUpdateAndDelete() throws Exception { RDBBlobStoreFriend.storeBlock(blobStore, digest, 0, data); // Metadata row should not have been touched Assert.assertFalse("entry was cleaned although it shouldn't have", - blobStore.deleteChunks(ImmutableList.of(id), beforeUpdateTs)); + blobStore.deleteChunks(List.of(id), beforeUpdateTs)); // Actual data row should still be present Assert.assertNotNull(RDBBlobStoreFriend.readBlockFromBackend(blobStore, digest)); } @@ -228,7 +225,7 @@ public void testDeleteChunks() throws Exception { byte[] digest2 = getDigest(data2); RDBBlobStoreFriend.storeBlock(blobStore, digest2, 0, data2); - Assert.assertEquals("meta entry was not removed", 1, blobStore.countDeleteChunks(ImmutableList.of(id1), now)); + Assert.assertEquals("meta entry was not removed", 1, blobStore.countDeleteChunks(List.of(id1), now)); Assert.assertFalse("data entry was not removed", RDBBlobStoreFriend.isDataEntryPresent(blobStore, digest1)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java index a833ad94cb3..e1a56780172 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java @@ -20,7 +20,7 @@ package org.apache.jackrabbit.oak.plugins.document.bundlor; import java.util.Collections; - +import java.util.List; import org.apache.jackrabbit.guava.common.collect.ArrayListMultimap; import org.apache.jackrabbit.guava.common.collect.ListMultimap; @@ -47,7 +47,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.SYS_PROP_DISABLE_JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.TestUtils.childBuilder; import static org.apache.jackrabbit.oak.plugins.document.TestUtils.createChild; @@ -185,7 +184,7 @@ public void diffFewChildren() throws Exception{ @Test public void jsopDiff() throws Exception{ JsopWriter w = new JsopBuilder(); - differ.diffChildren(of("a", "b"), of("b", "c"), w); + differ.diffChildren(List.of("a", "b"), List.of("b", "c"), w); //removed a //changed b @@ -246,7 +245,7 @@ private AbstractDocumentNodeState adns(NodeState root, String path){ } private SecondaryStoreCache configureSecondary(){ - SecondaryStoreBuilder builder = createBuilder(new PathFilter(of("/"), Collections.emptyList())); + SecondaryStoreBuilder builder = createBuilder(new PathFilter(List.of("/"), Collections.emptyList())); builder.metaPropNames(DocumentNodeStore.META_PROP_NAMES); SecondaryStoreCache cache = builder.buildCache(); SecondaryStoreObserver observer = builder.buildObserver(cache); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java index 9e0f958c535..63ab8c5e904 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java @@ -26,13 +26,13 @@ import java.util.Set; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.document.Collection; import org.apache.jackrabbit.oak.plugins.document.Document; import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider; @@ -67,7 +67,6 @@ import static java.lang.String.format; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.commons.io.FileUtils.ONE_MB; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.commons.PathUtils.concat; @@ -1047,7 +1046,7 @@ private static void dump(NodeState state){ } private static List childNames(NodeState state, String path){ - return copyOf(getNode(state, path).getChildNodeNames()); + return CollectionUtils.toList(getNode(state, path).getChildNodeNames()); } static NodeBuilder newNode(String typeName){ diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java index 4e855dc26a3..7c0ee5eb1f4 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document.secondary; import java.io.IOException; @@ -51,7 +50,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreObserverTest.create; import static org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreObserverTest.documentState; @@ -78,7 +76,7 @@ public void setUp() throws IOException { @Test public void basicTest() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c", "/x/y/z"); @@ -92,7 +90,7 @@ public void basicTest() throws Exception{ @Test public void updateAndReadAtReadRev() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c", "/x/y/z"); @@ -130,7 +128,7 @@ public void updateAndReadAtReadRev() throws Exception{ @Test public void updateAndReadAtPrevRevision() throws Exception { - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c"); @@ -154,7 +152,7 @@ public void updateAndReadAtPrevRevision() throws Exception { @Test public void binarySearch() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); List roots = new ArrayList<>(); List revs = new ArrayList<>(); @@ -185,7 +183,7 @@ public void binarySearch() throws Exception{ @Test public void readWithSecondaryLagging() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreCache cache = createBuilder(pathFilter).buildCache(); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(cache); @@ -220,7 +218,7 @@ public void readWithSecondaryLagging() throws Exception{ @Test public void isCached() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); assertTrue(cache.isCached(Path.fromString("/a"))); assertTrue(cache.isCached(Path.fromString("/a/b"))); @@ -229,7 +227,7 @@ public void isCached() throws Exception{ @Test public void bundledNodes() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/"), empty)); primary.setNodeStateCache(cache); NodeBuilder builder = primary.getRoot().builder(); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java index dee3e0b948b..14762e9912f 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document.secondary; import java.io.IOException; @@ -40,7 +39,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -61,7 +59,7 @@ public void setUp() throws IOException { @Test public void basicSetup() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -77,7 +75,7 @@ public void basicSetup() throws Exception{ @Test public void childNodeAdded() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -95,7 +93,7 @@ public void childNodeAdded() throws Exception{ @Test public void childNodeChangedAndExclude() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), of("/a/b")); + PathFilter pathFilter = new PathFilter(List.of("/a"), List.of("/a/b")); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -112,7 +110,7 @@ public void childNodeChangedAndExclude() throws Exception{ @Test public void childNodeDeleted() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java index c3c3985cd1c..c302b002c21 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java @@ -20,14 +20,13 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Timer; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; import org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider; import org.junit.After; +import java.util.List; import java.util.concurrent.ScheduledExecutorService; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.lang.management.ManagementFactory.getPlatformMBeanServer; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; @@ -61,7 +60,7 @@ public abstract class BaseUpdaterTest { static final String NODES_REMOVE_THROTTLING_TIMER = "NODES_REMOVE_THROTTLING_TIMER"; final ScheduledExecutorService executor = newSingleThreadScheduledExecutor(); final MetricStatisticsProvider provider = new MetricStatisticsProvider(getPlatformMBeanServer(), executor); - final ImmutableList ids = of("a", "b"); + final List ids = List.of("a", "b"); Meter getMeter(String name) { return provider.getRegistry().getMeters().get(name); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java index d15c3d01a0a..c04742ae511 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java @@ -20,7 +20,8 @@ import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; +import java.util.List; + import static org.apache.jackrabbit.oak.plugins.document.Collection.BLOBS; import static org.apache.jackrabbit.oak.plugins.document.Collection.CLUSTER_NODES; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; @@ -84,10 +85,10 @@ public void updateNodes() { @Test public void updateNodesWithPreviousDocId() { - cMUWithoutThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(1, 1, 100); - cMUWithThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithThrottling(1, 1, 100); } @@ -99,17 +100,17 @@ public void updateNodesNotSuccessfully() { @Test public void updateNodesEmptyList() { - cMUWithoutThrottling.update(NODES, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(NODES, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(0, 0, 0); } @Test public void updateNonNodesJournalCollection() { - cMUWithoutThrottling.update(BLOBS, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(BLOBS, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(0, 0, 0); assertJournalWithoutThrottling(0, 0); - cMUWithThrottling.update(CLUSTER_NODES, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(CLUSTER_NODES, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithThrottling(0, 0, 0); assertJournalWithThrottling(0, 0); } @@ -134,10 +135,10 @@ public void updateWithJournalNotSuccessfully() { @Test public void updateWithJournalEmptyList() { - cMUWithThrottling.update(JOURNAL, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(JOURNAL, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertJournalWithThrottling(0, 100); - cMUWithoutThrottling.update(JOURNAL, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(JOURNAL, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertJournalWithoutThrottling(0, 100); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java index 18b5ff9431a..58dc36c5bd7 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java @@ -18,7 +18,8 @@ import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; +import java.util.List; + import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.util.StatsCollectorUtil.getCreateStatsConsumer; @@ -54,31 +55,31 @@ public void updateWithNullStatsConsumer() { @Test public void updateNodesEmptyList() { - uMUWithoutThrottling.update(NODES, 100, of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(0, 0, 0); } @Test public void updateNonNodesCollection() { - uMUWithThrottling.update(JOURNAL, 100, of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(JOURNAL, 100, List.of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(0, 0, 0); } @Test public void updateNodes() { - uMUWithThrottling.update(NODES, 100, of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(NODES, 100, List.of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(2, 0, 50); - uMUWithoutThrottling.update(NODES, 100, of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(2, 0, 50); } @Test public void updateNodesWithPreviousDocId() { - uMUWithThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(1, 1, 100); - uMUWithoutThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(1, 1, 100); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java index 36fc0143ae9..5e2e671fb50 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java @@ -22,7 +22,6 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.commons.codec.binary.Hex; @@ -443,34 +442,34 @@ public void getAllDocuments() throws CommitFailedException { @Test public void getMaxExternalRevisionTime() { int localClusterId = 1; - List revs = ImmutableList.of(); + List revs = Collections.emptyList(); long revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(Long.MIN_VALUE, revTime); - revs = ImmutableList.of(Revision.fromString("r1-0-1")); + revs = List.of(Revision.fromString("r1-0-1")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(Long.MIN_VALUE, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r2-0-2")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r3-0-1"), Revision.fromString("r2-0-2")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r2-0-2"), Revision.fromString("r2-0-3")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r3-0-2"), Revision.fromString("r2-0-3")); diff --git a/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java b/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java index d90dca96b5b..e4d649c0184 100644 --- a/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java +++ b/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java @@ -24,9 +24,9 @@ import static org.junit.Assert.fail; import java.util.Collection; +import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.AbstractNodeState; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -57,7 +57,7 @@ public static Collection fixtures() { builder.child("y"); builder.child("z"); NodeState base = builder.getNodeState(); - return ImmutableList.of( + return List.of( new Object[] { base }, new Object[] { ModifiedNodeState.squeeze(base) } ); diff --git a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java index cc7fd536843..dbe7f4bbb75 100644 --- a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java +++ b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java @@ -30,7 +30,6 @@ import javax.jcr.Session; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.JackrabbitWorkspace; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -187,7 +186,7 @@ public void verifyCustomPrivileges() throws Exception { assertNotNull(aggregate); assertFalse(aggregate.isAbstract()); assertTrue(aggregate.isAggregate()); - List agg = ImmutableList.copyOf(aggregate.getDeclaredAggregatePrivileges()); + List agg = List.of(aggregate.getDeclaredAggregatePrivileges()); assertEquals(2, agg.size()); assertTrue(agg.contains(privilege)); assertTrue(agg.contains(manager.getPrivilege(JCR_READ))); @@ -196,7 +195,7 @@ public void verifyCustomPrivileges() throws Exception { assertNotNull(aggregate2); assertTrue(aggregate2.isAbstract()); assertTrue(aggregate2.isAggregate()); - List agg2 = ImmutableList.copyOf(aggregate2.getDeclaredAggregatePrivileges()); + List agg2 = List.of(aggregate2.getDeclaredAggregatePrivileges()); assertEquals(2, agg2.size()); assertTrue(agg2.contains(aggregate)); assertTrue(agg2.contains(privilege2)); diff --git a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java index 6b4a6c4b4b6..d728fc8fd74 100644 --- a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java +++ b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java @@ -27,7 +27,6 @@ import javax.jcr.version.VersionIterator; import javax.jcr.version.VersionManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.migration.version.VersionCopyConfiguration; @@ -37,7 +36,7 @@ public class VersionCopyTestUtils { - public static List LABELS = ImmutableList.of("1.0", "1.1", "1.2"); + public static List LABELS = List.of("1.0", "1.1", "1.2"); public static Node getOrAddNode(Node parent, String relPath) throws RepositoryException { Node currentParent = parent;