You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2015/05/27 13:42:36 UTC
svn commit: r1681992 - in /sling/trunk/testing: ./ mocks/sling-mock-oak/
mocks/sling-mock-oak/src/ mocks/sling-mock-oak/src/main/
mocks/sling-mock-oak/src/main/java/ mocks/sling-mock-oak/src/main/java/org/
mocks/sling-mock-oak/src/main/java/org/apache/...
Author: rombert
Date: Wed May 27 11:42:35 2015
New Revision: 1681992
URL: http://svn.apache.org/r1681992
Log:
SLING-4605 - Add support for an Oak resource resolver type mock
Initial revision of the sling-mock-oak module
Added:
sling/trunk/testing/mocks/sling-mock-oak/
sling/trunk/testing/mocks/sling-mock-oak/README.txt
sling/trunk/testing/mocks/sling-mock-oak/pom.xml
sling/trunk/testing/mocks/sling-mock-oak/src/
sling/trunk/testing/mocks/sling-mock-oak/src/main/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java
- copied, changed from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java
- copied, changed from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java
- copied, changed from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java
sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/
sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/
sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/
sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/app.cnd
Modified:
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
sling/trunk/testing/pom.xml
Added: sling/trunk/testing/mocks/sling-mock-oak/README.txt
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/README.txt?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/README.txt (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/README.txt Wed May 27 11:42:35 2015
@@ -0,0 +1,11 @@
+Apache Sling Testing Sling Mock Jackrabbit Oak-based Resource Resolver
+
+Implements a resource resolver type for Jackrabbit Oak that can be used in unit tests based on Sling Mocks.
+
+This is a separate maven artifacts because it introduces a lot of further dependencies.
+
+Please note: This adapter for Jackrabbit Oak is still experimental, not all sling-mock features are working.
+(see disabled unit tests with comments)
+
+Documentation:
+http://sling.apache.org/documentation/development/sling-mock.html
Added: sling/trunk/testing/mocks/sling-mock-oak/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/pom.xml?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/pom.xml (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/pom.xml Wed May 27 11:42:35 2015
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>22</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Testing Sling Mock Oak-based Resource Resolver</name>
+ <description>Implements a resource resolver type for Jackrabbit Oak that can be used in unit tests based on Sling Mocks.</description>
+
+ <properties>
+ <sling.java.version>6</sling.java.version>
+ <oak.version>1.2.2</oak.version>
+ <jackrabbit.version>2.10.1</jackrabbit.version>
+ </properties>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-oak</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-oak</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak</url>
+ </scm>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ <classifier>tests</classifier>
+ <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>
+ <artifactId>oak-jcr</artifactId>
+ <version>${oak.version}</version>
+ </dependency>
+
+ <!-- Ensure we depend on more recent jackrabbit artifacts required by Oak -->
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ <version>${jackrabbit.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ <version>${jackrabbit.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.logging-mock</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!-- Publish test artifact -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-scr-scrdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Copied: sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java (from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java)
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java?p2=sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java&p1=sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java&r1=1681625&r2=1681992&rev=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java Wed May 27 11:42:35 2015
@@ -16,8 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.sling.testing.mock.sling.oak;
+
+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.spi.ResourceResolverTypeAdapter;
+
/**
- * Mock implementation of selected Sling APIs.
+ * Resource resolver type adapter for Jackrabbit Oak repository.
*/
-@aQute.bnd.annotation.Version("1.3")
-package org.apache.sling.testing.mock.sling;
+public class OakMockResourceResolverAdapter implements ResourceResolverTypeAdapter {
+
+ @Override
+ public ResourceResolverFactory newResourceResolverFactory() {
+ return null;
+ }
+
+ @Override
+ public SlingRepository newSlingRepository() {
+
+ return new RepositoryUtil.RepositoryWrapper(new Jcr().createRepository());
+ }
+
+}
Copied: sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java (from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java)
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java?p2=sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java&p1=sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java&r1=1681625&r2=1681992&rev=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java Wed May 27 11:42:35 2015
@@ -17,7 +17,7 @@
* under the License.
*/
/**
- * Mock implementation of selected Sling APIs.
+ * Sling Mock Jackrabbit Oak-based Resource Resolver
*/
-@aQute.bnd.annotation.Version("1.3")
-package org.apache.sling.testing.mock.sling;
+@aQute.bnd.annotation.Version("0.1")
+package org.apache.sling.testing.mock.sling.oak;
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,55 @@
+/*
+ * 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.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;
+
+public class ContentLoaderBinaryTest extends AbstractContentLoaderBinaryTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ 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;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,58 @@
+/*
+ * 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.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;
+
+public class ContentLoaderJsonDamTest extends AbstractContentLoaderJsonDamTest {
+
+ @Override
+ 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;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,58 @@
+/*
+ * 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.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;
+
+public class ContentLoaderJsonTest extends AbstractContentLoaderJsonTest {
+
+ @Override
+ 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;
+ }
+
+}
Copied: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java (from r1681625, sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java)
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java?p2=sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java&p1=sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java&r1=1681625&r2=1681992&rev=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java Wed May 27 11:42:35 2015
@@ -16,8 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- * Mock implementation of selected Sling APIs.
- */
-@aQute.bnd.annotation.Version("1.3")
-package org.apache.sling.testing.mock.sling;
+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
+ protected ResourceResolverType getResourceResolverType() {
+ return ResourceResolverType.JCR_OAK;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,55 @@
+/*
+ * 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.resource;
+
+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.resource.AbstractJcrResourceResolverTest;
+
+public class JcrResourceResolverTest extends AbstractJcrResourceResolverTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ 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;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,63 @@
+/*
+ * 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.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;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java Wed May 27 11:42:35 2015
@@ -0,0 +1,55 @@
+/*
+ * 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.resource;
+
+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.resource.AbstractSlingCrudResourceResolverTest;
+
+public class SlingCrudResourceResolverTest extends AbstractSlingCrudResourceResolverTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ 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;
+ }
+
+}
Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/app.cnd
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/app.cnd?rev=1681992&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/app.cnd (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/resources/SLING-INF/nodetypes/app.cnd Wed May 27 11:42:35 2015
@@ -0,0 +1,26 @@
+//
+// 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
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java?rev=1681992&r1=1681991&r2=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java Wed May 27 11:42:35 2015
@@ -66,6 +66,20 @@ public enum ResourceResolverType {
*/
JCR_JACKRABBIT("org.apache.sling.testing.mock.sling.jackrabbit.JackrabbitMockResourceResolverAdapter",
"org.apache.sling:org.apache.sling.testing.sling-mock-jackrabbit"),
+
+ /**
+ * Uses a real JCR Jackrabbit Oak repository.
+ * <ul>
+ * <li>Uses the real Sling Resource Resolver and JCR Resource mapping
+ * implementation.</li>
+ * <li>The JCR repository is started on first access, this may take some
+ * seconds.</li>
+ * <li>Beware: The repository is not cleared for each unit test, so make
+ * sure us use a unique node path for each unit test.</li>
+ * </ul>
+ */
+ JCR_OAK("org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter",
+ "org.apache.sling:org.apache.sling.testing.sling-mock-jackrabbit-oak"),
/**
* Provides resource resolver environment without any ResourceProvider.
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java?rev=1681992&r1=1681991&r2=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/package-info.java Wed May 27 11:42:35 2015
@@ -19,5 +19,5 @@
/**
* Mock implementation of selected Sling APIs.
*/
-@aQute.bnd.annotation.Version("1.3")
+@aQute.bnd.annotation.Version("1.4")
package org.apache.sling.testing.mock.sling;
Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java?rev=1681992&r1=1681991&r2=1681992&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java Wed May 27 11:42:35 2015
@@ -161,7 +161,8 @@ public abstract class AbstractSlingCrudR
// TODO: enable this test when JCR resource implementation supports
// writing Date objects (SLING-3846)
if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
- && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT) {
+ && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT
+ && getResourceResolverType() != ResourceResolverType.JCR_OAK ) {
assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
}
}
@@ -173,7 +174,8 @@ public abstract class AbstractSlingCrudR
// TODO: enable this test when JCR resource implementation supports
// writing Date objects (SLING-3846)
if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
- && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT) {
+ && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT
+ && getResourceResolverType() != ResourceResolverType.JCR_OAK ) {
Calendar calendarValue = props.get("dateProp", Calendar.class);
assertNotNull(calendarValue);
assertEquals(DATE_VALUE, calendarValue.getTime());
Modified: sling/trunk/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/pom.xml?rev=1681992&r1=1681991&r2=1681992&view=diff
==============================================================================
--- sling/trunk/testing/pom.xml (original)
+++ sling/trunk/testing/pom.xml Wed May 27 11:42:35 2015
@@ -57,6 +57,7 @@
<module>mocks/osgi-mock</module>
<module>mocks/sling-mock</module>
<module>mocks/sling-mock-jackrabbit</module>
+ <module>mocks/sling-mock-oak</module>
<module>sling-pax-util</module>
<module>samples/sample-tests</module>
<module>samples/failing-tests</module>