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

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

commit 3e338711c0e384d4c620c5f1d875869289d5be9a
Author: Stefan Seifert <[email protected]>
AuthorDate: Mon Sep 28 22:16:38 2015 +0000

    SLING-5064 manual registration of node types no longer required; register 
namespaces and node types centrally depending on NodeTypeMode
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-oak@1705787
 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  12 ---
 .../sling/oak/OakMockResourceResolverAdapter.java  |  30 +-----
 .../testing/mock/sling/oak/RepositoryWrapper.java  | 102 +++++++++++++++++++++
 .../oak/contentimport/ContentLoaderBinaryTest.java |  24 -----
 .../contentimport/ContentLoaderJsonDamTest.java    |  29 +-----
 .../oak/contentimport/ContentLoaderJsonTest.java   |  27 ------
 .../mock/sling/oak/resource/JcrNamespaceTest.java  |   3 -
 .../oak/resource/MultipleResourceResolverTest.java |  34 +------
 src/test/resources/SLING-INF/nodetypes/app.cnd     |  26 ------
 9 files changed, 105 insertions(+), 182 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5135d42..4081c11 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,18 +62,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.testing</artifactId>
-            <version>2.0.16</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.jmock</groupId>
-                    <artifactId>jmock-junit4</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        
         <!-- Depend on oak-jcr, which pulls in all needed Oak artifacts -->
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
diff --git 
a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java
 
b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java
index a017407..393fdc1 100644
--- 
a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java
+++ 
b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java
@@ -18,14 +18,9 @@
  */
 package org.apache.sling.testing.mock.sling.oak;
 
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
 import org.apache.jackrabbit.oak.jcr.Jcr;
 import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.commons.testing.jcr.RepositoryUtil;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.testing.mock.sling.context.NodeTypeDefinitionScanner;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 
 /**
@@ -40,30 +35,7 @@ public class OakMockResourceResolverAdapter implements 
ResourceResolverTypeAdapt
 
     @Override
     public SlingRepository newSlingRepository() {
-        SlingRepository slingRepository = new 
RepositoryUtil.RepositoryWrapper(new Jcr().createRepository());
-        registerJcrNodeTypes(slingRepository);
-        return slingRepository;
-    }
-
-    /**
-     * Registers all JCR node types found in classpath.
-     * @param slingRepository Sling repository
-     */
-    @SuppressWarnings("deprecation")
-    private static void registerJcrNodeTypes(SlingRepository slingRepository) {
-      Session session = null;
-      try {
-          session =  slingRepository.loginAdministrative(null);
-          NodeTypeDefinitionScanner.get().register(session);
-      }
-      catch (RepositoryException ex) {
-          throw new RuntimeException("Error registering JCR nodetypes: " + 
ex.getMessage(), ex);
-      }
-      finally {
-          if (session != null) {
-              session.logout();
-          }
-      }
+        return new RepositoryWrapper(new Jcr().createRepository());
     }
 
 }
diff --git 
a/src/main/java/org/apache/sling/testing/mock/sling/oak/RepositoryWrapper.java 
b/src/main/java/org/apache/sling/testing/mock/sling/oak/RepositoryWrapper.java
new file mode 100644
index 0000000..6c0d9d1
--- /dev/null
+++ 
b/src/main/java/org/apache/sling/testing/mock/sling/oak/RepositoryWrapper.java
@@ -0,0 +1,102 @@
+/*
+ * 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.mock.sling.oak;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
+
+import org.apache.sling.jcr.api.SlingRepository;
+
+public final class RepositoryWrapper implements SlingRepository {
+
+    private static final String ADMIN_NAME = "admin";
+    private static final String ADMIN_PASSWORD = "admin";
+
+    protected final Repository wrapped;
+
+    public RepositoryWrapper(Repository r) {
+        wrapped = r;
+    }
+
+    public String getDescriptor(String key) {
+        return wrapped.getDescriptor(key);
+    }
+
+    public String[] getDescriptorKeys() {
+        return wrapped.getDescriptorKeys();
+    }
+
+    public String getDefaultWorkspace() {
+        return "default";
+    }
+
+    public Session login() throws LoginException, RepositoryException {
+        return wrapped.login();
+    }
+
+    public Session login(Credentials credentials, String workspaceName) 
+            throws LoginException, NoSuchWorkspaceException, 
RepositoryException {
+        return wrapped.login(credentials, (workspaceName == null ? 
getDefaultWorkspace() : workspaceName));
+    }
+
+    public Session login(Credentials credentials) 
+            throws LoginException, RepositoryException {
+        return wrapped.login(credentials);
+    }
+
+    public Session login(String workspaceName) 
+            throws LoginException, NoSuchWorkspaceException, 
RepositoryException {
+        return wrapped.login((workspaceName == null ? getDefaultWorkspace() : 
workspaceName));
+    }
+
+    public Session loginAdministrative(String workspaceName) 
+            throws RepositoryException {
+        final Credentials credentials = new SimpleCredentials(ADMIN_NAME, 
ADMIN_PASSWORD.toCharArray());
+        return this.login(credentials, (workspaceName == null ? 
getDefaultWorkspace() : workspaceName));
+    }
+
+    @Override
+    public Session loginService(String subServiceName, String workspaceName) 
+            throws LoginException, RepositoryException {
+        return loginAdministrative(workspaceName);
+    }
+    
+    public Value getDescriptorValue(String key) {
+        return wrapped.getDescriptorValue(key);
+    }
+
+    public Value[] getDescriptorValues(String key) {
+        return wrapped.getDescriptorValues(key);
+    }
+
+    public boolean isSingleValueDescriptor(String key) {
+        return wrapped.isSingleValueDescriptor(key);
+    }
+
+    public boolean isStandardDescriptor(String key) {
+        return wrapped.isStandardDescriptor(key);
+    }
+
+}
\ No newline at end of file
diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
index 9072a48..1515912 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
@@ -18,14 +18,6 @@
  */
 package org.apache.sling.testing.mock.sling.oak.contentimport;
 
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.commons.testing.jcr.RepositoryUtil;
-import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderBinaryTest;
 
@@ -36,20 +28,4 @@ public class ContentLoaderBinaryTest extends 
AbstractContentLoaderBinaryTest {
         return ResourceResolverType.JCR_OAK;
     }
 
-    @Override
-    protected ResourceResolver newResourceResolver() {
-        ResourceResolver resolver = 
MockSling.newResourceResolver(getResourceResolverType());
-
-        // register sling node types
-        try {
-            
RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
-        } catch (IOException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        } catch (RepositoryException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        }
-
-        return resolver;
-    }
-
 }
diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
index 4cbd95c..76b3a5c 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
@@ -18,14 +18,6 @@
  */
 package org.apache.sling.testing.mock.sling.oak.contentimport;
 
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.commons.testing.jcr.RepositoryUtil;
-import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonDamTest;
 
@@ -35,24 +27,5 @@ public class ContentLoaderJsonDamTest extends 
AbstractContentLoaderJsonDamTest {
     protected ResourceResolverType getResourceResolverType() {
         return ResourceResolverType.JCR_OAK;
     }
-
-    @Override
-    protected ResourceResolver newResourceResolver() {
-        ResourceResolver resolver = 
MockSling.newResourceResolver(getResourceResolverType());
-
-        // register sling and app node types
-        try {
-            Session session = resolver.adaptTo(Session.class);
-            RepositoryUtil.registerSlingNodeTypes(session);
-            RepositoryUtil.registerNodeType(session,
-                    
ContentLoaderJsonTest.class.getResourceAsStream("/SLING-INF/nodetypes/app.cnd"));
-        } catch (IOException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        } catch (RepositoryException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        }
-
-        return resolver;
-    }
-
+    
 }
diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
index 904f9c8..a1a5189 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
@@ -18,14 +18,6 @@
  */
 package org.apache.sling.testing.mock.sling.oak.contentimport;
 
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.commons.testing.jcr.RepositoryUtil;
-import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonTest;
 
@@ -36,23 +28,4 @@ public class ContentLoaderJsonTest extends 
AbstractContentLoaderJsonTest {
         return ResourceResolverType.JCR_OAK;
     }
 
-    @Override
-    protected ResourceResolver newResourceResolver() {
-        ResourceResolver resolver = 
MockSling.newResourceResolver(getResourceResolverType());
-
-        // register sling and app node types
-        try {
-            Session session = resolver.adaptTo(Session.class);
-            RepositoryUtil.registerSlingNodeTypes(session);
-            RepositoryUtil.registerNodeType(session,
-                    
ContentLoaderJsonTest.class.getResourceAsStream("/SLING-INF/nodetypes/app.cnd"));
-        } catch (IOException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        } catch (RepositoryException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        }
-
-        return resolver;
-    }
-
 }
diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java
index e661d1c..0325b18 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java
@@ -20,10 +20,7 @@ package org.apache.sling.testing.mock.sling.oak.resource;
 
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.resource.AbstractJcrNamespaceTest;
-import org.junit.Ignore;
 
-//TEST IS DISABLED currently, it does not work with oak repository yet
-@Ignore
 public class JcrNamespaceTest extends AbstractJcrNamespaceTest {
 
     @Override
diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
index 090fb4d..ebd4727 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
@@ -18,46 +18,14 @@
  */
 package org.apache.sling.testing.mock.sling.oak.resource;
 
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.sling.api.resource.LoginException;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.commons.testing.jcr.RepositoryUtil;
-import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import 
org.apache.sling.testing.mock.sling.resource.AbstractMultipleResourceResolverTest;
-import org.junit.Ignore;
 
-//TEST IS DISABLED currently, it does not work with jackrabbit repository yet
-@Ignore
 public class MultipleResourceResolverTest extends 
AbstractMultipleResourceResolverTest {
 
     @Override
     protected ResourceResolverType getResourceResolverType() {
         return ResourceResolverType.JCR_OAK;
     }
-
-    @Override
-    protected ResourceResolverFactory newResourceResolerFactory() {
-        ResourceResolverFactory factory = 
MockSling.newResourceResolverFactory(getResourceResolverType());
-
-        // register sling node types
-        try {
-            ResourceResolver resolver = factory.getResourceResolver(null);
-            
RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
-        } catch (LoginException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        } catch (IOException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        } catch (RepositoryException ex) {
-            throw new RuntimeException("Unable to register sling node types.", 
ex);
-        }
-
-        return factory;
-    }
-
+    
 }
diff --git a/src/test/resources/SLING-INF/nodetypes/app.cnd 
b/src/test/resources/SLING-INF/nodetypes/app.cnd
deleted file mode 100644
index 105d39f..0000000
--- a/src/test/resources/SLING-INF/nodetypes/app.cnd
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-//  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.
-//
-<app='http://example.com/jcr/app/1.0'>
-<dam='http://example.com/jcr/dam/1.0'>
-
-[app:Page] > nt:unstructured
-[app:PageContent] > nt:unstructured
-
-[dam:Asset] > nt:unstructured
-[dam:AssetContent] > nt:unstructured

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

Reply via email to