sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject [sling-org-apache-sling-resourceresolver] branch master updated: SLING-7537 : Provide a way to get the search paths without login into a resource resolver
Date Thu, 08 Mar 2018 13:20:30 GMT
This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 97d21b7  SLING-7537 : Provide a way to get the search paths without login into a
resource resolver
97d21b7 is described below

commit 97d21b7997c541f0407f6f89368f1fa106b5fdc6
Author: Carsten Ziegeler <cziegele@adobe.com>
AuthorDate: Thu Mar 8 14:20:24 2018 +0100

    SLING-7537 : Provide a way to get the search paths without login into a resource resolver
---
 pom.xml                                            |  2 +-
 .../impl/CommonResourceResolverFactoryImpl.java    |  3 +-
 .../impl/ResourceResolverFactoryActivator.java     | 25 +++++++++--------
 .../impl/ResourceResolverFactoryImpl.java          | 17 +++++++++---
 .../impl/ResourceResolverImpl.java                 | 31 +++++++++++----------
 .../resourceresolver/impl/ResourceTypeUtil.java    | 14 ++++++----
 .../impl/observation/BasicObservationReporter.java |  8 +++---
 .../impl/observation/ResourceChangeListImpl.java   |  6 ++--
 .../observation/ResourceChangeListenerInfo.java    | 11 ++++----
 .../ResourceChangeListenerWhiteboard.java          |  4 +--
 .../impl/ResourceResolverImplTest.java             | 32 +++++++++++-----------
 .../impl/ResourceTypeUtilTest.java                 | 28 +++++++++++--------
 .../observation/BasicObservationReporterTest.java  | 23 ++++++++--------
 .../ResourceChangeListenerInfoTest.java            | 10 +++++--
 14 files changed, 122 insertions(+), 92 deletions(-)

diff --git a/pom.xml b/pom.xml
index adc9a86..7275590 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,7 +103,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.16.2</version>
+            <version>2.16.5-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
index 92f44b4..8cef27d 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
@@ -343,7 +343,8 @@ public class CommonResourceResolverFactoryImpl implements ResourceResolverFactor
         return this.activator.getResourceDecoratorTracker();
     }
 
-    public String[] getSearchPath() {
+    @Override
+    public List<String> getSearchPath() {
         return this.activator.getSearchPath();
     }
 
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
index 12aa1c5..5984363 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
@@ -97,7 +97,7 @@ public class ResourceResolverFactoryActivator {
     private volatile BidiMap virtualURLMap;
 
     /** the search path for ResourceResolver.getResource(String) */
-    private volatile String[] searchPath;
+    private volatile List<String> searchPath = Collections.emptyList();
 
     /** the root location of the /etc/map entries */
     private volatile String mapRoot;
@@ -167,7 +167,7 @@ public class ResourceResolverFactoryActivator {
         return mappings;
     }
 
-    public String[] getSearchPath() {
+    public List<String> getSearchPath() {
         return searchPath;
     }
 
@@ -267,22 +267,25 @@ public class ResourceResolverFactoryActivator {
         }
 
         // from configuration if available
-        searchPath = config.resource_resolver_searchpath();
-        if (searchPath != null && searchPath.length > 0) {
-            for (int i = 0; i < searchPath.length; i++) {
+        final List<String> searchPathList = new ArrayList<>();
+        if (config.resource_resolver_searchpath() != null && config.resource_resolver_searchpath().length
> 0) {
+            for(String path : config.resource_resolver_searchpath()) {
                 // ensure leading slash
-                if (!searchPath[i].startsWith("/")) {
-                    searchPath[i] = "/" + searchPath[i];
+                if (!path.startsWith("/")) {
+                    path = "/".concat(path);
                 }
                 // ensure trailing slash
-                if (!searchPath[i].endsWith("/")) {
-                    searchPath[i] += "/";
+                if (!path.endsWith("/")) {
+                    path = path.concat("/");
                 }
+                searchPathList.add(path);
             }
         }
-        if (searchPath == null) {
-            searchPath = new String[] { "/" };
+        if (searchPathList.isEmpty()) {
+            searchPathList.add("/");
         }
+        this.searchPath = Collections.unmodifiableList(searchPathList);
+
         // the root of the resolver mappings
         mapRoot = config.resource_resolver_map_location();
         mapRootPrefix = mapRoot + '/';
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
index b325563..f0f466c 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
@@ -19,6 +19,7 @@
 package org.apache.sling.resourceresolver.impl;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.sling.api.resource.LoginException;
@@ -63,7 +64,7 @@ public class ResourceResolverFactoryImpl implements ResourceResolverFactory
{
     @Override
     public ResourceResolver getServiceResourceResolver(final Map<String, Object> passedAuthenticationInfo)
throws LoginException {
         // create a copy of the passed authentication info as we modify the map
-        final Map<String, Object> authenticationInfo = new HashMap<String, Object>();
+        final Map<String, Object> authenticationInfo = new HashMap<>();
         final String subServiceName;
         if ( passedAuthenticationInfo != null ) {
             authenticationInfo.putAll(passedAuthenticationInfo);
@@ -112,11 +113,11 @@ public class ResourceResolverFactoryImpl implements ResourceResolverFactory
{
     public ResourceResolver getAdministrativeResourceResolver(
             Map<String, Object> authenticationInfo) throws LoginException {
         // usingBundle is required as bundles must now be whitelisted to use this method
-        if(usingBundle == null) {
+        if (usingBundle == null) {
             throw new LoginException("usingBundle is null");
         }
-        if(authenticationInfo == null) {
-            authenticationInfo = new HashMap<String, Object>();
+        if (authenticationInfo == null) {
+            authenticationInfo = new HashMap<>();
         }
         authenticationInfo.put(ResourceProvider.AUTH_SERVICE_BUNDLE, this.usingBundle);
         return commonFactory.getAdministrativeResourceResolver(authenticationInfo);
@@ -129,4 +130,12 @@ public class ResourceResolverFactoryImpl implements ResourceResolverFactory
{
     public ResourceResolver getThreadResourceResolver() {
         return commonFactory.getThreadResourceResolver();
     }
+
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolverFactory#getSearchPath()
+     */
+    @Override
+    public List<String> getSearchPath() {
+        return commonFactory.getSearchPath();
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
index f2d2f0a..66eba96 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -355,10 +356,12 @@ public class ResourceResolverImpl extends SlingAdaptable implements
ResourceReso
 
                 } else {
 
-                    final String[] searchPath = getSearchPath();
-                    for (int spi = 0; res == null && spi < searchPath.length;
spi++) {
-                        logger.debug("resolve: Try relative mapped path with search path
entry {}", searchPath[spi]);
-                        res = resolveInternal(searchPath[spi] + realPath, parsedPath.getParameters());
+                    for(final String path : factory.getSearchPath()) {
+                        logger.debug("resolve: Try relative mapped path with search path
entry {}", path);
+                        res = resolveInternal(path + realPath, parsedPath.getParameters());
+                        if ( res != null ) {
+                            break;
+                        }
                     }
 
                 }
@@ -614,7 +617,8 @@ public class ResourceResolverImpl extends SlingAdaptable implements ResourceReso
     @Override
     public String[] getSearchPath() {
         checkClosed();
-        return factory.getSearchPath().clone();
+        final List<String> searchPath = factory.getSearchPath();
+        return searchPath.toArray(new String[searchPath.size()]);
     }
 
     // ---------- direct resource access without resolution
@@ -679,13 +683,10 @@ public class ResourceResolverImpl extends SlingAdaptable implements
ResourceReso
 
                 // otherwise we have to apply the search path
                 // (don't use this.getSearchPath() to save a few cycle for not cloning)
-                final String[] paths = factory.getSearchPath();
-                if (paths != null) {
-                    for (final String prefix : factory.getSearchPath()) {
-                        result = getResource(prefix + path);
-                        if (result != null) {
-                            break;
-                        }
+                for (final String prefix : factory.getSearchPath()) {
+                    result = getResource(prefix + path);
+                    if (result != null) {
+                        break;
                     }
                 }
             }
@@ -1094,7 +1095,7 @@ public class ResourceResolverImpl extends SlingAdaptable implements
ResourceReso
      */
     private String ensureAbsPath(String path) {
         if (!path.startsWith("/")) {
-            path = getSearchPath()[0] + path;
+            path = factory.getSearchPath().get(0) + path;
         }
         return path;
     }
@@ -1229,13 +1230,13 @@ public class ResourceResolverImpl extends SlingAdaptable implements
ResourceReso
              // Check if the resource is of the given type. This method first checks the
              // resource type of the resource, then its super resource type and continues
              //  to go up the resource super type hierarchy.
-             if (ResourceTypeUtil.areResourceTypesEqual(resourceType, resource.getResourceType(),
getSearchPath())) {
+             if (ResourceTypeUtil.areResourceTypesEqual(resourceType, resource.getResourceType(),
factory.getSearchPath())) {
                  result = true;
              } else {
                  Set<String> superTypesChecked = new HashSet<>();
                  String superType = this.getParentResourceType(resource);
                  while (!result && superType != null) {
-                     if (ResourceTypeUtil.areResourceTypesEqual(resourceType, superType,
getSearchPath())) {
+                     if (ResourceTypeUtil.areResourceTypesEqual(resourceType, superType,
factory.getSearchPath())) {
                          result = true;
                      } else {
                          superTypesChecked.add(superType);
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtil.java b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtil.java
index d069275..28d9ea9 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtil.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtil.java
@@ -18,8 +18,12 @@
  */
 package org.apache.sling.resourceresolver.impl;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
 
+import org.apache.sling.api.resource.ResourceResolver;
+
 /**
  * Some helper methods for doing comparisons on resource types.
  * This class is private the resource resolver bundle.
@@ -29,17 +33,17 @@ public class ResourceTypeUtil {
 
     /**
      * Returns <code>true</code> if the given resource type are equal.
-     * 
-     * In case the value of any of the given resource types 
+     *
+     * In case the value of any of the given resource types
      * starts with one of the resource resolver's search paths
-     * it is converted to a relative resource type by stripping off 
+     * it is converted to a relative resource type by stripping off
      * the resource resolver's search path before doing the comparison.
      *
      * @param resourceType A resource type
      * @param anotherResourceType Another resource type to compare with {@link resourceType}.
      * @return <code>true</code> if the resource type equals the given resource
type.
      */
-    public static boolean areResourceTypesEqual(@Nonnull String resourceType, @Nonnull String
anotherResourceType, @Nonnull String[] searchPath) {
+    public static boolean areResourceTypesEqual(@Nonnull String resourceType, @Nonnull String
anotherResourceType, @Nonnull List<String> searchPath) {
         return relativizeResourceType(resourceType, searchPath).equals(relativizeResourceType(anotherResourceType,
searchPath));
     }
 
@@ -50,7 +54,7 @@ public class ResourceTypeUtil {
      * @param searchPath the search paths to strip off from the given resource type.
      * @return the relative resource type
      */
-    public static String relativizeResourceType(@Nonnull String resourceType, @Nonnull String[]
searchPath) {
+    public static String relativizeResourceType(@Nonnull String resourceType, @Nonnull List<String>
searchPath) {
         if (resourceType.startsWith("/")) {
             for (String prefix : searchPath) {
                 if (resourceType.startsWith(prefix)) {
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java
b/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java
index 2a7334a..54b2e8c 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java
@@ -46,7 +46,7 @@ public class BasicObservationReporter implements ObservationReporter {
     private final List<ObserverConfiguration> configs;
 
     /** The search path. */
-    private final String[] searchPath;
+    private final List<String> searchPath;
 
     /**
      * Create a reporter listening for resource provider changes
@@ -55,10 +55,10 @@ public class BasicObservationReporter implements ObservationReporter {
      * @param infos The listeners map
      */
     public BasicObservationReporter(
-            final String[] searchPath,
+            final List<String> searchPath,
             final Collection<ResourceChangeListenerInfo> infos) {
         this.searchPath = searchPath;
-        final Set<String> paths = new HashSet<String>();
+        final Set<String> paths = new HashSet<>();
         final List<ResourceChangeListenerInfo> result = new ArrayList<>();
         for(final ResourceChangeListenerInfo info : infos) {
             if ( !info.getProviderChangeTypes().isEmpty() ) {
@@ -84,7 +84,7 @@ public class BasicObservationReporter implements ObservationReporter {
      * @param excludePaths Excluded paths for that provider
      */
     public BasicObservationReporter(
-            final String[] searchPath,
+            final List<String> searchPath,
             final Collection<ResourceChangeListenerInfo> infos,
             final Path providerPath,
             final PathSet excludePaths) {
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
index a128091..92d2780 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
@@ -29,13 +29,13 @@ import org.apache.sling.api.resource.observation.ResourceChangeList;
 
 public class ResourceChangeListImpl implements ResourceChangeList {
 
-    private final String[] searchPath;
+    private final List<String> searchPath;
 
     private boolean locked = false;
 
     private final ArrayList<ResourceChange> list = new ArrayList<>();
 
-    public ResourceChangeListImpl(final String[] searchPath) {
+    public ResourceChangeListImpl(final List<String> searchPath) {
         this.searchPath = searchPath;
     }
 
@@ -163,7 +163,7 @@ public class ResourceChangeListImpl implements ResourceChangeList {
 
     @Override
     public String[] getSearchPath() {
-        return this.searchPath.clone();
+        return this.searchPath.toArray(new String[this.searchPath.size()]);
     }
 
     @Override
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfo.java
b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfo.java
index 0d9eadb..70c7238 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfo.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfo.java
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -61,9 +62,9 @@ public class ResourceChangeListenerInfo implements Comparable<ResourceChangeList
 
     private volatile ResourceChangeListener listener;
 
-    public ResourceChangeListenerInfo(final ServiceReference<ResourceChangeListener>
ref, final String[] searchPaths) {
+    public ResourceChangeListenerInfo(final ServiceReference<ResourceChangeListener>
ref, final List<String> searchPaths) {
         boolean configValid = true;
-        final Set<String> pathsSet = new HashSet<String>();
+        final Set<String> pathsSet = new HashSet<>();
         final String paths[] = toStringArray(ref.getProperty(PATHS), null);
         if ( paths != null ) {
             for(final String p : paths) {
@@ -115,8 +116,8 @@ public class ResourceChangeListenerInfo implements Comparable<ResourceChangeList
         }
         this.paths = PathSet.fromStringCollection(pathsSet);
         if (ref.getProperty(CHANGES) != null ) {
-            final Set<ChangeType> rts = new HashSet<ChangeType>();
-            final Set<ChangeType> pts = new HashSet<ChangeType>();
+            final Set<ChangeType> rts = new HashSet<>();
+            final Set<ChangeType> pts = new HashSet<>();
             try {
                 for (final String changeName : toStringArray(ref.getProperty(CHANGES))) {
                     final ChangeType ct = ChangeType.valueOf(changeName);
@@ -151,7 +152,7 @@ public class ResourceChangeListenerInfo implements Comparable<ResourceChangeList
         }
 
         if ( ref.getProperty(ResourceChangeListener.PROPERTY_NAMES_HINT) != null ) {
-            this.propertyNamesHint = new HashSet<String>();
+            this.propertyNamesHint = new HashSet<>();
             for(final String val : PropertiesUtil.toStringArray(ref.getProperty(ResourceChangeListener.PROPERTY_NAMES_HINT))
) {
                 this.propertyNamesHint.add(val);
             }
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerWhiteboard.java
b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerWhiteboard.java
index 9c4b0c9..cb947aa 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerWhiteboard.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerWhiteboard.java
@@ -51,11 +51,11 @@ public class ResourceChangeListenerWhiteboard implements ResourceProviderTracker
 
     private volatile ServiceTracker<ResourceChangeListener, ServiceReference<ResourceChangeListener>>
tracker;
 
-    private volatile String[] searchPath;
+    private volatile List<String> searchPath;
 
     public void activate(final BundleContext bundleContext,
             final ResourceProviderTracker resourceProviderTracker,
-            final String[] searchPath) {
+            final List<String> searchPath) {
         this.searchPath = searchPath;
         this.resourceProviderTracker = resourceProviderTracker;
         this.resourceProviderTracker.setObservationReporterGenerator(this);
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
index 5d943ef..3eee2cf 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -408,7 +409,7 @@ public class ResourceResolverImplTest {
         anon1.close();
 
         // same workspace but admin user
-        final Map<String, Object> admin0Cred = new HashMap<String, Object>();
+        final Map<String, Object> admin0Cred = new HashMap<>();
         admin0Cred.put(ResourceResolverFactory.USER, "admin");
         admin0Cred.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
         final ResourceResolver admin0 = anon0.clone(admin0Cred);
@@ -429,7 +430,7 @@ public class ResourceResolverImplTest {
         admin1.close();
 
         // same workspace but anonymous user
-        final Map<String, Object> anon0Cred = new HashMap<String, Object>();
+        final Map<String, Object> anon0Cred = new HashMap<>();
         anon0Cred.put(ResourceResolverFactory.USER, "anonymous");
         final ResourceResolver anon0 = admin0.clone(anon0Cred);
         assertEquals("anonymous", anon0.getUserID());
@@ -439,7 +440,7 @@ public class ResourceResolverImplTest {
     }
 
     @Test public void test_attributes_from_authInfo() throws Exception {
-        final Map<String, Object> authInfo = new HashMap<String, Object>();
+        final Map<String, Object> authInfo = new HashMap<>();
         authInfo.put(ResourceResolverFactory.USER, "admin");
         authInfo.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
         authInfo.put("testAttributeString", "AStringValue");
@@ -451,7 +452,7 @@ public class ResourceResolverImplTest {
         assertEquals("admin", rr.getAttribute(ResourceResolverFactory.USER));
         assertNull(rr.getAttribute(ResourceResolverFactory.PASSWORD));
 
-        final HashSet<String> validNames = new HashSet<String>();
+        final HashSet<String> validNames = new HashSet<>();
         validNames.add(ResourceResolverFactory.USER);
         validNames.add("testAttributeString");
         validNames.add("testAttributeNumber");
@@ -635,7 +636,7 @@ public class ResourceResolverImplTest {
 
     private PathBasedResourceResolverImpl getPathBasedResourceResolver(String[] searchPaths)
{
         try {
-            final List<ResourceResolver> resolvers = new ArrayList<ResourceResolver>();
+            final List<ResourceResolver> resolvers = new ArrayList<>();
             final PathBasedResourceResolverImpl resolver = new PathBasedResourceResolverImpl(resolvers,
resourceProviderTracker, searchPaths);
             resolvers.add(resolver);
             return resolver;
@@ -647,10 +648,9 @@ public class ResourceResolverImplTest {
 
     private static class PathBasedResourceResolverImpl extends ResourceResolverImpl {
 
-        private final Map<String, Resource> resources = new HashMap<String, Resource>();
-        private final String[] searchPaths;
+        private final Map<String, Resource> resources = new HashMap<>();
 
-        public PathBasedResourceResolverImpl(final List<ResourceResolver> resolvers,
final ResourceProviderTracker resourceProviderTracker, String[] searchPaths) throws LoginException
{
+        public PathBasedResourceResolverImpl(final List<ResourceResolver> resolvers,
final ResourceProviderTracker resourceProviderTracker, final String[] searchPaths) throws
LoginException {
             this(new CommonResourceResolverFactoryImpl(new ResourceResolverFactoryActivator())
{
                 @Override
                 public ResourceResolver getAdministrativeResourceResolver(
@@ -662,12 +662,17 @@ public class ResourceResolverImplTest {
                         Map<String, Object> authenticationInfo) throws LoginException
{
                     return resolvers.get(0);
                 }
-            }, resourceProviderTracker, searchPaths);
+                @Override
+                public List<String> getSearchPath() {
+                    return Arrays.asList(searchPaths);
+                }
+
+
+            }, resourceProviderTracker);
         }
 
-        public PathBasedResourceResolverImpl(CommonResourceResolverFactoryImpl factory, ResourceProviderTracker
resourceProviderTracker, String[] searchPaths) throws LoginException {
+        public PathBasedResourceResolverImpl(CommonResourceResolverFactoryImpl factory, ResourceProviderTracker
resourceProviderTracker) throws LoginException {
             super(factory, false, null, resourceProviderTracker);
-            this.searchPaths = searchPaths;
         }
 
         public Resource add(final Resource r) {
@@ -676,11 +681,6 @@ public class ResourceResolverImplTest {
         }
 
         @Override
-        public String[] getSearchPath() {
-            return searchPaths;
-        }
-
-        @Override
         public Resource getResource(final String path) {
             final String p = (path.startsWith("/") ? path : "/" + path);
             return this.resources.get(p);
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtilTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtilTest.java
index 7fb8ba1..af553a1 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtilTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/ResourceTypeUtilTest.java
@@ -22,24 +22,30 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import org.junit.Test;
 
 public class ResourceTypeUtilTest {
 
+    private static final List<String> SEARCH_PATHS = Arrays.asList(new String[] { "/apps/",
"/libs/" });
+
     @Test public void testAreResourceTypesEqual() {
-        assertTrue(ResourceTypeUtil.areResourceTypesEqual("some/type", "/apps/some/type",
new String[]{"/apps/", "/libs/"}));
-        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "some/type",
new String[]{"/apps/", "/libs/"}));
-        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/apps/some/type",
new String[]{"/apps/", "/libs/"}));
-        assertTrue(ResourceTypeUtil.areResourceTypesEqual("some/type", "some/type", new String[]{"/apps/",
"/libs/"}));
-        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/libs/some/type",
new String[]{"/apps/", "/libs/"}));
-        assertFalse(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/libs/some/type",
new String[]{}));
+        assertTrue(ResourceTypeUtil.areResourceTypesEqual("some/type", "/apps/some/type",
SEARCH_PATHS));
+        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "some/type",
SEARCH_PATHS));
+        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/apps/some/type",
SEARCH_PATHS));
+        assertTrue(ResourceTypeUtil.areResourceTypesEqual("some/type", "some/type", SEARCH_PATHS));
+        assertTrue(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/libs/some/type",
SEARCH_PATHS));
+        assertFalse(ResourceTypeUtil.areResourceTypesEqual("/apps/some/type", "/libs/some/type",
Collections.EMPTY_LIST));
     }
 
     @Test public void testRelativizeResourceType() {
-        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("relative/type",
new String[]{"/apps/", "/libs/"}));
-        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("/apps/relative/type",
new String[]{"/apps/", "/libs/"}));
-        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("/libs/relative/type",
new String[]{"/apps/", "/libs/"}));
-        assertEquals("", ResourceTypeUtil.relativizeResourceType("/apps/", new String[]{"/apps/",
"/libs/"}));
-        assertEquals("/some/prefix/type", ResourceTypeUtil.relativizeResourceType("/some/prefix/type",
new String[]{"/apps/", "/libs/"}));
+        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("relative/type",
SEARCH_PATHS));
+        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("/apps/relative/type",
SEARCH_PATHS));
+        assertEquals("relative/type", ResourceTypeUtil.relativizeResourceType("/libs/relative/type",
SEARCH_PATHS));
+        assertEquals("", ResourceTypeUtil.relativizeResourceType("/apps/", SEARCH_PATHS));
+        assertEquals("/some/prefix/type", ResourceTypeUtil.relativizeResourceType("/some/prefix/type",
SEARCH_PATHS));
     }
 }
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporterTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporterTest.java
index 1917166..e0f0c12 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporterTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporterTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -44,23 +45,23 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 
 public class BasicObservationReporterTest {
-    
-    private static final String[] SEARCH_PATHS = new String[] { "/apps", "/libs" };
-    
+
+    private static final List<String> SEARCH_PATHS = Arrays.asList(new String[] { "/apps/",
"/libs/" });
+
     @Test
     public void testRootProvider() {
         ResourceChangeListenerInfo allPathListener = resourceChangeListenerInfo("/");
         ResourceChangeListenerInfo appsPathListener = resourceChangeListenerInfo("/apps");
         ResourceChangeListenerInfo appsApp2PathListener = resourceChangeListenerInfo("/apps/app2");
         ResourceChangeListenerInfo globListener = resourceChangeListenerInfo("glob:/apps/**/*.html");
-        
+
         BasicObservationReporter underTest = new BasicObservationReporter(SEARCH_PATHS,
                 ImmutableList.of(allPathListener, appsPathListener, appsApp2PathListener,
globListener),
                 new Path("/"), PathSet.EMPTY_SET);
-        
+
         underTest.reportChanges(changes("/apps/app1/path1.html"), false);
         underTest.reportChanges(changes("/content/path2/jcr:content"), false);
-        
+
         assertListener(allPathListener, "/apps/app1/path1.html", "/content/path2/jcr:content");
         assertListener(appsPathListener, "/apps/app1/path1.html");
         assertListener(appsApp2PathListener);
@@ -73,13 +74,13 @@ public class BasicObservationReporterTest {
         ResourceChangeListenerInfo appsPathListener = resourceChangeListenerInfo("/apps");
         ResourceChangeListenerInfo appsApp2PathListener = resourceChangeListenerInfo("/apps/app2");
         ResourceChangeListenerInfo globListener = resourceChangeListenerInfo("glob:/apps/**/*.html");
-        
+
         BasicObservationReporter underTest = new BasicObservationReporter(SEARCH_PATHS,
                 ImmutableList.of(allPathListener, appsPathListener, appsApp2PathListener,
globListener),
                 new Path("/apps/app1"), PathSet.EMPTY_SET);
-        
+
         underTest.reportChanges(changes("/apps/app1/path1.html"), false);
-        
+
         assertListener(allPathListener, "/apps/app1/path1.html");
         assertListener(appsPathListener, "/apps/app1/path1.html");
         assertListener(appsApp2PathListener);
@@ -94,7 +95,7 @@ public class BasicObservationReporterTest {
         info.setListener(mock(ResourceChangeListener.class));
         return info;
     }
-    
+
     private static Iterable<ResourceChange> changes(String... paths) {
         List<ResourceChange> changes = new ArrayList<>();
         for (String path : paths) {
@@ -102,7 +103,7 @@ public class BasicObservationReporterTest {
         }
         return changes;
     }
-    
+
     @SuppressWarnings("unchecked")
     private static void assertListener(ResourceChangeListenerInfo info, String... paths)
{
         Set<String> expectedPaths = ImmutableSet.copyOf(paths);
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfoTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfoTest.java
index 52aab70..d5c80aa 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfoTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListenerInfoTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.sling.api.resource.observation.ResourceChangeListener;
@@ -28,11 +30,13 @@ import org.osgi.framework.ServiceReference;
 
 public class ResourceChangeListenerInfoTest {
 
+    private static final List<String> SEARCH_PATHS = Arrays.asList(new String[] { "/apps/",
"/libs/" });
+
     @Test
     public void testGetExpandedRelativePaths() {
         ServiceReference reference = mock(ServiceReference.class);
         when(reference.getProperty(ResourceChangeListener.PATHS)).thenReturn(new String[]
{"project/components/page/page.html"});
-        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
new String[] {"/apps/", "/libs/"});
+        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
SEARCH_PATHS);
         Set<String> paths = rcli.getPaths().toStringSet();
         assertTrue("PathSet " + paths.toString() + " does not contain /apps/project/components/page/page.html.",
                 paths.contains("/apps/project/components/page/page.html"));
@@ -44,7 +48,7 @@ public class ResourceChangeListenerInfoTest {
     public void testDotPathConfig() {
         ServiceReference reference = mock(ServiceReference.class);
         when(reference.getProperty(ResourceChangeListener.PATHS)).thenReturn(new String[]
{"."});
-        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
new String[] {"/apps/", "/libs/"});
+        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
SEARCH_PATHS);
         Set<String> paths = rcli.getPaths().toStringSet();
         assertTrue("PathSet " + paths.toString() + " does not contain /apps/", paths.contains("/apps"));
         assertTrue("PathSet " + paths.toString() + " does not contain /libs/.", paths.contains("/libs"));
@@ -54,7 +58,7 @@ public class ResourceChangeListenerInfoTest {
     public void testGlobPatternExpansion() {
         ServiceReference reference = mock(ServiceReference.class);
         when(reference.getProperty(ResourceChangeListener.PATHS)).thenReturn(new String[]
{"glob:./**/*.html"});
-        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
new String[] {"/apps/", "/libs/"});
+        final ResourceChangeListenerInfo rcli = new ResourceChangeListenerInfo(reference,
SEARCH_PATHS);
         Set<String> paths = rcli.getPaths().toStringSet();
         assertTrue("PathSet " + paths.toString() + " does not contain glob:/apps/**/*.html.",
paths.contains("glob:/apps/**/*.html"));
         assertTrue("PathSet " + paths.toString() + " does not contain glob:/libs/**/*.html.",
paths.contains("glob:/libs/**/*.html"));

-- 
To stop receiving notification emails like this one, please contact
cziegeler@apache.org.

Mime
View raw message