sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1634835 - in /sling/trunk/testing/mocks: jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/ jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/ resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/ res...
Date Tue, 28 Oct 2014 10:17:59 GMT
Author: sseifert
Date: Tue Oct 28 10:17:59 2014
New Revision: 1634835

URL: http://svn.apache.org/r1634835
Log:
SLING-4108 JCR/Sling/ResourceResolver Mock: Support providing authentication info

Added:
    sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
  (with props)
Modified:
    sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
    sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
    sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
    sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
    sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/package-info.java
    sling/trunk/testing/mocks/jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
    sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
    sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
    sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverFactory.java
    sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockSlingRepository.java
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java

Modified: sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
Tue Oct 28 10:17:59 2014
@@ -21,6 +21,9 @@ package org.apache.sling.testing.mock.jc
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * Factory for mock JCR objects.
@@ -32,6 +35,11 @@ public final class MockJcr {
      */
     public static final String DEFAULT_WORKSPACE = "mockedWorkspace";
 
+    /**
+     * Default user id
+     */
+    public static final String DEFAULT_USER_ID = "admin";
+
     private MockJcr() {
         // static methods only
     }
@@ -52,8 +60,23 @@ public final class MockJcr {
      * @return JCR session
      */
     public static Session newSession() {
+        return newSession(null, null);
+    }
+
+    /**
+     * Create a new mocked in-memory JCR session. It contains only the root
+     * node. All data of the session is thrown away if it gets garbage
+     * collected.
+     * @param userId User id for the mock environment.
+     * @param workspaceName Workspace name for the mock environment.
+     * @return JCR session
+     */
+    public static Session newSession(String userId, String workspaceName) {
         try {
-            return newRepository().login();
+            return newRepository().login(
+                    new SimpleCredentials(StringUtils.defaultString(userId, DEFAULT_USER_ID),
new char[0]),
+                    StringUtils.defaultString(workspaceName, DEFAULT_WORKSPACE)
+            );
         } catch (RepositoryException ex) {
             throw new RuntimeException("Creating mocked JCR session failed.", ex);
         }

Modified: sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
Tue Oct 28 10:17:59 2014
@@ -24,9 +24,11 @@ import java.util.Map;
 import javax.jcr.Credentials;
 import javax.jcr.Repository;
 import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * Mock {@link Repository} implementation. The data is stored inside the mocked
@@ -44,22 +46,28 @@ class MockRepository implements Reposito
     
     @Override
     public Session login() {
-        return new MockSession(this, items);
+        return login(null, null);
     }
 
     @Override
     public Session login(final String workspaceName) {
-        return login();
+        return login(null, workspaceName);
     }
 
     @Override
     public Session login(final Credentials credentials) {
-        return login();
+        return login(credentials, null);
     }
 
     @Override
     public Session login(final Credentials credentials, final String workspaceName) {
-        return login();
+        String userId = null;
+        if (credentials instanceof SimpleCredentials) {
+            userId = ((SimpleCredentials)credentials).getUserID();
+        }
+        return new MockSession(this, items,
+                StringUtils.defaultString(userId, MockJcr.DEFAULT_USER_ID),
+                StringUtils.defaultString(workspaceName, MockJcr.DEFAULT_WORKSPACE));
     }
 
     @Override

Modified: sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
Tue Oct 28 10:17:59 2014
@@ -54,11 +54,14 @@ class MockSession implements Session {
     private final Repository repository;
     private final Workspace workspace;
     private final Map<String, ItemData> items;
+    private final String userId;
 
-    public MockSession(Repository repository, Map<String,ItemData> items) {
+    public MockSession(Repository repository, Map<String,ItemData> items,
+            String userId, String workspaceName) {
         this.repository = repository;
-        this.workspace = new MockWorkspace(this);
+        this.workspace = new MockWorkspace(this, workspaceName);
         this.items = items;
+        this.userId = userId;
     }
 
     @Override
@@ -208,7 +211,7 @@ class MockSession implements Session {
 
     @Override
     public String getUserID() {
-        return "mockedUserId";
+        return this.userId;
     }
 
     @Override

Modified: sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
Tue Oct 28 10:17:59 2014
@@ -38,6 +38,7 @@ import org.xml.sax.ContentHandler;
 class MockWorkspace implements Workspace {
 
     private final Session session;
+    private final String workspaceName;
     private final NamespaceRegistry namespaceRegistry = new MockNamespaceRegistry();
     private final ObservationManager observationManager = new MockObservationManager();
     private final NodeTypeManager nodeTypeManager = new MockNodeTypeManager();
@@ -45,8 +46,9 @@ class MockWorkspace implements Workspace
     /**
      * @param session JCR session
      */
-    public MockWorkspace(final Session session) {
+    public MockWorkspace(Session session, String workspaceName) {
         this.session = session;
+        this.workspaceName = workspaceName;
     }
 
     @Override
@@ -56,7 +58,7 @@ class MockWorkspace implements Workspace
 
     @Override
     public String getName() {
-        return MockJcr.DEFAULT_WORKSPACE;
+        return this.workspaceName;
     }
 
     @Override

Modified: sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/package-info.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/package-info.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/main/java/org/apache/sling/testing/mock/jcr/package-info.java
Tue Oct 28 10:17:59 2014
@@ -21,4 +21,3 @@
  */
 @aQute.bnd.annotation.Version("1.0")
 package org.apache.sling.testing.mock.jcr;
-

Modified: sling/trunk/testing/mocks/jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
(original)
+++ sling/trunk/testing/mocks/jcr-mock/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
Tue Oct 28 10:17:59 2014
@@ -202,7 +202,14 @@ public class MockSessionTest {
 
     @Test
     public void testUserId() {
-        assertEquals("mockedUserId", this.session.getUserID());
+        assertEquals(MockJcr.DEFAULT_USER_ID, this.session.getUserID());
+    }
+
+    @Test
+    public void testWithCustomUserWorkspace() {
+        Session mySession = MockJcr.newSession("myUser", "myWorkspace");
+        assertEquals("myUser", mySession.getUserID());
+        assertEquals("myWorkspace", mySession.getWorkspace().getName());
     }
 
     @Test

Modified: sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
(original)
+++ sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
Tue Oct 28 10:17:59 2014
@@ -53,13 +53,23 @@ public class MockResourceResolver extend
     private final MockResourceResolverFactoryOptions options;
 
     private final MockResourceResolverFactory factory;
+    
+    private final Map<String,Object> attributes;
 
     public MockResourceResolver(final MockResourceResolverFactoryOptions options,
             final MockResourceResolverFactory factory,
             final Map<String, Map<String, Object>> resources) {
+        this(options, factory, resources, Collections.<String,Object>emptyMap());
+    }
+
+    public MockResourceResolver(final MockResourceResolverFactoryOptions options,
+            final MockResourceResolverFactory factory,
+            final Map<String, Map<String, Object>> resources,
+            final Map<String,Object> attributes) {
         this.factory = factory;
         this.options = options;
         this.resources = resources;
+        this.attributes = attributes;
     }
 
     @Override
@@ -268,13 +278,12 @@ public class MockResourceResolver extend
 
     @Override
     public Iterator<String> getAttributeNames() {
-        final List<String> emptyList = Collections.emptyList();
-        return emptyList.iterator();
+        return attributes.keySet().iterator();
     }
 
     @Override
     public Object getAttribute(final String name) {
-        return null;
+        return attributes.get(name);
     }
 
     @Override

Modified: sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
(original)
+++ sling/trunk/testing/mocks/resourceresolver-mock/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
Tue Oct 28 10:17:59 2014
@@ -64,7 +64,14 @@ public class MockResourceResolverFactory
     @Override
     public ResourceResolver getResourceResolver(
             final Map<String, Object> authenticationInfo) throws LoginException {
-        final ResourceResolver result = new MockResourceResolver(options, this, resources);
+        
+        // put user name in resolver attributes
+        Map<String,Object> attributes = new HashMap<String, Object>();
+        if (authenticationInfo!=null) {
+            attributes.put(ResourceResolverFactory.USER, authenticationInfo.get(ResourceResolverFactory.USER));
+        }
+        
+        final ResourceResolver result = new MockResourceResolver(options, this, resources,
attributes);
         Stack<ResourceResolver> resolverStack = resolverStackHolder.get();
         if ( resolverStack == null ) {
             resolverStack = new Stack<ResourceResolver>();

Added: sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java?rev=1634835&view=auto
==============================================================================
--- sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
(added)
+++ sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
Tue Oct 28 10:17:59 2014
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.resourceresolver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Map;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Test different variants of login for resource resolver.
+ */
+public class ResourceResolverLoginTest {
+
+    private static final Map<String,Object> AUTH_INFO = ImmutableMap.<String, Object>of(
+                ResourceResolverFactory.USER, "myUser");
+    
+    private MockResourceResolverFactory factory;
+    
+    @Before
+    public void setUp() {
+        factory = new MockResourceResolverFactory();
+    }
+
+    @Test
+    public void testGetResourceResolverWithoutAuthInfo() throws LoginException {
+        ResourceResolver resolver = factory.getResourceResolver(null);
+        assertNotNull(resolver);
+        assertNull(resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+    @Test
+    public void testGetResourceResolverWithAuthInfo() throws LoginException {
+        ResourceResolver resolver = factory.getResourceResolver(AUTH_INFO);
+        assertNotNull(resolver);
+        assertEquals("myUser", resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+    @Test
+    public void testGetAdministrativeResourceResolverWithoutAuthInfo() throws LoginException
{
+        ResourceResolver resolver = factory.getAdministrativeResourceResolver(null);
+        assertNotNull(resolver);
+        assertNull(resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+    @Test
+    public void testGetAdminstrativeResourceResolverWithAuthInfo() throws LoginException
{
+        ResourceResolver resolver = factory.getAdministrativeResourceResolver(AUTH_INFO);
+        assertNotNull(resolver);
+        assertNull(resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+    @Test
+    public void testGetServiceResourceResolverWithoutAuthInfo() throws LoginException {
+        ResourceResolver resolver = factory.getServiceResourceResolver(null);
+        assertNotNull(resolver);
+        assertNull(resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+    @Test
+    public void testGetServiceResourceResolverWithAuthInfo() throws LoginException {
+        ResourceResolver resolver = factory.getServiceResourceResolver(AUTH_INFO);
+        assertNotNull(resolver);
+        assertNull(resolver.getAttribute(ResourceResolverFactory.USER));
+    }
+
+}

Propchange: sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Tue Oct 28 10:17:59 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/resourceresolver-mock/src/test/java/org/apache/sling/testing/resourceresolver/ResourceResolverLoginTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverFactory.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverFactory.java
(original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverFactory.java
Tue Oct 28 10:17:59 2014
@@ -53,8 +53,7 @@ class MockJcrResourceResolverFactory imp
         this.slingRepository = repository;
     }
 
-    @Override
-    public ResourceResolver getResourceResolver(final Map<String, Object> authenticationInfo)
throws LoginException {
+    private ResourceResolver getResourceResolverInternal(Map<String, Object> authenticationInfo,
boolean isAdmin) throws LoginException {
         // setup mock OSGi environment
         Dictionary<String, Object> resourceProviderFactoryProps = new Hashtable<String,
Object>();
         resourceProviderFactoryProps.put(Constants.SERVICE_VENDOR, "sling-mock");
@@ -72,8 +71,15 @@ class MockJcrResourceResolverFactory imp
         MockOsgi.injectServices(jcrResourceProviderFactory, componentContext.getBundleContext());
         MockOsgi.activate(jcrResourceProviderFactory, componentContext.getBundleContext(),
                 ImmutableMap.<String, Object> of());
-        ResourceProvider resourceProvider = jcrResourceProviderFactory
-                .getAdministrativeResourceProvider(new HashMap<String, Object>());
+        
+        ResourceProvider resourceProvider;
+        if (isAdmin) {
+            resourceProvider = jcrResourceProviderFactory.getAdministrativeResourceProvider(authenticationInfo);
+        }
+        else {
+            resourceProvider = jcrResourceProviderFactory.getResourceProvider(authenticationInfo);
+        }
+        
         Dictionary<Object, Object> resourceProviderProps = new Hashtable<Object,
Object>();
         resourceProviderProps.put(ResourceProvider.ROOTS, new String[] { "/" });
         componentContext.getBundleContext().registerService(ResourceProvider.class.getName(),
resourceProvider,
@@ -88,7 +94,7 @@ class MockJcrResourceResolverFactory imp
                 getServiceReferenceProperties(resourceProviderServiceReference));
         activator.activate(componentContext);
         CommonResourceResolverFactoryImpl commonFactoryImpl = new CommonResourceResolverFactoryImpl(activator);
-        ResourceResolverContext context = new ResourceResolverContext(true, null, new ResourceAccessSecurityTracker());
+        ResourceResolverContext context = new ResourceResolverContext(true, authenticationInfo,
new ResourceAccessSecurityTracker());
         ResourceResolverImpl resourceResolver = new ResourceResolverImpl(commonFactoryImpl,
context);
         return resourceResolver;
     }
@@ -103,15 +109,20 @@ class MockJcrResourceResolverFactory imp
     }
 
     @Override
+    public ResourceResolver getResourceResolver(final Map<String, Object> authenticationInfo)
throws LoginException {
+        return getResourceResolverInternal(authenticationInfo, false);
+    }
+    
+    @Override
     public ResourceResolver getAdministrativeResourceResolver(final Map<String, Object>
authenticationInfo)
             throws LoginException {
-        return getResourceResolver(authenticationInfo);
+        return getResourceResolverInternal(authenticationInfo, true);
     }
 
     // part of Sling API 2.7
     public ResourceResolver getServiceResourceResolver(final Map<String, Object> authenticationInfo)
             throws LoginException {
-        return getResourceResolver(authenticationInfo);
+        return getResourceResolverInternal(authenticationInfo, true);
     }
 
 }

Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockSlingRepository.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockSlingRepository.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockSlingRepository.java
(original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/MockSlingRepository.java
Tue Oct 28 10:17:59 2014
@@ -41,14 +41,14 @@ class MockSlingRepository implements Sli
     }
 
     @Override
-    public Session loginAdministrative(final String workspace) throws RepositoryException
{
-        return login();
+    public Session loginAdministrative(final String workspaceName) throws RepositoryException
{
+        return login(workspaceName);
     }
 
     @Override
-    public Session loginService(final String subServiceName, final String workspace) throws
LoginException,
-            RepositoryException {
-        return login();
+    public Session loginService(final String subServiceName, final String workspaceName)
+            throws LoginException, RepositoryException {
+        return login(workspaceName);
     }
 
     @Override

Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java?rev=1634835&r1=1634834&r2=1634835&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
(original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
Tue Oct 28 10:17:59 2014
@@ -44,8 +44,17 @@ public abstract class AbstractMultipleRe
     @Test
     public void testMultipleResourceResolver() throws Exception {
         ResourceResolverFactory factory = newResourceResolerFactory();
-        ResourceResolver resolver1 = factory.getResourceResolver(null);
-        ResourceResolver resolver2 = factory.getResourceResolver(null);
+        ResourceResolver resolver1 = factory.getResourceResolver(ImmutableMap.<String,
Object>of(
+                ResourceResolverFactory.USER, "user1"));
+        ResourceResolver resolver2 = factory.getResourceResolver(ImmutableMap.<String,
Object>of(
+                ResourceResolverFactory.USER, "user2"));
+        
+        // validate user names
+        // TODO: enable this tests when updated to latest jcr-mock/resourceresolver-mock
versions
+        /*
+        assertEquals("user1", resolver1.getAttribute(ResourceResolverFactory.USER));
+        assertEquals("user2", resolver2.getAttribute(ResourceResolverFactory.USER));
+        */
         
         // add a resource in resolver 1
         Resource root = resolver1.getResource("/");



Mime
View raw message