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 fd0d1a01f1347cfb91d5ceed6807948f2a80b717 Author: Robert Munteanu <[email protected]> AuthorDate: Wed May 27 11:42:35 2015 +0000 SLING-4605 - Add support for an Oak resource resolver type mock Initial revision of the sling-mock-oak module git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-oak@1681992 13f79535-47bb-0310-9956-ffa450edef68 --- README.txt | 11 ++ pom.xml | 163 +++++++++++++++++++++ .../sling/oak/OakMockResourceResolverAdapter.java | 43 ++++++ .../sling/testing/mock/sling/oak/package-info.java | 23 +++ .../oak/contentimport/ContentLoaderBinaryTest.java | 55 +++++++ .../contentimport/ContentLoaderJsonDamTest.java | 58 ++++++++ .../oak/contentimport/ContentLoaderJsonTest.java | 58 ++++++++ .../mock/sling/oak/resource/JcrNamespaceTest.java | 34 +++++ .../oak/resource/JcrResourceResolverTest.java | 55 +++++++ .../oak/resource/MultipleResourceResolverTest.java | 63 ++++++++ .../resource/SlingCrudResourceResolverTest.java | 55 +++++++ src/test/resources/SLING-INF/nodetypes/app.cnd | 26 ++++ 12 files changed, 644 insertions(+) diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..7a173cc --- /dev/null +++ b/README.txt @@ -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 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..39975f4 --- /dev/null +++ b/pom.xml @@ -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> 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 new file mode 100644 index 0000000..895608b --- /dev/null +++ b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockResourceResolverAdapter.java @@ -0,0 +1,43 @@ +/* + * 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 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; + +/** + * Resource resolver type adapter for Jackrabbit Oak repository. + */ +public class OakMockResourceResolverAdapter implements ResourceResolverTypeAdapter { + + @Override + public ResourceResolverFactory newResourceResolverFactory() { + return null; + } + + @Override + public SlingRepository newSlingRepository() { + + return new RepositoryUtil.RepositoryWrapper(new Jcr().createRepository()); + } + +} diff --git a/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java new file mode 100644 index 0000000..55bdc9d --- /dev/null +++ b/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ +/** + * Sling Mock Jackrabbit Oak-based Resource Resolver + */ [email protected]("0.1") +package org.apache.sling.testing.mock.sling.oak; 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 new file mode 100644 index 0000000..9072a48 --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderBinaryTest.java @@ -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; + } + +} 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 new file mode 100644 index 0000000..4cbd95c --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonDamTest.java @@ -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; + } + +} 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 new file mode 100644 index 0000000..904f9c8 --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java @@ -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; + } + +} 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 new file mode 100644 index 0000000..e661d1c --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrNamespaceTest.java @@ -0,0 +1,34 @@ +/* + * 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 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; + } + +} diff --git a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java new file mode 100644 index 0000000..894ef08 --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/JcrResourceResolverTest.java @@ -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; + } + +} 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 new file mode 100644 index 0000000..090fb4d --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/MultipleResourceResolverTest.java @@ -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; + } + +} diff --git a/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java new file mode 100644 index 0000000..ec7755c --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/SlingCrudResourceResolverTest.java @@ -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; + } + +} diff --git a/src/test/resources/SLING-INF/nodetypes/app.cnd b/src/test/resources/SLING-INF/nodetypes/app.cnd new file mode 100644 index 0000000..105d39f --- /dev/null +++ b/src/test/resources/SLING-INF/nodetypes/app.cnd @@ -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 -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
