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 2017/10/18 23:20:40 UTC
[sling-org-apache-sling-resourcebuilder] branch master created (now
9d45499)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git.
at 9d45499 SLING-7167 Adjust READMEs
This branch includes the following new commits:
new a3e05fa SLING-5356 - move resourcebuilder under bundles/extensions
new 064b111 SLING-5712 - avoid windows file separator issues in ClassResourceVisitor, based on a patch by Emanuele Lombardi, thanks!
new 16fbf22 SLING-6035 ResourceBuilder: Support absolute paths This closes #165
new 3813d4e SLING-6036 ResourceBuilder: Reusing ResourceBuilder instances
new 6b2675e add infinitest.filters to ignore list
new 63d3114 SLING-6039 ResourceBuilder: Split up ResourceBuilder and ResourceBuilderFactory
new 13b6dd9 SLING-6040 split up ResourceBuilder project into impl and integration-tests to remove dependency to sling-mock in impl project
new 290cd24 Rats - the rat plugin was unhappy when building from this folder
new ffe1cdd SLING-6040 revert last two commits rev. 1759507, 1759545 - there is a better solution
new 4af46b2 SLING-6040 use resourceresolver-mock instead of sling-mock to avoid cyclic dependency to sling-mock referencing the resourcebuilder itself
new 793a426 update testing dependencies
new 331a3f1 add mockito test dependency
new 7c1013e SLING-6050 ResourceBuilder: Support Map for resource properties
new 833ebaa fix javadoc error
new f97a268 update dependencies
new e6a162f [maven-release-plugin] prepare release org.apache.sling.resourcebuilder-1.0.0
new 1d483d8 [maven-release-plugin] prepare for next development iteration
new f68ee97 update dependencies to latest snapshots until released versions are available in maven central
new 8907912 switch back to released versions
new fcc4107 SLING-6132 ResourceBuilder: Use absolute resource path should switch to hierachy mode
new a460d16 cosmetic: add package version and update rat file ignore list
new 179a5dc SLING-6132 fix integration test setup
new 3650738 [maven-release-plugin] prepare release org.apache.sling.resourcebuilder-1.0.2
new 6eb1bb3 [maven-release-plugin] prepare for next development iteration
new 9d45499 SLING-7167 Adjust READMEs
The 25 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-resourcebuilder] 18/25: update dependencies
to latest snapshots until released versions are available in maven central
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit f68ee97ab96fb69d1e6e94a1a2852baf7902fd05
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 22:15:54 2016 +0000
update dependencies to latest snapshots until released versions are available in maven central
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760812 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 79d4f6a..a6bd885 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,7 +234,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.18</version>
+ <version>1.0.19-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -246,7 +246,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.teleporter</artifactId>
- <version>1.0.8</version>
+ <version>1.0.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 03/25: SLING-6035
ResourceBuilder: Support absolute paths This closes #165
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 16fbf22ad2a3d43693398f8ad71831dd7c292dd5
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 5 19:36:07 2016 +0000
SLING-6035 ResourceBuilder: Support absolute paths
This closes #165
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759348 13f79535-47bb-0310-9956-ffa450edef68
---
.gitignore | 1 +
.../sling/resourcebuilder/api/ResourceBuilder.java | 7 ++--
.../resourcebuilder/impl/ResourceBuilderImpl.java | 39 ++++++++++++++--------
.../impl/ResourceBuilderImplTest.java | 24 ++++++++++---
4 files changed, 49 insertions(+), 22 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0829d12
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+sling
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
index 1a1f965..07ae787 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
@@ -45,12 +45,13 @@ public interface ResourceBuilder {
/** Create a Resource, which optionally becomes the current
* parent Resource.
- * @param relativePath The path of the Resource to create, relative to
- * this builder's current parent Resource.
+ * @param path The path of the Resource to create.
+ * If it's a relative path this builder's current resource is used as parent.
+ * Otherwise the resource is created ad the given absoulte path.
* @param properties optional name-value pairs
* @return this builder
*/
- ResourceBuilder resource(String relativePath, Object ... properties);
+ ResourceBuilder resource(String path, Object ... properties);
/** Create a file under the current parent resource
* @param filename The name of the created file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
index 48b9be9..4905387 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -85,12 +85,16 @@ public class ResourceBuilderImpl implements ResourceBuilder {
return this;
}
- private void checkRelativePath(String relativePath) {
- if(relativePath.startsWith("/")) {
- throw new IllegalArgumentException("Path is not relative:" + relativePath);
+ private boolean isAbsolutePath(String path) {
+ return path.startsWith("/") && !path.contains("..");
+ }
+
+ private void checkRelativePath(String path) {
+ if(path.startsWith("/")) {
+ throw new IllegalArgumentException("Path is not relative:" + path);
}
- if(relativePath.contains("..")) {
- throw new IllegalArgumentException("Path contains invalid pattern '..': " + relativePath);
+ if(path.contains("..")) {
+ throw new IllegalArgumentException("Path contains invalid pattern '..': " + path);
}
}
@@ -104,19 +108,28 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
@Override
- public ResourceBuilder resource(String relativePath, Object... properties) {
+ public ResourceBuilder resource(String path, Object... properties) {
Resource r = null;
- checkRelativePath(relativePath);
- final String parentPath = parentPath(relativePath);
+
+ final String parentPath;
+ final String fullPath;
+ if (isAbsolutePath(path)) {
+ parentPath = ResourceUtil.getParent(path);
+ fullPath = path;
+ }
+ else {
+ checkRelativePath(path);
+ parentPath = parentPath(path);
+ fullPath = currentParent.getPath() + "/" + path;
+ }
final Resource myParent = ensureResourceExists(parentPath);
- final String fullPath = currentParent.getPath() + "/" + relativePath;
try {
r = currentParent.getResourceResolver().getResource(fullPath);
final Map<String, Object> props = MapArgsConverter.toMap(properties);
if(r == null) {
r = currentParent.getResourceResolver().create(myParent,
- ResourceUtil.getName(relativePath), props);
+ ResourceUtil.getName(fullPath), props);
} else {
// Resource exists, set our properties
final ModifiableValueMap mvm = r.adaptTo(ModifiableValueMap.class);
@@ -129,13 +142,11 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
} catch(PersistenceException pex) {
throw new RuntimeException(
- "PersistenceException while creating Resource " + relativePath
- + " under " + currentParent.getPath(), pex);
+ "PersistenceException while creating Resource " + fullPath, pex);
}
if(r == null) {
- throw new RuntimeException("Failed to get or create resource " + relativePath
- + " under " + currentParent.getPath());
+ throw new RuntimeException("Failed to get or create resource " + fullPath);
} else if(hierarchyMode) {
currentParent = r;
}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index 608a813..6d3cf52 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -200,11 +200,6 @@ public class ResourceBuilderImplTest {
}
@Test(expected=IllegalArgumentException.class)
- public void absolutePathFails() throws Exception {
- getBuilder(testRootPath).resource("/absolute");
- }
-
- @Test(expected=IllegalArgumentException.class)
public void aboveParentFails() throws Exception {
getBuilder(testRootPath).resource("../foo");
}
@@ -332,4 +327,23 @@ public class ResourceBuilderImplTest {
// Resource is created at root in this case
A.assertResource("/d/e/f");
}
+
+ @Test
+ public void absolutePath() throws Exception {
+ new ResourceBuilderService()
+ .forResolver(resourceResolver)
+ .resource("/a/b/c")
+ .resource("/a/b/f")
+ .resource("/g/h/i")
+ .resource("j/l/m")
+ .resource("/o/p/q");
+
+ // absolute paths are supported and can be mixed with relative paths
+ A.assertResource("/a/b/c");
+ A.assertResource("/a/b/f");
+ A.assertResource("/g/h/i");
+ A.assertResource("/g/h/i/j/l/m");
+ A.assertResource("/o/p/q");
+ }
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 12/25: add mockito test
dependency
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 331a3f18ca83a2a515740a42e3f5bcee8750ccf7
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 8 19:52:08 2016 +0000
add mockito test dependency
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759897 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4f75093..e98e378 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,7 +156,7 @@
<goals>
<goal>copy-dependencies</goal>
</goals>
- <phase>process-resources</phase>
+ <phase>process-resources</phase>
<configuration>
<includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
@@ -174,7 +174,7 @@
<goals>
<goal>copy-dependencies</goal>
</goals>
- <phase>process-resources</phase>
+ <phase>process-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<excludeTransitive>true</excludeTransitive>
@@ -235,7 +235,7 @@
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
<version>1.0.17-SNAPSHOT</version>
- <scope>provided</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -251,6 +251,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.launchpad</artifactId>
<version>8</version>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 21/25: cosmetic: add
package version and update rat file ignore list
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit a460d16cd8e015acd11603c12c5915c6223a758f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Oct 11 16:47:15 2016 +0000
cosmetic: add package version and update rat file ignore list
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764300 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 1 +
.../sling/resourcebuilder/api/package-info.java | 23 ++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/pom.xml b/pom.xml
index 79d4f6a..e9c437b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
<excludes>
<exclude>src/test/resources/**</exclude>
<exclude>sling/**</exclude>
+ <exclude>infinitest.filters</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/package-info.java b/src/main/java/org/apache/sling/resourcebuilder/api/package-info.java
new file mode 100644
index 0000000..9cb1bc9
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/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.
+ */
+/**
+ * ResourceBuilder API.
+ */
+@aQute.bnd.annotation.Version("1.0.0")
+package org.apache.sling.resourcebuilder.api;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 16/25:
[maven-release-plugin] prepare release
org.apache.sling.resourcebuilder-1.0.0
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit e6a162fd721b51cf19c02ae98cd6227828315eb7
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 21:21:16 2016 +0000
[maven-release-plugin] prepare release org.apache.sling.resourcebuilder-1.0.0
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760766 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 532 ++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 266 insertions(+), 266 deletions(-)
diff --git a/pom.xml b/pom.xml
index 08ce17a..1cf5a8e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,266 +1,266 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>26</version>
- <relativePath/>
- </parent>
-
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Sling Resource Builder</name>
- <description>Utilities to create Sling content</description>
-
- <properties>
- <!-- Set this to run the server on a specific port
- <http.port></http.port>
- -->
-
- <!-- Set this to run tests against an existing server instance -->
- <keepJarRunning>false</keepJarRunning>
-
- <!--
- Options for the VM that executes our runnable jar.
- Set debugging options here to debug teleported tests.
- -->
- <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
-
- <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
- selected port number -->
- <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
- </properties>
- <scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
- </scm>
-
- <build>
- <plugins>
- <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>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>src/test/resources/**</exclude>
- <exclude>sling/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <!-- Find free ports to run our server -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>reserve-server-port</id>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <portNames>
- <portName>http.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}</directory>
- <includes>
- <!-- sling folder is the workdir of the executable jar that we test -->
- <include>sling/**</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <systemPropertyVariables>
- <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
- <keepJarRunning>${keepJarRunning}</keepJarRunning>
- <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
- <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
- <jar.executor.server.port>${http.port}</jar.executor.server.port>
- <additional.bundles.path>${project.build.directory}</additional.bundles.path>
- <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
- <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
- <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
-
- <!-- Additional bundles to install for testing -->
- <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
- <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-runnable-jar</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- <execution>
- <!--
- Consider all dependencies as candidates to be installed
- as additional bundles. We use system properties to define
- which bundles to install in which order.
- -->
- <id>copy-additional-bundles</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.mime</artifactId>
- <version>2.1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
- <version>1.1.14</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.18</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.14</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.teleporter</artifactId>
- <version>1.0.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad</artifactId>
- <version>8</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>26</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <version>1.0.0</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Resource Builder</name>
+ <description>Utilities to create Sling content</description>
+
+ <properties>
+ <!-- Set this to run the server on a specific port
+ <http.port></http.port>
+ -->
+
+ <!-- Set this to run tests against an existing server instance -->
+ <keepJarRunning>false</keepJarRunning>
+
+ <!--
+ Options for the VM that executes our runnable jar.
+ Set debugging options here to debug teleported tests.
+ -->
+ <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
+
+ <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
+ selected port number -->
+ <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
+ </properties>
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <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>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>src/test/resources/**</exclude>
+ <exclude>sling/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- Find free ports to run our server -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>reserve-server-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>http.port</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}</directory>
+ <includes>
+ <!-- sling folder is the workdir of the executable jar that we test -->
+ <include>sling/**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <systemPropertyVariables>
+ <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
+ <keepJarRunning>${keepJarRunning}</keepJarRunning>
+ <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
+ <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
+ <jar.executor.server.port>${http.port}</jar.executor.server.port>
+ <additional.bundles.path>${project.build.directory}</additional.bundles.path>
+ <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
+ <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
+ <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
+
+ <!-- Additional bundles to install for testing -->
+ <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
+ <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-runnable-jar</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ <execution>
+ <!--
+ Consider all dependencies as candidates to be installed
+ as additional bundles. We use system properties to define
+ which bundles to install in which order.
+ -->
+ <id>copy-additional-bundles</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
+ <version>1.1.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.core</artifactId>
+ <version>1.0.18</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.tools</artifactId>
+ <version>1.0.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.teleporter</artifactId>
+ <version>1.0.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.launchpad</artifactId>
+ <version>8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 07/25: SLING-6040 split up
ResourceBuilder project into impl and integration-tests to remove
dependency to sling-mock in impl project
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 13b6dd9187eae9e57a606ca7a376f494b1f245cd
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Sep 6 20:49:03 2016 +0000
SLING-6040 split up ResourceBuilder project into impl and integration-tests to remove dependency to sling-mock in impl project
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759507 13f79535-47bb-0310-9956-ffa450edef68
---
impl/pom.xml | 86 ++++++++
.../sling/resourcebuilder/api/ResourceBuilder.java | 0
.../api/ResourceBuilderFactory.java | 0
.../resourcebuilder/impl/MapArgsConverter.java | 0
.../impl/ResourceBuilderFactoryService.java | 0
.../resourcebuilder/impl/ResourceBuilderImpl.java | 0
.../resourcebuilder/impl/MapArgsConverterTest.java | 0
.gitignore => integration-tests/.gitignore | 0
pom.xml => integration-tests/pom.xml | 15 +-
.../customizers/RBIT_TeleporterCustomizer.java | 0
.../impl/ResourceBuilderImplTest.java | 4 +
.../sling/resourcebuilder/it/FileRetrievalIT.java | 0
.../resourcebuilder/it/ResourceBuilderIT.java | 0
.../sling/resourcebuilder/it/TestEnvironment.java | 0
.../resourcebuilder/test/ResourceAssertions.java | 0
.../src}/test/resources/files/models.js | 0
.../src}/test/resources/files/myapp.json | 0
.../src}/test/resources/files/text.html | 0
pom.xml | 230 +--------------------
19 files changed, 113 insertions(+), 222 deletions(-)
diff --git a/impl/pom.xml b/impl/pom.xml
new file mode 100644
index 0000000..f1bc4f5
--- /dev/null
+++ b/impl/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>26</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Resource Builder</name>
+ <description>Utilities to create Sling content</description>
+
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <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>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
similarity index 100%
rename from src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
rename to impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java b/impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
similarity index 100%
rename from src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
rename to impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java b/impl/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
similarity index 100%
rename from src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
rename to impl/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java b/impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
similarity index 100%
rename from src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
rename to impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
similarity index 100%
rename from src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
rename to impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java b/impl/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
similarity index 100%
rename from src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
rename to impl/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
diff --git a/.gitignore b/integration-tests/.gitignore
similarity index 100%
rename from .gitignore
rename to integration-tests/.gitignore
diff --git a/pom.xml b/integration-tests/pom.xml
similarity index 93%
copy from pom.xml
copy to integration-tests/pom.xml
index 3b90050..8ed0a79 100644
--- a/pom.xml
+++ b/integration-tests/pom.xml
@@ -27,14 +27,17 @@
<relativePath/>
</parent>
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <artifactId>org.apache.sling.resourcebuilder.integration-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Apache Sling Resource Builder</name>
+ <name>Apache Sling Resource Builder Integration Tests</name>
<description>Utilities to create Sling content</description>
<properties>
+ <!-- version of the ResourceBuilder impl -->
+ <resourcebuilder.version>0.0.1-SNAPSHOT</resourcebuilder.version>
+
<!-- Set this to run the server on a specific port
<http.port></http.port>
-->
@@ -143,7 +146,8 @@
<!-- Additional bundles to install for testing -->
<sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
- <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
+ <sling.additional.bundle.2>org.apache.sling.resourcebuilder-${resourcebuilder.version}.jar</sling.additional.bundle.2>
+ <sling.additional.bundle.3>${project.artifactId}-${project.version}.jar</sling.additional.bundle.3>
</systemPropertyVariables>
</configuration>
</plugin>
@@ -189,6 +193,11 @@
<dependencies>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <version>${resourcebuilder.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
diff --git a/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java b/integration-tests/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
similarity index 100%
rename from src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
rename to integration-tests/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
similarity index 98%
rename from src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
rename to integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index 9ab055f..45f4df0 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -40,6 +40,10 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+/**
+ * This unit test is not part of the ResourceBuilder impl project to avoid a dependency
+ * to the sling-mock project there (because sling-mock itself has a dependency to the ResourceBuilder).
+ */
public class ResourceBuilderImplTest {
private String testRootPath;
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
similarity index 100%
rename from src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
rename to integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
similarity index 100%
rename from src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
rename to integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
similarity index 100%
rename from src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
rename to integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
diff --git a/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java b/integration-tests/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
similarity index 100%
rename from src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
rename to integration-tests/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
diff --git a/src/test/resources/files/models.js b/integration-tests/src/test/resources/files/models.js
similarity index 100%
rename from src/test/resources/files/models.js
rename to integration-tests/src/test/resources/files/models.js
diff --git a/src/test/resources/files/myapp.json b/integration-tests/src/test/resources/files/myapp.json
similarity index 100%
rename from src/test/resources/files/myapp.json
rename to integration-tests/src/test/resources/files/myapp.json
diff --git a/src/test/resources/files/text.html b/integration-tests/src/test/resources/files/text.html
similarity index 100%
rename from src/test/resources/files/text.html
rename to integration-tests/src/test/resources/files/text.html
diff --git a/pom.xml b/pom.xml
index 3b90050..f1690af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,229 +27,21 @@
<relativePath/>
</parent>
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <artifactId>org.apache.sling.resourcebuilder.reactor</artifactId>
+ <packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Sling Resource Builder</name>
+ <name>Apache Sling Resource Builder Reactor</name>
<description>Utilities to create Sling content</description>
- <properties>
- <!-- Set this to run the server on a specific port
- <http.port></http.port>
- -->
-
- <!-- Set this to run tests against an existing server instance -->
- <keepJarRunning>false</keepJarRunning>
-
- <!--
- Options for the VM that executes our runnable jar.
- Set debugging options here to debug teleported tests.
- -->
- <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
-
- <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
- selected port number -->
- <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
- </properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
</scm>
-
- <build>
- <plugins>
- <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>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>src/test/resources/**</exclude>
- <exclude>sling/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <!-- Find free ports to run our server -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>reserve-server-port</id>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <portNames>
- <portName>http.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}</directory>
- <includes>
- <!-- sling folder is the workdir of the executable jar that we test -->
- <include>sling/**</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <systemPropertyVariables>
- <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
- <keepJarRunning>${keepJarRunning}</keepJarRunning>
- <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
- <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
- <jar.executor.server.port>${http.port}</jar.executor.server.port>
- <additional.bundles.path>${project.build.directory}</additional.bundles.path>
- <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
- <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
- <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
-
- <!-- Additional bundles to install for testing -->
- <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
- <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-runnable-jar</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- <execution>
- <!--
- Consider all dependencies as candidates to be installed
- as additional bundles. We use system properties to define
- which bundles to install in which order.
- -->
- <id>copy-additional-bundles</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.mime</artifactId>
- <version>2.1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>1.6.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.14</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.teleporter</artifactId>
- <!-- SNAPSHOT required due to SLING-5712 -->
- <version>1.0.7-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad</artifactId>
- <version>8</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+
+ <modules>
+ <module>impl</module>
+ <module>integration-tests</module>
+ </modules>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 17/25:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 1d483d8d75732ccb70c4b8412d9700e019b8adac
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 21:21:30 2016 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760768 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1cf5a8e..79d4f6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Apache Sling Resource Builder</name>
@@ -53,9 +53,9 @@
<jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
</properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.0</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 10/25: SLING-6040 use
resourceresolver-mock instead of sling-mock to avoid cyclic dependency to
sling-mock referencing the resourcebuilder itself
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 4af46b2b91f6ee149d53c86122f7643f05c2e727
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 8 13:01:51 2016 +0000
SLING-6040 use resourceresolver-mock instead of sling-mock to avoid cyclic dependency to sling-mock referencing the resourcebuilder itself
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759810 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 16 +++++++++----
.../impl/ResourceBuilderImplTest.java | 27 +++++++++++++---------
2 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3b90050..3713f2c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,9 +53,9 @@
<jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
</properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
</scm>
<build>
@@ -221,8 +221,14 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>1.6.0</version>
+ <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
+ <version>1.1.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index 9ab055f..e33b900 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -21,6 +21,8 @@ package org.apache.sling.resourcebuilder.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
import java.util.Random;
import java.util.UUID;
@@ -32,28 +34,29 @@ import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.commons.mime.MimeTypeService;
import org.apache.sling.resourcebuilder.api.ResourceBuilder;
import org.apache.sling.resourcebuilder.test.ResourceAssertions;
-import org.apache.sling.testing.mock.sling.ResourceResolverType;
-import org.apache.sling.testing.mock.sling.junit.SlingContext;
-import org.apache.sling.testing.mock.sling.services.MockMimeTypeService;
+import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+@RunWith(MockitoJUnitRunner.class)
public class ResourceBuilderImplTest {
private String testRootPath;
- private ResourceResolver resourceResolver;
private long lastModified;
private Random random = new Random(System.currentTimeMillis());
- private static final MimeTypeService mimeTypeService = new MockMimeTypeService();
private ResourceAssertions A;
- @Rule
- public SlingContext context = new SlingContext(ResourceResolverType.RESOURCERESOLVER_MOCK);
+ @Mock
+ private MimeTypeService mimeTypeService;
+
+ private ResourceResolver resourceResolver;
private Resource getTestRoot(String path) throws PersistenceException {
- final Resource root = context.resourceResolver().resolve("/");
+ final Resource root = resourceResolver.resolve("/");
assertNotNull("Expecting non-null root", root);
return resourceResolver.create(root, ResourceUtil.getName(path), null);
}
@@ -82,9 +85,11 @@ public class ResourceBuilderImplTest {
}
@Before
- public void setup() {
+ public void setup() throws Exception {
+ when(mimeTypeService.getMimeType(anyString())).thenReturn("application/javascript");
+ resourceResolver = new MockResourceResolverFactory().getResourceResolver(null);
+
testRootPath = "/" + UUID.randomUUID().toString();
- resourceResolver = context.resourceResolver();
A = new ResourceAssertions(testRootPath, resourceResolver);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 08/25: Rats - the rat
plugin was unhappy when building from this folder
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 290cd24c71325a22f2571c7829f0a2edb7cee7b9
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Sep 7 05:58:42 2016 +0000
Rats - the rat plugin was unhappy when building from this folder
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759545 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/pom.xml b/pom.xml
index f1690af..5f62447 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,20 @@
<url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
</scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>sling/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<modules>
<module>impl</module>
<module>integration-tests</module>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 23/25:
[maven-release-plugin] prepare release
org.apache.sling.resourcebuilder-1.0.2
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 3650738f41842c6315c2f0f38fe8c8a28a069791
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Oct 14 22:15:02 2016 +0000
[maven-release-plugin] prepare release org.apache.sling.resourcebuilder-1.0.2
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764975 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index e9c437b..b4014e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2</version>
<packaging>bundle</packaging>
<name>Apache Sling Resource Builder</name>
@@ -53,9 +53,9 @@
<jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
</properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 19/25: switch back to
released versions
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 89079125f5ec62bda089fa9f1c93f28a7320649e
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 19 09:26:36 2016 +0000
switch back to released versions
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1761405 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index a6bd885..79d4f6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,7 +234,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.19-SNAPSHOT</version>
+ <version>1.0.18</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -246,7 +246,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.teleporter</artifactId>
- <version>1.0.9-SNAPSHOT</version>
+ <version>1.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 05/25: add
infinitest.filters to ignore list
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 6b2675ef716bac54ad375e9927930fc51f6b02d4
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Sep 6 10:07:26 2016 +0000
add infinitest.filters to ignore list
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759403 13f79535-47bb-0310-9956-ffa450edef68
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 0829d12..a9c1268 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-sling
\ No newline at end of file
+sling
+infinitest.filters
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 20/25: SLING-6132
ResourceBuilder: Use absolute resource path should switch to hierachy mode
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit fcc410761f299058bf9b01963462f40532d46eec
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Oct 11 16:39:43 2016 +0000
SLING-6132 ResourceBuilder: Use absolute resource path should switch to hierachy mode
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764295 13f79535-47bb-0310-9956-ffa450edef68
---
.../resourcebuilder/impl/ResourceBuilderImpl.java | 7 ++++---
.../impl/ResourceBuilderImplTest.java | 20 ++++++++++++++++++++
.../resourcebuilder/test/ResourceAssertions.java | 2 +-
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
index fcc4cae..d95d35a 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -112,7 +112,8 @@ public class ResourceBuilderImpl implements ResourceBuilder {
final String parentPath;
final String fullPath;
- if (isAbsolutePath(path)) {
+ boolean absolutePath = isAbsolutePath(path);
+ if (absolutePath) {
parentPath = ResourceUtil.getParent(path);
fullPath = path;
}
@@ -145,8 +146,8 @@ public class ResourceBuilderImpl implements ResourceBuilder {
if (r == null) {
throw new RuntimeException("Failed to get or create resource " + fullPath);
- } else if(hierarchyMode) {
- return cloneResourceBuilder(r, this.intermediatePrimaryType, this.hierarchyMode);
+ } else if (hierarchyMode || absolutePath) {
+ return cloneResourceBuilder(r, this.intermediatePrimaryType, true);
}
return this;
}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index e025c16..4289489 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -367,6 +367,26 @@ public class ResourceBuilderImplTest {
}
@Test
+ public void absolutePathSwitchBackToSiblingMode() throws Exception {
+ new ResourceBuilderFactoryService()
+ .forResolver(resourceResolver)
+ .resource("/a").siblingsMode().resource("a1").resource("a2")
+ .resource("/b").siblingsMode().resource("b1").resource("b2")
+ .resource("/c").resource("c1").resource("c11");
+
+ // make sure sibling mode is switched back to hierarchy mode when absolute resources is used
+ A.assertResource("/a");
+ A.assertResource("/a/a1");
+ A.assertResource("/a/a2");
+ A.assertResource("/b");
+ A.assertResource("/b/b1");
+ A.assertResource("/b/b2");
+ A.assertResource("/c");
+ A.assertResource("/c/c1");
+ A.assertResource("/c/c1/c11");
+ }
+
+ @Test
public void reuseInstance() throws Exception {
ResourceBuilder content = new ResourceBuilderFactoryService()
.forResolver(resourceResolver)
diff --git a/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java b/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
index cea2069..787c66d 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
@@ -52,7 +52,7 @@ public class ResourceAssertions {
}
public Resource assertResource(String path) {
- final Resource result = resourceResolver.resolve(fullPath(path));
+ final Resource result = resourceResolver.getResource(fullPath(path));
assertNotNull("Expecting resource to exist:" + path, result);
return result;
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 11/25: update testing
dependencies
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 793a42627aaa3f388643b5fafa56c6d81855fd44
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 8 13:05:17 2016 +0000
update testing dependencies
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759812 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3713f2c..4f75093 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,13 +234,13 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.14</version>
+ <version>1.0.17-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.10</version>
+ <version>1.0.14</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 24/25:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 6eb1bb3bad6d6c3ffd5363c47282971f13d652ea
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Oct 14 22:15:17 2016 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764977 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index b4014e9..e525975 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Apache Sling Resource Builder</name>
@@ -53,9 +53,9 @@
<jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
</properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.resourcebuilder-1.0.2</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 22/25: SLING-6132 fix
integration test setup
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 179a5dc6ff417bb616fca1d4637e09fadec7c6f1
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Oct 11 16:58:54 2016 +0000
SLING-6132 fix integration test setup
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764303 13f79535-47bb-0310-9956-ffa450edef68
---
src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java | 2 +-
.../java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java | 2 +-
src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java | 3 ---
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
index 1991c27..76630a8 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
@@ -56,7 +56,7 @@ public class FileRetrievalIT {
@Before
public void setup() throws LoginException, PersistenceException {
E = new TestEnvironment(teleporter);
- A = new ResourceAssertions(E.testRootPath, E.resolver);
+ A = new ResourceAssertions(E.parent.getPath(), E.resolver);
}
@After
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
index 9c16b12..3ec402c 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
@@ -49,7 +49,7 @@ public class ResourceBuilderIT {
@Before
public void setup() throws LoginException, PersistenceException {
E = new TestEnvironment(teleporter);
- A = new ResourceAssertions(E.testRootPath, E.resolver);
+ A = new ResourceAssertions(E.parent.getPath(), E.resolver);
}
@After
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
index f5625e9..0678392 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
@@ -28,7 +28,6 @@ import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.junit.rules.TeleporterRule;
import org.apache.sling.resourcebuilder.api.ResourceBuilder;
import org.apache.sling.resourcebuilder.api.ResourceBuilderFactory;
-import org.apache.sling.resourcebuilder.test.ResourceAssertions;
class TestEnvironment {
@@ -37,7 +36,6 @@ class TestEnvironment {
final ResourceResolver resolver;
final String testRootPath;
final Resource parent;
- final ResourceAssertions A;
TestEnvironment(TeleporterRule teleporter) throws LoginException, PersistenceException {
testRootPath = getClass().getSimpleName() + "-" + UUID.randomUUID().toString();
@@ -46,7 +44,6 @@ class TestEnvironment {
parent = resolver.create(root, testRootPath, null);
builderService = teleporter.getService(ResourceBuilderFactory.class);
builder = builderService.forParent(parent);
- A = new ResourceAssertions(testRootPath, resolver);
}
void cleanup() throws PersistenceException {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 25/25: SLING-7167 Adjust
READMEs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 9d4549939444cfb9dcdcc3eca6751eb3e1201581
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 09:24:06 2017 +0000
SLING-7167 Adjust READMEs
add missing README
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810706 13f79535-47bb-0310-9956-ffa450edef68
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9f19557
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# Apache Sling Resource Builder
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 02/25: SLING-5712 - avoid
windows file separator issues in ClassResourceVisitor,
based on a patch by Emanuele Lombardi, thanks!
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 064b111683d57314f7241305e8859bb56ed1f825
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed May 11 14:16:08 2016 +0000
SLING-5712 - avoid windows file separator issues in ClassResourceVisitor, based on a patch by Emanuele Lombardi, thanks!
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1743376 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 427019b..3b90050 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,8 +240,8 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.teleporter</artifactId>
- <!-- SNAPSHOT required due to SLING-5365 -->
- <version>1.0.5-SNAPSHOT</version>
+ <!-- SNAPSHOT required due to SLING-5712 -->
+ <version>1.0.7-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 04/25: SLING-6036
ResourceBuilder: Reusing ResourceBuilder instances
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 3813d4e8bf81d3c1c692fa22cf25e324fb7473b8
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 5 20:06:48 2016 +0000
SLING-6036 ResourceBuilder: Reusing ResourceBuilder instances
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759351 13f79535-47bb-0310-9956-ffa450edef68
---
.../resourcebuilder/impl/ResourceBuilderImpl.java | 35 ++++++++++++----------
.../impl/ResourceBuilderImplTest.java | 22 +++++++++++++-
2 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
index 4905387..3440a27 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -59,8 +59,18 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
originalParent = parent;
resourceResolver = originalParent.getResourceResolver();
- withIntermediatePrimaryType(null);
- atParent();
+ intermediatePrimaryType = DEFAULT_PRIMARY_TYPE;
+ currentParent = parent;
+ hierarchyMode = true;
+ }
+
+ private ResourceBuilderImpl cloneResourceBuilder(Resource newCurrentParent,
+ String newIntermediatePrimaryType, boolean newHierarchyMode) {
+ ResourceBuilderImpl clone = new ResourceBuilderImpl(originalParent, mimeTypeService);
+ clone.currentParent = newCurrentParent;
+ clone.intermediatePrimaryType = newIntermediatePrimaryType;
+ clone.hierarchyMode = newHierarchyMode;
+ return clone;
}
@Override
@@ -80,9 +90,7 @@ public class ResourceBuilderImpl implements ResourceBuilder {
@Override
public ResourceBuilder atParent() {
- currentParent = originalParent;
- hierarchyMode();
- return this;
+ return cloneResourceBuilder(originalParent, this.intermediatePrimaryType, true);
}
private boolean isAbsolutePath(String path) {
@@ -145,10 +153,10 @@ public class ResourceBuilderImpl implements ResourceBuilder {
"PersistenceException while creating Resource " + fullPath, pex);
}
- if(r == null) {
+ if (r == null) {
throw new RuntimeException("Failed to get or create resource " + fullPath);
} else if(hierarchyMode) {
- currentParent = r;
+ return cloneResourceBuilder(r, this.intermediatePrimaryType, this.hierarchyMode);
}
return this;
}
@@ -231,9 +239,8 @@ public class ResourceBuilderImpl implements ResourceBuilder {
throw new RuntimeException("Unable to get or created file resource " + relativePath + " under " + currentParent.getPath());
}
if(hierarchyMode) {
- currentParent = file;
+ return cloneResourceBuilder(file, this.intermediatePrimaryType, this.hierarchyMode);
}
-
return this;
}
@@ -244,20 +251,18 @@ public class ResourceBuilderImpl implements ResourceBuilder {
@Override
public ResourceBuilder withIntermediatePrimaryType(String primaryType) {
- intermediatePrimaryType = primaryType == null ? DEFAULT_PRIMARY_TYPE : primaryType;
- return this;
+ String intermediatePrimaryType = primaryType == null ? DEFAULT_PRIMARY_TYPE : primaryType;
+ return cloneResourceBuilder(currentParent, intermediatePrimaryType, hierarchyMode);
}
@Override
public ResourceBuilder siblingsMode() {
- hierarchyMode = false;
- return this;
+ return cloneResourceBuilder(currentParent, intermediatePrimaryType, false);
}
@Override
public ResourceBuilder hierarchyMode() {
- hierarchyMode = true;
- return this;
+ return cloneResourceBuilder(currentParent, intermediatePrimaryType, true);
}
@Override
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index 6d3cf52..def23ac 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -30,6 +30,7 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
import org.apache.sling.resourcebuilder.test.ResourceAssertions;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
@@ -345,5 +346,24 @@ public class ResourceBuilderImplTest {
A.assertResource("/g/h/i/j/l/m");
A.assertResource("/o/p/q");
}
-
+
+ @Test
+ public void reuseInstance() throws Exception {
+ ResourceBuilder content = new ResourceBuilderService()
+ .forResolver(resourceResolver)
+ .resource("/content");
+ content.resource("a");
+ content.resource("b/c");
+ content.resource("/test")
+ .siblingsMode()
+ .resource("1")
+ .resource("2");
+
+ A.assertResource("/content/a");
+ A.assertResource("/content/b/c");
+ A.assertResource("/test");
+ A.assertResource("/test/1");
+ A.assertResource("/test/2");
+ }
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 09/25: SLING-6040 revert
last two commits rev. 1759507, 1759545 - there is a better solution
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit ffe1cdd3271f910e4b3e38a881b3ecaaecc9387a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 8 12:54:03 2016 +0000
SLING-6040 revert last two commits rev. 1759507, 1759545 - there is a better solution
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759803 13f79535-47bb-0310-9956-ffa450edef68
---
integration-tests/.gitignore => .gitignore | 0
impl/pom.xml | 86 -------
integration-tests/pom.xml | 264 ---------------------
pom.xml | 218 ++++++++++++++++-
.../sling/resourcebuilder/api/ResourceBuilder.java | 0
.../api/ResourceBuilderFactory.java | 0
.../resourcebuilder/impl/MapArgsConverter.java | 0
.../impl/ResourceBuilderFactoryService.java | 0
.../resourcebuilder/impl/ResourceBuilderImpl.java | 0
.../customizers/RBIT_TeleporterCustomizer.java | 0
.../resourcebuilder/impl/MapArgsConverterTest.java | 0
.../impl/ResourceBuilderImplTest.java | 4 -
.../sling/resourcebuilder/it/FileRetrievalIT.java | 0
.../resourcebuilder/it/ResourceBuilderIT.java | 0
.../sling/resourcebuilder/it/TestEnvironment.java | 0
.../resourcebuilder/test/ResourceAssertions.java | 0
.../src => src}/test/resources/files/models.js | 0
.../src => src}/test/resources/files/myapp.json | 0
.../src => src}/test/resources/files/text.html | 0
19 files changed, 206 insertions(+), 366 deletions(-)
diff --git a/integration-tests/.gitignore b/.gitignore
similarity index 100%
rename from integration-tests/.gitignore
rename to .gitignore
diff --git a/impl/pom.xml b/impl/pom.xml
deleted file mode 100644
index f1bc4f5..0000000
--- a/impl/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>26</version>
- <relativePath/>
- </parent>
-
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Sling Resource Builder</name>
- <description>Utilities to create Sling content</description>
-
- <scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder/impl</url>
- </scm>
-
- <build>
- <plugins>
- <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>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.mime</artifactId>
- <version>2.1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
deleted file mode 100644
index 8ed0a79..0000000
--- a/integration-tests/pom.xml
+++ /dev/null
@@ -1,264 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>26</version>
- <relativePath/>
- </parent>
-
- <artifactId>org.apache.sling.resourcebuilder.integration-tests</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Sling Resource Builder Integration Tests</name>
- <description>Utilities to create Sling content</description>
-
- <properties>
- <!-- version of the ResourceBuilder impl -->
- <resourcebuilder.version>0.0.1-SNAPSHOT</resourcebuilder.version>
-
- <!-- Set this to run the server on a specific port
- <http.port></http.port>
- -->
-
- <!-- Set this to run tests against an existing server instance -->
- <keepJarRunning>false</keepJarRunning>
-
- <!--
- Options for the VM that executes our runnable jar.
- Set debugging options here to debug teleported tests.
- -->
- <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
-
- <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
- selected port number -->
- <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
- </properties>
- <scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</url>
- </scm>
-
- <build>
- <plugins>
- <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>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>src/test/resources/**</exclude>
- <exclude>sling/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <!-- Find free ports to run our server -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>reserve-server-port</id>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <portNames>
- <portName>http.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}</directory>
- <includes>
- <!-- sling folder is the workdir of the executable jar that we test -->
- <include>sling/**</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <systemPropertyVariables>
- <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
- <keepJarRunning>${keepJarRunning}</keepJarRunning>
- <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
- <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
- <jar.executor.server.port>${http.port}</jar.executor.server.port>
- <additional.bundles.path>${project.build.directory}</additional.bundles.path>
- <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
- <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
- <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
-
- <!-- Additional bundles to install for testing -->
- <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
- <sling.additional.bundle.2>org.apache.sling.resourcebuilder-${resourcebuilder.version}.jar</sling.additional.bundle.2>
- <sling.additional.bundle.3>${project.artifactId}-${project.version}.jar</sling.additional.bundle.3>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-runnable-jar</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- <execution>
- <!--
- Consider all dependencies as candidates to be installed
- as additional bundles. We use system properties to define
- which bundles to install in which order.
- -->
- <id>copy-additional-bundles</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>${resourcebuilder.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.mime</artifactId>
- <version>2.1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>1.6.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.14</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.teleporter</artifactId>
- <!-- SNAPSHOT required due to SLING-5712 -->
- <version>1.0.7-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad</artifactId>
- <version>8</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/pom.xml b/pom.xml
index 5f62447..3b90050 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,35 +27,229 @@
<relativePath/>
</parent>
- <artifactId>org.apache.sling.resourcebuilder.reactor</artifactId>
- <packaging>pom</packaging>
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Apache Sling Resource Builder Reactor</name>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Resource Builder</name>
<description>Utilities to create Sling content</description>
+ <properties>
+ <!-- Set this to run the server on a specific port
+ <http.port></http.port>
+ -->
+
+ <!-- Set this to run tests against an existing server instance -->
+ <keepJarRunning>false</keepJarRunning>
+
+ <!--
+ Options for the VM that executes our runnable jar.
+ Set debugging options here to debug teleported tests.
+ -->
+ <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
+
+ <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
+ selected port number -->
+ <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
+ </properties>
<scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</developerConnection>
- <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/resourcebuilder</url>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</url>
</scm>
-
+
<build>
<plugins>
<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>
+ </plugin>
+ <plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes>
+ <exclude>src/test/resources/**</exclude>
<exclude>sling/**</exclude>
</excludes>
</configuration>
</plugin>
- </plugins>
+ <plugin>
+ <!-- Find free ports to run our server -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>reserve-server-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>http.port</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}</directory>
+ <includes>
+ <!-- sling folder is the workdir of the executable jar that we test -->
+ <include>sling/**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <systemPropertyVariables>
+ <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
+ <keepJarRunning>${keepJarRunning}</keepJarRunning>
+ <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
+ <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
+ <jar.executor.server.port>${http.port}</jar.executor.server.port>
+ <additional.bundles.path>${project.build.directory}</additional.bundles.path>
+ <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
+ <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
+ <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
+
+ <!-- Additional bundles to install for testing -->
+ <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
+ <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-runnable-jar</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ <execution>
+ <!--
+ Consider all dependencies as candidates to be installed
+ as additional bundles. We use system properties to define
+ which bundles to install in which order.
+ -->
+ <id>copy-additional-bundles</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
- <modules>
- <module>impl</module>
- <module>integration-tests</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.core</artifactId>
+ <version>1.0.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.tools</artifactId>
+ <version>1.0.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.teleporter</artifactId>
+ <!-- SNAPSHOT required due to SLING-5712 -->
+ <version>1.0.7-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.launchpad</artifactId>
+ <version>8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
similarity index 100%
rename from impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
rename to src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
diff --git a/impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
similarity index 100%
rename from impl/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
rename to src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
diff --git a/impl/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java b/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
similarity index 100%
rename from impl/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
rename to src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
diff --git a/impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
similarity index 100%
rename from impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
rename to src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
diff --git a/impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
similarity index 100%
rename from impl/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
rename to src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
diff --git a/integration-tests/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java b/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
similarity index 100%
rename from integration-tests/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
rename to src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
diff --git a/impl/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
similarity index 100%
rename from impl/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
rename to src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
diff --git a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
similarity index 98%
rename from integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
rename to src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index 45f4df0..9ab055f 100644
--- a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -40,10 +40,6 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-/**
- * This unit test is not part of the ResourceBuilder impl project to avoid a dependency
- * to the sling-mock project there (because sling-mock itself has a dependency to the ResourceBuilder).
- */
public class ResourceBuilderImplTest {
private String testRootPath;
diff --git a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
similarity index 100%
rename from integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
rename to src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
diff --git a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
similarity index 100%
rename from integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
rename to src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
diff --git a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
similarity index 100%
rename from integration-tests/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
rename to src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
diff --git a/integration-tests/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java b/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
similarity index 100%
rename from integration-tests/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
rename to src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
diff --git a/integration-tests/src/test/resources/files/models.js b/src/test/resources/files/models.js
similarity index 100%
rename from integration-tests/src/test/resources/files/models.js
rename to src/test/resources/files/models.js
diff --git a/integration-tests/src/test/resources/files/myapp.json b/src/test/resources/files/myapp.json
similarity index 100%
rename from integration-tests/src/test/resources/files/myapp.json
rename to src/test/resources/files/myapp.json
diff --git a/integration-tests/src/test/resources/files/text.html b/src/test/resources/files/text.html
similarity index 100%
rename from integration-tests/src/test/resources/files/text.html
rename to src/test/resources/files/text.html
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 01/25: SLING-5356 - move
resourcebuilder under bundles/extensions
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit a3e05facc03919f2c21a32918bde2b5fc9ddecc7
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Jan 6 13:59:59 2016 +0000
SLING-5356 - move resourcebuilder under bundles/extensions
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1723329 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 255 ++++++++++++++++
.../sling/resourcebuilder/api/ResourceBuilder.java | 102 +++++++
.../resourcebuilder/impl/MapArgsConverter.java | 43 +++
.../resourcebuilder/impl/ResourceBuilderImpl.java | 261 ++++++++++++++++
.../impl/ResourceBuilderService.java | 110 +++++++
.../customizers/RBIT_TeleporterCustomizer.java | 46 +++
.../resourcebuilder/impl/MapArgsConverterTest.java | 49 +++
.../impl/ResourceBuilderImplTest.java | 335 +++++++++++++++++++++
.../sling/resourcebuilder/it/FileRetrievalIT.java | 93 ++++++
.../resourcebuilder/it/ResourceBuilderIT.java | 127 ++++++++
.../sling/resourcebuilder/it/TestEnvironment.java | 57 ++++
.../resourcebuilder/test/ResourceAssertions.java | 136 +++++++++
src/test/resources/files/models.js | 1 +
src/test/resources/files/myapp.json | 4 +
src/test/resources/files/text.html | 3 +
15 files changed, 1622 insertions(+)
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..427019b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>26</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Resource Builder</name>
+ <description>Utilities to create Sling content</description>
+
+ <properties>
+ <!-- Set this to run the server on a specific port
+ <http.port></http.port>
+ -->
+
+ <!-- Set this to run tests against an existing server instance -->
+ <keepJarRunning>false</keepJarRunning>
+
+ <!--
+ Options for the VM that executes our runnable jar.
+ Set debugging options here to debug teleported tests.
+ -->
+ <jar.executor.vm.options>-Xmx512m</jar.executor.vm.options>
+
+ <!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
+ selected port number -->
+ <jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
+ </properties>
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</developerConnection>
+ <url>https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/resourcebuilder</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <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>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>src/test/resources/**</exclude>
+ <exclude>sling/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- Find free ports to run our server -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>reserve-server-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>http.port</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}</directory>
+ <includes>
+ <!-- sling folder is the workdir of the executable jar that we test -->
+ <include>sling/**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <systemPropertyVariables>
+ <!-- these are the minimal options required for the jar executor, see bundle-with-it module for more -->
+ <keepJarRunning>${keepJarRunning}</keepJarRunning>
+ <jar.executor.jar.options>${jar.executor.jar.options}</jar.executor.jar.options>
+ <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
+ <jar.executor.server.port>${http.port}</jar.executor.server.port>
+ <additional.bundles.path>${project.build.directory}</additional.bundles.path>
+ <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
+ <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
+ <server.ready.path.3>/sling-test/sling/sling-test.html:Sling client library tests</server.ready.path.3>
+
+ <!-- Additional bundles to install for testing -->
+ <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
+ <sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-runnable-jar</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <includeArtifactIds>org.apache.sling.launchpad</includeArtifactIds>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ <execution>
+ <!--
+ Consider all dependencies as candidates to be installed
+ as additional bundles. We use system properties to define
+ which bundles to install in which order.
+ -->
+ <id>copy-additional-bundles</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <excludeTransitive>true</excludeTransitive>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.core</artifactId>
+ <version>1.0.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.tools</artifactId>
+ <version>1.0.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.teleporter</artifactId>
+ <!-- SNAPSHOT required due to SLING-5365 -->
+ <version>1.0.5-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.launchpad</artifactId>
+ <version>8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
new file mode 100644
index 0000000..1a1f965
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.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.resourcebuilder.api;
+
+import java.io.InputStream;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+
+import aQute.bnd.annotation.ProviderType;
+
+/** Builds Sling Resources using a simple fluent API */
+@ProviderType
+public interface ResourceBuilder {
+
+ /** Default primary type for resources created by this builder */
+ public static final String DEFAULT_PRIMARY_TYPE = "nt:unstructured";
+
+ /** Start a ResourceBuilder using the supplied parent resource
+ * @return the new builder
+ * */
+ ResourceBuilder forParent(Resource parent);
+
+ /** Start a ResourceBuilder using the supplied ResourceResolver,
+ * starting with the root resource as the builder's parent resource.
+ * @return the new builder
+ * */
+ ResourceBuilder forResolver(ResourceResolver r);
+
+ /** Create a Resource, which optionally becomes the current
+ * parent Resource.
+ * @param relativePath The path of the Resource to create, relative to
+ * this builder's current parent Resource.
+ * @param properties optional name-value pairs
+ * @return this builder
+ */
+ ResourceBuilder resource(String relativePath, Object ... properties);
+
+ /** Create a file under the current parent resource
+ * @param filename The name of the created file
+ * @param data The file data
+ * @param mimeType If null, use the Sling MimeTypeService to set the mime type
+ * @param lastModified if < 0, current time is used
+ * @return this builder
+ */
+ ResourceBuilder file(String filename, InputStream data, String mimeType, long lastModified);
+
+ /** Create a file under the current parent resource. Mime type is set using the
+ * Sling MimeTypeService, and last modified is set to current time.
+ * @param filename The name of the created file
+ * @param data The file data
+ * @return this builder
+ */
+ ResourceBuilder file(String filename, InputStream data);
+
+ /** Commit created resources */
+ ResourceBuilder commit();
+
+ /** Set the primary type for intermediate resources created
+ * when the parent of resource being created does not exist.
+ * @param primaryType If null the DEFAULT_PRIMARY_TYPE is used.
+ * @return this builder
+ */
+ ResourceBuilder withIntermediatePrimaryType(String primaryType);
+
+ /** Set siblings mode (as opposed to hierarchy mode) where creating a resource
+ * doesn't change the current parent. Used to create flat structures.
+ * This is off by default.
+ * @return this builder
+ */
+ ResourceBuilder siblingsMode();
+
+ /** Set hierarchy mode (as opposed to siblings mode) where creating a resource
+ * sets it as the current parent. Used to create tree structures.
+ * This is on by default.
+ * @return this builder
+ */
+ ResourceBuilder hierarchyMode();
+
+ /** Return the current parent resource */
+ Resource getCurrentParent();
+
+ /** Reset the current parent Resource to the original one.
+ * Also activates hierarchyMode which is the default mode. */
+ ResourceBuilder atParent();
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java b/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.java
new file mode 100644
index 0000000..433dfb2
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/MapArgsConverter.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.resourcebuilder.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Convert arguments which are a list of Object to a Map, used
+ * to simplify our builder's syntax.
+ */
+public class MapArgsConverter {
+
+ /** Convert an args list to a Map */
+ public static Map<String, Object> toMap(Object ... args) {
+ if(args.length % 2 != 0) {
+ throw new IllegalArgumentException("args must be an even number of name/values:" + Arrays.asList(args));
+ }
+ final Map<String, Object> result = new HashMap<String, Object>();
+ for(int i=0 ; i < args.length; i+=2) {
+ result.put(args[i].toString(), args[i+1]);
+ }
+ return Collections.unmodifiableMap(result);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
new file mode 100644
index 0000000..48b9be9
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -0,0 +1,261 @@
+/*
+ * 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.resourcebuilder.impl;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.api.resource.ModifiableValueMap;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+
+/** ResourceBuilder implementation */
+public class ResourceBuilderImpl implements ResourceBuilder {
+ private final Resource originalParent;
+ private final ResourceResolver resourceResolver;
+ private Resource currentParent;
+ private String intermediatePrimaryType;
+ private boolean hierarchyMode;
+
+ public static final String JCR_PRIMARYTYPE = "jcr:primaryType";
+ public static final String JCR_MIMETYPE = "jcr:mimeType";
+ public static final String JCR_LASTMODIFIED = "jcr:lastModified";
+ public static final String JCR_DATA = "jcr:data";
+ public static final String JCR_CONTENT = "jcr:content";
+ public static final String NT_RESOURCE = "nt:resource";
+ public static final String NT_FILE = "nt:file";
+
+ public static final String CANNOT_RESTART =
+ "Cannot reset the parent resource or resource resolver, please create a new "
+ + "builder using the ResourceBuilder service";
+
+ private final MimeTypeService mimeTypeService;
+
+ public ResourceBuilderImpl(Resource parent, MimeTypeService mts) {
+ mimeTypeService = mts;
+ if(parent == null) {
+ throw new IllegalArgumentException("Parent resource is null");
+ }
+ originalParent = parent;
+ resourceResolver = originalParent.getResourceResolver();
+ withIntermediatePrimaryType(null);
+ atParent();
+ }
+
+ @Override
+ public ResourceBuilder forParent(Resource parent) {
+ throw new UnsupportedOperationException(CANNOT_RESTART);
+ }
+
+ @Override
+ public ResourceBuilder forResolver(ResourceResolver v) {
+ throw new UnsupportedOperationException(CANNOT_RESTART);
+ }
+
+ @Override
+ public Resource getCurrentParent() {
+ return currentParent;
+ }
+
+ @Override
+ public ResourceBuilder atParent() {
+ currentParent = originalParent;
+ hierarchyMode();
+ return this;
+ }
+
+ private void checkRelativePath(String relativePath) {
+ if(relativePath.startsWith("/")) {
+ throw new IllegalArgumentException("Path is not relative:" + relativePath);
+ }
+ if(relativePath.contains("..")) {
+ throw new IllegalArgumentException("Path contains invalid pattern '..': " + relativePath);
+ }
+ }
+
+ private String parentPath(String relativePath) {
+ final String parentPath = currentParent.getPath();
+ final String fullPath =
+ parentPath.endsWith("/") ?
+ parentPath + relativePath :
+ parentPath + "/" + relativePath;
+ return ResourceUtil.getParent(fullPath);
+ }
+
+ @Override
+ public ResourceBuilder resource(String relativePath, Object... properties) {
+ Resource r = null;
+ checkRelativePath(relativePath);
+ final String parentPath = parentPath(relativePath);
+ final Resource myParent = ensureResourceExists(parentPath);
+ final String fullPath = currentParent.getPath() + "/" + relativePath;
+
+ try {
+ r = currentParent.getResourceResolver().getResource(fullPath);
+ final Map<String, Object> props = MapArgsConverter.toMap(properties);
+ if(r == null) {
+ r = currentParent.getResourceResolver().create(myParent,
+ ResourceUtil.getName(relativePath), props);
+ } else {
+ // Resource exists, set our properties
+ final ModifiableValueMap mvm = r.adaptTo(ModifiableValueMap.class);
+ if(mvm == null) {
+ throw new IllegalStateException("Cannot modify properties of " + r.getPath());
+ }
+ for(Map.Entry <String, Object> e : props.entrySet()) {
+ mvm.put(e.getKey(), e.getValue());
+ }
+ }
+ } catch(PersistenceException pex) {
+ throw new RuntimeException(
+ "PersistenceException while creating Resource " + relativePath
+ + " under " + currentParent.getPath(), pex);
+ }
+
+ if(r == null) {
+ throw new RuntimeException("Failed to get or create resource " + relativePath
+ + " under " + currentParent.getPath());
+ } else if(hierarchyMode) {
+ currentParent = r;
+ }
+ return this;
+ }
+
+ /** Create a Resource at the specified path if none exists yet,
+ * using the current intermediate primary type. "Stolen" from
+ * the sling-mock module's ContentBuilder class.
+ * @param path Resource path
+ * @return Resource at path (existing or newly created)
+ */
+ protected final Resource ensureResourceExists(String path) {
+ if(path == null || path.length() == 0 || path.equals("/")) {
+ return resourceResolver.getResource("/");
+ }
+ Resource resource = resourceResolver.getResource(path);
+ if (resource != null) {
+ return resource;
+ }
+ String parentPath = ResourceUtil.getParent(path);
+ String name = ResourceUtil.getName(path);
+ Resource parentResource = ensureResourceExists(parentPath);
+ try {
+ resource = resourceResolver.create(
+ parentResource,
+ name,
+ MapArgsConverter.toMap(JCR_PRIMARYTYPE, intermediatePrimaryType));
+ return resource;
+ } catch (PersistenceException ex) {
+ throw new RuntimeException("Unable to create intermediate resource at " + path, ex);
+ }
+ }
+
+ protected String getMimeType(String filename, String userSuppliedMimeType) {
+ if(userSuppliedMimeType != null) {
+ return userSuppliedMimeType;
+ }
+ return mimeTypeService.getMimeType(filename);
+ }
+
+ protected long getLastModified(long userSuppliedValue) {
+ if(userSuppliedValue < 0) {
+ return System.currentTimeMillis();
+ }
+ return userSuppliedValue;
+ }
+
+ @Override
+ public ResourceBuilder file(String relativePath, InputStream data, String mimeType, long lastModified) {
+ checkRelativePath(relativePath);
+ final String name = ResourceUtil.getName(relativePath);
+ if(data == null) {
+ throw new IllegalArgumentException("Data is null for file " + name);
+ }
+
+ Resource file = null;
+ final ResourceResolver resolver = currentParent.getResourceResolver();
+ final String parentPath = parentPath(relativePath);
+
+ final Resource parent = ensureResourceExists(parentPath);
+ try {
+ final String fullPath = currentParent.getPath() + "/" + name;
+ if(resolver.getResource(fullPath) != null) {
+ throw new IllegalStateException("Resource already exists:" + fullPath);
+ }
+ final Map<String, Object> fileProps = new HashMap<String, Object>();
+ fileProps.put(JCR_PRIMARYTYPE, NT_FILE);
+ file = resolver.create(parent, name, fileProps);
+
+ final Map<String, Object> contentProps = new HashMap<String, Object>();
+ contentProps.put(JCR_PRIMARYTYPE, NT_RESOURCE);
+ contentProps.put(JCR_MIMETYPE, getMimeType(name, mimeType));
+ contentProps.put(JCR_LASTMODIFIED, getLastModified(lastModified));
+ contentProps.put(JCR_DATA, data);
+ resolver.create(file, JCR_CONTENT, contentProps);
+ } catch(PersistenceException pex) {
+ throw new RuntimeException("Unable to create file under " + currentParent.getPath(), pex);
+ }
+
+ if(file == null) {
+ throw new RuntimeException("Unable to get or created file resource " + relativePath + " under " + currentParent.getPath());
+ }
+ if(hierarchyMode) {
+ currentParent = file;
+ }
+
+ return this;
+ }
+
+ @Override
+ public ResourceBuilder file(String filename, InputStream data) {
+ return file(filename, data, null, -1);
+ }
+
+ @Override
+ public ResourceBuilder withIntermediatePrimaryType(String primaryType) {
+ intermediatePrimaryType = primaryType == null ? DEFAULT_PRIMARY_TYPE : primaryType;
+ return this;
+ }
+
+ @Override
+ public ResourceBuilder siblingsMode() {
+ hierarchyMode = false;
+ return this;
+ }
+
+ @Override
+ public ResourceBuilder hierarchyMode() {
+ hierarchyMode = true;
+ return this;
+ }
+
+ @Override
+ public ResourceBuilder commit() {
+ try {
+ resourceResolver.commit();
+ } catch (PersistenceException ex) {
+ throw new RuntimeException("Unable to commit", ex);
+ }
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java
new file mode 100644
index 0000000..87f68db
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java
@@ -0,0 +1,110 @@
+/*
+ * 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.resourcebuilder.impl;
+
+import java.io.InputStream;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+
+/** ResourceBuilder service, only implements the for* methods to
+ * create new builders. This allows us to provide a single service
+ * interface which transparently becomes stateful, by switching from
+ * this object to the ResourceBuilderImpl.
+ */
+@Component
+@Service(value=ResourceBuilder.class)
+public class ResourceBuilderService implements ResourceBuilder {
+
+ @Reference
+ private MimeTypeService mimeTypeService;
+
+
+ private ResourceBuilder notStarted() {
+ throw new IllegalStateException(
+ "This ResourceBuilder is not started, please use the"
+ + "forParent or forResolver methods to start it."
+ );
+ }
+
+ @Override
+ public ResourceBuilder forParent(Resource parent) {
+ return new ResourceBuilderImpl(parent, mimeTypeService);
+ }
+
+ @Override
+ public ResourceBuilder forResolver(ResourceResolver r) {
+ final Resource root = r.getResource("/");
+ if(root == null) {
+ throw new IllegalStateException("Cannot read root resource");
+ }
+ return forParent(root);
+ }
+
+ @Override
+ public ResourceBuilder resource(String relativePath, Object... properties) {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder file(String filename, InputStream data, String mimeType, long lastModified) {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder file(String filename, InputStream data) {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder commit() {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder withIntermediatePrimaryType(String primaryType) {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder siblingsMode() {
+ return notStarted();
+ }
+
+ @Override
+ public ResourceBuilder hierarchyMode() {
+ return notStarted();
+ }
+
+ @Override
+ public Resource getCurrentParent() {
+ notStarted();
+ return null;
+ }
+
+ @Override
+ public ResourceBuilder atParent() {
+ return notStarted();
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java b/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
new file mode 100644
index 0000000..765923b
--- /dev/null
+++ b/src/test/java/org/apache/sling/junit/teleporter/customizers/RBIT_TeleporterCustomizer.java
@@ -0,0 +1,46 @@
+/*
+ * 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.junit.teleporter.customizers;
+
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+import org.apache.sling.testing.teleporter.client.ClientSideTeleporter;
+import org.apache.sling.testing.tools.sling.SlingTestBase;
+import org.apache.sling.testing.tools.sling.TimeoutsProvider;
+
+import aQute.bnd.osgi.Constants;
+
+/** Setup the ClientSideTeleporter for our integration tests.
+ */
+public class RBIT_TeleporterCustomizer implements TeleporterRule.Customizer {
+
+ private final static SlingTestBase S = new SlingTestBase();
+
+ @Override
+ public void customize(TeleporterRule t, String options) {
+ final ClientSideTeleporter cst = (ClientSideTeleporter)t;
+ cst.setBaseUrl(S.getServerBaseUrl());
+ cst.setServerCredentials(S.getServerUsername(), S.getServerPassword());
+ cst.setTestReadyTimeoutSeconds(TimeoutsProvider.getInstance().getTimeout(5));
+
+ // Make sure our bundle API is imported instead of embedded
+ final String apiPackage = ResourceBuilder.class.getPackage().getName();
+ cst.includeDependencyPrefix("org.apache.sling.resourcebuilder");
+ cst.excludeDependencyPrefix(apiPackage);
+ cst.getAdditionalBundleHeaders().put(Constants.IMPORT_PACKAGE, apiPackage);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
new file mode 100644
index 0000000..ec1a411
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/MapArgsConverterTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.resourcebuilder.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.apache.sling.api.resource.PersistenceException;
+import org.junit.Test;
+
+public class MapArgsConverterTest {
+
+ @Test
+ public void validArguments() throws PersistenceException {
+ final Map<String, Object> m = MapArgsConverter.toMap("foo", "bar", "count", 21);
+ assertEquals(2, m.size());
+ assertEquals("bar", m.get("foo"));
+ assertEquals(21, m.get("count"));
+ }
+
+ @Test
+ public void noArguments() throws PersistenceException {
+ final Map<String, Object> m = MapArgsConverter.toMap();
+ assertTrue(m.isEmpty());
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void barArguments() throws PersistenceException {
+ MapArgsConverter.toMap("foo", "bar", "count");
+ }
+}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
new file mode 100644
index 0000000..608a813
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -0,0 +1,335 @@
+/*
+ * 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.resourcebuilder.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.resourcebuilder.test.ResourceAssertions;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.apache.sling.testing.mock.sling.services.MockMimeTypeService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class ResourceBuilderImplTest {
+
+ private String testRootPath;
+ private ResourceResolver resourceResolver;
+ private long lastModified;
+ private Random random = new Random(System.currentTimeMillis());
+ private static final MimeTypeService mimeTypeService = new MockMimeTypeService();
+ private ResourceAssertions A;
+
+ @Rule
+ public SlingContext context = new SlingContext(ResourceResolverType.RESOURCERESOLVER_MOCK);
+
+ private Resource getTestRoot(String path) throws PersistenceException {
+ final Resource root = context.resourceResolver().resolve("/");
+ assertNotNull("Expecting non-null root", root);
+ return resourceResolver.create(root, ResourceUtil.getName(path), null);
+ }
+
+ private ResourceBuilderImpl getBuilder(String path) throws Exception {
+ lastModified = random.nextLong();
+
+ final Resource parent = getTestRoot(path);
+ final ResourceBuilderImpl result = new ResourceBuilderImpl(parent, mimeTypeService) {
+ @Override
+ protected long getLastModified(long userSuppliedValue) {
+ final long now = System.currentTimeMillis();
+ final long superValue = super.getLastModified(-1);
+ final long maxDelta = 60 * 1000L;
+ if(superValue < now || superValue - now > maxDelta) {
+ fail("getLastModified does not seem to use current time as its default value");
+ }
+
+ if(userSuppliedValue >= 0) {
+ return super.getLastModified(userSuppliedValue);
+ }
+ return lastModified;
+ }
+ };
+ return result;
+ }
+
+ @Before
+ public void setup() {
+ testRootPath = "/" + UUID.randomUUID().toString();
+ resourceResolver = context.resourceResolver();
+ A = new ResourceAssertions(testRootPath, resourceResolver);
+ }
+
+ @After
+ public void cleanup() throws PersistenceException {
+ final Resource r = resourceResolver.getResource(testRootPath);
+ if(r != null) {
+ resourceResolver.delete(r);
+ resourceResolver.commit();
+ }
+ }
+
+ @Test
+ public void basicResource() throws Exception {
+ getBuilder(testRootPath)
+ .resource("child", "title", "foo")
+ .commit();
+
+ A.assertProperties("child", "title", "foo");
+ assertEquals(A.fullPath("child"), A.assertResource("child").getPath());
+ }
+
+ @Test
+ public void ensureResourceExists() throws Exception {
+
+ class MyResourceBuilder extends ResourceBuilderImpl {
+ MyResourceBuilder() {
+ super(resourceResolver.getResource("/"), null);
+ }
+
+ Resource r(String path) {
+ return ensureResourceExists(path);
+ }
+ };
+ final MyResourceBuilder b = new MyResourceBuilder();
+
+ assertEquals("/", b.r(null).getPath());
+ assertEquals("/", b.r("").getPath());
+ assertEquals("/", b.r("/").getPath());
+ }
+
+ @Test
+ public void deepResource() throws Exception {
+ getBuilder(testRootPath)
+ .resource("a/b/c", "title", "foo")
+ .commit();
+
+ A.assertProperties("a/b/c", "title", "foo");
+ assertEquals(A.fullPath("a/b/c"), A.assertResource("a/b/c").getPath());
+ A.assertResource("a/b");
+ A.assertResource("a");
+ }
+
+ @Test
+ public void intermediatePrimaryTypes() throws Exception {
+ getBuilder(testRootPath)
+ .resource("a/b/c")
+ .withIntermediatePrimaryType("foo")
+ .resource("d/e")
+ .withIntermediatePrimaryType(null)
+ .resource("f/g")
+ .commit();
+
+ A.assertProperties("a/b", ResourceBuilderImpl.JCR_PRIMARYTYPE, "nt:unstructured");
+ A.assertProperties("a/b/c/d", ResourceBuilderImpl.JCR_PRIMARYTYPE, "foo");
+ A.assertProperties("a/b/c/d/e/f", ResourceBuilderImpl.JCR_PRIMARYTYPE, "nt:unstructured");
+ }
+
+ @Test
+ public void resetParent() throws Exception {
+ getBuilder(testRootPath)
+ .resource("a/b/c")
+ .siblingsMode()
+ .resource("one")
+ .resource("two")
+ .atParent() // also sets hierarchyMode
+ .resource("d/e")
+ .resource("f/g")
+ .siblingsMode()
+ .resource("three")
+ .resource("four")
+ .commit();
+
+ A.assertResource("a/b/c");
+ A.assertResource("a/b/c/one");
+ A.assertResource("a/b/c/two");
+ A.assertResource("d/e");
+ A.assertResource("d/e/f/g");
+ A.assertResource("d/e/f/g/three");
+ A.assertResource("d/e/f/g/four");
+ }
+
+ @Test
+ public void noResetParent() throws Exception {
+ getBuilder(testRootPath)
+ .resource("a/b/c")
+ .resource("d/e")
+ .commit();
+
+ A.assertResource("a/b/c");
+ A.assertResource("a/b/c/d/e");
+ }
+
+ @Test
+ public void getParent() throws Exception {
+ final Resource parent = getBuilder(testRootPath).getCurrentParent();
+ assertNotNull(parent);
+ assertEquals(testRootPath, parent.getPath());
+ }
+
+ @Test(expected=RuntimeException.class)
+ public void missingParentFails() throws Exception {
+ new ResourceBuilderImpl(null, null).resource("foo");
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void absolutePathFails() throws Exception {
+ getBuilder(testRootPath).resource("/absolute");
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void aboveParentFails() throws Exception {
+ getBuilder(testRootPath).resource("../foo");
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void aboveParentFailsFile() throws Exception {
+ getBuilder(testRootPath).file("../foo.js", null);
+ }
+
+ @Test
+ public void simpleTree() throws Exception {
+ getBuilder(testRootPath)
+ .resource("a/b/c", "title", "foo", "count", 21)
+ .siblingsMode()
+ .resource("1")
+ .resource("2")
+ .resource("3")
+ .hierarchyMode()
+ .resource("with")
+ .resource("more/here", "it", "worked")
+ .resource("deepest", "it", "worked")
+ .commit();
+
+ A.assertProperties("a/b/c", "count", 21, "title", "foo");
+ A.assertProperties("a/b/c/with/more/here", "it", "worked");
+ A.assertResource("a/b/c/with/more/here/deepest");
+ A.assertResource("a/b/c/1");
+ A.assertResource("a/b/c/2");
+ A.assertResource("a/b/c/3");
+ }
+
+ @Test
+ public void treeWithFiles() throws Exception {
+ getBuilder(testRootPath)
+ .resource("apps/myapp/components/resource")
+ .siblingsMode()
+ .file("models.js", getClass().getResourceAsStream("/files/models.js"), "MT1", 42)
+ .file("text.html", getClass().getResourceAsStream("/files/text.html"), "MT2", 43)
+ .atParent()
+ .file("apps/myapp.json", getClass().getResourceAsStream("/files/myapp.json"), "MT3", 44)
+ .atParent()
+ .resource("apps/content/myapp/resource")
+ .atParent()
+ .resource("apps/content", "title", "foo")
+ .file("myapp.json", getClass().getResourceAsStream("/files/myapp.json"), "MT4", 45)
+ .commit()
+ ;
+
+ A.assertResource("apps/content/myapp/resource");
+ A.assertResource("apps/myapp/components/resource");
+ A.assertProperties("apps/content", "title", "foo");
+
+ A.assertFile("apps/myapp/components/resource/models.js",
+ "MT1", "function someJavascriptFunction()", 42L);
+ A.assertFile("apps/myapp/components/resource/text.html",
+ "MT2", "This is an html file", 43L);
+ A.assertFile("apps/myapp.json",
+ "MT3", "\"sling:resourceType\":\"its/resource/type\"", 44L);
+ A.assertFile("apps/content/myapp.json",
+ "MT4", "\"sling:resourceType\":\"its/resource/type\"", 45L);
+ }
+
+ @Test
+ public void autoMimetype() throws Exception {
+ getBuilder(testRootPath)
+ .file("models.js", getClass().getResourceAsStream("/files/models.js"), null, 42)
+ .commit()
+ ;
+ A.assertFile("models.js",
+ "application/javascript", "function someJavascriptFunction()", 42L);
+ }
+
+ @Test
+ public void autoLastModified() throws Exception {
+ getBuilder(testRootPath)
+ .file("models.js", getClass().getResourceAsStream("/files/models.js"), "MT1", -1)
+ .commit()
+ ;
+ A.assertFile("models.js",
+ "MT1", "function someJavascriptFunction()", lastModified);
+ }
+
+ @Test
+ public void autoEverything() throws Exception {
+ getBuilder(testRootPath)
+ .file("a/b/c/models.js", getClass().getResourceAsStream("/files/models.js"))
+ .commit()
+ ;
+ A.assertFile("a/b/c/models.js",
+ "application/javascript", "function someJavascriptFunction()", lastModified);
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void duplicatedFileFails() throws Exception {
+ getBuilder(testRootPath)
+ .siblingsMode()
+ .file("models.js", getClass().getResourceAsStream("/files/models.js"), null, 42)
+ .file("models.js", getClass().getResourceAsStream("/files/models.js"), null, 42)
+ ;
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void nullDataFails() throws Exception {
+ getBuilder(testRootPath)
+ .file("models.js", null, null, 42)
+ ;
+ }
+
+ @Test
+ public void forParent() throws PersistenceException {
+ new ResourceBuilderService()
+ .forParent(getTestRoot(testRootPath))
+ .resource("a/b/c")
+ .commit();
+ A.assertResource("a/b/c");
+ }
+
+ @Test
+ public void forResolver() throws PersistenceException {
+ new ResourceBuilderService()
+ .forResolver(resourceResolver)
+ .resource("d/e/f")
+ .commit();
+
+ // Resource is created at root in this case
+ A.assertResource("/d/e/f");
+ }
+}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
new file mode 100644
index 0000000..1991c27
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/FileRetrievalIT.java
@@ -0,0 +1,93 @@
+/*
+ * 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.resourcebuilder.it;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletException;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.resourcebuilder.test.ResourceAssertions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Verify that our file structure is correct,
+ * by creating a file and retrieving it via
+ * a Sling request.
+ */
+public class FileRetrievalIT {
+
+ @Rule
+ public final TeleporterRule teleporter =
+ TeleporterRule
+ .forClass(getClass(), "RBIT_Teleporter")
+ .withResources("/files/");
+
+ private TestEnvironment E;
+ private ResourceAssertions A;
+
+ @Before
+ public void setup() throws LoginException, PersistenceException {
+ E = new TestEnvironment(teleporter);
+ A = new ResourceAssertions(E.testRootPath, E.resolver);
+ }
+
+ @After
+ public void cleanup() throws PersistenceException {
+ E.cleanup();
+ }
+
+ @Test
+ public void createAndeRtrieveFile() throws IOException, ServletException {
+ final String expected = "yes, it worked";
+ final long startTime = System.currentTimeMillis();
+ final String mimeType = "application/javascript";
+
+ E.builder
+ .resource("somefolder")
+ .file("the-model.js", getClass().getResourceAsStream("/files/models.js"))
+ .commit();
+
+ final Resource r = A.assertFile("somefolder/the-model.js", mimeType, expected, -1L);
+
+ final ResourceMetadata meta = r.getResourceMetadata();
+ assertTrue("Expecting a last modified time >= startTime", meta.getModificationTime() >= startTime);
+ assertEquals("Expecting the correct mime-type", mimeType, meta.getContentType());
+
+ final InputStream is = r.adaptTo(InputStream.class);
+ assertNotNull("Expecting InputStream for file resource " + r.getPath(), is);
+ try {
+ final String content = A.readFully(is);
+ assertTrue("Expecting [" + expected + "] in content", content.contains(expected));
+ } finally {
+ is.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
new file mode 100644
index 0000000..b869e41
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
@@ -0,0 +1,127 @@
+/*
+ * 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.resourcebuilder.it;
+
+import static org.junit.Assert.fail;
+import java.io.IOException;
+import java.util.Comparator;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.resourcebuilder.test.ResourceAssertions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Server-side integration test for the
+ * ResourceBuilder, acquired via the ResourceBuilderProvider
+ */
+public class ResourceBuilderIT {
+
+ @Rule
+ public final TeleporterRule teleporter =
+ TeleporterRule
+ .forClass(getClass(), "RBIT_Teleporter")
+ .withResources("/files/");
+
+ private TestEnvironment E;
+ private ResourceAssertions A;
+
+ @Before
+ public void setup() throws LoginException, PersistenceException {
+ E = new TestEnvironment(teleporter);
+ A = new ResourceAssertions(E.testRootPath, E.resolver);
+ }
+
+ @After
+ public void cleanup() throws PersistenceException {
+ E.cleanup();
+ }
+
+
+ @Test
+ public void simpleResource() {
+ E.builder
+ .resource("foo", "title", E.testRootPath)
+ .commit();
+ A.assertProperties("foo", "title", E.testRootPath);
+ }
+
+ @Test
+ public void smallTreeWithFile() throws IOException {
+ E.builder
+ .resource("somefolder")
+ .file("the-model.js", getClass().getResourceAsStream("/files/models.js"), "foo", 42L)
+ .commit();
+
+ A.assertFile("somefolder/the-model.js", "foo", "yes, it worked", 42L);
+ }
+
+ @Test
+ public void fileAutoValues() throws IOException {
+ final long startTime = System.currentTimeMillis();
+ E.builder
+ .resource("a/b/c")
+ .file("model2.js", getClass().getResourceAsStream("/files/models.js"))
+ .commit();
+
+ final Comparator<Long> moreThanStartTime = new Comparator<Long>() {
+ @Override
+ public int compare(Long expected, Long fromResource) {
+ if(fromResource >= startTime) {
+ return 0;
+ }
+ fail("last-modified is not >= than current time:" + fromResource + " < " + startTime);
+ return -1;
+ }
+ };
+
+ A.assertFile("a/b/c/model2.js", "application/javascript", "yes, it worked", startTime, moreThanStartTime);
+ }
+
+ @Test
+ public void usingResolver() throws IOException {
+ E.builderService.forResolver(E.resolver).resource("foo/a/b").commit();
+ E.builderService.forResolver(E.resolver).resource("foo/c/d").commit();
+ A.assertResource("/foo/a/b");
+ A.assertResource("/foo/c/d");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void restartFailsA() throws IOException {
+ E.builder.forParent(E.resolver.getResource("/"));
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void restartFailsB() throws IOException {
+ E.builder.forResolver(E.resolver);
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void notStartedFailsA() throws IOException {
+ E.builderService.resource("foo");
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void notStartedFailsB() throws IOException {
+ E.builderService.file("foo", null);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
new file mode 100644
index 0000000..4749587
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
@@ -0,0 +1,57 @@
+/*
+ * 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.resourcebuilder.it;
+
+import java.util.UUID;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+import org.apache.sling.resourcebuilder.test.ResourceAssertions;
+
+class TestEnvironment {
+
+ final ResourceBuilder builder;
+ final ResourceBuilder builderService;
+ final ResourceResolver resolver;
+ final String testRootPath;
+ final Resource parent;
+ final ResourceAssertions A;
+
+ TestEnvironment(TeleporterRule teleporter) throws LoginException, PersistenceException {
+ testRootPath = getClass().getSimpleName() + "-" + UUID.randomUUID().toString();
+ resolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+ final Resource root = resolver.getResource("/");
+ parent = resolver.create(root, testRootPath, null);
+ builderService = teleporter.getService(ResourceBuilder.class);
+ builder = builderService.forParent(parent);
+ A = new ResourceAssertions(testRootPath, resolver);
+ }
+
+ void cleanup() throws PersistenceException {
+ if(resolver != null && parent != null) {
+ resolver.delete(parent);
+ resolver.commit();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java b/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
new file mode 100644
index 0000000..cea2069
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourcebuilder/test/ResourceAssertions.java
@@ -0,0 +1,136 @@
+/*
+ * 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.resourcebuilder.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.resourcebuilder.impl.MapArgsConverter;
+import org.apache.sling.resourcebuilder.impl.ResourceBuilderImpl;
+
+/** Utilities for asserting Resources and their properties */
+public class ResourceAssertions {
+
+ private final ResourceResolver resourceResolver;
+ private final String testRootPath;
+
+ public ResourceAssertions(String testRootPath, ResourceResolver r) {
+ this.testRootPath = testRootPath;
+ this.resourceResolver = r;
+ }
+
+ public String fullPath(String path) {
+ return path.startsWith("/") ? path : testRootPath + "/" + path;
+ }
+
+ public Resource assertResource(String path) {
+ final Resource result = resourceResolver.resolve(fullPath(path));
+ assertNotNull("Expecting resource to exist:" + path, result);
+ return result;
+ }
+
+ /** Assert that a file exists and verify its properties. */
+ public Resource assertFile(String path, String mimeType, String expectedContent, Long lastModified) throws IOException {
+ final Comparator<Long> defaultComparator = new Comparator<Long>() {
+ @Override
+ public int compare(Long expected, Long fromResource) {
+ if(expected == -1) {
+ return 0;
+ }
+ return expected.compareTo(fromResource);
+ }
+ };
+ return assertFile(path, mimeType, expectedContent, lastModified, defaultComparator);
+ }
+
+ public String readFully(InputStream is) throws IOException {
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ IOUtils.copy(is, bos);
+ return new String(bos.toByteArray());
+ } finally {
+ bos.close();
+ is.close();
+ }
+ }
+
+ /** Assert that a file exists and verify its properties. */
+ public Resource assertFile(String path, String mimeType, String expectedContent, Long lastModified, Comparator<Long> lastModifiedComparator) throws IOException {
+ final Resource r = assertResource(path);
+ assertNotNull("Expecting resource to exist:" + path, r);
+
+ // Files are stored according to the standard JCR structure
+ final ValueMap fileVm = r.adaptTo(ValueMap.class);
+ assertNotNull("Expecting ValueMap for " + r.getPath(), fileVm);
+ assertEquals("Expecting an nt:file at " + r.getPath(),
+ ResourceBuilderImpl.NT_FILE, fileVm.get(ResourceBuilderImpl.JCR_PRIMARYTYPE));
+ final Resource jcrContent = r.getChild(ResourceBuilderImpl.JCR_CONTENT);
+ assertNotNull("Expecting subresource:" + ResourceBuilderImpl.JCR_CONTENT, jcrContent);
+ final ValueMap vm = jcrContent.adaptTo(ValueMap.class);
+ assertNotNull("Expecting ValueMap for " + jcrContent.getPath(), vm);
+ assertEquals("Expecting nt:Resource type for " + jcrContent.getPath(),
+ ResourceBuilderImpl.NT_RESOURCE, vm.get(ResourceBuilderImpl.JCR_PRIMARYTYPE));
+ assertEquals("Expecting the correct mime-type", mimeType, vm.get(ResourceBuilderImpl.JCR_MIMETYPE));
+ assertEquals("Expecting the correct last modified",
+ 0, lastModifiedComparator.compare(lastModified, getLastModified(vm)));
+
+ final InputStream is = vm.get(ResourceBuilderImpl.JCR_DATA, InputStream.class);
+ assertNotNull("Expecting InputStream property on nt:resource:" + ResourceBuilderImpl.JCR_DATA, is);
+ final String content = readFully(is);
+ assertTrue("Expecting content to contain " + expectedContent, content.contains(expectedContent));
+
+ return r;
+ }
+
+ private Long getLastModified(ValueMap vm) {
+ final Object o = vm.get(ResourceBuilderImpl.JCR_LASTMODIFIED);
+ if(o instanceof Long) {
+ return (Long)o;
+ } else if(o instanceof Calendar) {
+ return ((Calendar)o).getTimeInMillis();
+ }
+ throw new IllegalArgumentException("Unexpected type " + o.getClass().getName());
+ }
+
+ public void assertProperties(String path, Object ...props) {
+ final Map<String, Object> expected = MapArgsConverter.toMap(props);
+ final Resource r = assertResource(path);
+ final ValueMap vm = r.adaptTo(ValueMap.class);
+ for(Map.Entry<String, Object> e : expected.entrySet()) {
+ final Object value = vm.get(e.getKey());
+ assertNotNull("Expecting property " + e.getKey() + " for resource " + r.getPath());
+ assertEquals(
+ "Expecting value " + e.getValue()
+ + " for property " + e.getKey() + " of resource " + r.getPath()
+ , e.getValue(), value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/files/models.js b/src/test/resources/files/models.js
new file mode 100644
index 0000000..142f8d3
--- /dev/null
+++ b/src/test/resources/files/models.js
@@ -0,0 +1 @@
+function someJavascriptFunction() { return "yes, it worked." }
\ No newline at end of file
diff --git a/src/test/resources/files/myapp.json b/src/test/resources/files/myapp.json
new file mode 100644
index 0000000..bd3edd2
--- /dev/null
+++ b/src/test/resources/files/myapp.json
@@ -0,0 +1,4 @@
+{
+ "jcr:primaryType":"some:NodeType",
+ "sling:resourceType":"its/resource/type"
+}
\ No newline at end of file
diff --git a/src/test/resources/files/text.html b/src/test/resources/files/text.html
new file mode 100644
index 0000000..57dfc39
--- /dev/null
+++ b/src/test/resources/files/text.html
@@ -0,0 +1,3 @@
+<html>
+This is an html file
+</html>
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 15/25: update dependencies
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit f97a26886dfbaa01b59ef35784c677e4b123abbb
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 21:20:38 2016 +0000
update dependencies
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760765 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index e98e378..08ce17a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,7 +234,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.17-SNAPSHOT</version>
+ <version>1.0.18</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -246,8 +246,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.teleporter</artifactId>
- <!-- SNAPSHOT required due to SLING-5712 -->
- <version>1.0.7-SNAPSHOT</version>
+ <version>1.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 06/25: SLING-6039
ResourceBuilder: Split up ResourceBuilder and ResourceBuilderFactory
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 63d3114b4447d461540ff2b2a20bdaa6865c42b4
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Sep 6 20:20:49 2016 +0000
SLING-6039 ResourceBuilder: Split up ResourceBuilder and ResourceBuilderFactory
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1759501 13f79535-47bb-0310-9956-ffa450edef68
---
.gitignore | 4 +-
.../sling/resourcebuilder/api/ResourceBuilder.java | 15 +----
.../api/ResourceBuilderFactory.java | 43 ++++++++++++++
...ice.java => ResourceBuilderFactoryService.java} | 68 ++--------------------
.../resourcebuilder/impl/ResourceBuilderImpl.java | 13 +----
.../impl/ResourceBuilderImplTest.java | 8 +--
.../resourcebuilder/it/ResourceBuilderIT.java | 22 +------
.../sling/resourcebuilder/it/TestEnvironment.java | 5 +-
8 files changed, 64 insertions(+), 114 deletions(-)
diff --git a/.gitignore b/.gitignore
index a9c1268..a9b9e09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
-sling
-infinitest.filters
\ No newline at end of file
+/sling
+/infinitest.filters
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
index 07ae787..3d33b26 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
@@ -21,7 +21,6 @@ package org.apache.sling.resourcebuilder.api;
import java.io.InputStream;
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
import aQute.bnd.annotation.ProviderType;
@@ -32,17 +31,6 @@ public interface ResourceBuilder {
/** Default primary type for resources created by this builder */
public static final String DEFAULT_PRIMARY_TYPE = "nt:unstructured";
- /** Start a ResourceBuilder using the supplied parent resource
- * @return the new builder
- * */
- ResourceBuilder forParent(Resource parent);
-
- /** Start a ResourceBuilder using the supplied ResourceResolver,
- * starting with the root resource as the builder's parent resource.
- * @return the new builder
- * */
- ResourceBuilder forResolver(ResourceResolver r);
-
/** Create a Resource, which optionally becomes the current
* parent Resource.
* @param path The path of the Resource to create.
@@ -100,4 +88,5 @@ public interface ResourceBuilder {
/** Reset the current parent Resource to the original one.
* Also activates hierarchyMode which is the default mode. */
ResourceBuilder atParent();
-}
\ No newline at end of file
+
+}
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.java
new file mode 100644
index 0000000..7d7bd2f
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilderFactory.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.resourcebuilder.api;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * Factory service for building {@link ResourceBuilder} instances.
+ */
+@ProviderType
+public interface ResourceBuilderFactory {
+
+ /** Start a ResourceBuilder using the supplied parent resource
+ * @return the new builder
+ * */
+ ResourceBuilder forParent(Resource parent);
+
+ /** Start a ResourceBuilder using the supplied ResourceResolver,
+ * starting with the root resource as the builder's parent resource.
+ * @return the new builder
+ * */
+ ResourceBuilder forResolver(ResourceResolver r);
+
+}
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
similarity index 51%
rename from src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java
rename to src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
index 87f68db..f02ca66 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderService.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderFactoryService.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.resourcebuilder.impl;
-import java.io.InputStream;
-
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
@@ -27,27 +25,18 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.mime.MimeTypeService;
import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+import org.apache.sling.resourcebuilder.api.ResourceBuilderFactory;
-/** ResourceBuilder service, only implements the for* methods to
- * create new builders. This allows us to provide a single service
- * interface which transparently becomes stateful, by switching from
- * this object to the ResourceBuilderImpl.
+/**
+ * ResourceBuilderFactory service.
*/
@Component
-@Service(value=ResourceBuilder.class)
-public class ResourceBuilderService implements ResourceBuilder {
+@Service(value=ResourceBuilderFactory.class)
+public class ResourceBuilderFactoryService implements ResourceBuilderFactory {
@Reference
private MimeTypeService mimeTypeService;
-
- private ResourceBuilder notStarted() {
- throw new IllegalStateException(
- "This ResourceBuilder is not started, please use the"
- + "forParent or forResolver methods to start it."
- );
- }
-
@Override
public ResourceBuilder forParent(Resource parent) {
return new ResourceBuilderImpl(parent, mimeTypeService);
@@ -62,49 +51,4 @@ public class ResourceBuilderService implements ResourceBuilder {
return forParent(root);
}
- @Override
- public ResourceBuilder resource(String relativePath, Object... properties) {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder file(String filename, InputStream data, String mimeType, long lastModified) {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder file(String filename, InputStream data) {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder commit() {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder withIntermediatePrimaryType(String primaryType) {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder siblingsMode() {
- return notStarted();
- }
-
- @Override
- public ResourceBuilder hierarchyMode() {
- return notStarted();
- }
-
- @Override
- public Resource getCurrentParent() {
- notStarted();
- return null;
- }
-
- @Override
- public ResourceBuilder atParent() {
- return notStarted();
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
index 3440a27..9b8781a 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -74,16 +74,6 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
@Override
- public ResourceBuilder forParent(Resource parent) {
- throw new UnsupportedOperationException(CANNOT_RESTART);
- }
-
- @Override
- public ResourceBuilder forResolver(ResourceResolver v) {
- throw new UnsupportedOperationException(CANNOT_RESTART);
- }
-
- @Override
public Resource getCurrentParent() {
return currentParent;
}
@@ -274,4 +264,5 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
return this;
}
-}
\ No newline at end of file
+
+}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index def23ac..9ab055f 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -311,7 +311,7 @@ public class ResourceBuilderImplTest {
@Test
public void forParent() throws PersistenceException {
- new ResourceBuilderService()
+ new ResourceBuilderFactoryService()
.forParent(getTestRoot(testRootPath))
.resource("a/b/c")
.commit();
@@ -320,7 +320,7 @@ public class ResourceBuilderImplTest {
@Test
public void forResolver() throws PersistenceException {
- new ResourceBuilderService()
+ new ResourceBuilderFactoryService()
.forResolver(resourceResolver)
.resource("d/e/f")
.commit();
@@ -331,7 +331,7 @@ public class ResourceBuilderImplTest {
@Test
public void absolutePath() throws Exception {
- new ResourceBuilderService()
+ new ResourceBuilderFactoryService()
.forResolver(resourceResolver)
.resource("/a/b/c")
.resource("/a/b/f")
@@ -349,7 +349,7 @@ public class ResourceBuilderImplTest {
@Test
public void reuseInstance() throws Exception {
- ResourceBuilder content = new ResourceBuilderService()
+ ResourceBuilder content = new ResourceBuilderFactoryService()
.forResolver(resourceResolver)
.resource("/content");
content.resource("a");
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
index b869e41..9c16b12 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/ResourceBuilderIT.java
@@ -19,6 +19,7 @@
package org.apache.sling.resourcebuilder.it;
import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.util.Comparator;
@@ -105,23 +106,4 @@ public class ResourceBuilderIT {
A.assertResource("/foo/c/d");
}
- @Test(expected=UnsupportedOperationException.class)
- public void restartFailsA() throws IOException {
- E.builder.forParent(E.resolver.getResource("/"));
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void restartFailsB() throws IOException {
- E.builder.forResolver(E.resolver);
- }
-
- @Test(expected=IllegalStateException.class)
- public void notStartedFailsA() throws IOException {
- E.builderService.resource("foo");
- }
-
- @Test(expected=IllegalStateException.class)
- public void notStartedFailsB() throws IOException {
- E.builderService.file("foo", null);
- }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
index 4749587..f5625e9 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/it/TestEnvironment.java
@@ -27,12 +27,13 @@ import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.junit.rules.TeleporterRule;
import org.apache.sling.resourcebuilder.api.ResourceBuilder;
+import org.apache.sling.resourcebuilder.api.ResourceBuilderFactory;
import org.apache.sling.resourcebuilder.test.ResourceAssertions;
class TestEnvironment {
final ResourceBuilder builder;
- final ResourceBuilder builderService;
+ final ResourceBuilderFactory builderService;
final ResourceResolver resolver;
final String testRootPath;
final Resource parent;
@@ -43,7 +44,7 @@ class TestEnvironment {
resolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
final Resource root = resolver.getResource("/");
parent = resolver.create(root, testRootPath, null);
- builderService = teleporter.getService(ResourceBuilder.class);
+ builderService = teleporter.getService(ResourceBuilderFactory.class);
builder = builderService.forParent(parent);
A = new ResourceAssertions(testRootPath, resolver);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 13/25: SLING-6050
ResourceBuilder: Support Map for resource properties
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 7c1013e0b4873bed579d84b2d0d67458dc2ea141
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 12 14:22:52 2016 +0000
SLING-6050 ResourceBuilder: Support Map for resource properties
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760380 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/resourcebuilder/api/ResourceBuilder.java | 13 +++++++++++-
.../resourcebuilder/impl/ResourceBuilderImpl.java | 24 +++++++++++++++++-----
.../impl/ResourceBuilderImplTest.java | 14 +++++++++++++
3 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
index 3d33b26..7cae0dd 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
@@ -19,6 +19,7 @@
package org.apache.sling.resourcebuilder.api;
import java.io.InputStream;
+import java.util.Map;
import org.apache.sling.api.resource.Resource;
@@ -39,7 +40,17 @@ public interface ResourceBuilder {
* @param properties optional name-value pairs
* @return this builder
*/
- ResourceBuilder resource(String path, Object ... properties);
+ ResourceBuilder resource(String path, Object... properties);
+
+ /** Create a Resource, which optionally becomes the current
+ * parent Resource.
+ * @param path The path of the Resource to create.
+ * If it's a relative path this builder's current resource is used as parent.
+ * Otherwise the resource is created ad the given absoulte path.
+ * @param properties Name-value pairs
+ * @return this builder
+ */
+ ResourceBuilder resource(String path, Map<String, Object> properties);
/** Create a file under the current parent resource
* @param filename The name of the created file
diff --git a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
index 9b8781a..fcc4cae 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImpl.java
@@ -27,6 +27,7 @@ import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.mime.MimeTypeService;
import org.apache.sling.resourcebuilder.api.ResourceBuilder;
@@ -106,7 +107,7 @@ public class ResourceBuilderImpl implements ResourceBuilder {
}
@Override
- public ResourceBuilder resource(String path, Object... properties) {
+ public ResourceBuilder resource(String path, Map<String,Object> properties) {
Resource r = null;
final String parentPath;
@@ -124,17 +125,16 @@ public class ResourceBuilderImpl implements ResourceBuilder {
try {
r = currentParent.getResourceResolver().getResource(fullPath);
- final Map<String, Object> props = MapArgsConverter.toMap(properties);
- if(r == null) {
+ if (r == null) {
r = currentParent.getResourceResolver().create(myParent,
- ResourceUtil.getName(fullPath), props);
+ ResourceUtil.getName(fullPath), properties);
} else {
// Resource exists, set our properties
final ModifiableValueMap mvm = r.adaptTo(ModifiableValueMap.class);
if(mvm == null) {
throw new IllegalStateException("Cannot modify properties of " + r.getPath());
}
- for(Map.Entry <String, Object> e : props.entrySet()) {
+ for(Map.Entry <String, Object> e : properties.entrySet()) {
mvm.put(e.getKey(), e.getValue());
}
}
@@ -151,6 +151,20 @@ public class ResourceBuilderImpl implements ResourceBuilder {
return this;
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public ResourceBuilder resource(String path, Object... properties) {
+ if (properties == null || properties.length == 0) {
+ return resource(path, ValueMap.EMPTY);
+ }
+ else if (properties.length == 1 && properties[0] instanceof Map) {
+ return resource(path, (Map<String,Object>)properties[0]);
+ }
+ else {
+ return resource(path, MapArgsConverter.toMap(properties));
+ }
+ }
+
/** Create a Resource at the specified path if none exists yet,
* using the current intermediate primary type. "Stolen" from
* the sling-mock module's ContentBuilder class.
diff --git a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
index e33b900..e025c16 100644
--- a/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
+++ b/src/test/java/org/apache/sling/resourcebuilder/impl/ResourceBuilderImplTest.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Random;
import java.util.UUID;
@@ -113,6 +115,18 @@ public class ResourceBuilderImplTest {
}
@Test
+ public void basicResourceWithMap() throws Exception {
+ Map<String,Object> props = new HashMap<String,Object>();
+ props.put("title", "foo");
+ getBuilder(testRootPath)
+ .resource("child", props)
+ .commit();
+
+ A.assertProperties("child", "title", "foo");
+ assertEquals(A.fullPath("child"), A.assertResource("child").getPath());
+ }
+
+ @Test
public void ensureResourceExists() throws Exception {
class MyResourceBuilder extends ResourceBuilderImpl {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-resourcebuilder] 14/25: fix javadoc error
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcebuilder.git
commit 833ebaa5fbb73e7925fc1dd9122a5d28d0c6f7fc
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 21:18:51 2016 +0000
fix javadoc error
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1760764 13f79535-47bb-0310-9956-ffa450edef68
---
src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
index 7cae0dd..a38d184 100644
--- a/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
+++ b/src/main/java/org/apache/sling/resourcebuilder/api/ResourceBuilder.java
@@ -56,7 +56,7 @@ public interface ResourceBuilder {
* @param filename The name of the created file
* @param data The file data
* @param mimeType If null, use the Sling MimeTypeService to set the mime type
- * @param lastModified if < 0, current time is used
+ * @param lastModified if < 0, current time is used
* @return this builder
*/
ResourceBuilder file(String filename, InputStream data, String mimeType, long lastModified);
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.