You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2025/12/18 09:45:02 UTC
(sling-org-apache-sling-commons-testing) branch feature/SLING-13036-update-deps-parent created (now 2000fdf)
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a change to branch feature/SLING-13036-update-deps-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git
at 2000fdf SLING-13036 apply spotless formatting
This branch includes the following new commits:
new 2706a6a update parent and dependencies
new a33ecaa SLING-13036 Update to parent 64, update various dependencies and fix dependency scopes
new 2000fdf SLING-13036 apply spotless formatting
The 3 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.
(sling-org-apache-sling-commons-testing) 03/03: SLING-13036 apply spotless formatting
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-13036-update-deps-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git
commit 2000fdf1c6de066a8979a14dc79a597b2d418176
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 18 10:44:50 2025 +0100
SLING-13036 apply spotless formatting
---
pom.xml | 26 +-
.../commons/testing/integration/HttpAnyMethod.java | 28 +-
.../integration/HttpStatusCodeException.java | 17 +-
.../commons/testing/integration/HttpTest.java | 54 ++--
.../commons/testing/integration/HttpTestBase.java | 315 +++++++++++----------
.../commons/testing/integration/HttpTestNode.java | 34 +--
.../commons/testing/integration/NameValuePair.java | 28 +-
.../testing/integration/NameValuePairList.java | 34 +--
.../integration/SlingIntegrationTestClient.java | 135 ++++-----
.../testing/integration/TestInfoPassingClient.java | 12 +-
.../sling/commons/testing/jcr/EventHelper.java | 64 +++--
.../apache/sling/commons/testing/jcr/MockNode.java | 137 +++++----
.../commons/testing/jcr/MockNodeIterator.java | 11 +-
.../sling/commons/testing/jcr/MockProperty.java | 148 +++++-----
.../testing/jcr/MockPropertyDefinition.java | 4 +-
.../commons/testing/jcr/MockPropertyIterator.java | 13 +-
.../sling/commons/testing/jcr/MockValue.java | 24 +-
.../commons/testing/jcr/RepositoryProvider.java | 27 +-
.../commons/testing/jcr/RepositoryTestBase.java | 21 +-
.../sling/commons/testing/jcr/RepositoryUtil.java | 80 +++---
.../apache/sling/commons/testing/junit/Retry.java | 8 +-
.../sling/commons/testing/junit/RetryRule.java | 53 ++--
.../commons/testing/junit/categories/Slow.java | 3 +-
.../sling/commons/testing/osgi/MockBundle.java | 31 +-
.../commons/testing/osgi/MockBundleContext.java | 43 +--
.../commons/testing/osgi/MockComponentContext.java | 11 +-
.../commons/testing/osgi/MockServiceReference.java | 3 +-
.../commons/testing/sling/MockRequestPathInfo.java | 26 +-
.../testing/sling/MockRequestProgressTracker.java | 23 +-
.../sling/commons/testing/sling/MockResource.java | 22 +-
.../testing/sling/MockResourceResolver.java | 44 +--
.../testing/sling/MockSlingHttpServletRequest.java | 96 +++----
.../sling/MockSlingHttpServletResponse.java | 264 ++++++++---------
.../commons/testing/util/JavascriptEngine.java | 49 ++--
.../sling/commons/testing/util/TestStringUtil.java | 6 +-
.../commons/testing/jcr/MockPropertyTest.java | 1 -
.../testing/jcr/RepositoryProviderTest.java | 14 +-
.../testing/jcr/RepositoryTestBaseTest.java | 2 +-
.../commons/testing/jcr/RepositoryUtilTest.java | 7 +-
.../sling/commons/testing/junit/RetryRuleTest.java | 62 ++--
.../commons/testing/sling/MockResourceTest.java | 24 +-
.../commons/testing/util/JavascriptEngineTest.java | 68 ++---
42 files changed, 1008 insertions(+), 1064 deletions(-)
diff --git a/pom.xml b/pom.xml
index 50135ec..4d3378f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?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
@@ -28,26 +28,24 @@
</parent>
<artifactId>org.apache.sling.commons.testing</artifactId>
- <packaging>jar</packaging>
<version>2.2.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
<name>Apache Sling Commons Testing</name>
- <description>
- Tools and utilities for automated testing of Sling modules
- </description>
-
- <properties>
- <sling.java.version>11</sling.java.version>
- <project.build.outputTimestamp>1743171324</project.build.outputTimestamp>
- </properties>
+ <description>Tools and utilities for automated testing of Sling modules</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-commons-testing.git</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-commons-testing.git</url>
</scm>
+ <properties>
+ <sling.java.version>11</sling.java.version>
+ <project.build.outputTimestamp>1743171324</project.build.outputTimestamp>
+ </properties>
+
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
@@ -148,21 +146,21 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
-
+
<!-- Logging for tests -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
-
+
<!-- Basic Test Controller JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
-
+
<!-- Provide for Test Mocks -->
<dependency>
<groupId>org.jmock</groupId>
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpAnyMethod.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpAnyMethod.java
index 7403806..5915603 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpAnyMethod.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpAnyMethod.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
@@ -21,7 +23,7 @@ import org.apache.commons.httpclient.HttpMethodBase;
/** Allows any HTTP method for HtttpClient */
public class HttpAnyMethod extends HttpMethodBase {
private final String methodName;
-
+
public HttpAnyMethod(String methodName, String uri) {
super(uri);
this.methodName = methodName;
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpStatusCodeException.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpStatusCodeException.java
index b5f6676..852755a 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpStatusCodeException.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpStatusCodeException.java
@@ -24,20 +24,17 @@ import java.io.IOException;
public class HttpStatusCodeException extends IOException {
private final int expectedStatus;
-
+
private final int actualStatus;
-
- public HttpStatusCodeException(int expectedStatus, int actualStatus,
- String method, String url) {
+
+ public HttpStatusCodeException(int expectedStatus, int actualStatus, String method, String url) {
this(expectedStatus, actualStatus, method, url, null);
}
- public HttpStatusCodeException(int expectedStatus, int actualStatus,
- String method, String url, String content) {
+ public HttpStatusCodeException(int expectedStatus, int actualStatus, String method, String url, String content) {
super("Expected status code " + expectedStatus + " for " + method
- + ", got " + actualStatus + ", URL=" + url
- + (content != null ? ", Content=[" + content + "]" : "")
- );
+ + ", got " + actualStatus + ", URL=" + url
+ + (content != null ? ", Content=[" + content + "]" : ""));
this.expectedStatus = expectedStatus;
this.actualStatus = actualStatus;
}
@@ -45,7 +42,7 @@ public class HttpStatusCodeException extends IOException {
public int getExpectedStatus() {
return expectedStatus;
}
-
+
public int getActualStatus() {
return actualStatus;
}
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpTest.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpTest.java
index bd6544b..0f7fa64 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpTest.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpTest.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
@@ -22,54 +24,54 @@ import org.apache.commons.httpclient.HttpClient;
/** Helper class for HTTP tests, extends HttpTestBase and adds
* a few utilities that we commonly use in our integration tests.
- *
+ *
* Meant to be used as a helper class in JUnit4-style tests, as we
- * gradually move away from JUnit3 style.
+ * gradually move away from JUnit3 style.
*/
public class HttpTest extends HttpTestBase {
protected String scriptPath;
protected String testText;
protected String displayUrl;
-
- public String uploadTestScript(String localFilename,String filenameOnServer) throws IOException {
+
+ public String uploadTestScript(String localFilename, String filenameOnServer) throws IOException {
return uploadTestScript(scriptPath, localFilename, filenameOnServer);
}
-
+
public static void assertContains(String content, String expected) {
- if(!content.contains(expected)) {
+ if (!content.contains(expected)) {
fail("Content does not contain '" + expected + "' (content=" + content + ")");
}
}
-
+
public static void assertNotContains(String content, String notExpected) {
- if(content.contains(notExpected)) {
+ if (content.contains(notExpected)) {
fail("Content contains '" + notExpected + "' (content=" + content + ")");
}
}
-
+
public void setScriptPath(String scriptPath) {
this.scriptPath = scriptPath;
}
-
+
public String getScriptPath() {
return scriptPath;
}
-
+
public SlingIntegrationTestClient getTestClient() {
return testClient;
}
-
+
public HttpClient getHttpClient() {
return httpClient;
}
-
+
/** Making this public here, changing the base class to public is not convenient
* as many derived classes override it as protected.
*/
public void setUp() throws Exception {
super.setUp();
}
-
+
/** Making this public here, changing the base class to public is not convenient
* as many derived classes override it as protected.
*/
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
index e0f4edd..5c483b7 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
@@ -1,21 +1,25 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
+import javax.servlet.http.HttpServletResponse;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -29,10 +33,7 @@ import java.util.regex.Pattern;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
-import javax.servlet.http.HttpServletResponse;
-
import junit.framework.TestCase;
-
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
@@ -54,23 +55,26 @@ import org.slf4j.MDC;
public class HttpTestBase extends TestCase {
private final Logger log = LoggerFactory.getLogger(getClass());
-
+
/** If this system property is set, the startup check is skipped. */
public static final String PROPERTY_SKIP_STARTUP_CHECK = "launchpad.skip.startupcheck";
- public static final String HTTP_URL = removeEndingSlash(System.getProperty("launchpad.http.server.url", "http://localhost:8080"));
+ public static final String HTTP_URL =
+ removeEndingSlash(System.getProperty("launchpad.http.server.url", "http://localhost:8080"));
public static final String HTTP_BASE_URL = removePath(HTTP_URL);
- public static final String WEBDAV_BASE_URL = removeEndingSlash(System.getProperty("launchpad.webdav.server.url", HTTP_BASE_URL));
- public static final String SERVLET_CONTEXT = removeEndingSlash(System.getProperty("launchpad.servlet.context", getPath(HTTP_URL)));
+ public static final String WEBDAV_BASE_URL =
+ removeEndingSlash(System.getProperty("launchpad.webdav.server.url", HTTP_BASE_URL));
+ public static final String SERVLET_CONTEXT =
+ removeEndingSlash(System.getProperty("launchpad.servlet.context", getPath(HTTP_URL)));
public static final String READINESS_MEDIA_TYPE_PROP = "launchpad.readiness.mediatype";
public static final String DEFAULT_READINESS_MEDIA_TYPE = ".txt:text/plain";
-
+
public static final String READY_URL_PROP_PREFIX = "launchpad.ready.";
public static final int MAX_READY_URL_INDEX = 50;
/** base path for test files */
public static final String TEST_PATH = "/launchpad-integration-tests";
-
+
public static final String HTTP_METHOD_GET = "GET";
public static final String HTTP_METHOD_POST = "POST";
@@ -84,13 +88,13 @@ public class HttpTestBase extends TestCase {
public static final String SLING_RESOURCE_TYPE = "sling:resourceType";
public static final String SLING_POST_SERVLET_CREATE_SUFFIX = "/";
- public static final String DEFAULT_EXT = ".txt";
-
- private String readinessCheckExtension;
- private String readinessCheckContentTypePrefix;
+ public static final String DEFAULT_EXT = ".txt";
+
+ private String readinessCheckExtension;
+ private String readinessCheckContentTypePrefix;
- public static final String EXECUTE_RESOURCE_TYPE = "SlingTesting" + HttpTestBase.class.getSimpleName();
- private static int executeCounter;
+ public static final String EXECUTE_RESOURCE_TYPE = "SlingTesting" + HttpTestBase.class.getSimpleName();
+ private static int executeCounter;
public static final int READY_TIMEOUT_SECONDS = Integer.getInteger("HttpTestBase.readyTimeoutSeconds", 60);
@@ -112,11 +116,11 @@ public class HttpTestBase extends TestCase {
public HttpTestBase() {
super("");
-
+
final String rmt = System.getProperty(READINESS_MEDIA_TYPE_PROP, DEFAULT_READINESS_MEDIA_TYPE);
- final String [] s = rmt.split(":");
- if(s.length != 2) {
- throw new IllegalStateException("Invalid " + READINESS_MEDIA_TYPE_PROP + ": " + rmt);
+ final String[] s = rmt.split(":");
+ if (s.length != 2) {
+ throw new IllegalStateException("Invalid " + READINESS_MEDIA_TYPE_PROP + ": " + rmt);
}
setReadinessContentType(s[0].trim(), s[1].trim());
}
@@ -132,7 +136,7 @@ public class HttpTestBase extends TestCase {
}
public static String removeEndingSlash(String str) {
- if(str != null && str.endsWith("/")) {
+ if (str != null && str.endsWith("/")) {
return str.substring(0, str.length() - 1);
}
return str;
@@ -140,8 +144,8 @@ public class HttpTestBase extends TestCase {
private static String removePath(String str) {
final int pos = str.indexOf(":/");
- final int slashPos = str.indexOf('/', pos+3);
- if ( slashPos != -1 ) {
+ final int slashPos = str.indexOf('/', pos + 3);
+ if (slashPos != -1) {
return str.substring(0, slashPos);
}
return str;
@@ -149,8 +153,8 @@ public class HttpTestBase extends TestCase {
private static String getPath(String str) {
final int pos = str.indexOf(":/");
- final int slashPos = str.indexOf('/', pos+3);
- if ( slashPos != -1 ) {
+ final int slashPos = str.indexOf('/', pos + 3);
+ if (slashPos != -1) {
return str.substring(slashPos);
}
return "";
@@ -167,7 +171,7 @@ public class HttpTestBase extends TestCase {
URL url = null;
try {
url = new URL(HTTP_BASE_URL);
- } catch(MalformedURLException mfe) {
+ } catch (MalformedURLException mfe) {
// MalformedURLException doesn't tell us the URL by default
throw new IOException("MalformedURLException: " + HTTP_BASE_URL);
}
@@ -176,7 +180,9 @@ public class HttpTestBase extends TestCase {
httpClient = new TestInfoPassingClient();
httpClient.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = getDefaultCredentials();
- httpClient.getState().setCredentials(new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);
+ httpClient
+ .getState()
+ .setCredentials(new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);
testClient = new SlingIntegrationTestClient(httpClient);
testClient.setFolderExistsTestExtension(readinessCheckExtension);
@@ -198,7 +204,7 @@ public class HttpTestBase extends TestCase {
super.tearDown();
- for(String url : urlsToDelete) {
+ for (String url : urlsToDelete) {
testClient.delete(url);
}
}
@@ -213,26 +219,25 @@ public class HttpTestBase extends TestCase {
// Use a static flag to make sure this runs only once in our test suite
// we must synchronize on this if we don't 2 threads could enter the check concurrently
// which would leave to random results.
- synchronized(startupCheckLock) {
+ synchronized (startupCheckLock) {
if (slingStartupOk != null) {
- if(slingStartupOk) {
+ if (slingStartupOk) {
return;
}
fail("Sling services not available. Already checked in earlier tests.");
}
- if ( System.getProperty(PROPERTY_SKIP_STARTUP_CHECK) != null ) {
+ if (System.getProperty(PROPERTY_SKIP_STARTUP_CHECK) != null) {
slingStartupOk = true;
return;
}
slingStartupOk = false;
}
- System.err.println("Checking if the required Sling services are started (timeout " + READY_TIMEOUT_SECONDS + " seconds)...");
- System.err.println(
- "(base URLs=" + HTTP_BASE_URL + " and " + WEBDAV_BASE_URL
- + "; servlet context="+ SERVLET_CONTEXT
- + "; readiness type=" + readinessCheckExtension + " : " + readinessCheckContentTypePrefix
- );
+ System.err.println("Checking if the required Sling services are started (timeout " + READY_TIMEOUT_SECONDS
+ + " seconds)...");
+ System.err.println("(base URLs=" + HTTP_BASE_URL + " and " + WEBDAV_BASE_URL
+ + "; servlet context=" + SERVLET_CONTEXT
+ + "; readiness type=" + readinessCheckExtension + " : " + readinessCheckContentTypePrefix);
// Try creating a node on server, every 500msec, until ok, with timeout
final List<String> exceptionMessages = new LinkedList<String>();
@@ -240,27 +245,27 @@ public class HttpTestBase extends TestCase {
final long startupTime = System.currentTimeMillis();
String lastException = "";
int nTimesOk = 0;
-
+
// Wait until slingServerReady returns true this many times,
// as in some cases more initializations might take place after
// this returns true
final int MIN_TIMES_OK = 4;
-
- while(!slingStartupOk && (System.currentTimeMillis() < startupTime + maxMsecToWait) ) {
+
+ while (!slingStartupOk && (System.currentTimeMillis() < startupTime + maxMsecToWait)) {
try {
- if(slingServerReady()) {
+ if (slingServerReady()) {
nTimesOk++;
- if(nTimesOk >= MIN_TIMES_OK) {
+ if (nTimesOk >= MIN_TIMES_OK) {
slingStartupOk = true;
break;
}
} else {
nTimesOk = 0;
}
- } catch(Exception e) {
+ } catch (Exception e) {
nTimesOk = 0;
final String newX = e.toString();
- if(!lastException.equals(newX)) {
+ if (!lastException.equals(newX)) {
exceptionMessages.add(newX);
}
lastException = newX;
@@ -268,12 +273,15 @@ public class HttpTestBase extends TestCase {
Thread.sleep(500L);
}
- if(slingStartupOk) {
+ if (slingStartupOk) {
log.info("Sling server found ready after {} msec", System.currentTimeMillis() - startupTime);
} else {
StringBuffer msg = new StringBuffer("Server does not seem to be ready, after ");
- msg.append(maxMsecToWait).append(" msec, got the following ").append(exceptionMessages.size()).append(" Exceptions:");
- for (String e: exceptionMessages) {
+ msg.append(maxMsecToWait)
+ .append(" msec, got the following ")
+ .append(exceptionMessages.size())
+ .append(" Exceptions:");
+ for (String e : exceptionMessages) {
msg.append(e).append("\n");
}
System.err.println(msg);
@@ -290,34 +298,36 @@ public class HttpTestBase extends TestCase {
final String url = HTTP_BASE_URL + "/WaitForSlingStartup/" + time;
// add some properties to the node
- final Map<String,String> props = new HashMap<String,String>();
+ final Map<String, String> props = new HashMap<String, String>();
props.put("time", time);
// POST, get URL of created node and get content
- String urlOfNewNode = null;
+ String urlOfNewNode = null;
try {
urlOfNewNode = testClient.createNode(url, props, null, true);
final GetMethod get = new GetMethod(urlOfNewNode + readinessCheckExtension);
final int status = httpClient.executeMethod(get);
- if(status!=200) {
+ if (status != 200) {
throw new HttpStatusCodeException(200, status, "GET", urlOfNewNode);
}
final Header h = get.getResponseHeader("Content-Type");
- final String contentType = h==null ? "" : h.getValue();
- if(!contentType.startsWith(readinessCheckContentTypePrefix)) {
- throw new IOException("Expected Content-Type=" + readinessCheckContentTypePrefix + " but got '" + contentType + "' for URL=" + urlOfNewNode);
+ final String contentType = h == null ? "" : h.getValue();
+ if (!contentType.startsWith(readinessCheckContentTypePrefix)) {
+ throw new IOException("Expected Content-Type=" + readinessCheckContentTypePrefix + " but got '"
+ + contentType + "' for URL=" + urlOfNewNode);
}
final String content = get.getResponseBodyAsString();
- if(!content.contains(time)) {
- throw new IOException("Content does not contain '" + time + "' (" + content + ") at URL=" + urlOfNewNode);
+ if (!content.contains(time)) {
+ throw new IOException(
+ "Content does not contain '" + time + "' (" + content + ") at URL=" + urlOfNewNode);
}
} finally {
- if(urlOfNewNode != null) {
+ if (urlOfNewNode != null) {
try {
testClient.delete(urlOfNewNode);
- } catch(Exception ignore) {
+ } catch (Exception ignore) {
}
}
}
@@ -326,43 +336,45 @@ public class HttpTestBase extends TestCase {
{
// need the trailing slash in case the base URL is the context root
final String webDavUrl = WEBDAV_BASE_URL + "/";
- final HttpAnyMethod options = new HttpAnyMethod("OPTIONS",webDavUrl);
+ final HttpAnyMethod options = new HttpAnyMethod("OPTIONS", webDavUrl);
final int status = httpClient.executeMethod(options);
- if(status!=200) {
+ if (status != 200) {
throw new HttpStatusCodeException(200, status, "OPTIONS", webDavUrl);
}
// The Allow header tells us that we're talking to a WebDAV server
final Header h = options.getResponseHeader("Allow");
- if(h == null) {
+ if (h == null) {
throw new IOException("Response does not contain Allow header, at URL=" + webDavUrl);
- } else if(h.getValue() == null) {
+ } else if (h.getValue() == null) {
throw new IOException("Allow header has null value at URL=" + webDavUrl);
- } else if(!h.getValue().contains("PROPFIND")) {
- throw new IOException("Allow header (" + h.getValue() + " does not contain PROPFIND, at URL=" + webDavUrl);
+ } else if (!h.getValue().contains("PROPFIND")) {
+ throw new IOException(
+ "Allow header (" + h.getValue() + " does not contain PROPFIND, at URL=" + webDavUrl);
}
}
-
+
// And check optional additional URLs for readyness
// Defined by system properties like
// launchpad.ready.1 = GET:/tmp/someUrl:200:expectedRegexpInResponse
{
- for(int i=0; i <= MAX_READY_URL_INDEX ; i++) {
+ for (int i = 0; i <= MAX_READY_URL_INDEX; i++) {
final String propName = READY_URL_PROP_PREFIX + i;
final String readyDef = System.getProperty(propName, "");
- final String [] parts = readyDef.split(":");
- if(parts.length == 4) {
+ final String[] parts = readyDef.split(":");
+ if (parts.length == 4) {
final String info = propName + "=" + readyDef;
- final HttpAnyMethod m = new HttpAnyMethod(parts[0],HTTP_BASE_URL + parts[1]);
+ final HttpAnyMethod m = new HttpAnyMethod(parts[0], HTTP_BASE_URL + parts[1]);
final int expectedStatus = Integer.valueOf(parts[2]);
final int status = httpClient.executeMethod(m);
- if(expectedStatus != status) {
- throw new IOException("Status " + status + " does not match expected value: " + info);
+ if (expectedStatus != status) {
+ throw new IOException("Status " + status + " does not match expected value: " + info);
}
final String content = m.getResponseBodyAsString();
final Pattern p = Pattern.compile("(?s).*" + parts[3] + ".*");
- if(!p.matcher(content).matches()) {
- throw new IOException("Content does not match expected regexp:" + info + ", content=" + content);
+ if (!p.matcher(content).matches()) {
+ throw new IOException(
+ "Content does not match expected regexp:" + info + ", content=" + content);
}
}
}
@@ -374,11 +386,12 @@ public class HttpTestBase extends TestCase {
/** Verify that given URL returns expectedStatusCode
* @return the HttpMethod executed
* @throws IOException */
- public HttpMethod assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException {
+ public HttpMethod assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage)
+ throws IOException {
final GetMethod get = new GetMethod(urlString);
final int status = httpClient.executeMethod(get);
- if(assertMessage == null) {
- assertEquals(urlString,expectedStatusCode, status);
+ if (assertMessage == null) {
+ assertEquals(urlString, expectedStatusCode, status);
} else {
assertEquals(assertMessage, expectedStatusCode, status);
}
@@ -395,18 +408,19 @@ public class HttpTestBase extends TestCase {
/** Execute a POST request and check status
* @return the HttpMethod executed
* @throws IOException */
- public HttpMethod assertPostStatus(String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
- throws IOException {
+ public HttpMethod assertPostStatus(
+ String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
+ throws IOException {
final PostMethod post = new PostMethod(url);
post.setFollowRedirects(false);
- if(postParams!=null) {
- final NameValuePair [] nvp = {};
+ if (postParams != null) {
+ final NameValuePair[] nvp = {};
post.setRequestBody(postParams.toArray(nvp));
}
final int status = httpClient.executeMethod(post);
- if(assertMessage == null) {
+ if (assertMessage == null) {
assertEquals(expectedStatusCode, status);
} else {
assertEquals(assertMessage, expectedStatusCode, status);
@@ -428,70 +442,75 @@ public class HttpTestBase extends TestCase {
* @param expectedContentType use CONTENT_TYPE_DONTCARE if must not be checked
* @throws IOException
* @throws HttpException */
- public String getContent(String url, String expectedContentType, List<NameValuePair> params, int expectedStatusCode) throws IOException {
- return getContent(url, expectedContentType, params, expectedStatusCode, HTTP_METHOD_GET);
+ public String getContent(String url, String expectedContentType, List<NameValuePair> params, int expectedStatusCode)
+ throws IOException {
+ return getContent(url, expectedContentType, params, expectedStatusCode, HTTP_METHOD_GET);
}
-
+
/** retrieve the contents of given URL and assert its content type
* @param expectedContentType use CONTENT_TYPE_DONTCARE if must not be checked
* @param httpMethod supports just GET and POST methods
* @throws IOException
* @throws HttpException */
- public String getContent(String url, String expectedContentType, List<NameValuePair> params, int expectedStatusCode, String httpMethod) throws IOException {
- HttpMethodBase method = null;
-
- if (HTTP_METHOD_GET.equals(httpMethod)){
- method= new GetMethod(url);
- }else if (HTTP_METHOD_POST.equals(httpMethod)){
- method = new PostMethod(url);
- } else{
- fail("Http Method not supported in this test suite, method: "+httpMethod);
- }
-
- if(params != null) {
- final NameValuePair [] nvp = new NameValuePair[0];
+ public String getContent(
+ String url,
+ String expectedContentType,
+ List<NameValuePair> params,
+ int expectedStatusCode,
+ String httpMethod)
+ throws IOException {
+ HttpMethodBase method = null;
+
+ if (HTTP_METHOD_GET.equals(httpMethod)) {
+ method = new GetMethod(url);
+ } else if (HTTP_METHOD_POST.equals(httpMethod)) {
+ method = new PostMethod(url);
+ } else {
+ fail("Http Method not supported in this test suite, method: " + httpMethod);
+ }
+
+ if (params != null) {
+ final NameValuePair[] nvp = new NameValuePair[0];
method.setQueryString(params.toArray(nvp));
}
final int status = httpClient.executeMethod(method);
final String content = getResponseBodyAsStream(method, 0);
- assertEquals("Expected status " + expectedStatusCode + " for " + url + " (content=" + content + ")",
- expectedStatusCode,status);
+ assertEquals(
+ "Expected status " + expectedStatusCode + " for " + url + " (content=" + content + ")",
+ expectedStatusCode,
+ status);
final Header h = method.getResponseHeader("Content-Type");
- if(expectedContentType == null) {
- if(h!=null) {
+ if (expectedContentType == null) {
+ if (h != null) {
fail("Expected null Content-Type, got " + h.getValue());
}
- } else if(CONTENT_TYPE_DONTCARE.equals(expectedContentType)) {
+ } else if (CONTENT_TYPE_DONTCARE.equals(expectedContentType)) {
// no check
- } else if(h==null) {
- fail(
- "Expected Content-Type that starts with '" + expectedContentType
- +" but got no Content-Type header at " + url
- );
+ } else if (h == null) {
+ fail("Expected Content-Type that starts with '" + expectedContentType
+ + " but got no Content-Type header at " + url);
} else {
assertTrue(
- "Expected Content-Type that starts with '" + expectedContentType
- + "' for " + url + ", got '" + h.getValue() + "'",
- h.getValue().startsWith(expectedContentType)
- );
+ "Expected Content-Type that starts with '" + expectedContentType + "' for " + url + ", got '"
+ + h.getValue() + "'",
+ h.getValue().startsWith(expectedContentType));
}
return content.toString();
-
}
-
/** upload rendering test script, and return its URL for future deletion */
- public String uploadTestScript(String scriptPath, String localFilename,String filenameOnServer) throws IOException {
+ public String uploadTestScript(String scriptPath, String localFilename, String filenameOnServer)
+ throws IOException {
final String url = WEBDAV_BASE_URL + scriptPath + "/" + filenameOnServer;
final String testFile = "/integration-test/" + localFilename;
final InputStream data = getClass().getResourceAsStream(testFile);
- if(data==null) {
+ if (data == null) {
fail("Test file not found:" + testFile);
}
try {
testClient.upload(url, data);
} finally {
- if(data!=null) {
+ if (data != null) {
data.close();
}
}
@@ -513,10 +532,10 @@ public class HttpTestBase extends TestCase {
}
final String resourceType = EXECUTE_RESOURCE_TYPE + counter;
final String scriptPath = "/apps/" + resourceType;
- testClient.mkdirs(WEBDAV_BASE_URL , scriptPath);
+ testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
final int pos = localFilename.lastIndexOf(".");
- if(pos < 1) {
+ if (pos < 1) {
throw new IllegalArgumentException("localFilename must have extension (" + localFilename + ")");
}
final String ext = localFilename.substring(pos + 1);
@@ -530,7 +549,7 @@ public class HttpTestBase extends TestCase {
toDelete.add(nodeUrl);
return getContent(nodeUrl + ".txt", CONTENT_TYPE_DONTCARE, params);
} finally {
- for(String url : toDelete) {
+ for (String url : toDelete) {
testClient.delete(url);
}
}
@@ -541,16 +560,15 @@ public class HttpTestBase extends TestCase {
}
/** Evaluate given code using given jsonData as the "data" object */
- public void assertJavascript(String expectedOutput, String jsonData, String code, String testInfo) throws IOException {
- final String result = javascriptEngine.execute(code, jsonData);
- if(!result.equals(expectedOutput)) {
- fail(
- "Expected '" + expectedOutput
+ public void assertJavascript(String expectedOutput, String jsonData, String code, String testInfo)
+ throws IOException {
+ final String result = javascriptEngine.execute(code, jsonData);
+ if (!result.equals(expectedOutput)) {
+ fail("Expected '" + expectedOutput
+ "' but got '" + result
+ "' for script='" + code + "'"
+ "' and data='" + jsonData + "'"
- + (testInfo==null ? "" : ", test info=" + testInfo)
- );
+ + (testInfo == null ? "" : ", test info=" + testInfo));
}
}
@@ -561,11 +579,11 @@ public class HttpTestBase extends TestCase {
final InputStream is = m.getResponseBodyAsStream();
final StringBuilder content = new StringBuilder();
final String charset = m.getResponseCharSet();
- final byte [] buffer = new byte[16384];
+ final byte[] buffer = new byte[16384];
int n = 0;
- while( (n = is.read(buffer, 0, buffer.length)) > 0) {
+ while ((n = is.read(buffer, 0, buffer.length)) > 0) {
content.append(new String(buffer, 0, n, charset));
- if(maxLength != 0 && content.length() > maxLength) {
+ if (maxLength != 0 && content.length() > maxLength) {
throw new IllegalArgumentException("Response body size is over maxLength (" + maxLength + ")");
}
}
@@ -577,32 +595,33 @@ public class HttpTestBase extends TestCase {
readinessCheckExtension = extension;
readinessCheckContentTypePrefix = contentTypePrefix;
}
-
+
/**
* Returns true if the bundle version deployed on the Sling instance is present and at least of the specified version
- *
+ *
* @param bundleSymbolicName the bundle name to check
* @param version the minimal version of the bundle that should be deployed
* @return true if the bundle is deployed with the specified version, false if it is not deployed or the version it too old
- * @throws IOException
+ * @throws IOException
*/
public boolean isBundleVersionAtLeast(String bundleSymbolicName, String version) throws IOException {
GetMethod method = new GetMethod(HTTP_BASE_URL + "/system/console/bundles/" + bundleSymbolicName + ".json");
int result = httpClient.executeMethod(method);
- if ( result != HttpServletResponse.SC_OK) {
+ if (result != HttpServletResponse.SC_OK) {
return false;
}
-
- try ( JsonReader jsonReader = Json.createReader(method.getResponseBodyAsStream()) ) {
+
+ try (JsonReader jsonReader = Json.createReader(method.getResponseBodyAsStream())) {
JsonObject bundleInfo = jsonReader.readObject();
- String bundleVersion = bundleInfo.getJsonArray("data").getJsonObject(0).getString("version");
+ String bundleVersion =
+ bundleInfo.getJsonArray("data").getJsonObject(0).getString("version");
Version bundleVer = new Version(bundleVersion);
- if ( bundleVer.compareTo(new Version(version)) < 0 ) {
+ if (bundleVer.compareTo(new Version(version)) < 0) {
return false;
}
}
-
+
return true;
}
}
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestNode.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestNode.java
index 77af85f..4f8b2c4 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestNode.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestNode.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
@@ -28,9 +30,10 @@ public class HttpTestNode {
public final String scriptPath;
private final SlingIntegrationTestClient testClient;
- public HttpTestNode(SlingIntegrationTestClient testClient, String parentPath, Map<String, String> properties) throws IOException {
+ public HttpTestNode(SlingIntegrationTestClient testClient, String parentPath, Map<String, String> properties)
+ throws IOException {
this.testClient = testClient;
- if(properties == null) {
+ if (properties == null) {
properties = new HashMap<String, String>();
}
testText = "This is a test node " + System.currentTimeMillis();
@@ -44,5 +47,4 @@ public class HttpTestNode {
public void delete() throws IOException {
testClient.delete(nodeUrl);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/NameValuePair.java b/src/main/java/org/apache/sling/commons/testing/integration/NameValuePair.java
index fe002cb..062da98 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/NameValuePair.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/NameValuePair.java
@@ -1,22 +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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
-
/**
* A basic name-value pair class.
*/
@@ -55,5 +56,4 @@ public class NameValuePair {
public String toString() {
return String.format("name=%s, value=%s", name, value);
}
-
}
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java b/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
index 39cfff2..6737675 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
@@ -56,7 +58,7 @@ public class NameValuePairList implements Iterable<NameValuePair> {
public void addIfNew(String name, String value) {
boolean found = false;
- for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext();) {
+ for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext(); ) {
NameValuePair current = li.next();
if (current.getName().equals(name)) {
found = true;
@@ -67,12 +69,11 @@ public class NameValuePairList implements Iterable<NameValuePair> {
if (!found) {
delegate.add(new NameValuePair(name, value));
}
-
}
public void addOrReplace(String name, String value) {
boolean replaced = false;
- for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext();) {
+ for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext(); ) {
NameValuePair current = li.next();
if (current.getName().equals(name)) {
if (!replaced) {
@@ -105,7 +106,7 @@ public class NameValuePairList implements Iterable<NameValuePair> {
public void prependIfNew(String name, String value) {
boolean found = false;
- for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext();) {
+ for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext(); ) {
NameValuePair current = li.next();
if (current.getName().equals(name)) {
found = true;
@@ -116,7 +117,6 @@ public class NameValuePairList implements Iterable<NameValuePair> {
if (!found) {
delegate.add(0, new NameValuePair(name, value));
}
-
}
public int size() {
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java b/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
index c3a1a2b..de7edfb 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.integration;
@@ -39,14 +41,14 @@ import org.apache.commons.httpclient.methods.multipart.StringPart;
/** Client functions to interact with Sling in integration tests */
public class SlingIntegrationTestClient {
private final HttpClient httpClient;
-
+
/** Extension to use to check if a folder exists */
private String folderExistsTestExtension = ".txt";
public SlingIntegrationTestClient(HttpClient client) {
this.httpClient = client;
}
-
+
public String getFolderExistsTestExtension() {
return folderExistsTestExtension;
}
@@ -76,24 +78,24 @@ public class SlingIntegrationTestClient {
public void mkdir(String url) throws IOException {
int status = 0;
status = httpClient.executeMethod(new GetMethod(url + folderExistsTestExtension));
- if(status != 200) {
- status = httpClient.executeMethod(new HttpAnyMethod("MKCOL",url));
- if(status!=201) {
+ if (status != 200) {
+ status = httpClient.executeMethod(new HttpAnyMethod("MKCOL", url));
+ if (status != 201) {
throw new IOException("mkdir(" + url + ") failed, status code=" + status);
}
}
}
/** Create the given directory via WebDAV, including parent directories */
- public void mkdirs(String baseUrl,String path) throws IOException {
- final String [] paths = path.split("/");
- if(baseUrl.endsWith("/")) {
- baseUrl = baseUrl.substring(0,baseUrl.length() - 1);
+ public void mkdirs(String baseUrl, String path) throws IOException {
+ final String[] paths = path.split("/");
+ if (baseUrl.endsWith("/")) {
+ baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
}
String currentPath = baseUrl;
- for(String pathElement : paths) {
- if(pathElement.length() == 0) {
+ for (String pathElement : paths) {
+ if (pathElement.length() == 0) {
continue;
}
currentPath += "/" + pathElement;
@@ -102,13 +104,13 @@ public class SlingIntegrationTestClient {
final String url = baseUrl + path;
final int status = httpClient.executeMethod(new GetMethod(url + folderExistsTestExtension));
- if(status!=200) {
+ if (status != 200) {
throw new HttpStatusCodeException(200, status, "GET", url);
}
}
/** Call the other createNode method with headers==null */
- public String createNode(String url, Map<String,String> nodeProperties) throws IOException {
+ public String createNode(String url, Map<String, String> nodeProperties) throws IOException {
return createNode(url, nodeProperties, null, false);
}
@@ -117,8 +119,9 @@ public class SlingIntegrationTestClient {
* @param multiPart if true, does a multipart POST
* @return the URL that Sling provides to display the node
*/
- public String createNode(String url, Map<String,String> clientNodeProperties, Map<String,String> requestHeaders,boolean multiPart)
- throws IOException {
+ public String createNode(
+ String url, Map<String, String> clientNodeProperties, Map<String, String> requestHeaders, boolean multiPart)
+ throws IOException {
return createNode(url, new NameValuePairList(clientNodeProperties), requestHeaders, multiPart);
}
@@ -127,23 +130,30 @@ public class SlingIntegrationTestClient {
* @param multiPart if true, does a multipart POST
* @return the URL that Sling provides to display the node
*/
- public String createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart)
- throws IOException {
- return createNode(url, clientNodeProperties, requestHeaders, multiPart, null, null, null);
+ public String createNode(
+ String url, NameValuePairList clientNodeProperties, Map<String, String> requestHeaders, boolean multiPart)
+ throws IOException {
+ return createNode(url, clientNodeProperties, requestHeaders, multiPart, null, null, null);
}
-
+
/** Create a node under given path, using a POST to Sling
* @param url under which node is created
* @param multiPart if true, does a multipart POST
* @param localFile file to upload
* @param fieldName name of the file field
- * @param typeHint typeHint of the file field
+ * @param typeHint typeHint of the file field
* @return the URL that Sling provides to display the node
*/
- public String createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart,
- File localFile, String fieldName, String typeHint)
- throws IOException {
-
+ public String createNode(
+ String url,
+ NameValuePairList clientNodeProperties,
+ Map<String, String> requestHeaders,
+ boolean multiPart,
+ File localFile,
+ String fieldName,
+ String typeHint)
+ throws IOException {
+
final PostMethod post = new PostMethod(url);
post.setFollowRedirects(false);
@@ -165,40 +175,41 @@ public class SlingIntegrationTestClient {
// string parts into stream data
nodeProperties.addOrReplace("_charset_", "UTF-8");
- if( nodeProperties.size() > 0) {
- if(multiPart) {
+ if (nodeProperties.size() > 0) {
+ if (multiPart) {
final List<Part> partList = new ArrayList<Part>();
- for(NameValuePair e : nodeProperties) {
+ for (NameValuePair e : nodeProperties) {
if (e.getValue() != null) {
partList.add(new StringPart(e.getName(), e.getValue(), "UTF-8"));
}
}
- if (localFile != null) {
+ if (localFile != null) {
partList.add(new FilePart(fieldName, localFile));
if (typeHint != null) {
- partList.add(new StringPart(fieldName + "@TypeHint", typeHint));
+ partList.add(new StringPart(fieldName + "@TypeHint", typeHint));
}
}
- final Part [] parts = partList.toArray(new Part[partList.size()]);
+ final Part[] parts = partList.toArray(new Part[partList.size()]);
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
} else {
- post.getParams().setContentCharset("UTF-8");
- for(NameValuePair e : nodeProperties) {
- post.addParameter(e.getName(),e.getValue());
+ post.getParams().setContentCharset("UTF-8");
+ for (NameValuePair e : nodeProperties) {
+ post.addParameter(e.getName(), e.getValue());
}
}
}
- if(requestHeaders != null) {
- for(Map.Entry<String,String> e : requestHeaders.entrySet()) {
+ if (requestHeaders != null) {
+ for (Map.Entry<String, String> e : requestHeaders.entrySet()) {
post.addRequestHeader(e.getKey(), e.getValue());
}
}
final int expected = 302;
final int status = httpClient.executeMethod(post);
- if(status!=expected) {
- throw new HttpStatusCodeException(expected, status, "POST", url, HttpTestBase.getResponseBodyAsStream(post, 0));
+ if (status != expected) {
+ throw new HttpStatusCodeException(
+ expected, status, "POST", url, HttpTestBase.getResponseBodyAsStream(post, 0));
}
String location = post.getResponseHeader("Location").getValue();
post.releaseConnection();
@@ -215,8 +226,7 @@ public class SlingIntegrationTestClient {
}
/** Upload to an file node structure, see SLING-168 */
- public void uploadToFileNode(String url, File localFile, String fieldName, String typeHint)
- throws IOException {
+ public void uploadToFileNode(String url, File localFile, String fieldName, String typeHint) throws IOException {
final Part[] parts = new Part[typeHint == null ? 1 : 2];
parts[0] = new FilePart(fieldName, localFile);
@@ -229,24 +239,24 @@ public class SlingIntegrationTestClient {
final int status = httpClient.executeMethod(post);
final int expected = 200;
- if(status!=expected) {
+ if (status != expected) {
throw new HttpStatusCodeException(expected, status, "POST", HttpTestBase.getResponseBodyAsStream(post, 0));
}
}
/** Upload multiple files to file node structures */
public void uploadToFileNodes(String url, File[] localFiles, String[] fieldNames, String[] typeHints)
- throws IOException {
+ throws IOException {
- List<Part> partsList = new ArrayList<Part>();
- for (int i=0; i < localFiles.length; i++) {
+ List<Part> partsList = new ArrayList<Part>();
+ for (int i = 0; i < localFiles.length; i++) {
Part filePart = new FilePart(fieldNames[i], localFiles[i]);
partsList.add(filePart);
if (typeHints != null) {
- Part typeHintPart = new StringPart(fieldNames[i] + "@TypeHint", typeHints[i]);
- partsList.add(typeHintPart);
+ Part typeHintPart = new StringPart(fieldNames[i] + "@TypeHint", typeHints[i]);
+ partsList.add(typeHintPart);
}
- }
+ }
final Part[] parts = partsList.toArray(new Part[partsList.size()]);
final PostMethod post = new PostMethod(url);
@@ -255,15 +265,15 @@ public class SlingIntegrationTestClient {
final int expected = 200;
final int status = httpClient.executeMethod(post);
- if(status!=expected) {
+ if (status != expected) {
throw new HttpStatusCodeException(expected, status, "POST", HttpTestBase.getResponseBodyAsStream(post, 0));
}
}
-
- public int post(String url, Map<String,String> properties) throws HttpException, IOException {
+
+ public int post(String url, Map<String, String> properties) throws HttpException, IOException {
final PostMethod post = new PostMethod(url);
post.getParams().setContentCharset("UTF-8");
- for(Entry<String, String> e : properties.entrySet()) {
+ for (Entry<String, String> e : properties.entrySet()) {
post.addParameter(e.getKey(), e.getValue());
}
return httpClient.executeMethod(post);
@@ -274,5 +284,4 @@ public class SlingIntegrationTestClient {
get.getParams().setContentCharset("UTF-8");
return httpClient.executeMethod(get);
}
-
}
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/TestInfoPassingClient.java b/src/main/java/org/apache/sling/commons/testing/integration/TestInfoPassingClient.java
index 314e33b..f95afab 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/TestInfoPassingClient.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/TestInfoPassingClient.java
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.sling.commons.testing.integration;
import java.io.IOException;
@@ -33,12 +32,11 @@ import org.slf4j.MDC;
* of outgoing HTTP request
*/
public class TestInfoPassingClient extends HttpClient {
- //Defined in org.apache.sling.testing.tools.junit.TestLogRule
+ // Defined in org.apache.sling.testing.tools.junit.TestLogRule
private static final String SLING_HEADER_PREFIX = "X-Sling-";
@Override
- public int executeMethod(HostConfiguration hostconfig, HttpMethod method,
- HttpState state) throws IOException {
+ public int executeMethod(HostConfiguration hostconfig, HttpMethod method, HttpState state) throws IOException {
addSlingHeaders(method);
return super.executeMethod(hostconfig, method, state);
}
@@ -47,13 +45,13 @@ public class TestInfoPassingClient extends HttpClient {
* Adds all MDC key-value pairs as HTTP header where the key starts
* with 'X-Sling-'
*/
- private static void addSlingHeaders(HttpMethod m){
- Map<?,?> mdc = MDC.getCopyOfContextMap();
+ private static void addSlingHeaders(HttpMethod m) {
+ Map<?, ?> mdc = MDC.getCopyOfContextMap();
if (mdc != null) {
for (Map.Entry<?, ?> e : mdc.entrySet()) {
Object key = e.getKey();
if (key instanceof String
- && ((String)key).startsWith(SLING_HEADER_PREFIX)
+ && ((String) key).startsWith(SLING_HEADER_PREFIX)
&& e.getValue() instanceof String) {
m.addRequestHeader((String) key, (String) e.getValue());
}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/EventHelper.java b/src/main/java/org/apache/sling/commons/testing/jcr/EventHelper.java
index f11fc53..375730b 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/EventHelper.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/EventHelper.java
@@ -29,28 +29,29 @@ import javax.jcr.observation.EventListener;
* have been delivered.
*/
public class EventHelper implements EventListener {
- private final Session session;
- private int eventCount;
- public static final String WAIT_NODE_FOLDER = "WAIT_NODE";
- public static final String WAIT_NODE_NODE = EventHelper.class.getSimpleName();
- private final Node waitNodeFolder;
+ private final Session session;
+ private int eventCount;
+ public static final String WAIT_NODE_FOLDER = "WAIT_NODE";
+ public static final String WAIT_NODE_NODE = EventHelper.class.getSimpleName();
+ private final Node waitNodeFolder;
- public EventHelper(Session s) throws RepositoryException {
- session = s;
+ public EventHelper(Session s) throws RepositoryException {
+ session = s;
final int eventTypes = Event.NODE_ADDED | Event.NODE_REMOVED;
final boolean isDeep = true;
final boolean noLocal = false;
- session.getWorkspace().getObservationManager().addEventListener(
- this, eventTypes, "/" + WAIT_NODE_FOLDER, isDeep, null, null, noLocal);
+ session.getWorkspace()
+ .getObservationManager()
+ .addEventListener(this, eventTypes, "/" + WAIT_NODE_FOLDER, isDeep, null, null, noLocal);
- if(session.getRootNode().hasNode(WAIT_NODE_FOLDER)) {
- waitNodeFolder = session.getRootNode().getNode(WAIT_NODE_FOLDER);
+ if (session.getRootNode().hasNode(WAIT_NODE_FOLDER)) {
+ waitNodeFolder = session.getRootNode().getNode(WAIT_NODE_FOLDER);
} else {
- waitNodeFolder = session.getRootNode().addNode(WAIT_NODE_FOLDER, "nt:unstructured");
+ waitNodeFolder = session.getRootNode().addNode(WAIT_NODE_FOLDER, "nt:unstructured");
}
session.save();
- }
+ }
public void onEvent(EventIterator it) {
eventCount++;
@@ -60,27 +61,28 @@ public class EventHelper implements EventListener {
* create or delete a a node and wait for the corresponding
* events to be received.
*/
- public void waitForEvents(long timeoutMsec) throws RepositoryException {
- final int targetEventCount = eventCount + 1;
+ public void waitForEvents(long timeoutMsec) throws RepositoryException {
+ final int targetEventCount = eventCount + 1;
- if(waitNodeFolder.hasNode(WAIT_NODE_NODE)) {
- waitNodeFolder.getNode(WAIT_NODE_NODE).remove();
- } else {
- waitNodeFolder.addNode(WAIT_NODE_NODE);
- }
- session.save();
+ if (waitNodeFolder.hasNode(WAIT_NODE_NODE)) {
+ waitNodeFolder.getNode(WAIT_NODE_NODE).remove();
+ } else {
+ waitNodeFolder.addNode(WAIT_NODE_NODE);
+ }
+ session.save();
- final long end = System.currentTimeMillis() + timeoutMsec;
- while(eventCount < targetEventCount && System.currentTimeMillis() < end) {
- try {
- Thread.sleep(100);
- } catch(InterruptedException ignored) {
- }
- }
+ final long end = System.currentTimeMillis() + timeoutMsec;
+ while (eventCount < targetEventCount && System.currentTimeMillis() < end) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ignored) {
+ }
+ }
- if(eventCount < targetEventCount) {
- throw new IllegalStateException("Event counter did not reach " + targetEventCount + ", waited " + timeoutMsec + " msec");
- }
+ if (eventCount < targetEventCount) {
+ throw new IllegalStateException(
+ "Event counter did not reach " + targetEventCount + ", waited " + timeoutMsec + " msec");
+ }
}
/**
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockNode.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockNode.java
index 997a41e..22d096e 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockNode.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockNode.java
@@ -18,14 +18,6 @@
*/
package org.apache.sling.commons.testing.jcr;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import javax.jcr.Binary;
import javax.jcr.InvalidLifecycleTransitionException;
import javax.jcr.Item;
@@ -49,13 +41,21 @@ import javax.jcr.version.Version;
import javax.jcr.version.VersionException;
import javax.jcr.version.VersionHistory;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.jackrabbit.util.ChildrenCollectorFilter;
// simple mock implementation of a node
public class MockNode implements Node {
private String path;
- private Map <String, Property> properties = new HashMap <String, Property>();
+ private Map<String, Property> properties = new HashMap<String, Property>();
private NodeType nodeType;
private Session session;
@@ -110,8 +110,7 @@ public class MockNode implements Node {
return "MockNode: path=" + getPath();
}
- public void addMixin(String mixinName) {
- }
+ public void addMixin(String mixinName) {}
public Node addNode(String relPath) {
return null;
@@ -125,19 +124,15 @@ public class MockNode implements Node {
return false;
}
- public void cancelMerge(Version version) {
-
- }
+ public void cancelMerge(Version version) {}
public Version checkin() {
return null;
}
- public void checkout() {
- }
+ public void checkout() {}
- public void doneMerge(Version version) {
- }
+ public void doneMerge(Version version) {}
public Version getBaseVersion() {
return null;
@@ -254,81 +249,93 @@ public class MockNode implements Node {
return null;
}
- public void orderBefore(String srcChildRelPath, String destChildRelPath) {
- }
+ public void orderBefore(String srcChildRelPath, String destChildRelPath) {}
- public void removeMixin(String mixinName) {
- }
+ public void removeMixin(String mixinName) {}
- public void restore(String versionName, boolean removeExisting) {
- }
+ public void restore(String versionName, boolean removeExisting) {}
- public void restore(Version version, boolean removeExisting) {
- }
+ public void restore(Version version, boolean removeExisting) {}
- public void restore(Version version, String relPath, boolean removeExisting) {
- }
+ public void restore(Version version, String relPath, boolean removeExisting) {}
- public void restoreByLabel(String versionLabel, boolean removeExisting) {
- }
+ public void restoreByLabel(String versionLabel, boolean removeExisting) {}
- public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, Value value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, Value[] values)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(values);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, String[] values)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(values);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, String value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, InputStream value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, boolean value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, double value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, long value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
return p;
}
- public Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ public Property setProperty(String name, Calendar value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
MockProperty p = new MockProperty(name);
p.setValue(value);
properties.put(name, p);
@@ -355,14 +362,11 @@ public class MockNode implements Node {
return null;
}
- public void unlock() {
- }
+ public void unlock() {}
- public void update(String srcWorkspaceName) {
- }
+ public void update(String srcWorkspaceName) {}
- public void accept(ItemVisitor visitor) {
- }
+ public void accept(ItemVisitor visitor) {}
public Item getAncestor(int depth) {
return null;
@@ -377,7 +381,7 @@ public class MockNode implements Node {
}
public void setSession(Session session) {
- this.session = session;
+ this.session = session;
}
public boolean isModified() {
@@ -392,20 +396,16 @@ public class MockNode implements Node {
return true;
}
- public void refresh(boolean keepChanges) {
- }
+ public void refresh(boolean keepChanges) {}
- public void remove() {
- }
+ public void remove() {}
- public void save() {
- }
+ public void save() {}
// JCR 2.0 methods
public void followLifecycleTransition(String transition)
- throws UnsupportedRepositoryOperationException,
- InvalidLifecycleTransitionException, RepositoryException {
+ throws UnsupportedRepositoryOperationException, InvalidLifecycleTransitionException, RepositoryException {
// TODO Auto-generated method stub
}
@@ -426,14 +426,12 @@ public class MockNode implements Node {
return null;
}
- public PropertyIterator getProperties(String[] nameGlobs)
- throws RepositoryException {
+ public PropertyIterator getProperties(String[] nameGlobs) throws RepositoryException {
// TODO Auto-generated method stub
return null;
}
- public PropertyIterator getReferences(String name)
- throws RepositoryException {
+ public PropertyIterator getReferences(String name) throws RepositoryException {
// TODO Auto-generated method stub
return null;
}
@@ -448,41 +446,40 @@ public class MockNode implements Node {
return null;
}
- public PropertyIterator getWeakReferences(String name)
- throws RepositoryException {
+ public PropertyIterator getWeakReferences(String name) throws RepositoryException {
// TODO Auto-generated method stub
return null;
}
- public void removeShare() throws VersionException, LockException,
- ConstraintViolationException, RepositoryException {
+ public void removeShare()
+ throws VersionException, LockException, ConstraintViolationException, RepositoryException {
// TODO Auto-generated method stub
}
- public void removeSharedSet() throws VersionException, LockException,
- ConstraintViolationException, RepositoryException {
+ public void removeSharedSet()
+ throws VersionException, LockException, ConstraintViolationException, RepositoryException {
// TODO Auto-generated method stub
}
public void setPrimaryType(String nodeTypeName)
- throws NoSuchNodeTypeException, VersionException,
- ConstraintViolationException, LockException, RepositoryException {
+ throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException,
+ RepositoryException {
// TODO Auto-generated method stub
}
public Property setProperty(String name, BigDecimal value)
- throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
// TODO Auto-generated method stub
return null;
}
public Property setProperty(String name, Binary value)
- throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeIterator.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeIterator.java
index fff3dba..a785e92 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeIterator.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeIterator.java
@@ -18,21 +18,21 @@
*/
package org.apache.sling.commons.testing.jcr;
-import java.util.NoSuchElementException;
-
import javax.jcr.Node;
import javax.jcr.NodeIterator;
+import java.util.NoSuchElementException;
+
public class MockNodeIterator implements NodeIterator {
private Node[] nodes;
private int idx;
- private static final Node [] EMPTY_NODE_ARRAY = {};
+ private static final Node[] EMPTY_NODE_ARRAY = {};
public MockNodeIterator() {
this(EMPTY_NODE_ARRAY);
}
-
+
public MockNodeIterator(Node[] nodes) {
this.nodes = (nodes != null) ? nodes : new Node[0];
this.idx = 0;
@@ -47,7 +47,7 @@ public class MockNodeIterator implements NodeIterator {
}
public long getPosition() {
- return idx-1;
+ return idx - 1;
}
public long getSize() {
@@ -69,5 +69,4 @@ public class MockNodeIterator implements NodeIterator {
public void remove() {
throw new UnsupportedOperationException();
}
-
}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockProperty.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockProperty.java
index 8e519a1..a5428a8 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockProperty.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockProperty.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.commons.testing.jcr;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
-
import javax.jcr.AccessDeniedException;
import javax.jcr.Binary;
import javax.jcr.InvalidItemStateException;
@@ -43,9 +39,13 @@ import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.version.VersionException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
+
public class MockProperty implements Property {
- private Value [] values = {};
+ private Value[] values = {};
private final String name;
public MockProperty(String name) {
@@ -104,7 +104,7 @@ public class MockProperty implements Property {
}
public String getString() throws ValueFormatException, RepositoryException {
- if(values.length > 0) return values[0].getString();
+ if (values.length > 0) return values[0].getString();
return null;
}
@@ -123,78 +123,86 @@ public class MockProperty implements Property {
return values;
}
- public void setValue(boolean value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- MockValue val = new MockValue();
- val.setValue(value);
- values = new MockValue[1];
- values[0] = val;
+ public void setValue(boolean value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ MockValue val = new MockValue();
+ val.setValue(value);
+ values = new MockValue[1];
+ values[0] = val;
}
- public void setValue(Calendar value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- MockValue val = new MockValue();
- val.setValue(value);
- values = new MockValue[1];
- values[0] = val;
+ public void setValue(Calendar value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ MockValue val = new MockValue();
+ val.setValue(value);
+ values = new MockValue[1];
+ values[0] = val;
}
- public void setValue(double value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- MockValue val = new MockValue();
- val.setValue(value);
- values = new MockValue[1];
- values[0] = val;
+ public void setValue(double value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ MockValue val = new MockValue();
+ val.setValue(value);
+ values = new MockValue[1];
+ values[0] = val;
}
- public void setValue(InputStream value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- MockValue val = new MockValue();
- val.setValue(value);
- values = new MockValue[1];
- values[0] = val;
+ public void setValue(InputStream value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ MockValue val = new MockValue();
+ val.setValue(value);
+ values = new MockValue[1];
+ values[0] = val;
}
- public void setValue(long value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- MockValue val = new MockValue();
- val.setValue(value);
- values = new MockValue[1];
- values[0] = val;
+ public void setValue(long value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ MockValue val = new MockValue();
+ val.setValue(value);
+ values = new MockValue[1];
+ values[0] = val;
}
- public void setValue(Node value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- }
+ public void setValue(Node value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {}
- public void setValue(String value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- values =new MockValue[1];
+ public void setValue(String value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ values = new MockValue[1];
values[0] = new MockValue(value);
}
- public void setValue(String[] inputValues) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
+ public void setValue(String[] inputValues)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
this.values = new MockValue[inputValues.length];
int i = 0;
- for(String str : inputValues) {
+ for (String str : inputValues) {
values[i++] = new MockValue(str);
}
}
- public void setValue(Value value) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- values = new Value[1];
- values[0] = value;
+ public void setValue(Value value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ values = new Value[1];
+ values[0] = value;
}
- public void setValue(Value[] values) throws ValueFormatException, VersionException, LockException,
- ConstraintViolationException, RepositoryException {
- this.values = values;
+ public void setValue(Value[] values)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
+ this.values = values;
}
- public void accept(ItemVisitor visitor) throws RepositoryException {
- }
+ public void accept(ItemVisitor visitor) throws RepositoryException {}
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
return null;
@@ -236,16 +244,14 @@ public class MockProperty implements Property {
return false;
}
- public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
- }
+ public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {}
- public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException {
- }
+ public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException {}
- public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException,
- InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException,
- NoSuchNodeTypeException, RepositoryException {
- }
+ public void save()
+ throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException,
+ ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException,
+ RepositoryException {}
// JCR 2.0 methods
@@ -254,14 +260,12 @@ public class MockProperty implements Property {
return null;
}
- public BigDecimal getDecimal() throws ValueFormatException,
- RepositoryException {
+ public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
// TODO Auto-generated method stub
return null;
}
- public Property getProperty() throws ItemNotFoundException,
- ValueFormatException, RepositoryException {
+ public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
// TODO Auto-generated method stub
return null;
}
@@ -270,16 +274,16 @@ public class MockProperty implements Property {
return values.length > 1;
}
- public void setValue(BigDecimal value) throws ValueFormatException,
- VersionException, LockException, ConstraintViolationException,
- RepositoryException {
+ public void setValue(BigDecimal value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
// TODO Auto-generated method stub
}
- public void setValue(Binary value) throws ValueFormatException,
- VersionException, LockException, ConstraintViolationException,
- RepositoryException {
+ public void setValue(Binary value)
+ throws ValueFormatException, VersionException, LockException, ConstraintViolationException,
+ RepositoryException {
// TODO Auto-generated method stub
}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyDefinition.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyDefinition.java
index 864f961..e7a0b67 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyDefinition.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyDefinition.java
@@ -28,8 +28,8 @@ public class MockPropertyDefinition implements PropertyDefinition {
public MockPropertyDefinition(boolean multiple) {
this.multiple = multiple;
-
}
+
public Value[] getDefaultValues() {
return null;
}
@@ -76,10 +76,12 @@ public class MockPropertyDefinition implements PropertyDefinition {
// TODO Auto-generated method stub
return null;
}
+
public boolean isFullTextSearchable() {
// TODO Auto-generated method stub
return false;
}
+
public boolean isQueryOrderable() {
// TODO Auto-generated method stub
return false;
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyIterator.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyIterator.java
index c141af4..7fcd18e 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyIterator.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockPropertyIterator.java
@@ -18,20 +18,20 @@
*/
package org.apache.sling.commons.testing.jcr;
-import java.util.Iterator;
-
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
+import java.util.Iterator;
+
public class MockPropertyIterator implements PropertyIterator {
private final Iterator<Property> iterator;
int index = 0;
-
- public MockPropertyIterator(Iterator <Property> it) {
+
+ public MockPropertyIterator(Iterator<Property> it) {
iterator = it;
}
-
+
public Property nextProperty() {
return iterator.next();
}
@@ -44,8 +44,7 @@ public class MockPropertyIterator implements PropertyIterator {
return -1;
}
- public void skip(long skipNum) {
- }
+ public void skip(long skipNum) {}
public boolean hasNext() {
return iterator.hasNext();
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/MockValue.java b/src/main/java/org/apache/sling/commons/testing/jcr/MockValue.java
index 8a1774b..f646ae5 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/MockValue.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/MockValue.java
@@ -18,16 +18,16 @@
*/
package org.apache.sling.commons.testing.jcr;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
-
import javax.jcr.Binary;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
+
public class MockValue implements Value {
private String stringValue;
@@ -39,8 +39,7 @@ public class MockValue implements Value {
private int propertyType;
private BigDecimal decimal;
- public MockValue() {
- }
+ public MockValue() {}
public MockValue(String str) {
stringValue = str;
@@ -75,29 +74,28 @@ public class MockValue implements Value {
return propertyType;
}
-
public void setValue(String stringValue) {
- this.stringValue = stringValue;
+ this.stringValue = stringValue;
}
public void setValue(boolean booleanValue) {
- this.booleanValue = booleanValue;
+ this.booleanValue = booleanValue;
}
public void setValue(Calendar calendarValue) {
- this.calendarValue = calendarValue;
+ this.calendarValue = calendarValue;
}
public void setValue(double doubleValue) {
- this.doubleValue = doubleValue;
+ this.doubleValue = doubleValue;
}
public void setValue(long longValue) {
- this.longValue = longValue;
+ this.longValue = longValue;
}
public void setValue(InputStream stream) {
- this.stream = stream;
+ this.stream = stream;
}
public void setDecimal(BigDecimal value) {
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryProvider.java b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryProvider.java
index 1ab2742..e6e02db 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryProvider.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryProvider.java
@@ -28,38 +28,37 @@ import org.apache.sling.jcr.api.SlingRepository;
public class RepositoryProvider {
private static RepositoryProvider INSTANCE;
private SlingRepository repository;
-
+
private static class ShutdownThread extends Thread {
@Override
public void run() {
try {
RepositoryUtil.stopRepository();
- } catch(Exception e) {
+ } catch (Exception e) {
System.out.println("Exception in ShutdownThread:" + e);
}
}
-
- };
-
- private RepositoryProvider() {
}
-
- public synchronized static RepositoryProvider instance() {
- if(INSTANCE == null) {
+ ;
+
+ private RepositoryProvider() {}
+
+ public static synchronized RepositoryProvider instance() {
+ if (INSTANCE == null) {
INSTANCE = new RepositoryProvider();
}
return INSTANCE;
}
-
+
/** Return a SlingRepository. First call initializes it, and a JVM
- * shutdown hook is registered to stop it.
- **/
+ * shutdown hook is registered to stop it.
+ **/
public synchronized SlingRepository getRepository() throws RepositoryException {
- if(repository == null) {
+ if (repository == null) {
RepositoryUtil.startRepository();
repository = RepositoryUtil.getRepository();
Runtime.getRuntime().addShutdownHook(new ShutdownThread());
}
return repository;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryTestBase.java b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryTestBase.java
index 3c990b4..92c4fb6 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryTestBase.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryTestBase.java
@@ -24,10 +24,9 @@ import javax.jcr.Session;
import javax.naming.NamingException;
import junit.framework.TestCase;
-
import org.apache.sling.jcr.api.SlingRepository;
-/** Base class for JUnit3-style tests which need a Repository.
+/** Base class for JUnit3-style tests which need a Repository.
* Should eventually be deprecated in favor of {@link RepositoryProvider}
* which is less intrusive
*/
@@ -35,28 +34,28 @@ public class RepositoryTestBase extends TestCase {
protected Node testRoot;
protected Session session;
private int counter;
-
+
@Override
protected void tearDown() throws Exception {
super.tearDown();
- if(session != null) {
+ if (session != null) {
session.logout();
}
}
- /** Return a JCR Session, initialized on demand */
+ /** Return a JCR Session, initialized on demand */
protected Session getSession() throws RepositoryException, NamingException {
- if(session == null) {
+ if (session == null) {
session = getRepository().loginAdministrative(null);
}
return session;
}
-
- /** Return a test root node, created on demand, with a unique path */
+
+ /** Return a test root node, created on demand, with a unique path */
protected Node getTestRootNode() throws RepositoryException, NamingException {
- if(testRoot==null) {
+ if (testRoot == null) {
final Node root = getSession().getRootNode();
- final Node classRoot = root.addNode(getClass().getSimpleName());
+ final Node classRoot = root.addNode(getClass().getSimpleName());
testRoot = classRoot.addNode(System.currentTimeMillis() + "_" + (++counter));
}
return testRoot;
@@ -66,4 +65,4 @@ public class RepositoryTestBase extends TestCase {
protected SlingRepository getRepository() throws RepositoryException, NamingException {
return RepositoryProvider.instance().getRepository();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
index c289a14..57f81bd 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
@@ -1,27 +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
+ * 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
+ * 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.
+ * 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.commons.testing.jcr;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
import javax.jcr.Credentials;
import javax.jcr.LoginException;
import javax.jcr.NoSuchWorkspaceException;
@@ -32,6 +28,12 @@ import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
import javax.naming.NamingException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.commons.cnd.CndImporter;
import org.apache.sling.jcr.api.SlingRepository;
@@ -61,10 +63,9 @@ public class RepositoryUtil {
* repository.
*/
public static void startRepository() throws RepositoryException {
- if ( adminSession == null ) {
+ if (adminSession == null) {
// copy the repository configuration file to the repository HOME_DIR
- InputStream ins = RepositoryUtil.class.getClassLoader().getResourceAsStream(
- CONFIG_FILE);
+ InputStream ins = RepositoryUtil.class.getClassLoader().getResourceAsStream(CONFIG_FILE);
if (ins == null) {
throw new RepositoryException("Cannot get " + CONFIG_FILE);
}
@@ -81,8 +82,7 @@ public class RepositoryUtil {
out.write(buf, 0, rd);
}
} catch (IOException ioe) {
- throw new RepositoryException("Cannot copy configuration file to "
- + configFile);
+ throw new RepositoryException("Cannot copy configuration file to " + configFile);
} finally {
try {
ins.close();
@@ -113,7 +113,7 @@ public class RepositoryUtil {
* Stop a repository.
*/
public static void stopRepository() throws NamingException {
- if ( adminSession != null ) {
+ if (adminSession != null) {
adminSession.logout();
adminSession = null;
repository = null;
@@ -155,12 +155,9 @@ public class RepositoryUtil {
public static void registerSlingNodeTypes(Session adminSession) throws IOException, RepositoryException {
final Class<RepositoryUtil> clazz = RepositoryUtil.class;
- registerNodeType(adminSession,
- clazz.getResourceAsStream("/SLING-INF/nodetypes/folder.cnd"));
- RepositoryUtil.registerNodeType(adminSession,
- clazz.getResourceAsStream("/SLING-INF/nodetypes/resource.cnd"));
- RepositoryUtil.registerNodeType(adminSession,
- clazz.getResourceAsStream("/SLING-INF/nodetypes/vanitypath.cnd"));
+ registerNodeType(adminSession, clazz.getResourceAsStream("/SLING-INF/nodetypes/folder.cnd"));
+ RepositoryUtil.registerNodeType(adminSession, clazz.getResourceAsStream("/SLING-INF/nodetypes/resource.cnd"));
+ RepositoryUtil.registerNodeType(adminSession, clazz.getResourceAsStream("/SLING-INF/nodetypes/vanitypath.cnd"));
}
public static final class RepositoryWrapper implements SlingRepository {
@@ -184,18 +181,16 @@ public class RepositoryUtil {
}
public Session login(Credentials credentials, String workspaceName)
- throws LoginException, NoSuchWorkspaceException,
- RepositoryException {
+ throws LoginException, NoSuchWorkspaceException, RepositoryException {
return wrapped.login(credentials, (workspaceName == null ? getDefaultWorkspace() : workspaceName));
}
- public Session login(Credentials credentials) throws LoginException,
- RepositoryException {
+ public Session login(Credentials credentials) throws LoginException, RepositoryException {
return wrapped.login(credentials);
}
- public Session login(String workspaceName) throws LoginException,
- NoSuchWorkspaceException, RepositoryException {
+ public Session login(String workspaceName)
+ throws LoginException, NoSuchWorkspaceException, RepositoryException {
return wrapped.login((workspaceName == null ? getDefaultWorkspace() : workspaceName));
}
@@ -203,10 +198,8 @@ public class RepositoryUtil {
return "default";
}
- public Session loginAdministrative(String workspaceName)
- throws RepositoryException {
- final Credentials credentials = new SimpleCredentials(ADMIN_NAME,
- ADMIN_PASSWORD.toCharArray());
+ public Session loginAdministrative(String workspaceName) throws RepositoryException {
+ final Credentials credentials = new SimpleCredentials(ADMIN_NAME, ADMIN_PASSWORD.toCharArray());
return this.login(credentials, (workspaceName == null ? getDefaultWorkspace() : workspaceName));
}
@@ -227,14 +220,15 @@ public class RepositoryUtil {
}
@Override
- public Session loginService(String subServiceName, String workspace) throws LoginException, RepositoryException {
+ public Session loginService(String subServiceName, String workspace)
+ throws LoginException, RepositoryException {
throw new UnsupportedOperationException();
}
@Override
- public Session impersonateFromService(String subServiceName, Credentials credentials, String workspaceName) throws LoginException, RepositoryException {
+ public Session impersonateFromService(String subServiceName, Credentials credentials, String workspaceName)
+ throws LoginException, RepositoryException {
throw new UnsupportedOperationException();
}
-
}
}
diff --git a/src/main/java/org/apache/sling/commons/testing/junit/Retry.java b/src/main/java/org/apache/sling/commons/testing/junit/Retry.java
index 219547a..9680722 100644
--- a/src/main/java/org/apache/sling/commons/testing/junit/Retry.java
+++ b/src/main/java/org/apache/sling/commons/testing/junit/Retry.java
@@ -24,10 +24,10 @@ import java.lang.annotation.RetentionPolicy;
/** Used to annotate JUnit tests as being retryable */
@Retention(RetentionPolicy.RUNTIME)
public @interface Retry {
-
- /** Retries for at most this many milliseconds */
+
+ /** Retries for at most this many milliseconds */
int timeoutMsec() default -1;
-
+
/** Wait this many milliseconds between retries */
int intervalMsec() default -1;
-}
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/junit/RetryRule.java b/src/main/java/org/apache/sling/commons/testing/junit/RetryRule.java
index d2d13ad..ec63380 100644
--- a/src/main/java/org/apache/sling/commons/testing/junit/RetryRule.java
+++ b/src/main/java/org/apache/sling/commons/testing/junit/RetryRule.java
@@ -26,12 +26,12 @@ import org.slf4j.LoggerFactory;
/** JUnit Rule that implements retries, see tests for usage example */
public class RetryRule implements TestRule {
-
+
public static final int DEFAULT_DEFAULT_TIMEOUT_MSEC = 5000;
public static final int DEFAULT_DEFAULT_INTERVAL_MSEC = 500;
-
+
private static final Logger log = LoggerFactory.getLogger(RetryRule.class);
-
+
private final long defaultTimeout;
private final long defaultInterval;
@@ -39,74 +39,73 @@ public class RetryRule implements TestRule {
public RetryRule() {
this(DEFAULT_DEFAULT_TIMEOUT_MSEC, DEFAULT_DEFAULT_INTERVAL_MSEC);
}
-
+
/** Create a RetryRule with specific values for default timeout and interval */
public RetryRule(long defaultTimeout, long defaultInterval) {
this.defaultTimeout = defaultTimeout;
this.defaultInterval = defaultInterval;
}
-
+
@Override
public String toString() {
return new StringBuilder()
- .append(getClass().getSimpleName())
- .append(", default interval=")
- .append(defaultInterval)
- .append(" msec, default timeout=")
- .append(defaultTimeout)
- .append(" msec")
- .toString();
+ .append(getClass().getSimpleName())
+ .append(", default interval=")
+ .append(defaultInterval)
+ .append(" msec, default timeout=")
+ .append(defaultTimeout)
+ .append(" msec")
+ .toString();
}
-
+
public Statement apply(final Statement statement, final Description description) {
return new Statement() {
-
+
private Throwable eval(Statement stmt) {
try {
stmt.evaluate();
- } catch(Throwable t) {
+ } catch (Throwable t) {
return t;
}
return null;
}
-
+
@Override
public void evaluate() throws Throwable {
int retries = 0;
Throwable t = eval(statement);
- if(t != null) {
+ if (t != null) {
final Retry r = description.getAnnotation(Retry.class);
- if(r != null) {
+ if (r != null) {
final long timeout = System.currentTimeMillis() + getTimeout(r.timeoutMsec());
- while(System.currentTimeMillis() < timeout) {
+ while (System.currentTimeMillis() < timeout) {
retries++;
t = eval(statement);
- if(t == null) {
+ if (t == null) {
break;
}
Thread.sleep(getInterval(r.intervalMsec()));
}
}
}
- if(t != null) {
- if(retries > 0) {
+ if (t != null) {
+ if (retries > 0) {
log.debug("{} fails after retrying {} time(s)", statement, retries);
}
throw t;
}
- if(retries > 0) {
+ if (retries > 0) {
log.debug("{} succeeds after retrying {} time(s)", statement, retries);
}
}
};
}
-
+
long getTimeout(long ruleTimeout) {
return ruleTimeout > 0 ? ruleTimeout : defaultTimeout;
}
-
+
long getInterval(long ruleInterval) {
return ruleInterval > 0 ? ruleInterval : defaultInterval;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/junit/categories/Slow.java b/src/main/java/org/apache/sling/commons/testing/junit/categories/Slow.java
index a17896a..c0ba2dd 100644
--- a/src/main/java/org/apache/sling/commons/testing/junit/categories/Slow.java
+++ b/src/main/java/org/apache/sling/commons/testing/junit/categories/Slow.java
@@ -20,5 +20,4 @@ package org.apache.sling.commons.testing.junit.categories;
/** JUnit Category for tests that are considered slow and
* are thus only run when explicitly enabled (by default off) */
-public interface Slow {
-}
\ No newline at end of file
+public interface Slow {}
diff --git a/src/main/java/org/apache/sling/commons/testing/osgi/MockBundle.java b/src/main/java/org/apache/sling/commons/testing/osgi/MockBundle.java
index 6bf0495..9e923bb 100644
--- a/src/main/java/org/apache/sling/commons/testing/osgi/MockBundle.java
+++ b/src/main/java/org/apache/sling/commons/testing/osgi/MockBundle.java
@@ -45,8 +45,7 @@ public class MockBundle implements Bundle {
}
@Override
- public Enumeration<URL> findEntries(String path, String filePattern,
- boolean recurse) {
+ public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
return null;
}
@@ -121,29 +120,19 @@ public class MockBundle implements Bundle {
}
@Override
- public void start() {
-
- }
+ public void start() {}
@Override
- public void stop() {
-
- }
+ public void stop() {}
@Override
- public void uninstall() {
-
- }
+ public void uninstall() {}
@Override
- public void update() {
-
- }
+ public void update() {}
@Override
- public void update(InputStream in) {
-
- }
+ public void update(InputStream in) {}
@Override
public BundleContext getBundleContext() {
@@ -151,12 +140,10 @@ public class MockBundle implements Bundle {
}
@Override
- public void start(int options) throws BundleException {
- }
+ public void start(int options) throws BundleException {}
@Override
- public void stop(int options) throws BundleException {
- }
+ public void stop(int options) throws BundleException {}
@Override
public Map getSignerCertificates(int signersType) {
@@ -185,4 +172,4 @@ public class MockBundle implements Bundle {
// TODO Auto-generated method stub
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/osgi/MockBundleContext.java b/src/main/java/org/apache/sling/commons/testing/osgi/MockBundleContext.java
index e690169..d5b980c 100644
--- a/src/main/java/org/apache/sling/commons/testing/osgi/MockBundleContext.java
+++ b/src/main/java/org/apache/sling/commons/testing/osgi/MockBundleContext.java
@@ -46,138 +46,111 @@ public class MockBundleContext implements BundleContext {
@Override
public String getProperty(String s) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public Bundle getBundle() {
return bundle;
-
}
@Override
public Bundle installBundle(String s) throws BundleException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
- public Bundle installBundle(String s, InputStream inputStream)
- throws BundleException {
+ public Bundle installBundle(String s, InputStream inputStream) throws BundleException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public Bundle getBundle(long l) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public Bundle[] getBundles() {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
- public void addServiceListener(ServiceListener serviceListener, String s)
- throws InvalidSyntaxException {
+ public void addServiceListener(ServiceListener serviceListener, String s) throws InvalidSyntaxException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void addServiceListener(ServiceListener serviceListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void removeServiceListener(ServiceListener serviceListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void addBundleListener(BundleListener bundleListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void removeBundleListener(BundleListener bundleListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void addFrameworkListener(FrameworkListener frameworkListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public void removeFrameworkListener(FrameworkListener frameworkListener) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
- public ServiceRegistration registerService(String[] strings, Object o,
- Dictionary dictionary) {
+ public ServiceRegistration registerService(String[] strings, Object o, Dictionary dictionary) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
- public ServiceRegistration registerService(String s, Object o,
- Dictionary dictionary) {
+ public ServiceRegistration registerService(String s, Object o, Dictionary dictionary) {
return new MockServiceRegistration();
}
@Override
- public ServiceReference[] getServiceReferences(String s, String s1)
- throws InvalidSyntaxException {
+ public ServiceReference[] getServiceReferences(String s, String s1) throws InvalidSyntaxException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
- public ServiceReference[] getAllServiceReferences(String s, String s1)
- throws InvalidSyntaxException {
+ public ServiceReference[] getAllServiceReferences(String s, String s1) throws InvalidSyntaxException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public ServiceReference getServiceReference(String s) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public Object getService(ServiceReference serviceReference) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public boolean ungetService(ServiceReference serviceReference) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public File getDataFile(String s) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
public Filter createFilter(String s) throws InvalidSyntaxException {
throw new UnsupportedOperationException("Not implemented");
-
}
@Override
@@ -187,8 +160,8 @@ public class MockBundleContext implements BundleContext {
}
@Override
- public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory,
- Dictionary<String, ?> properties) {
+ public <S> ServiceRegistration<S> registerService(
+ Class<S> clazz, ServiceFactory<S> factory, Dictionary<String, ?> properties) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/org/apache/sling/commons/testing/osgi/MockComponentContext.java b/src/main/java/org/apache/sling/commons/testing/osgi/MockComponentContext.java
index 5ec1ff6..9af03d3 100644
--- a/src/main/java/org/apache/sling/commons/testing/osgi/MockComponentContext.java
+++ b/src/main/java/org/apache/sling/commons/testing/osgi/MockComponentContext.java
@@ -18,13 +18,13 @@
*/
package org.apache.sling.commons.testing.osgi;
+import javax.servlet.Servlet;
+
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
-import javax.servlet.Servlet;
-
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -63,7 +63,6 @@ public class MockComponentContext implements ComponentContext {
services.put(reference, service);
}
-
public void setProperty(Object key, Object value) {
// noinspection unchecked
this.properties.put(key.toString(), value);
@@ -92,12 +91,10 @@ public class MockComponentContext implements ComponentContext {
}
@Override
- public void disableComponent(String name) {
- }
+ public void disableComponent(String name) {}
@Override
- public void enableComponent(String name) {
- }
+ public void enableComponent(String name) {}
@Override
public ComponentInstance getComponentInstance() {
diff --git a/src/main/java/org/apache/sling/commons/testing/osgi/MockServiceReference.java b/src/main/java/org/apache/sling/commons/testing/osgi/MockServiceReference.java
index b527d62..6143276 100644
--- a/src/main/java/org/apache/sling/commons/testing/osgi/MockServiceReference.java
+++ b/src/main/java/org/apache/sling/commons/testing/osgi/MockServiceReference.java
@@ -74,5 +74,4 @@ public class MockServiceReference implements ServiceReference {
public Dictionary<String, Object> getProperties() {
return props;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockRequestPathInfo.java b/src/main/java/org/apache/sling/commons/testing/sling/MockRequestPathInfo.java
index 12e2645..cf0ae15 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockRequestPathInfo.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockRequestPathInfo.java
@@ -33,18 +33,18 @@ class MockRequestPathInfo implements RequestPathInfo {
private final String suffix;
- private final String path;
+ private final String path;
- public MockRequestPathInfo(String selectors, String extension, String suffix) {
- this(selectors, extension, suffix, null);
- }
+ public MockRequestPathInfo(String selectors, String extension, String suffix) {
+ this(selectors, extension, suffix, null);
+ }
- public MockRequestPathInfo(String selectors, String extension, String suffix, String path) {
- this.selectors = selectors;
- this.extension = extension;
- this.suffix = suffix;
- this.path = path;
- }
+ public MockRequestPathInfo(String selectors, String extension, String suffix, String path) {
+ this.selectors = selectors;
+ this.extension = extension;
+ this.suffix = suffix;
+ this.path = path;
+ }
public String getExtension() {
return extension;
@@ -59,12 +59,10 @@ class MockRequestPathInfo implements RequestPathInfo {
}
public String[] getSelectors() {
- return (getSelectorString() != null)
- ? getSelectorString().split("\\.")
- : new String[0];
+ return (getSelectorString() != null) ? getSelectorString().split("\\.") : new String[0];
}
public String getSuffix() {
return suffix;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockRequestProgressTracker.java b/src/main/java/org/apache/sling/commons/testing/sling/MockRequestProgressTracker.java
index 41c43e2..a8a25a0 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockRequestProgressTracker.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockRequestProgressTracker.java
@@ -26,28 +26,21 @@ import org.apache.sling.api.request.RequestProgressTracker;
public class MockRequestProgressTracker implements RequestProgressTracker {
- public void dump(PrintWriter writer) {
- }
+ public void dump(PrintWriter writer) {}
public Iterator<String> getMessages() {
- return Collections.<String> emptyList().iterator();
+ return Collections.<String>emptyList().iterator();
}
- public void log(String message) {
- }
+ public void log(String message) {}
- public void log(String format, Object... args) {
- }
+ public void log(String format, Object... args) {}
- public void logTimer(String timerName) {
- }
+ public void logTimer(String timerName) {}
- public void logTimer(String timerName, String format, Object... args) {
- }
+ public void logTimer(String timerName, String format, Object... args) {}
- public void startTimer(String timerName) {
- }
+ public void startTimer(String timerName) {}
- public void done() {
- }
+ public void done() {}
}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockResource.java b/src/main/java/org/apache/sling/commons/testing/sling/MockResource.java
index d74d737..1721750 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockResource.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockResource.java
@@ -18,38 +18,36 @@
*/
package org.apache.sling.commons.testing.sling;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
-import java.util.HashMap;
-import java.util.Map;
-
public class MockResource extends SyntheticResource {
private String resourceType;
private String resourceSuperType;
- private Map<String,Object> properties = new HashMap<String,Object>();
+ private Map<String, Object> properties = new HashMap<String, Object>();
- public MockResource(ResourceResolver resourceResolver, String path,
- String resourceType) {
+ public MockResource(ResourceResolver resourceResolver, String path, String resourceType) {
this(resourceResolver, path, resourceType, null);
}
- public MockResource(ResourceResolver resourceResolver, String path,
- String resourceType, String resourceSuperType) {
+ public MockResource(ResourceResolver resourceResolver, String path, String resourceType, String resourceSuperType) {
super(resourceResolver, path, resourceType);
setResourceType(resourceType);
setResourceSuperType(resourceSuperType);
}
- public void addProperty(String key, Object value){
- this.properties.put(key,value);
+ public void addProperty(String key, Object value) {
+ this.properties.put(key, value);
}
- public Map<String,Object> getProperties(){
+ public Map<String, Object> getProperties() {
return this.properties;
}
@@ -82,7 +80,7 @@ public class MockResource extends SyntheticResource {
map.put("resourceSuperType", resourceSuperType);
}
for (String key : this.properties.keySet()) {
- map.put(key,this.properties.get(key));
+ map.put(key, this.properties.get(key));
}
return (AdapterType) map;
}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java b/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
index 847412d..a8d9e12 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
@@ -18,14 +18,14 @@
*/
package org.apache.sling.commons.testing.sling;
+import javax.servlet.http.HttpServletRequest;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
@@ -58,19 +58,16 @@ public class MockResourceResolver implements ResourceResolver {
@Deprecated
public Resource resolve(HttpServletRequest request) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Deprecated
public Resource resolve(String absPath) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Deprecated
public String map(String resourcePath) {
- return resourcePath; // a rather simplistic 1:1 map...
-
+ return resourcePath; // a rather simplistic 1:1 map...
}
@Deprecated
@@ -89,7 +86,6 @@ public class MockResourceResolver implements ResourceResolver {
@Deprecated
public String[] getSearchPath() {
return searchPath.clone();
-
}
@Deprecated
@@ -128,8 +124,7 @@ public class MockResourceResolver implements ResourceResolver {
while (elements.hasNext()) {
Resource next = elements.next();
String path = next.getPath();
- if (path.startsWith(parentPath)
- && path.indexOf('/', parentPath.length()) < 0) {
+ if (path.startsWith(parentPath) && path.indexOf('/', parentPath.length()) < 0) {
return next;
}
}
@@ -141,20 +136,16 @@ public class MockResourceResolver implements ResourceResolver {
@Deprecated
public Iterator<Resource> findResources(String query, String language) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Deprecated
- public Iterator<Map<String, Object>> queryResources(String query,
- String language) {
+ public Iterator<Map<String, Object>> queryResources(String query, String language) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Deprecated
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
throw new UnsupportedOperationException("Not implemented");
-
}
@Deprecated
@@ -163,7 +154,7 @@ public class MockResourceResolver implements ResourceResolver {
this.searchPath = new String[0];
} else {
this.searchPath = new String[searchPath.length];
- for (int i=0; i < searchPath.length; i++) {
+ for (int i = 0; i < searchPath.length; i++) {
String entry = searchPath[i];
if (!entry.endsWith("/")) {
entry = entry.concat("/");
@@ -175,7 +166,7 @@ public class MockResourceResolver implements ResourceResolver {
@Deprecated
public String map(HttpServletRequest request, String resourcePath) {
- return request.getContextPath() + resourcePath;
+ return request.getContextPath() + resourcePath;
}
@Deprecated
@@ -199,8 +190,7 @@ public class MockResourceResolver implements ResourceResolver {
}
@Deprecated
- public ResourceResolver clone(Map<String, Object> authenticationInfo)
- throws LoginException {
+ public ResourceResolver clone(Map<String, Object> authenticationInfo) throws LoginException {
return null;
}
@@ -215,18 +205,15 @@ public class MockResourceResolver implements ResourceResolver {
}
@Deprecated
- public void commit() throws PersistenceException {
- }
+ public void commit() throws PersistenceException {}
@Deprecated
- public Resource create(Resource arg0, String arg1, Map<String, Object> arg2)
- throws PersistenceException {
+ public Resource create(Resource arg0, String arg1, Map<String, Object> arg2) throws PersistenceException {
return null;
}
@Deprecated
- public void delete(Resource arg0) throws PersistenceException {
- }
+ public void delete(Resource arg0) throws PersistenceException {}
@Deprecated
public Iterable<Resource> getChildren(Resource arg0) {
@@ -254,12 +241,10 @@ public class MockResourceResolver implements ResourceResolver {
}
@Deprecated
- public void refresh() {
- }
+ public void refresh() {}
@Deprecated
- public void revert() {
- }
+ public void revert() {}
@Deprecated
@Override
@@ -275,8 +260,7 @@ public class MockResourceResolver implements ResourceResolver {
@Deprecated
@Override
- public boolean orderBefore(@NotNull Resource parent, @NotNull String name,
- @Nullable String followingSiblingName)
+ public boolean orderBefore(@NotNull Resource parent, @NotNull String name, @Nullable String followingSiblingName)
throws UnsupportedOperationException, PersistenceException, IllegalArgumentException {
throw new UnsupportedOperationException();
}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
index 0e18172..a938091 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
@@ -18,16 +18,6 @@
*/
package org.apache.sling.commons.testing.sling;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
import javax.servlet.AsyncContext;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
@@ -42,6 +32,16 @@ import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.Part;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.RequestDispatcherOptions;
import org.apache.sling.api.request.RequestParameter;
@@ -68,10 +68,10 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
private final String queryString;
- private final String scheme;
- private final String server;
- private final int port;
- private final String contextPath;
+ private final String scheme;
+ private final String server;
+ private final int port;
+ private final String contextPath;
private boolean secure = false;
@@ -85,35 +85,39 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
this(null, null, null, null, null);
}
- public MockSlingHttpServletRequest(String resourcePath, String selectors,
- String extension, String suffix, String queryString) {
- this(resourcePath, selectors, extension, suffix, queryString,
- resourcePath, null, null, 0, null);
+ public MockSlingHttpServletRequest(
+ String resourcePath, String selectors, String extension, String suffix, String queryString) {
+ this(resourcePath, selectors, extension, suffix, queryString, resourcePath, null, null, 0, null);
}
- public MockSlingHttpServletRequest(String resourcePath, String selectors,
- String extension, String suffix, String queryString,
- String requestPath, String scheme, String server, int port,
- String contextPath) {
- this.resource = new SyntheticResource(null, resourcePath, RESOURCE_TYPE);
- this.requestPathInfo = new MockRequestPathInfo(selectors, extension,
- suffix, requestPath);
- this.queryString = queryString;
- this.scheme = scheme;
- this.server = server;
- this.port = port;
- this.contextPath = contextPath;
+ public MockSlingHttpServletRequest(
+ String resourcePath,
+ String selectors,
+ String extension,
+ String suffix,
+ String queryString,
+ String requestPath,
+ String scheme,
+ String server,
+ int port,
+ String contextPath) {
+ this.resource = new SyntheticResource(null, resourcePath, RESOURCE_TYPE);
+ this.requestPathInfo = new MockRequestPathInfo(selectors, extension, suffix, requestPath);
+ this.queryString = queryString;
+ this.scheme = scheme;
+ this.server = server;
+ this.port = port;
+ this.contextPath = contextPath;
- setMethod(null);
- }
+ setMethod(null);
+ }
public void setResourceResolver(ResourceResolver resolver) {
this.mockResourceResolver = resolver;
// recreate request resource with the new resolver
if (resource.getResourceResolver() == null) {
- this.resource = new SyntheticResource(resolver, resource.getPath(),
- resource.getResourceType());
+ this.resource = new SyntheticResource(resolver, resource.getPath(), resource.getResourceType());
}
}
@@ -135,14 +139,12 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
}
@Override
- public RequestDispatcher getRequestDispatcher(String path,
- RequestDispatcherOptions options) {
+ public RequestDispatcher getRequestDispatcher(String path, RequestDispatcherOptions options) {
return null;
}
@Override
- public RequestDispatcher getRequestDispatcher(Resource resource,
- RequestDispatcherOptions options) {
+ public RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions options) {
return null;
}
@@ -214,10 +216,10 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
return null;
}
- @Override
+ @Override
public String getContextPath() {
- return contextPath;
- }
+ return contextPath;
+ }
@Override
public Cookie[] getCookies() {
@@ -469,19 +471,13 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
}
@Override
- public void removeAttribute(String name) {
-
- }
+ public void removeAttribute(String name) {}
@Override
- public void setAttribute(String name, Object o) {
-
- }
+ public void setAttribute(String name, Object o) {}
@Override
- public void setCharacterEncoding(String env) {
-
- }
+ public void setCharacterEncoding(String env) {}
@Override
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletResponse.java b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletResponse.java
index da94c42..5db4163 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletResponse.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletResponse.java
@@ -18,200 +18,200 @@
*/
package org.apache.sling.commons.testing.sling;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Locale;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-
import org.apache.sling.api.SlingHttpServletResponse;
public class MockSlingHttpServletResponse implements SlingHttpServletResponse {
- private StringBuffer output = new StringBuffer();
- private String contentType;
- private String encoding;
- private int status = SC_OK;
+ private StringBuffer output = new StringBuffer();
+ private String contentType;
+ private String encoding;
+ private int status = SC_OK;
- public StringBuffer getOutput() {
- return output;
- }
+ public StringBuffer getOutput() {
+ return output;
+ }
- @Override
+ @Override
public void addCookie(Cookie cookie) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addCookie");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addCookie");
+ }
- @Override
+ @Override
public boolean containsHeader(String s) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".containsHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".containsHeader");
+ }
- @Override
+ @Override
public String encodeURL(String s) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeURL");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeURL");
+ }
- @Override
+ @Override
public String encodeRedirectURL(String s) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeRedirectURL");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeRedirectURL");
+ }
- @Override
+ @Override
@SuppressWarnings("deprecation")
@Deprecated
public String encodeUrl(String s) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeUrl");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeUrl");
+ }
- @Override
+ @Override
@SuppressWarnings("deprecation")
public String encodeRedirectUrl(String s) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeRedirectUrl");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".encodeRedirectUrl");
+ }
- @Override
+ @Override
public void sendError(int i, String s) throws IOException {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendError");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendError");
+ }
- @Override
+ @Override
public void sendError(int i) throws IOException {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendError");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendError");
+ }
- @Override
+ @Override
public void sendRedirect(String s) throws IOException {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendRedirect");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".sendRedirect");
+ }
- @Override
+ @Override
public void setDateHeader(String s, long l) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setDateHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setDateHeader");
+ }
- @Override
+ @Override
public void addDateHeader(String s, long l) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addDateHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addDateHeader");
+ }
- @Override
+ @Override
public void setHeader(String s, String s1) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setHeader");
+ }
- @Override
+ @Override
public void addHeader(String s, String s1) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addHeader");
+ }
- @Override
+ @Override
public void setIntHeader(String s, int i) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setIntHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setIntHeader");
+ }
- @Override
+ @Override
public void addIntHeader(String s, int i) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addIntHeader");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".addIntHeader");
+ }
- @Override
+ @Override
public void setStatus(int i) {
- this.status = i;
- }
+ this.status = i;
+ }
- @Override
+ @Override
@SuppressWarnings("deprecation")
@Deprecated
public void setStatus(int i, String s) {
- this.status = i;
- }
+ this.status = i;
+ }
- @Override
+ @Override
public String getCharacterEncoding() {
- return encoding;
- }
+ return encoding;
+ }
- @Override
+ @Override
public String getContentType() {
- return contentType;
- }
+ return contentType;
+ }
- @Override
+ @Override
public ServletOutputStream getOutputStream() throws IOException {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getOutputStream");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getOutputStream");
+ }
- @Override
+ @Override
public PrintWriter getWriter() throws IOException {
- MockSlingHttpServletResponse.MockWriter writer = new MockWriter(output);
- return new PrintWriter(writer);
- }
+ MockSlingHttpServletResponse.MockWriter writer = new MockWriter(output);
+ return new PrintWriter(writer);
+ }
- @Override
+ @Override
public void setCharacterEncoding(String encoding) {
- this.encoding = encoding;
- }
+ this.encoding = encoding;
+ }
- @Override
+ @Override
public void setContentLength(int i) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setContentLength");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setContentLength");
+ }
- @Override
+ @Override
public void setContentType(String contentType) {
- this.contentType = contentType;
- }
+ this.contentType = contentType;
+ }
- @Override
+ @Override
public void setBufferSize(int i) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setBufferSize");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setBufferSize");
+ }
- @Override
+ @Override
public int getBufferSize() {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getBufferSize");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getBufferSize");
+ }
- @Override
+ @Override
public void flushBuffer() throws IOException {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".flushBuffer");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".flushBuffer");
+ }
- @Override
+ @Override
public void resetBuffer() {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".resetBuffer");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".resetBuffer");
+ }
- @Override
+ @Override
public boolean isCommitted() {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".isCommitted");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".isCommitted");
+ }
- @Override
+ @Override
public void reset() {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".reset");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".reset");
+ }
- @Override
+ @Override
public void setLocale(Locale locale) {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setLocale");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".setLocale");
+ }
- @Override
+ @Override
public Locale getLocale() {
- throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getLocale");
- }
+ throw new UnsupportedOperationException("Not implemented: " + getClass().getName() + ".getLocale");
+ }
- @Override
+ @Override
public <AdapterType> AdapterType adaptTo(Class<AdapterType> adapterTypeClass) {
- return null;
- }
+ return null;
+ }
- @Override
+ @Override
public int getStatus() {
// TODO Auto-generated method stub
return 0;
@@ -242,25 +242,25 @@ public class MockSlingHttpServletResponse implements SlingHttpServletResponse {
}
private class MockWriter extends Writer {
- private StringBuffer buf;
-
- public MockWriter(StringBuffer output) {
- buf = output;
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- buf.append(cbuf, off, len);
- }
-
- @Override
- public void flush() throws IOException {
- buf.setLength(0);
- }
-
- @Override
- public void close() throws IOException {
- buf = null;
- }
- }
+ private StringBuffer buf;
+
+ public MockWriter(StringBuffer output) {
+ buf = output;
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ buf.append(cbuf, off, len);
+ }
+
+ @Override
+ public void flush() throws IOException {
+ buf.setLength(0);
+ }
+
+ @Override
+ public void close() throws IOException {
+ buf = null;
+ }
+ }
}
diff --git a/src/main/java/org/apache/sling/commons/testing/util/JavascriptEngine.java b/src/main/java/org/apache/sling/commons/testing/util/JavascriptEngine.java
index f157017..a763292 100644
--- a/src/main/java/org/apache/sling/commons/testing/util/JavascriptEngine.java
+++ b/src/main/java/org/apache/sling/commons/testing/util/JavascriptEngine.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.util;
@@ -23,12 +25,12 @@ import java.io.StringWriter;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ScriptableObject;
-/** Simplistic Javascript engine using Rhino, meant
+/** Simplistic Javascript engine using Rhino, meant
* for automated tests */
public class JavascriptEngine {
- /** Execute supplied code against supplied data,
- * see JavascriptEngineTest for examples */
- public String execute(String code, String jsonData) throws IOException {
+ /** Execute supplied code against supplied data,
+ * see JavascriptEngineTest for examples */
+ public String execute(String code, String jsonData) throws IOException {
final String jsCode = "data=" + jsonData + ";\n" + code;
final Context rhinoContext = Context.enter();
final ScriptableObject scope = rhinoContext.initStandardObjects();
@@ -40,16 +42,11 @@ public class JavascriptEngine {
final int lineNumber = 1;
final Object securityDomain = null;
try {
- rhinoContext.evaluateString(
- scope,
- jsCode,
- getClass().getSimpleName(),
- lineNumber,
- securityDomain);
- } catch(Exception e) {
- final IOException ioe = new IOException("While executing [" + code + "]:" + e);
- ioe.initCause(e);
- throw ioe;
+ rhinoContext.evaluateString(scope, jsCode, getClass().getSimpleName(), lineNumber, securityDomain);
+ } catch (Exception e) {
+ final IOException ioe = new IOException("While executing [" + code + "]:" + e);
+ ioe.initCause(e);
+ throw ioe;
}
// check script output
diff --git a/src/main/java/org/apache/sling/commons/testing/util/TestStringUtil.java b/src/main/java/org/apache/sling/commons/testing/util/TestStringUtil.java
index f732d62..f0ca9b7 100644
--- a/src/main/java/org/apache/sling/commons/testing/util/TestStringUtil.java
+++ b/src/main/java/org/apache/sling/commons/testing/util/TestStringUtil.java
@@ -20,18 +20,18 @@ package org.apache.sling.commons.testing.util;
/** String utilities for testing */
public class TestStringUtil {
- static private final String NATIVE_LINE_SEP = System.getProperty("line.separator");
+ private static final String NATIVE_LINE_SEP = System.getProperty("line.separator");
/** Replace \n with . in strings to make it easier to compare visually for testing */
public static String flatten(String str) {
// First replace native line-endings
- if(str.indexOf(NATIVE_LINE_SEP) >= 0) {
+ if (str.indexOf(NATIVE_LINE_SEP) >= 0) {
str = str.replace(NATIVE_LINE_SEP, ".");
}
// Now find non-native line-endings, e.g. cygwin needs this
- if(str.indexOf('\n') >= 0) {
+ if (str.indexOf('\n') >= 0) {
str = str.replace('\n', '.');
}
diff --git a/src/test/java/org/apache/sling/commons/testing/jcr/MockPropertyTest.java b/src/test/java/org/apache/sling/commons/testing/jcr/MockPropertyTest.java
index 6cad207..827366a 100644
--- a/src/test/java/org/apache/sling/commons/testing/jcr/MockPropertyTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/jcr/MockPropertyTest.java
@@ -42,5 +42,4 @@ public class MockPropertyTest {
assertTrue(prop.isMultiple());
assertTrue(prop.getDefinition().isMultiple());
}
-
}
diff --git a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryProviderTest.java b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryProviderTest.java
index e0cd15d..82224b6 100644
--- a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryProviderTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryProviderTest.java
@@ -18,29 +18,29 @@
*/
package org.apache.sling.commons.testing.jcr;
-import static org.junit.Assert.assertNotNull;
-
import javax.jcr.Session;
import org.apache.sling.jcr.api.SlingRepository;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
/** JUnit 4 style RepositoryProvider test */
public class RepositoryProviderTest {
private SlingRepository repo;
-
+
@Before
public void getRepo() throws Exception {
repo = RepositoryProvider.instance().getRepository();
}
-
- @Test
+
+ @Test
public void testRepository() throws Exception {
assertNotNull("Expecting SlingRepository to be setup", repo);
}
-
- @Test
+
+ @Test
public void testRootNode() throws Exception {
final Session s = repo.loginAdministrative(null);
try {
diff --git a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryTestBaseTest.java b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryTestBaseTest.java
index 8881009..9e1b4ec 100644
--- a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryTestBaseTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryTestBaseTest.java
@@ -22,7 +22,7 @@ import javax.jcr.Node;
/** Test the RepositoryTestBase */
public class RepositoryTestBaseTest extends RepositoryTestBase {
-
+
public void testTestNode() throws Exception {
final Node n = getTestRootNode();
assertNotNull("Expecting to get a test Node", n);
diff --git a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryUtilTest.java b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryUtilTest.java
index 81c392d..6c25787 100644
--- a/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryUtilTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/jcr/RepositoryUtilTest.java
@@ -18,10 +18,10 @@
*/
package org.apache.sling.commons.testing.jcr;
-import static org.junit.Assert.assertNotNull;
-
import javax.jcr.Session;
+import static org.junit.Assert.assertNotNull;
+
/**
* This is a simple test for the repository util. We start
* the repository, try to login as admin and anonymous and
@@ -29,7 +29,8 @@ import javax.jcr.Session;
*/
public class RepositoryUtilTest {
- @org.junit.Test public void testRepository() throws Exception {
+ @org.junit.Test
+ public void testRepository() throws Exception {
// start the repository
RepositoryUtil.startRepository();
diff --git a/src/test/java/org/apache/sling/commons/testing/junit/RetryRuleTest.java b/src/test/java/org/apache/sling/commons/testing/junit/RetryRuleTest.java
index ea03904..2776a18 100644
--- a/src/test/java/org/apache/sling/commons/testing/junit/RetryRuleTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/junit/RetryRuleTest.java
@@ -1,28 +1,30 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.commons.testing.junit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class RetryRuleTest {
private int setupCounter;
private int callCount = 0;
@@ -30,24 +32,24 @@ public class RetryRuleTest {
@Rule
public final RetryRule retryRule = new RetryRule();
-
+
@Before
public void setup() {
setupCounter = 0;
}
-
+
@Retry
@Test
public void testDefaultParameters() {
callCount++;
setupCounter++;
-
- if(callTime > 0) {
+
+ if (callTime > 0) {
final long delta = System.currentTimeMillis();
assertTrue("Expecting at least 500 msec between calls", delta >= 500);
}
callTime = System.currentTimeMillis();
-
+
assertTrue("Expecting to be called several times before passing", callCount > 3);
assertEquals("Expecting setup() to be called before every retry", 1, setupCounter);
@@ -55,52 +57,52 @@ public class RetryRuleTest {
callTime = -1;
callCount = 0;
}
-
+
@Retry
@Test
public void testRetryOnException() throws Exception {
callCount++;
setupCounter++;
- if(callCount <= 3) {
+ if (callCount <= 3) {
throw new Exception("Expecting to be called several times before passing");
}
-
+
assertEquals("Expecting setup() to be called before every retry", 1, setupCounter);
// Once we pass, reset counters for other tests
callTime = -1;
callCount = 0;
}
-
- @Retry(timeoutMsec=500, intervalMsec=1)
+
+ @Retry(timeoutMsec = 500, intervalMsec = 1)
@Test
public void testCustomParameters() {
callCount++;
setupCounter++;
-
+
assertTrue("Expecting to be called many times before passing", callCount > 100);
assertEquals("Expecting setup() to be called before every retry", 1, setupCounter);
-
+
// Once we pass, reset callTime for other tests
callTime = -1;
callCount = 0;
}
-
+
@Test
public void testDefaultDefaultTimings() {
final RetryRule r = new RetryRule();
assertEquals("Expecting default default timeout", RetryRule.DEFAULT_DEFAULT_TIMEOUT_MSEC, r.getTimeout(-1));
assertEquals("Expecting default default interval", RetryRule.DEFAULT_DEFAULT_INTERVAL_MSEC, r.getInterval(-1));
}
-
+
@Test
public void testSpecifiedDefaultTimings() {
final RetryRule r = new RetryRule(12, 42);
assertEquals("Expecting specified default timeout", 12, r.getTimeout(-1));
assertEquals("Expecting specified default interval", 42, r.getInterval(-1));
}
-
+
@Test
public void testRuleTimings() {
final RetryRule r = new RetryRule(12, 42);
diff --git a/src/test/java/org/apache/sling/commons/testing/sling/MockResourceTest.java b/src/test/java/org/apache/sling/commons/testing/sling/MockResourceTest.java
index 7661bae..f40bb4a 100644
--- a/src/test/java/org/apache/sling/commons/testing/sling/MockResourceTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/sling/MockResourceTest.java
@@ -18,46 +18,46 @@
*/
package org.apache.sling.commons.testing.sling;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ValueMap;
-import org.junit.Test;
-
public class MockResourceTest {
public static final String PATH = "/foo/bar";
public static final String RT = "someResourceType";
-
- @Test
+
+ @Test
public void basicTest() throws Exception {
final MockResource r = new MockResource(null, PATH, RT);
r.addProperty("1", Integer.MAX_VALUE);
r.addProperty("2", "two");
-
+
assertTrue(r instanceof Resource);
assertEquals(PATH, r.getPath());
assertEquals(RT, r.getResourceType());
assertNull(r.getResourceSuperType());
-
+
final ValueMap m = r.adaptTo(ValueMap.class);
assertEquals(Integer.MAX_VALUE, m.get("1"));
assertEquals("two", m.get("2"));
-
+
// changes to r do not affect m
assertNull(m.get("third"));
r.getProperties().put("third", "trois");
assertNull(m.get("third"));
-
+
// but we get the new value after adapting again
assertEquals("trois", r.adaptTo(ValueMap.class).get("third"));
}
-
+
@Test
public void testNoProperties() throws Exception {
final MockResource r = new MockResource(null, PATH, RT);
assertNotNull(r.adaptTo(ValueMap.class));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/commons/testing/util/JavascriptEngineTest.java b/src/test/java/org/apache/sling/commons/testing/util/JavascriptEngineTest.java
index 7f4d78a..88a2ef4 100644
--- a/src/test/java/org/apache/sling/commons/testing/util/JavascriptEngineTest.java
+++ b/src/test/java/org/apache/sling/commons/testing/util/JavascriptEngineTest.java
@@ -1,46 +1,48 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * 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
+ * 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.
+ * 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.commons.testing.util;
import java.io.IOException;
-import org.apache.sling.commons.testing.util.JavascriptEngine;
import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
public class JavascriptEngineTest {
- private final JavascriptEngine engine = new JavascriptEngine();
-
- @Test
- public void testSimpleScripts() throws IOException {
-
- // Each triplet of data is: json data, code, expected output
- final String [] data = {
- "{}", "out.print('hello')", "hello",
- "{ i:26, j:'a' }", "out.print(data.i + data.j)", "26a",
- "{ i:'ab', j:'cd' }", "out.print(data.i) ; out.print('+') ; out.print(data.j)", "ab+cd"
- };
-
- for(int i=0; i < data.length; i+= 3) {
- final String json = data[i];
- final String code = data[i+1];
- final String expected = data[i+2];
- final String actual = engine.execute(code, json);
- assertEquals("At index " + i, expected, actual);
- }
- }
+ private final JavascriptEngine engine = new JavascriptEngine();
+
+ @Test
+ public void testSimpleScripts() throws IOException {
+
+ // Each triplet of data is: json data, code, expected output
+ final String[] data = {
+ "{}", "out.print('hello')", "hello",
+ "{ i:26, j:'a' }", "out.print(data.i + data.j)", "26a",
+ "{ i:'ab', j:'cd' }", "out.print(data.i) ; out.print('+') ; out.print(data.j)", "ab+cd"
+ };
+
+ for (int i = 0; i < data.length; i += 3) {
+ final String json = data[i];
+ final String code = data[i + 1];
+ final String expected = data[i + 2];
+ final String actual = engine.execute(code, json);
+ assertEquals("At index " + i, expected, actual);
+ }
+ }
}
(sling-org-apache-sling-commons-testing) 02/03: SLING-13036 Update to parent 64, update various dependencies and fix dependency scopes
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-13036-update-deps-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git
commit a33ecaa6e99a9a6ba0a8f299303571bfc62de098
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 18 10:42:35 2025 +0100
SLING-13036 Update to parent 64, update various dependencies and fix dependency scopes
---
.sling-module.json | 6 +-
pom.xml | 72 ++++++++++++++--------
.../sling/commons/testing/jcr/RepositoryUtil.java | 12 +++-
.../testing/sling/MockResourceResolver.java | 71 +++++++++++++++++++++
.../testing/sling/MockSlingHttpServletRequest.java | 7 +++
5 files changed, 138 insertions(+), 30 deletions(-)
diff --git a/.sling-module.json b/.sling-module.json
index 7f9d118..cfad4d2 100644
--- a/.sling-module.json
+++ b/.sling-module.json
@@ -1,7 +1,5 @@
{
"jenkins": {
- "jdks": [
- 11
- ]
+ "jdks": [17, 21]
}
-}
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 1c407a2..50135ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
+ <artifactId>sling-bundle-parent</artifactId>
<version>64</version>
<relativePath />
</parent>
@@ -45,8 +45,8 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git</developerConnection>
<url>https://github.com/apache/sling-org-apache-sling-commons-testing.git</url>
- <tag>HEAD</tag>
- </scm>
+ <tag>HEAD</tag>
+ </scm>
<dependencies>
<dependency>
@@ -56,17 +56,25 @@
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <version>7.0.0</version>
+ <artifactId>org.osgi.framework</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>7.0.0</version>
+ <artifactId>org.osgi.service.cm</artifactId>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!--
Dependencies required for testing and provided
transitively to modules using this artifact
@@ -74,19 +82,13 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.4.2</version>
+ <version>2.25.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
- <version>2.0.6</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <version>2.0</version>
+ <version>2.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -114,7 +116,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.adapter</artifactId>
- <version>2.0.4</version>
+ <version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -141,25 +143,24 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.johnzon</artifactId>
- <version>2.0.0</version>
- <scope>compile</scope>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.johnzon</artifactId>
+ <version>2.0.0</version>
+ <scope>compile</scope>
</dependency>
-
<!-- Logging for tests -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <scope>compile</scope>
+ <scope>test</scope>
</dependency>
<!-- Basic Test Controller JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
<!-- Provide for Test Mocks -->
@@ -167,7 +168,28 @@
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.12.0</version>
- <scope>compile</scope>
+ <scope>test</scope>
</dependency>
+
+ <!-- Running jackrabbit tests -->
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.17.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyshared</artifactId>
+ <version>10.17.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbytools</artifactId>
+ <version>10.17.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
index 1981bfc..c289a14 100644
--- a/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
+++ b/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
@@ -134,7 +134,7 @@ public class RepositoryUtil {
* with the node type manager available from the given <code>session</code>.
* <p>
* This method is not synchronized. It is up to the calling method to
- * prevent paralell execution.
+ * prevent parallel execution.
*
* @param session The <code>Session</code> providing the node type manager
* through which the node type is to be registered.
@@ -226,5 +226,15 @@ public class RepositoryUtil {
return wrapped.isStandardDescriptor(key);
}
+ @Override
+ public Session loginService(String subServiceName, String workspace) throws LoginException, RepositoryException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Session impersonateFromService(String subServiceName, Credentials credentials, String workspaceName) throws LoginException, RepositoryException {
+ throw new UnsupportedOperationException();
+ }
+
}
}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java b/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
index f0ba860..847412d 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
@@ -30,6 +30,8 @@ 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.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @deprecated Please use the Mock Resource Resolver Implementation from testing/resourceresolver-mock instead.
@@ -43,33 +45,40 @@ public class MockResourceResolver implements ResourceResolver {
private Map<String, Collection<Resource>> children = new LinkedHashMap<String, Collection<Resource>>();
+ @Deprecated
public void addResource(Resource resource) {
this.resources.put(resource.getPath(), resource);
}
+ @Deprecated
public void addChildren(Resource parent, Collection<Resource> children) {
this.children.put(parent.getPath(), children);
}
+ @Deprecated
public Resource resolve(HttpServletRequest request) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public Resource resolve(String absPath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public String map(String resourcePath) {
return resourcePath; // a rather simplistic 1:1 map...
}
+ @Deprecated
public Resource getResource(String path) {
return resources.get(path);
}
+ @Deprecated
public Resource getResource(Resource base, String path) {
if (!path.startsWith("/")) {
path = base.getPath() + "/" + path;
@@ -77,11 +86,13 @@ public class MockResourceResolver implements ResourceResolver {
return getResource(path);
}
+ @Deprecated
public String[] getSearchPath() {
return searchPath.clone();
}
+ @Deprecated
public Iterator<Resource> listChildren(final Resource parent) {
Collection<Resource> childCollection = children.get(parent.getPath());
if (childCollection != null) {
@@ -127,22 +138,26 @@ public class MockResourceResolver implements ResourceResolver {
};
}
+ @Deprecated
public Iterator<Resource> findResources(String query, String language) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public Iterator<Map<String, Object>> queryResources(String query,
String language) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public void setSearchPath(String... searchPath) {
if (searchPath == null) {
this.searchPath = new String[0];
@@ -158,73 +173,129 @@ public class MockResourceResolver implements ResourceResolver {
}
}
+ @Deprecated
public String map(HttpServletRequest request, String resourcePath) {
return request.getContextPath() + resourcePath;
}
+ @Deprecated
public Resource resolve(HttpServletRequest request, String absPath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Deprecated
public void close() {
// nothing to do
}
+ @Deprecated
public String getUserID() {
return null;
}
+ @Deprecated
public boolean isLive() {
return true;
}
+ @Deprecated
public ResourceResolver clone(Map<String, Object> authenticationInfo)
throws LoginException {
return null;
}
+ @Deprecated
public Object getAttribute(String name) {
return null;
}
+ @Deprecated
public Iterator<String> getAttributeNames() {
return null;
}
+ @Deprecated
public void commit() throws PersistenceException {
}
+ @Deprecated
public Resource create(Resource arg0, String arg1, Map<String, Object> arg2)
throws PersistenceException {
return null;
}
+ @Deprecated
public void delete(Resource arg0) throws PersistenceException {
}
+ @Deprecated
public Iterable<Resource> getChildren(Resource arg0) {
return null;
}
+ @Deprecated
public String getParentResourceType(Resource arg0) {
return null;
}
+ @Deprecated
public String getParentResourceType(String arg0) {
return null;
}
+ @Deprecated
public boolean hasChanges() {
return false;
}
+ @Deprecated
public boolean isResourceType(Resource arg0, String arg1) {
return false;
}
+ @Deprecated
public void refresh() {
}
+ @Deprecated
public void revert() {
}
+
+ @Deprecated
+ @Override
+ public @Nullable Resource getParent(@NotNull Resource child) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ @Override
+ public boolean hasChildren(@NotNull Resource resource) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ @Override
+ public boolean orderBefore(@NotNull Resource parent, @NotNull String name,
+ @Nullable String followingSiblingName)
+ throws UnsupportedOperationException, PersistenceException, IllegalArgumentException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ @Override
+ public Resource copy(String srcAbsPath, String destAbsPath) throws PersistenceException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ @Override
+ public Resource move(String srcAbsPath, String destAbsPath) throws PersistenceException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ @Override
+ public @NotNull Map<String, Object> getPropertyMap() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
index 1524477..0e18172 100644
--- a/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/commons/testing/sling/MockSlingHttpServletRequest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.security.Principal;
import java.util.Collection;
import java.util.Enumeration;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
@@ -50,6 +51,7 @@ import org.apache.sling.api.request.RequestProgressTracker;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
+import org.jetbrains.annotations.NotNull;
/**
* Mock request object. This does not do anything useful, it just returns the
@@ -576,4 +578,9 @@ public class MockSlingHttpServletRequest implements SlingHttpServletRequest {
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public @NotNull List<RequestParameter> getRequestParameterList() {
+ throw new UnsupportedOperationException();
+ }
}
(sling-org-apache-sling-commons-testing) 01/03: update parent and dependencies
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-13036-update-deps-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-testing.git
commit 2706a6aa1a51da8a3d78131fb3bba7e1276d9ab2
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 18 10:08:24 2025 +0100
update parent and dependencies
---
pom.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index a5ab887..1c407a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>47</version>
+ <version>64</version>
<relativePath />
</parent>
@@ -37,8 +37,8 @@
</description>
<properties>
+ <sling.java.version>11</sling.java.version>
<project.build.outputTimestamp>1743171324</project.build.outputTimestamp>
- <jackrabbit.version>2.14.3</jackrabbit.version>
</properties>
<scm>
@@ -52,16 +52,19 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>7.0.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>7.0.0</version>
+ <scope>provided</scope>
</dependency>
<!--
@@ -88,14 +91,12 @@
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- <version>${jackrabbit.version}</version>
+ <artifactId>oak-jackrabbit-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
- <version>${jackrabbit.version}</version>
<scope>compile</scope>
</dependency>
<dependency>