You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/10/31 17:16:30 UTC

svn commit: r1767335 - in /sling/trunk/bundles/jcr/resource: ./ src/main/java/org/apache/sling/jcr/resource/internal/ src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/ src/main/java/org/apache/sling/jcr/resource/internal/scripting/ src/t...

Author: cziegeler
Date: Mon Oct 31 17:16:30 2016
New Revision: 1767335

URL: http://svn.apache.org/viewvc?rev=1767335&view=rev
Log:
Move to latest parent pom and use R6 OSGi annotations

Modified:
    sling/trunk/bundles/jcr/resource/pom.xml
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrSystemUserValidator.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapper.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapperTest.java

Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Mon Oct 31 17:16:30 2016
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>28</version>
+        <version>29</version>
         <relativePath />
     </parent>
 
@@ -57,10 +57,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.sling</groupId>
                 <artifactId>maven-sling-plugin</artifactId>
                 <executions>

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java Mon Oct 31 17:16:30 2016
@@ -23,14 +23,6 @@ import java.util.Map;
 
 import javax.jcr.Session;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
@@ -38,6 +30,11 @@ import org.apache.sling.commons.classloa
 import org.apache.sling.jcr.resource.JcrResourceConstants;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -48,13 +45,12 @@ import org.slf4j.LoggerFactory;
  * <li><code>JcrResourceResolverFactory</code> service
  * </ul>
  */
-@Component(name = "org.apache.sling.jcr.resource.internal.LegacyJcrResourceResolverFactoryImpl")
-@Service(value = JcrResourceResolverFactory.class)
-@Properties({
-        @Property(name = Constants.SERVICE_DESCRIPTION, value = "Apache Sling JcrResourceResolverFactory Implementation"),
-        @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation")
-
-})
+@Component(name = "org.apache.sling.jcr.resource.internal.LegacyJcrResourceResolverFactoryImpl",
+           service = JcrResourceResolverFactory.class,
+           property = {
+                   Constants.SERVICE_DESCRIPTION + "=Apache Sling JcrResourceResolverFactory Implementation",
+                   Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+           })
 public class JcrResourceResolverFactoryImpl implements
         JcrResourceResolverFactory {
 
@@ -62,7 +58,7 @@ public class JcrResourceResolverFactoryI
     private ResourceResolverFactory delegatee;
 
     /** The dynamic class loader */
-    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC)
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
     private volatile DynamicClassLoaderManager dynamicClassLoaderManager;
 
     @Activate

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrSystemUserValidator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrSystemUserValidator.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrSystemUserValidator.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrSystemUserValidator.java Mon Oct 31 17:16:30 2016
@@ -17,25 +17,25 @@
 package org.apache.sling.jcr.resource.internal;
 
 import java.lang.reflect.Method;
-import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.serviceusermapping.ServiceUserValidator;
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,10 +47,22 @@ import org.slf4j.LoggerFactory;
  *
  * @see org.apache.jackrabbit.api.security.user.User#isSystemUser()
  */
-@Component(label="Apache Sling JCR System User Validator", description="Enforces the usage of JCR system users for all user mappings being used in the 'Sling Service User Mapper Service'", metatype=true)
-@Service(ServiceUserValidator.class)
+@Designate(ocd = JcrSystemUserValidator.Config.class)
+@Component(service = ServiceUserValidator.class,
+           property = {
+                   Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+           })
 public class JcrSystemUserValidator implements ServiceUserValidator {
 
+    @ObjectClassDefinition(
+            name = "Apache Sling JCR System User Validator",
+            description = "Enforces the usage of JCR system users for all user mappings being used in the 'Sling Service User Mapper Service'")
+    public @interface Config {
+
+        @AttributeDefinition(name = "Allow only JCR System Users",
+                description="If set to true, only user IDs bound to JCR system users are allowed in the user mappings of the 'Sling Service User Mapper Service'. Otherwise all users are allowed!")
+        boolean allow_only_system_user() default true;
+    }
     /**
      * logger instance
      */
@@ -58,16 +70,11 @@ public class JcrSystemUserValidator impl
 
     @Reference
     private volatile SlingRepository repository;
-    
-    public static final boolean PROP_ALLOW_ONLY_SYSTEM_USERS_DEFAULT = true;
-    
-    @Property(boolValue=PROP_ALLOW_ONLY_SYSTEM_USERS_DEFAULT, label="Allow only JCR System Users", description="If set to true, only user IDs bound to JCR system users are allowed in the user mappings of the 'Sling Service User Mapper Service'. Otherwise all users are allowed!")
-    public static final String PROP_ALLOW_ONLY_SYSTEM_USERS = "allow.only.system.user";
 
     private final Method isSystemUserMethod;
 
     private final Set<String> validIds = new CopyOnWriteArraySet<String>();
-    
+
     private boolean allowOnlySystemUsers;
 
     public JcrSystemUserValidator() {
@@ -81,10 +88,11 @@ public class JcrSystemUserValidator impl
     }
 
     @Activate
-    public void activate(final Map<String, Object> config) {
-        allowOnlySystemUsers = PropertiesUtil.toBoolean(config.get(PROP_ALLOW_ONLY_SYSTEM_USERS),PROP_ALLOW_ONLY_SYSTEM_USERS_DEFAULT);
+    public void activate(final Config config) {
+        allowOnlySystemUsers = config.allow_only_system_user();
     }
 
+    @Override
     public boolean isValid(final String serviceUserId, final String serviceName, final String subServiceName) {
         if (serviceUserId == null) {
             log.debug("The provided service user id is null");

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java Mon Oct 31 17:16:30 2016
@@ -38,15 +38,6 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.UserManager;
@@ -72,22 +63,26 @@ import org.apache.sling.spi.resource.pro
 import org.apache.sling.spi.resource.provider.ResourceProvider;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Component(name="org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory")
-@Service(value = ResourceProvider.class)
-@Properties({ @Property(name = ResourceProvider.PROPERTY_NAME, value = "JCR"),
-        @Property(name = ResourceProvider.PROPERTY_ROOT, value = "/"),
-        @Property(name = ResourceProvider.PROPERTY_MODIFIABLE, boolValue = true),
-        @Property(name = ResourceProvider.PROPERTY_ADAPTABLE, boolValue = true),
-        @Property(name = ResourceProvider.PROPERTY_AUTHENTICATE, value = ResourceProvider.AUTHENTICATE_REQUIRED),
-        @Property(name = ResourceProvider.PROPERTY_ATTRIBUTABLE, boolValue = true),
-        @Property(name = ResourceProvider.PROPERTY_REFRESHABLE, boolValue = true)
-})
-@Reference(name = "dynamicClassLoaderManager",
-           referenceInterface = DynamicClassLoaderManager.class,
-           cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC)
+@Component(name="org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory",
+           service = ResourceProvider.class,
+           property = {
+                   ResourceProvider.PROPERTY_NAME + "=JCR",
+                   ResourceProvider.PROPERTY_ROOT + "=/",
+                   ResourceProvider.PROPERTY_MODIFIABLE + ":Boolean=true",
+                   ResourceProvider.PROPERTY_ADAPTABLE + ":Boolean=true",
+                   ResourceProvider.PROPERTY_ATTRIBUTABLE + ":Boolean=true",
+                   ResourceProvider.PROPERTY_REFRESHABLE + ":Boolean=true",
+                   ResourceProvider.PROPERTY_AUTHENTICATE + "=" + ResourceProvider.AUTHENTICATE_REQUIRED
+           })
 public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
 
     /** Logger */
@@ -103,7 +98,7 @@ public class JcrResourceProvider extends
         IGNORED_PROPERTIES.add("jcr:createdBy");
     }
 
-    @Reference(name = REPOSITORY_REFERNENCE_NAME, referenceInterface = SlingRepository.class)
+    @Reference(name = REPOSITORY_REFERNENCE_NAME, service = SlingRepository.class)
     private ServiceReference<SlingRepository> repositoryReference;
 
     @Reference
@@ -113,7 +108,7 @@ public class JcrResourceProvider extends
     private LoginAdminWhitelist loginAdminWhitelist;
 
     /** This service is only available on OAK, therefore optional and static) */
-    @Reference(policy=ReferencePolicy.STATIC, cardinality=ReferenceCardinality.OPTIONAL_UNARY)
+    @Reference(policy=ReferencePolicy.STATIC, cardinality=ReferenceCardinality.OPTIONAL)
     private Executor executor;
 
     /** The JCR listener base configuration. */
@@ -151,6 +146,9 @@ public class JcrResourceProvider extends
         this.stateFactory = null;
     }
 
+    @Reference(name = "dynamicClassLoaderManager",
+            service = DynamicClassLoaderManager.class,
+            cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
     protected void bindDynamicClassLoaderManager(final DynamicClassLoaderManager dynamicClassLoaderManager) {
         this.classLoaderManagerReference.set(dynamicClassLoaderManager);
     }

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapper.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapper.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapper.java Mon Oct 31 17:16:30 2016
@@ -21,14 +21,13 @@ package org.apache.sling.jcr.resource.in
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyUnbounded;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,25 +38,30 @@ import org.slf4j.LoggerFactory;
  * @deprecated
  */
 @Deprecated
-@Service(value = PathMapper.class)
-@Component(metatype = true,
-        label = "Apache Sling JCR Resource Provider Path Mapper",
+@Designate(ocd = PathMapper.Config.class)
+@Component(service = PathMapper.class,
+           property = {
+                   Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+           })
+public class PathMapper {
+
+    @ObjectClassDefinition(name = "Apache Sling JCR Resource Provider Path Mapper",
         description = "This service provides path mappings for JCR nodes.")
+    public @interface Config {
 
-public class PathMapper {
+        @AttributeDefinition(name = "Path Mapping",
+                description = "Defines an obtional path mapping for a path." +
+                        "Each mapping entry is expressed as follow: <JCRPath>:<resourcePath>. As an example: /foo:/libs, " +
+                        "this maps the JCR node /foo to the resource /libs. If the resource path is specified as '.', " +
+                        " the JCR tree is not visible in the resource tree. This should not be considered a security feature " +
+                        " as the nodes are still accessible through the JCR api. Mapping a JCR path to the root is not allowed. " +
+                        "The mappings are evaluated as ordered in the configuration.")
+        String[] path_mapping();
+    }
 
     /** Logger */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Property(unbounded = PropertyUnbounded.ARRAY,
-            label = "Path mapping", description = "Defines an obtional path mapping for a path." +
-            "Each mapping entry is expressed as follow: <JCRPath>:<resourcePath>. As an example: /foo:/libs, " +
-            "this maps the JCR node /foo to the resource /libs. If the resource path is specified as '.', " +
-            " the JCR tree is not visible in the resource tree. This should not be considered a security feature " +
-            " as the nodes are still accessible through the JCR api. Mapping a JCR path to the root is not allowed. " +
-            "The mappings are evaluated as ordered in the configuration.")
-    private static final String PATH_MAPPING = "path.mapping";
-
     /** The mappings. */
     private final List<Mapping> mappings = new ArrayList<Mapping>();
 
@@ -81,9 +85,9 @@ public class PathMapper {
     }
 
     @Activate
-    private void activate(final Map<String, Object> props) {
+    private void activate(final Config configObj) {
         mappings.clear();
-        final String[] config = PropertiesUtil.toStringArray(props.get(PATH_MAPPING), null);
+        final String[] config = configObj.path_mapping();
         if ( config != null ) {
             log.warn("The Apache Sling JCR Path Mapper is deprecated.");
             for (final String mapping : config) {

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java Mon Oct 31 17:16:30 2016
@@ -20,22 +20,19 @@ import javax.jcr.Node;
 import javax.jcr.Session;
 import javax.script.Bindings;
 
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.scripting.api.BindingsValuesProvider;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Component;
 
 /**
  * BindingsValuesProvider for currentNode and currentSession object.
  */
-@Component
-@Service
-@Properties({
-        @Property(name = Constants.SERVICE_DESCRIPTION, value = "Apache Sling CurrentNode BindingsValuesProvider"),
-        @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation") })
+@Component(service = BindingsValuesProvider.class,
+           property = {
+                   Constants.SERVICE_DESCRIPTION + "=Apache Sling CurrentNode BindingsValuesProvider",
+                   Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+           })
 public class JcrObjectsBindingsValuesProvider implements BindingsValuesProvider {
 
     private static final String PROP_CURRENT_NODE = "currentNode";
@@ -44,6 +41,7 @@ public class JcrObjectsBindingsValuesPro
     /**
      * {@inheritDoc}
      */
+    @Override
     public void addBindings(final Bindings bindings) {
         final Resource resource = (Resource) bindings.get("resource");
         if (resource != null) {

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapperTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapperTest.java?rev=1767335&r1=1767334&r2=1767335&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapperTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/PathMapperTest.java Mon Oct 31 17:16:30 2016
@@ -21,24 +21,31 @@ package org.apache.sling.jcr.resource.in
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import junitx.util.PrivateAccessor;
+import java.lang.annotation.Annotation;
 
 import org.junit.Test;
 
+import junitx.util.PrivateAccessor;
+
 public class PathMapperTest {
 
     @Test public void mappingTest() throws Throwable {
-        final Map<String, Object> config = new HashMap<String, Object>();
-        config.put("path.mapping", new String[] {
-                "/libs:/foo",
-                "/hidden:.",
-                "/deep/node:/deep/resource"
-        });
+        final PathMapper.Config config = new PathMapper.Config() {
+
+            @Override
+            public Class<? extends Annotation> annotationType() {
+                return null;
+            }
+
+            @Override
+            public String[] path_mapping() {
+                return new String[] {"/libs:/foo",
+                        "/hidden:.",
+                        "/deep/node:/deep/resource"};
+            }
+        };
         final PathMapper pm = new PathMapper();
-        PrivateAccessor.invoke(pm, "activate", new Class[] {Map.class}, new Object[] {config});
+        PrivateAccessor.invoke(pm, "activate", new Class[] {PathMapper.Config.class}, new Object[] {config});
 
         assertEquals("/", pm.mapResourcePathToJCRPath("/"));
         assertEquals("/", pm.mapJCRPathToResourcePath("/"));