This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.testing.resourceresolver-mock-1.1.10
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit e8ce0e7157eaeb3e003115a9e0864ccd5649bbaf
Author: Robert Munteanu <[email protected]>
AuthorDate: Mon Mar 30 09:22:01 2015 +0000

    SLING-4500: make sure that root has a primary type
    
    This closes #72
    
    Submitted By: Santiago Garcia Pimentel
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/resourceresolver-mock@1670023
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../MockResourceResolverFactory.java               |  7 +++-
 .../resourceresolver/RootResourceTypeTest.java     | 48 ++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
index 8046d74..8af9392 100644
--- 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
+++ 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
@@ -28,10 +28,13 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.osgi.service.event.EventAdmin;
 
+
 /**
  * Simple resource resolver factory
  */
 public class MockResourceResolverFactory implements ResourceResolverFactory {
+    
+    private static final String ROOT_PRIMARY_TYPE="rep:root";
 
     /** We use a linked hash map to preserve creation order. */
     private final Map<String, Map<String, Object>> resources = new 
LinkedHashMap<String, Map<String, Object>>();
@@ -59,7 +62,9 @@ public class MockResourceResolverFactory implements 
ResourceResolverFactory {
      */
     public MockResourceResolverFactory(final 
MockResourceResolverFactoryOptions options) {
         this.options = options;
-        resources.put("/", new HashMap<String, Object>());
+        Map<String, Object> props= new HashMap<String,Object>();
+        props.put(MockResource.JCR_PRIMARYTYPE, ROOT_PRIMARY_TYPE);
+        resources.put("/", props);
     }
 
     @Override
diff --git 
a/src/test/java/org/apache/sling/testing/resourceresolver/RootResourceTypeTest.java
 
b/src/test/java/org/apache/sling/testing/resourceresolver/RootResourceTypeTest.java
new file mode 100644
index 0000000..9cda4c4
--- /dev/null
+++ 
b/src/test/java/org/apache/sling/testing/resourceresolver/RootResourceTypeTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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 java.io.IOException;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class RootResourceTypeTest {
+
+
+    private ResourceResolver resourceResolver;
+
+    @Before
+    public final void setUp() throws IOException, LoginException {
+        resourceResolver = new 
MockResourceResolverFactory().getResourceResolver(null);       
+    }
+
+    
+    @Test
+    public void testIsResourceResolver() {
+        Resource root= resourceResolver.getResource("/");
+        Assert.assertTrue(root.isResourceType("rep:root"));
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to