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 2024/12/11 08:42:43 UTC
(sling-org-apache-sling-launchpad-test-services) branch experimental/working-3 created (now ddb4f95)
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a change to branch experimental/working-3
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-test-services.git
at ddb4f95 apply spotless formatting
This branch includes the following new commits:
new ddb4f95 apply spotless formatting
The 1 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-launchpad-test-services) 01/01: 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 experimental/working-3
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-test-services.git
commit ddb4f95e82a3ed2a9f93133020437e76b03310cb
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Dec 11 09:42:33 2024 +0100
apply spotless formatting
---
pom.xml | 48 +-
.../adapter/NotReallyAnAdapterFactory.java | 31 +-
.../adapter/ReallyAnAdapterFactory.java | 32 +-
.../testservices/events/EventsCounter.java | 28 +-
.../testservices/events/EventsCounterImpl.java | 68 +-
.../testservices/events/package-info.java | 2 +-
.../exported/FakeSlingHttpServletRequest.java | 63 +-
.../testservices/exported/MappingsFacade.java | 48 +-
.../testservices/exported/StringTransformer.java | 26 +-
.../launchpad/testservices/exported/TestEnum.java | 28 +-
.../testservices/exported/package-info.java | 2 +-
.../testservices/filters/NoPropertyFilter.java | 29 +-
.../testservices/filters/SlingFilter.java | 45 +-
.../filters/SlingFilterWithPattern.java | 39 +-
.../launchpad/testservices/filters/TestFilter.java | 42 +-
.../handlers/AbstractDeleteHandler.java | 19 +-
.../testservices/handlers/AbstractHandler.java | 26 +-
.../testservices/handlers/TestDeleteHandler1.java | 8 +-
.../testservices/handlers/TestDeleteHandler2.java | 6 +-
.../testservices/handlers/TestHandler1.java | 12 +-
.../testservices/handlers/TestHandler2.java | 11 +-
.../testservices/handlers/TestHandler3.java | 11 +-
.../testservices/jcr/FullTextQueryServlet.java | 30 +-
.../testservices/jcr/TestNamespaceMapper.java | 37 +-
.../testservices/jcr/WorkspaceCreator.java | 5 +-
.../launchpad/testservices/models/DummyModel.java | 30 +-
.../testservices/models/package-info.java | 2 +-
.../testservices/post/DummyModification.java | 32 +-
.../post/OldStylePostOperationExample.java | 34 +-
.../post/SlingPostOperationExample.java | 36 +-
.../testservices/post/SlingPostProcessorOne.java | 36 +-
.../testservices/post/SlingPostProcessorTwo.java | 36 +-
.../repository/FirstRepositoryInitializer.java | 40 +-
.../repository/SecondRepositoryInitializer.java | 42 +-
.../repository/SystemUsersInitializer.java | 47 +-
.../resource/TestResourceDecorator.java | 30 +-
.../resourceprovider/PlanetResource.java | 58 +-
.../resourceprovider/PlanetsResourceProvider.java | 72 +-
.../scripting/GroovyBindingsValuesProvider.java | 38 +-
.../scripting/JSPBindingsValuesProvider.java | 35 +-
.../StandaloneScriptExecutionServlet.java | 80 +-
.../scripting/StringBindingsValuesProvider.java | 34 +-
.../LowerRankingStringTransformer.java | 36 +-
.../LowercaseStringTransformer.java | 32 +-
.../serversidetests/MappingEventsTest.java | 92 +-
.../ResourceResolverWithVanityBloomFilterTest.java | 1336 +++++++++-----------
.../UppercaseStringTransformer.java | 32 +-
.../serversidetests/WriteableResourcesTest.java | 71 +-
.../servlets/AnonymousAccessConfigServlet.java | 63 +-
.../servlets/CustomPostResponseCreatorImpl.java | 41 +-
.../testservices/servlets/DomServlet.java | 49 +-
.../servlets/ExportedPackageServlet.java | 48 +-
.../testservices/servlets/ExtensionServlet.java | 41 +-
.../testservices/servlets/GetConfigServlet.java | 72 +-
.../testservices/servlets/HtmlDefaultServlet.java | 45 +-
.../testservices/servlets/HtmlResponseServlet.java | 42 +-
.../testservices/servlets/JakartaJsonServlet.java | 53 +-
.../testservices/servlets/JaxbServlet.java | 12 +-
.../testservices/servlets/MiscUnsafeServlet.java | 18 +-
.../servlets/NamespaceTestServlet.java | 40 +-
.../testservices/servlets/PathsServlet.java | 39 +-
.../servlets/PathsServletNodeServlet.java | 44 +-
.../servlets/PlanetResourceRenderingServlet.java | 57 +-
.../servlets/PrefixServletMinusOne.java | 43 +-
.../testservices/servlets/PrefixServletZero.java | 43 +-
.../testservices/servlets/PutMethodServlet.java | 54 +-
.../testservices/servlets/R6WhiteboardServlet.java | 37 +-
.../servlets/RepositoryDescriptorsServlet.java | 54 +-
.../servlets/RequestUriOptingServlet.java | 42 +-
.../testservices/servlets/SaxServlet.java | 18 +-
.../testservices/servlets/SelectorServlet.java | 35 +-
.../testservices/servlets/TestServlet.java | 100 +-
.../testservices/servlets/XpathServlet.java | 15 +-
.../requestdispatcher/OriginalResponseServlet.java | 13 +-
.../RequestDispatcherIncludeBufferedServlet.java | 16 +-
.../RequestDispatcherIncludeDirectServlet.java | 13 +-
76 files changed, 2007 insertions(+), 2117 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3989e62..dcbf429 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
@@ -31,37 +31,18 @@
<version>13-SNAPSHOT</version>
<name>Apache Sling Launchpad Testing Services</name>
- <description>
- Sling services used by the Launchpad Testing integration tests
- </description>
+ <description>Sling services used by the Launchpad Testing integration tests</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-test-services.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-test-services.git</developerConnection>
+ <tag>HEAD</tag>
<url>https://github.com/apache/sling-org-apache-sling-launchpad-test-services.git</url>
- <tag>HEAD</tag>
- </scm>
+ </scm>
<properties>
<project.build.outputTimestamp>2022-02-25T16:00:25Z</project.build.outputTimestamp>
</properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>src/main/resources/SLING-INF/res/sling-test/sling/from-bundle/foo.txt</exclude>
- <exclude>src/main/resources/SLING-INF/res/sling-test/sling/SLING-1733/sling-1733.txt</exclude>
- <exclude>src/main/resources/SLING-INF/content/property-types-test.json</exclude>
- <exclude>src/main/resources/SLING-INF/content/ROOT.json</exclude>
- <exclude>src/main/resources/SLING-INF/install/org.apache.sling.scripting.jsp.JspScriptEngineFactory.json</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
@@ -96,7 +77,7 @@
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
@@ -179,7 +160,24 @@
<artifactId>org.apache.sling.servlets.annotations</artifactId>
<version>1.2.6</version>
</dependency>
-
+
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>src/main/resources/SLING-INF/res/sling-test/sling/from-bundle/foo.txt</exclude>
+ <exclude>src/main/resources/SLING-INF/res/sling-test/sling/SLING-1733/sling-1733.txt</exclude>
+ <exclude>src/main/resources/SLING-INF/content/property-types-test.json</exclude>
+ <exclude>src/main/resources/SLING-INF/content/ROOT.json</exclude>
+ <exclude>src/main/resources/SLING-INF/install/org.apache.sling.scripting.jsp.JspScriptEngineFactory.json</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/adapter/NotReallyAnAdapterFactory.java b/src/main/java/org/apache/sling/launchpad/testservices/adapter/NotReallyAnAdapterFactory.java
index c01d423..3536874 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/adapter/NotReallyAnAdapterFactory.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/adapter/NotReallyAnAdapterFactory.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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.adapter;
@@ -34,5 +36,4 @@ public class NotReallyAnAdapterFactory implements AdapterFactory {
// TODO Auto-generated method stub
return null;
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/adapter/ReallyAnAdapterFactory.java b/src/main/java/org/apache/sling/launchpad/testservices/adapter/ReallyAnAdapterFactory.java
index 12a0b5e..8c0301e 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/adapter/ReallyAnAdapterFactory.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/adapter/ReallyAnAdapterFactory.java
@@ -1,23 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.adapter;
import org.apache.sling.api.adapter.AdapterFactory;
import org.osgi.service.component.annotations.Component;
+
/**
* Service which actually is an adapter factory. See SLING-2522.
*/
@@ -33,5 +36,4 @@ public class ReallyAnAdapterFactory implements AdapterFactory {
// TODO Auto-generated method stub
return null;
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounter.java b/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounter.java
index 07155a3..76cdf3e 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounter.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounter.java
@@ -1,22 +1,24 @@
/*
- * 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.launchpad.testservices.events;
/** Provide access to events counts */
public interface EventsCounter {
int getEventsCount(String topic);
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounterImpl.java b/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounterImpl.java
index 53ea8a5..d568b12 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounterImpl.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/events/EventsCounterImpl.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.launchpad.testservices.events;
+import javax.servlet.ServletException;
+
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.servlet.ServletException;
-
import org.apache.felix.utils.json.JSONWriter;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -39,36 +41,36 @@ import org.slf4j.LoggerFactory;
*/
@SuppressWarnings("serial")
@Component(
- immediate=true,
+ immediate = true,
service = {
- javax.servlet.Servlet.class,
- org.osgi.service.event.EventHandler.class,
- org.apache.sling.launchpad.testservices.events.EventsCounter.class
+ javax.servlet.Servlet.class,
+ org.osgi.service.event.EventHandler.class,
+ org.apache.sling.launchpad.testservices.events.EventsCounter.class
},
property = {
"service.description:String=Paths Test Servlet",
"service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/EventsCounter",
- "sling.servlet.extensions:String=json",
+ "sling.servlet.paths:String=/testing/EventsCounter",
+ "sling.servlet.extensions:String=json",
org.osgi.service.event.EventConstants.EVENT_TOPIC + ":String=" + SlingConstants.TOPIC_RESOURCE_ADDED,
- org.osgi.service.event.EventConstants.EVENT_TOPIC + ":String=" + SlingConstants.TOPIC_RESOURCE_RESOLVER_MAPPING_CHANGED
- }
-)
-public class EventsCounterImpl extends SlingSafeMethodsServlet implements EventHandler,EventsCounter {
+ org.osgi.service.event.EventConstants.EVENT_TOPIC + ":String="
+ + SlingConstants.TOPIC_RESOURCE_RESOLVER_MAPPING_CHANGED
+ })
+public class EventsCounterImpl extends SlingSafeMethodsServlet implements EventHandler, EventsCounter {
private final Map<String, AtomicInteger> counters = new HashMap<>();
private final Logger log = LoggerFactory.getLogger(getClass());
-
+
public synchronized void handleEvent(Event event) {
final String topic = event.getTopic();
AtomicInteger counter = counters.computeIfAbsent(topic, k -> new AtomicInteger());
counter.incrementAndGet();
log.debug("{} counter is now {}", topic, counter.get());
}
-
+
public synchronized int getEventsCount(String topic) {
final AtomicInteger counter = counters.get(topic);
- if(counter == null) {
+ if (counter == null) {
log.debug("getEventsCount({}) returns 0, counter not found", topic);
return 0;
}
@@ -76,20 +78,20 @@ public class EventsCounterImpl extends SlingSafeMethodsServlet implements EventH
}
@Override
- protected void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response)
- throws ServletException, IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
final JSONWriter w = new JSONWriter(response.getWriter());
w.object();
- for(Map.Entry<String, AtomicInteger> entry : counters.entrySet()) {
+ for (Map.Entry<String, AtomicInteger> entry : counters.entrySet()) {
w.key(entry.getKey()).value(entry.getValue());
}
w.endObject();
w.flush();
- } catch(IOException je) {
- throw (IOException)new IOException("JSONException in doGet").initCause(je);
+ } catch (IOException je) {
+ throw (IOException) new IOException("JSONException in doGet").initCause(je);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/events/package-info.java b/src/main/java/org/apache/sling/launchpad/testservices/events/package-info.java
index 0541ae8..708658f 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/events/package-info.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/events/package-info.java
@@ -18,4 +18,4 @@
*/
@org.osgi.annotation.versioning.Version("2.0.17")
-package org.apache.sling.launchpad.testservices.events;
\ No newline at end of file
+package org.apache.sling.launchpad.testservices.events;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/exported/FakeSlingHttpServletRequest.java b/src/main/java/org/apache/sling/launchpad/testservices/exported/FakeSlingHttpServletRequest.java
index 3a66388..48f194c 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/exported/FakeSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/exported/FakeSlingHttpServletRequest.java
@@ -1,31 +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.launchpad.testservices.exported;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
import javax.servlet.AsyncContext;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
@@ -41,6 +33,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.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
public class FakeSlingHttpServletRequest implements HttpServletRequest {
private final String pathInfo;
@@ -65,13 +67,11 @@ public class FakeSlingHttpServletRequest implements HttpServletRequest {
this(null, null, -1, pathInfo, httpMethod);
}
- public FakeSlingHttpServletRequest(String scheme, String host, int port,
- String pathInfo) {
+ public FakeSlingHttpServletRequest(String scheme, String host, int port, String pathInfo) {
this(scheme, host, port, pathInfo, null);
}
- public FakeSlingHttpServletRequest(String scheme, String host, int port,
- String pathInfo, String httpMethod) {
+ public FakeSlingHttpServletRequest(String scheme, String host, int port, String pathInfo, String httpMethod) {
this.scheme = (scheme == null) ? "http" : scheme;
this.host = (host == null) ? "localhost" : host;
this.port = port;
@@ -195,15 +195,13 @@ public class FakeSlingHttpServletRequest implements HttpServletRequest {
return contextPath;
}
- public void removeAttribute(String name) {
- }
+ public void removeAttribute(String name) {}
public void setAttribute(String name, Object o) {
attrs.put(name, o);
}
- public void setCharacterEncoding(String env) {
- }
+ public void setCharacterEncoding(String env) {}
public String getAuthType() {
return null;
@@ -350,12 +348,12 @@ public class FakeSlingHttpServletRequest implements HttpServletRequest {
@Override
public void login(String username, String password) throws ServletException {
- //no-op
+ // no-op
}
@Override
public void logout() throws ServletException {
- //no-op
+ // no-op
}
@Override
@@ -372,5 +370,4 @@ public class FakeSlingHttpServletRequest implements HttpServletRequest {
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException {
return null;
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/exported/MappingsFacade.java b/src/main/java/org/apache/sling/launchpad/testservices/exported/MappingsFacade.java
index 997f4a1..cc8fe43 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/exported/MappingsFacade.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/exported/MappingsFacade.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.launchpad.testservices.exported;
@@ -29,19 +31,20 @@ public class MappingsFacade {
private static final Logger logger = LoggerFactory.getLogger(MappingsFacade.class);
private final EventsCounter eventsCounter;
private static boolean firstInstance = true;
-
+
// How long to wait for mapping updates
public static final String MAPPING_UPDATE_TIMEOUT_MSEC = "ResourceResolverTest.mapping.update.timeout.msec";
private static final long updateTimeout = Long.parseLong(System.getProperty(MAPPING_UPDATE_TIMEOUT_MSEC, "10000"));
public MappingsFacade(EventsCounter c) {
- if(firstInstance) {
- logger.info("updateTimeout = {}, use {} system property to change", updateTimeout, MAPPING_UPDATE_TIMEOUT_MSEC);
+ if (firstInstance) {
+ logger.info(
+ "updateTimeout = {}, use {} system property to change", updateTimeout, MAPPING_UPDATE_TIMEOUT_MSEC);
firstInstance = false;
}
eventsCounter = c;
}
-
+
/** Save a Session that has mapping changes, and wait for the OSGi event
* that signals that mappings have been updated.
* @param session the JCR session
@@ -50,12 +53,15 @@ public class MappingsFacade {
*/
public String saveMappings(Session session) throws Exception {
final int oldEventsCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC);
- logger.debug("Saving Session and waiting for event counter {} to change from current value {}", MAPPING_EVENT_TOPIC, oldEventsCount);
+ logger.debug(
+ "Saving Session and waiting for event counter {} to change from current value {}",
+ MAPPING_EVENT_TOPIC,
+ oldEventsCount);
session.save();
final long timeout = System.currentTimeMillis() + updateTimeout;
- while(System.currentTimeMillis() < timeout) {
- final int newCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC);
- if(newCount != oldEventsCount) {
+ while (System.currentTimeMillis() < timeout) {
+ final int newCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC);
+ if (newCount != oldEventsCount) {
// Sleeping here shouldn't be needed but it looks
// like mappings are not immediately updated once the event arrives
logger.debug("Event counter {} is now {}", MAPPING_EVENT_TOPIC, newCount);
@@ -64,7 +70,7 @@ public class MappingsFacade {
}
try {
Thread.sleep(10);
- } catch(InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
}
return "Timeout waiting for " + MAPPING_EVENT_TOPIC + " event, after " + updateTimeout + " msec";
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/exported/StringTransformer.java b/src/main/java/org/apache/sling/launchpad/testservices/exported/StringTransformer.java
index 8170572..96dcbcb 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/exported/StringTransformer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/exported/StringTransformer.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.launchpad.testservices.exported;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/exported/TestEnum.java b/src/main/java/org/apache/sling/launchpad/testservices/exported/TestEnum.java
index 0dabd85..4184b42 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/exported/TestEnum.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/exported/TestEnum.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.launchpad.testservices.exported;
@@ -21,7 +23,7 @@ public enum TestEnum {
BAR;
public static TestEnum parse(String str) {
- if(str.contains("foo")) {
+ if (str.contains("foo")) {
return FOO;
}
return BAR;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/exported/package-info.java b/src/main/java/org/apache/sling/launchpad/testservices/exported/package-info.java
index eb4573e..c1184eb 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/exported/package-info.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/exported/package-info.java
@@ -18,4 +18,4 @@
*/
@org.osgi.annotation.versioning.Version("2.2.0")
-package org.apache.sling.launchpad.testservices.exported;
\ No newline at end of file
+package org.apache.sling.launchpad.testservices.exported;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/filters/NoPropertyFilter.java b/src/main/java/org/apache/sling/launchpad/testservices/filters/NoPropertyFilter.java
index 37cfbf4..9f608b2 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/filters/NoPropertyFilter.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/filters/NoPropertyFilter.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.launchpad.testservices.filters;
@@ -25,8 +27,7 @@ import org.osgi.service.component.annotations.Component;
"service.description:String=NoProperty Test Filter",
"service.vendor:String=The Apache Software Foundation",
"sling.filter.scope:String=request"
- }
- )
+ })
public class NoPropertyFilter extends TestFilter {
@Override
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilter.java b/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilter.java
index 7bf7c01..9674ada 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilter.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilter.java
@@ -1,38 +1,39 @@
/*
- * 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.launchpad.testservices.filters;
import org.osgi.service.component.annotations.Component;
/** Example/test Filter */
-@Component(immediate=true,
- service = javax.servlet.Filter.class,
- property = {
- "service.description:String=SlingFilter Test Filter",
- "service.vendor:String=The Apache Software Foundation",
- "filter.scope:String=request",
- "sling.filter.scope:String=request"
- }
-)
+@Component(
+ immediate = true,
+ service = javax.servlet.Filter.class,
+ property = {
+ "service.description:String=SlingFilter Test Filter",
+ "service.vendor:String=The Apache Software Foundation",
+ "filter.scope:String=request",
+ "sling.filter.scope:String=request"
+ })
public class SlingFilter extends TestFilter {
@Override
protected String getHeaderName() {
return "FILTER_COUNTER_SLING";
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilterWithPattern.java b/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilterWithPattern.java
index 2cf8506..972b59a 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilterWithPattern.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/filters/SlingFilterWithPattern.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.launchpad.testservices.filters;
@@ -20,14 +22,14 @@ import org.osgi.service.component.annotations.Component;
/** Example/test Filter with sling.filter.pattern see also SLING-4294 */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Filter.class,
property = {
- "service.description:String=SlingFilter Test Filter",
- "service.vendor:String=The Apache Software Foundation",
- "filter.scope:String=request",
- "sling.filter.scope:String=request",
- "sling.filter.pattern:String=/system.*"
+ "service.description:String=SlingFilter Test Filter",
+ "service.vendor:String=The Apache Software Foundation",
+ "filter.scope:String=request",
+ "sling.filter.scope:String=request",
+ "sling.filter.pattern:String=/system.*"
})
public class SlingFilterWithPattern extends TestFilter {
@@ -35,5 +37,4 @@ public class SlingFilterWithPattern extends TestFilter {
protected String getHeaderName() {
return "FILTER_COUNTER_SLING_WITH_PATTERN";
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/filters/TestFilter.java b/src/main/java/org/apache/sling/launchpad/testservices/filters/TestFilter.java
index 92996e8..66bd585 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/filters/TestFilter.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/filters/TestFilter.java
@@ -1,24 +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.launchpad.testservices.filters;
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicInteger;
-
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -28,6 +27,9 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
/** Base class for test filters */
abstract class TestFilter implements Filter {
@@ -35,20 +37,20 @@ abstract class TestFilter implements Filter {
// nothing to do
}
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
String header = getHeaderName();
- AtomicInteger current = (AtomicInteger) ((HttpServletRequest)request).getAttribute(header);
+ AtomicInteger current = (AtomicInteger) ((HttpServletRequest) request).getAttribute(header);
if (current == null) {
current = new AtomicInteger(0);
- ((HttpServletRequest)request).setAttribute(header, current);
+ ((HttpServletRequest) request).setAttribute(header, current);
}
((HttpServletResponse) response).setHeader(header, String.valueOf(current.incrementAndGet()));
chain.doFilter(request, response);
}
- public void destroy() {
- }
+ public void destroy() {}
protected abstract String getHeaderName();
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractDeleteHandler.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractDeleteHandler.java
index 09d44d3..681318f 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractDeleteHandler.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractDeleteHandler.java
@@ -16,27 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.sling.launchpad.testservices.handlers;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
import org.apache.jackrabbit.server.io.DeleteContext;
import org.apache.jackrabbit.server.io.DeleteHandler;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavResource;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
public abstract class AbstractDeleteHandler implements DeleteHandler {
protected String HANDLER_NAME = "";
protected String HANDLER_BKP;
@Override
- public boolean delete(DeleteContext deleteContext,
- DavResource resource) throws DavException {
+ public boolean delete(DeleteContext deleteContext, DavResource resource) throws DavException {
try {
- deleteContext.getSession().getWorkspace().move(resource.getResourcePath(), resource.getResourcePath() + HANDLER_BKP);
+ deleteContext
+ .getSession()
+ .getWorkspace()
+ .move(resource.getResourcePath(), resource.getResourcePath() + HANDLER_BKP);
return true;
} catch (RepositoryException e) {
return false;
@@ -44,8 +45,7 @@ public abstract class AbstractDeleteHandler implements DeleteHandler {
}
@Override
- public boolean canDelete(DeleteContext deleteContext,
- DavResource resource) {
+ public boolean canDelete(DeleteContext deleteContext, DavResource resource) {
try {
Node nodeToDelete = deleteContext.getSession().getNode(resource.getResourcePath());
return HANDLER_NAME.equals(nodeToDelete.getName());
@@ -53,5 +53,4 @@ public abstract class AbstractDeleteHandler implements DeleteHandler {
return false;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
index 169057f..8c901c4 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
@@ -18,6 +18,12 @@
*/
package org.apache.sling.launchpad.testservices.handlers;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import java.io.IOException;
+import java.util.Map;
+
import org.apache.jackrabbit.server.io.ExportContext;
import org.apache.jackrabbit.server.io.IOManager;
import org.apache.jackrabbit.server.io.ImportContext;
@@ -26,21 +32,15 @@ import org.apache.jackrabbit.server.io.PropertyImportContext;
import org.apache.jackrabbit.webdav.DavResource;
import org.apache.jackrabbit.webdav.property.PropEntry;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import java.io.IOException;
-import java.util.Map;
-
/**
* This handler can export only if the path given in the context contains the handler name.
*/
-public abstract class AbstractHandler implements
- org.apache.jackrabbit.server.io.IOHandler,
- org.apache.jackrabbit.server.io.PropertyHandler {
+public abstract class AbstractHandler
+ implements org.apache.jackrabbit.server.io.IOHandler, org.apache.jackrabbit.server.io.PropertyHandler {
private static final String HANDLER_IDENTIFIER = "handler-identifier";
- private IOManager ioManager ;
+ private IOManager ioManager;
// IOHandler
@@ -116,7 +116,8 @@ public abstract class AbstractHandler implements
return false;
}
- public Map<? extends PropEntry, ?> importProperties(PropertyImportContext context, boolean b) throws RepositoryException {
+ public Map<? extends PropEntry, ?> importProperties(PropertyImportContext context, boolean b)
+ throws RepositoryException {
throw new UnsupportedOperationException();
}
@@ -132,6 +133,5 @@ public abstract class AbstractHandler implements
//
- public abstract String getHandlerName() ;
-
-}
\ No newline at end of file
+ public abstract String getHandlerName();
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler1.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler1.java
index 3de8bcd..b4a0cc4 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler1.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler1.java
@@ -24,15 +24,11 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = DeleteHandler.class,
- property = {
- Constants.SERVICE_RANKING + ":Integer=2"
- }
- )
-public class TestDeleteHandler1 extends AbstractDeleteHandler{
+ property = {Constants.SERVICE_RANKING + ":Integer=2"})
+public class TestDeleteHandler1 extends AbstractDeleteHandler {
public TestDeleteHandler1() {
this.HANDLER_NAME = "test-delete-handler-1";
this.HANDLER_BKP = "backed-up-by-" + HANDLER_NAME;
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler2.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler2.java
index e5d8970..2ce409c 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler2.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestDeleteHandler2.java
@@ -24,15 +24,11 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = DeleteHandler.class,
- property = {
- Constants.SERVICE_RANKING + ":Integer=2"
- }
- )
+ property = {Constants.SERVICE_RANKING + ":Integer=2"})
public class TestDeleteHandler2 extends AbstractDeleteHandler {
public TestDeleteHandler2() {
this.HANDLER_NAME = "test-delete-handler-2";
this.HANDLER_BKP = "backed-up-by-" + HANDLER_NAME;
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
index d1c413c..6371873 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
@@ -23,18 +23,14 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = {
- org.apache.jackrabbit.server.io.IOHandler.class,
- org.apache.jackrabbit.server.io.PropertyHandler.class
+ org.apache.jackrabbit.server.io.IOHandler.class,
+ org.apache.jackrabbit.server.io.PropertyHandler.class
},
- property = {
- Constants.SERVICE_RANKING + ":Integer=3"
- }
- )
+ property = {Constants.SERVICE_RANKING + ":Integer=3"})
public class TestHandler1 extends AbstractHandler {
@Override
- public String getHandlerName(){
+ public String getHandlerName() {
return "test-io-handler-1";
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
index 63e617e..1d9bb0d 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
@@ -23,17 +23,14 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = {
- org.apache.jackrabbit.server.io.IOHandler.class,
- org.apache.jackrabbit.server.io.PropertyHandler.class
+ org.apache.jackrabbit.server.io.IOHandler.class,
+ org.apache.jackrabbit.server.io.PropertyHandler.class
},
- property = {
- Constants.SERVICE_RANKING + ":Integer=2"
- }
- )
+ property = {Constants.SERVICE_RANKING + ":Integer=2"})
public class TestHandler2 extends AbstractHandler {
@Override
- public String getHandlerName(){
+ public String getHandlerName() {
return "test-io-handler-11";
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
index ce61d9f..a5b3a17 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
@@ -23,17 +23,14 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = {
- org.apache.jackrabbit.server.io.IOHandler.class,
- org.apache.jackrabbit.server.io.PropertyHandler.class
+ org.apache.jackrabbit.server.io.IOHandler.class,
+ org.apache.jackrabbit.server.io.PropertyHandler.class
},
- property = {
- Constants.SERVICE_RANKING + ":Integer=1"
- }
- )
+ property = {Constants.SERVICE_RANKING + ":Integer=1"})
public class TestHandler3 extends AbstractHandler {
@Override
- public String getHandlerName(){
+ public String getHandlerName() {
return "test-io-handler-111";
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/jcr/FullTextQueryServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/jcr/FullTextQueryServlet.java
index 97f1698..e5bce01 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/jcr/FullTextQueryServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/jcr/FullTextQueryServlet.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.launchpad.testservices.jcr;
-import java.io.IOException;
-
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -28,6 +26,8 @@ import javax.jcr.query.QueryResult;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -35,16 +35,16 @@ import org.osgi.service.component.annotations.Component;
/** Servlet used to test HtmlResponse escaping */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=FullText Query Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/fullTextQuery"
+ "service.description:String=FullText Query Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/fullTextQuery"
})
/**
* Outputs paths of nodes matching the specified full-text search
- *
+ *
* <p>The paths are written in text format, one per line.</p>
*
*/
@@ -57,28 +57,28 @@ public class FullTextQueryServlet extends SlingSafeMethodsServlet {
throws ServletException, IOException {
response.setContentType("text/plain");
-
+
String queryText = request.getParameter("q");
- if ( queryText == null || queryText.isEmpty() ) {
+ if (queryText == null || queryText.isEmpty()) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.getWriter().write("Missing mandatory 'q' parameter");
return;
}
Session session = request.getResourceResolver().adaptTo(Session.class);
-
+
try {
- Query query = session.getWorkspace().getQueryManager().createQuery("SELECT * FROM [nt:base] AS s WHERE CONTAINS(s.*, $queryText)", Query.JCR_SQL2);
+ Query query = session.getWorkspace()
+ .getQueryManager()
+ .createQuery("SELECT * FROM [nt:base] AS s WHERE CONTAINS(s.*, $queryText)", Query.JCR_SQL2);
query.bindValue("queryText", session.getValueFactory().createValue(queryText));
- QueryResult result = query.execute();
+ QueryResult result = query.execute();
NodeIterator iterator = result.getNodes();
- while( iterator.hasNext() ) {
+ while (iterator.hasNext()) {
response.getWriter().println(iterator.nextNode().getPath());
}
} catch (RepositoryException e) {
throw new ServletException(e);
}
-
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/jcr/TestNamespaceMapper.java b/src/main/java/org/apache/sling/launchpad/testservices/jcr/TestNamespaceMapper.java
index 9786c24..9ed7b73 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/jcr/TestNamespaceMapper.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/jcr/TestNamespaceMapper.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.launchpad.testservices.jcr;
@@ -26,18 +28,17 @@ import org.osgi.service.component.annotations.Component;
* Test Implementation of NamespaceMapper
*/
@Component(
- immediate=true,
+ immediate = true,
service = org.apache.sling.jcr.api.NamespaceMapper.class,
property = {
- "service.description:String=Test NamespaceMapper",
- "service.vendor:String=The Apache Software Foundation",
- "filter.scope:String=request",
- "sling.filter.scope:String=request"
+ "service.description:String=Test NamespaceMapper",
+ "service.vendor:String=The Apache Software Foundation",
+ "filter.scope:String=request",
+ "sling.filter.scope:String=request"
})
public class TestNamespaceMapper implements NamespaceMapper {
public void defineNamespacePrefixes(Session session) throws RepositoryException {
session.setNamespacePrefix("test2", "http://sling.apache.org/test/two");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/jcr/WorkspaceCreator.java b/src/main/java/org/apache/sling/launchpad/testservices/jcr/WorkspaceCreator.java
index 532721b..c9d8ec2 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/jcr/WorkspaceCreator.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/jcr/WorkspaceCreator.java
@@ -28,10 +28,7 @@ import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
-@Component(
- property = {
- Constants.SERVICE_DESCRIPTION + ":String=Generates Test Workspaces ws1, ws2, ws3"
- })
+@Component(property = {Constants.SERVICE_DESCRIPTION + ":String=Generates Test Workspaces ws1, ws2, ws3"})
public class WorkspaceCreator {
@Reference
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java b/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java
index 0f4f3ff..3cbd5a8 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.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.launchpad.testservices.models;
@@ -25,12 +27,12 @@ import org.apache.sling.models.annotations.Model;
public class DummyModel {
private String message;
-
+
@PostConstruct
public void init() {
message = "from-sling-model";
}
-
+
public String getMessage() {
return message;
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/models/package-info.java b/src/main/java/org/apache/sling/launchpad/testservices/models/package-info.java
index 5445b90..66040d7 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/models/package-info.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/models/package-info.java
@@ -18,4 +18,4 @@
*/
@org.osgi.annotation.versioning.Version("2.0.16")
-package org.apache.sling.launchpad.testservices.models;
\ No newline at end of file
+package org.apache.sling.launchpad.testservices.models;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/post/DummyModification.java b/src/main/java/org/apache/sling/launchpad/testservices/post/DummyModification.java
index f5d4fea..a7bd3d0 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/post/DummyModification.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/post/DummyModification.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.launchpad.testservices.post;
@@ -24,10 +26,10 @@ import org.apache.sling.servlets.post.ModificationType;
public class DummyModification {
static final String PARAM_NAME = DummyModification.class.getSimpleName();
-
+
static void maybeAdd(SlingHttpServletRequest request, List<Modification> mods, String name) {
- if(request.getParameter(PARAM_NAME) != null) {
+ if (request.getParameter(PARAM_NAME) != null) {
mods.add(new Modification(ModificationType.CREATE, "source:" + name, "dest:" + name));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/post/OldStylePostOperationExample.java b/src/main/java/org/apache/sling/launchpad/testservices/post/OldStylePostOperationExample.java
index 832818a..408e843 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/post/OldStylePostOperationExample.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/post/OldStylePostOperationExample.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.launchpad.testservices.post;
@@ -29,10 +31,8 @@ import org.osgi.service.component.annotations.Component;
/** Example using the now deprecated SlingPostOperation */
@Component(
- immediate=true,
- property = {
- SlingPostOperation.PROP_OPERATION_NAME + ":String=test:OldStylePostOperationExample"
- })
+ immediate = true,
+ property = {SlingPostOperation.PROP_OPERATION_NAME + ":String=test:OldStylePostOperationExample"})
public class OldStylePostOperationExample implements SlingPostOperation {
public void run(SlingHttpServletRequest request, HtmlResponse response, SlingPostProcessor[] processors) {
@@ -43,7 +43,7 @@ public class OldStylePostOperationExample implements SlingPostOperation {
response.setTitle("Content modified by " + getClass().getSimpleName());
n.setProperty(getClass().getName(), "Old-style operation was applied to " + n.getPath());
n.getSession().save();
- } catch(RepositoryException re) {
+ } catch (RepositoryException re) {
throw new SlingException(getClass().getSimpleName() + " failed", re);
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostOperationExample.java b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostOperationExample.java
index 35c68e0..884353a 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostOperationExample.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostOperationExample.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.launchpad.testservices.post;
@@ -29,10 +31,8 @@ import org.osgi.service.component.annotations.Component;
/** Example PostOperation used in integration tests */
@Component(
- immediate=true,
- property = {
- PostOperation.PROP_OPERATION_NAME + ":String=test:SlingPostOperationExample"
- })
+ immediate = true,
+ property = {PostOperation.PROP_OPERATION_NAME + ":String=test:SlingPostOperationExample"})
public class SlingPostOperationExample implements PostOperation {
public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors) {
final Resource r = request.getResource();
@@ -42,8 +42,8 @@ public class SlingPostOperationExample implements PostOperation {
response.setTitle("Content modified by " + getClass().getSimpleName());
n.setProperty(getClass().getName(), "Operation was applied to " + n.getPath());
n.getSession().save();
- } catch(RepositoryException re) {
+ } catch (RepositoryException re) {
throw new SlingException(getClass().getSimpleName() + " failed", re);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorOne.java b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorOne.java
index e1c49aa..46a8a08 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorOne.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorOne.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.launchpad.testservices.post;
@@ -25,14 +27,10 @@ import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
/** Example SlingPostProcessor used in integration tests */
-@Component(
- property = {
- Constants.SERVICE_RANKING + ":Integer=2"
- })
+@Component(property = {Constants.SERVICE_RANKING + ":Integer=2"})
public class SlingPostProcessorOne implements SlingPostProcessor {
@Override
- public void process(SlingHttpServletRequest request, List<Modification> mods)
- throws Exception {
+ public void process(SlingHttpServletRequest request, List<Modification> mods) throws Exception {
DummyModification.maybeAdd(request, mods, getClass().getSimpleName());
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorTwo.java b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorTwo.java
index 6ef3f23..a1490ae 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorTwo.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/post/SlingPostProcessorTwo.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.launchpad.testservices.post;
@@ -25,14 +27,10 @@ import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
/** Example SlingPostProcessor used in integration tests */
-@Component(
- property = {
- Constants.SERVICE_RANKING + ":Integer=1"
- })
+@Component(property = {Constants.SERVICE_RANKING + ":Integer=1"})
public class SlingPostProcessorTwo implements SlingPostProcessor {
@Override
- public void process(SlingHttpServletRequest request, List<Modification> mods)
- throws Exception {
+ public void process(SlingHttpServletRequest request, List<Modification> mods) throws Exception {
DummyModification.maybeAdd(request, mods, getClass().getSimpleName());
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/repository/FirstRepositoryInitializer.java b/src/main/java/org/apache/sling/launchpad/testservices/repository/FirstRepositoryInitializer.java
index 369f1f8..36702ec 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/repository/FirstRepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/repository/FirstRepositoryInitializer.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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.repository;
@@ -32,20 +34,20 @@ import org.slf4j.LoggerFactory;
@Component(
service = SlingRepositoryInitializer.class,
property = {
- // Execute this before SecondRepositoryInitializer
- Constants.SERVICE_RANKING + ":Integer=100"
+ // Execute this before SecondRepositoryInitializer
+ Constants.SERVICE_RANKING + ":Integer=100"
})
public class FirstRepositoryInitializer implements SlingRepositoryInitializer {
private final Logger log = LoggerFactory.getLogger(getClass());
-
+
public static final String SIGNAL_NODE_PATH = "/" + FirstRepositoryInitializer.class.getName();
-
+
@Override
public void processRepository(SlingRepository repo) throws Exception {
final Session s = repo.loginAdministrative(null);
try {
- if(s.itemExists(SIGNAL_NODE_PATH)) {
+ if (s.itemExists(SIGNAL_NODE_PATH)) {
log.warn("{} already exists, these tests expect to run on an empty repository", SIGNAL_NODE_PATH);
} else {
s.getRootNode().addNode(SIGNAL_NODE_PATH.substring(1));
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/repository/SecondRepositoryInitializer.java b/src/main/java/org/apache/sling/launchpad/testservices/repository/SecondRepositoryInitializer.java
index 84a6bf1..483837b 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/repository/SecondRepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/repository/SecondRepositoryInitializer.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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.repository;
@@ -26,27 +28,27 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * SlingRepositoryInitializer that adds a property to the node created by
+ * SlingRepositoryInitializer that adds a property to the node created by
* FirstRepositoryInitializer.
*/
@Component(
service = SlingRepositoryInitializer.class,
property = {
- // Execute this after FirstRepositoryInitializer
- Constants.SERVICE_RANKING + ":Integer=200"
+ // Execute this after FirstRepositoryInitializer
+ Constants.SERVICE_RANKING + ":Integer=200"
})
public class SecondRepositoryInitializer implements SlingRepositoryInitializer {
private final Logger log = LoggerFactory.getLogger(getClass());
-
+
public static final String SIGNAL_PROPERTY_NAME = SecondRepositoryInitializer.class.getSimpleName();
-
+
@Override
public void processRepository(SlingRepository repo) throws Exception {
final Session s = repo.loginAdministrative(null);
try {
final String path = FirstRepositoryInitializer.SIGNAL_NODE_PATH;
- if(!s.itemExists(path)) {
+ if (!s.itemExists(path)) {
log.warn("{} not found, should have been created by another initializer", path);
} else {
s.getNode(path).setProperty(SIGNAL_PROPERTY_NAME, System.currentTimeMillis());
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java b/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java
index 5927895..eef64ff 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.repository;
+import javax.jcr.Session;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -23,8 +27,6 @@ import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.List;
-import javax.jcr.Session;
-
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.jcr.api.SlingRepositoryInitializer;
import org.apache.sling.jcr.repoinit.JcrRepoInitOpsProcessor;
@@ -40,20 +42,19 @@ import org.slf4j.LoggerFactory;
* Meant to be used for our integration tests until we can create those from
* the provisioning model.
*/
-@Component(
- service = SlingRepositoryInitializer.class)
+@Component(service = SlingRepositoryInitializer.class)
public class SystemUsersInitializer implements SlingRepositoryInitializer {
private final Logger log = LoggerFactory.getLogger(getClass());
-
+
public static final String REPOINIT_FILE = "/repoinit.txt";
@Reference
private RepoInitParser parser;
-
+
@Reference
private JcrRepoInitOpsProcessor processor;
-
+
@Override
public void processRepository(SlingRepository repo) throws Exception {
final Session s = repo.loginAdministrative(null);
@@ -62,9 +63,9 @@ public class SystemUsersInitializer implements SlingRepositoryInitializer {
if (is == null) {
throw new IOException("Class Resource not found:" + REPOINIT_FILE);
}
- final List<Operation> ops;
+ final List<Operation> ops;
try (final Reader r = new InputStreamReader(is, StandardCharsets.UTF_8)) {
- ops = parser.parse(r);
+ ops = parser.parse(r);
}
log.info("Executing {} repoinit Operations", ops.size());
processor.apply(s, ops);
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java b/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
index ac263bd..008c619 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.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.launchpad.testservices.resource;
@@ -32,13 +34,13 @@ public class TestResourceDecorator implements ResourceDecorator {
private final String PATH = "/testing/" + getClass().getSimpleName() + "/";
private static final String RESOURCE_TYPE = "TEST_RESOURCE_DECORATOR_RESOURCE_TYPE";
-
+
public Resource decorate(Resource resource, HttpServletRequest request) {
return decorate(resource);
}
public Resource decorate(Resource resource) {
- if(resource.getPath().startsWith(PATH)) {
+ if (resource.getPath().startsWith(PATH)) {
return new ResourceWrapper(resource) {
@Override
public String getResourceType() {
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java b/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
index 051d319..aa6d13b 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
@@ -1,45 +1,47 @@
/*
- * 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.launchpad.testservices.resourceprovider;
import java.util.HashMap;
+import org.apache.sling.adapter.annotations.Adaptable;
+import org.apache.sling.adapter.annotations.Adapter;
import org.apache.sling.api.resource.AbstractResource;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
-import org.apache.sling.adapter.annotations.Adaptable;
-import org.apache.sling.adapter.annotations.Adapter;
/** A Sling Resource that represents a planet */
-@Adaptable(adaptableClass=Resource.class, adapters={
- @Adapter({ValueMap.class})
-})
+@Adaptable(
+ adaptableClass = Resource.class,
+ adapters = {@Adapter({ValueMap.class})})
public class PlanetResource extends AbstractResource implements Resource {
private final String path;
private final ResourceMetadata metadata;
private final ValueMap valueMap;
private final ResourceResolver resolver;
-
+
public static final String RESOURCE_TYPE = "sling/test-services/planet";
-
+
static class PlanetValueMap extends ValueMapDecorator {
PlanetValueMap(String name, int distance) {
super(new HashMap<>());
@@ -47,22 +49,22 @@ public class PlanetResource extends AbstractResource implements Resource {
put("distance", distance);
}
}
-
+
PlanetResource(ResourceResolver resolver, String path, ValueMap valueMap) {
this.path = path;
-
+
this.valueMap = valueMap;
this.resolver = resolver;
-
+
metadata = new ResourceMetadata();
metadata.setResolutionPath(path);
}
-
+
@Override
public String toString() {
return getClass().getSimpleName() + " " + path;
}
-
+
public String getPath() {
return path;
}
@@ -82,13 +84,13 @@ public class PlanetResource extends AbstractResource implements Resource {
public String getResourceType() {
return RESOURCE_TYPE;
}
-
+
@Override
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
- if(type == ValueMap.class) {
- return (AdapterType)valueMap;
+ if (type == ValueMap.class) {
+ return (AdapterType) valueMap;
}
return super.adaptTo(type);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetsResourceProvider.java b/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetsResourceProvider.java
index d820c16..61d7c85 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetsResourceProvider.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetsResourceProvider.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.launchpad.testservices.resourceprovider;
@@ -32,9 +34,9 @@ import org.apache.sling.spi.resource.provider.ResourceProvider;
import org.osgi.service.component.annotations.Component;
/** Test/example ResourceProvider that provides info about
- * the Solar System's planets at /planets.
- * Use /planets.tidy.-1.json to GET the whole thing.
- *
+ * the Solar System's planets at /planets.
+ * Use /planets.tidy.-1.json to GET the whole thing.
+ *
* This uses the new (February 2016) spi.ResourceProvider base class.
* If you need an example based on the old ResourceProvider interface,
* see this code at svn revision 1727946.
@@ -42,20 +44,20 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = ResourceProvider.class,
property = {
- ResourceProvider.PROPERTY_NAME + ":String=Planets",
- ResourceProvider.PROPERTY_ROOT + ":String=" + PlanetsResourceProvider.ROOT
+ ResourceProvider.PROPERTY_NAME + ":String=Planets",
+ ResourceProvider.PROPERTY_ROOT + ":String=" + PlanetsResourceProvider.ROOT
})
public class PlanetsResourceProvider extends ResourceProvider<DoesNotNeedAContext> {
/** Our planet data. PlanetResource is created when resolving, as
* it points to a specific ResourceResolver. */
private static final Map<String, ValueMap> PLANETS = new HashMap<>();
-
- /** This can be configurable of course */
+
+ /** This can be configurable of course */
public static final String ROOT = "/planets";
-
+
/* Planet data from http://nineplanets.org/data.html
- * (not that we care much about accuracy for this example ;-)
+ * (not that we care much about accuracy for this example ;-)
*/
static {
definePlanet("Mercury", 57910);
@@ -71,21 +73,21 @@ public class PlanetsResourceProvider extends ResourceProvider<DoesNotNeedAContex
final String moonPath = ROOT + "/earth/moon";
PLANETS.put(moonPath, new PlanetResource.PlanetValueMap("Moon", 384));
}
-
+
/** If this provider required a context this would be more elaborate,
* but for this simple example we don't need one.
*/
- public static class DoesNotNeedAContext {
- };
-
+ public static class DoesNotNeedAContext {}
+ ;
+
@Override
- public Resource getResource(ResolveContext<DoesNotNeedAContext> ctx,
- String path, ResourceContext resourceContext, Resource parent) {
+ public Resource getResource(
+ ResolveContext<DoesNotNeedAContext> ctx, String path, ResourceContext resourceContext, Resource parent) {
// Synthetic resource for our root, so that /planets works
- if((ROOT).equals(path)) {
+ if ((ROOT).equals(path)) {
return new SyntheticResource(ctx.getResourceResolver(), path, PlanetResource.RESOURCE_TYPE);
}
-
+
// Not root, return a Planet if we have one
final ValueMap data = PLANETS.get(path);
return data == null ? null : new PlanetResource(ctx.getResourceResolver(), path, data);
@@ -93,11 +95,11 @@ public class PlanetsResourceProvider extends ResourceProvider<DoesNotNeedAContex
@Override
public Iterator<Resource> listChildren(ResolveContext<DoesNotNeedAContext> ctx, Resource parent) {
- if(parent.getPath().startsWith(ROOT)) {
+ if (parent.getPath().startsWith(ROOT)) {
// Not the most efficient thing...good enough for this example
final List<Resource> kids = new ArrayList<>();
- for(Map.Entry<String, ValueMap> e : PLANETS.entrySet()) {
- if(parent.getPath().equals(parentPath(e.getKey()))) {
+ for (Map.Entry<String, ValueMap> e : PLANETS.entrySet()) {
+ if (parent.getPath().equals(parentPath(e.getKey()))) {
kids.add(new PlanetResource(parent.getResourceResolver(), e.getKey(), e.getValue()));
}
}
@@ -106,15 +108,15 @@ public class PlanetsResourceProvider extends ResourceProvider<DoesNotNeedAContex
return null;
}
}
-
+
private static String parentPath(String path) {
final int lastSlash = path.lastIndexOf("/");
return lastSlash > 0 ? path.substring(0, lastSlash) : "";
}
-
+
private static ValueMap definePlanet(String name, int distance) {
final ValueMap valueMap = new PlanetResource.PlanetValueMap(name, distance);
PLANETS.put(ROOT + "/" + name.toLowerCase(), valueMap);
return valueMap;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/scripting/GroovyBindingsValuesProvider.java b/src/main/java/org/apache/sling/launchpad/testservices/scripting/GroovyBindingsValuesProvider.java
index e114fd9..731d282 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/scripting/GroovyBindingsValuesProvider.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/scripting/GroovyBindingsValuesProvider.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.launchpad.testservices.scripting;
@@ -20,18 +22,18 @@ import javax.script.Bindings;
import org.apache.sling.scripting.api.BindingsValuesProvider;
import org.osgi.service.component.annotations.Component;
+
/** Example/test BindingsValuesProvider targeting groovy scripts */
@Component(
- immediate=true,
+ immediate = true,
property = {
- "service.description:String=Groovy BindingsValuesProvider",
- "service.vendor:String=The Apache Software Foundation",
- "javax.script.name:String=groovy"
+ "service.description:String=Groovy BindingsValuesProvider",
+ "service.vendor:String=The Apache Software Foundation",
+ "javax.script.name:String=groovy"
})
public class GroovyBindingsValuesProvider implements BindingsValuesProvider {
public void addBindings(Bindings bindings) {
- bindings.put("groovyHelloWorld", "Hello World from Groovy!");
+ bindings.put("groovyHelloWorld", "Hello World from Groovy!");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java b/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java
index d18669a..9ea3005 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.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.launchpad.testservices.scripting;
@@ -23,15 +25,14 @@ import org.osgi.service.component.annotations.Component;
/** Example/test BindingsValuesProvider targeting JSP scripts */
@Component(
- immediate=true,
+ immediate = true,
property = {
- "service.description:String=JSP BindingsValuesProvider",
- "service.vendor:String=The Apache Software Foundation"
+ "service.description:String=JSP BindingsValuesProvider",
+ "service.vendor:String=The Apache Software Foundation"
})
public class JSPBindingsValuesProvider implements BindingsValuesProvider {
public void addBindings(Bindings bindings) {
- bindings.put("jspHelloWorld", "Hello World from JSP!");
+ bindings.put("jspHelloWorld", "Hello World from JSP!");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/scripting/StandaloneScriptExecutionServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/scripting/StandaloneScriptExecutionServlet.java
index 193bf81..3ac6049 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/scripting/StandaloneScriptExecutionServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/scripting/StandaloneScriptExecutionServlet.java
@@ -1,26 +1,28 @@
/*
- * 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.launchpad.testservices.scripting;
+import javax.servlet.ServletException;
+
import java.io.IOException;
import java.io.StringWriter;
-import javax.servlet.ServletException;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.scripting.SlingBindings;
@@ -30,37 +32,37 @@ import org.osgi.service.component.annotations.Component;
/**
* Test Servlet that executes a named script in standalone mode, i.e.
- * without a request or response.
+ * without a request or response.
*/
-
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=StandaloneScriptExecutionServlet Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.selectors:String=StandaloneScriptExecutionServlet",
- "sling.servlet.extensions:String=txt"
+ "service.description:String=StandaloneScriptExecutionServlet Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.selectors:String=StandaloneScriptExecutionServlet",
+ "sling.servlet.extensions:String=txt"
})
@SuppressWarnings("serial")
public class StandaloneScriptExecutionServlet extends SlingSafeMethodsServlet {
- @Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
- final SlingScript script = request.getResource().adaptTo(SlingScript.class);
- if(script == null) {
- throw new ServletException("Resource does not adapt to a SlingScript:" + request.getResource().getPath());
- }
-
- // Execute the script without providing a request or response, in the simplest possible way
- final SlingBindings bindings = new SlingBindings();
- final StringWriter sw = new StringWriter();
- bindings.put("StandaloneScriptExecutionServletOutput", sw);
- script.eval(bindings);
-
- response.setContentType("text/plain");
- response.getWriter().write(sw.toString());
- }
+ @Override
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ final SlingScript script = request.getResource().adaptTo(SlingScript.class);
+ if (script == null) {
+ throw new ServletException("Resource does not adapt to a SlingScript:"
+ + request.getResource().getPath());
+ }
+
+ // Execute the script without providing a request or response, in the simplest possible way
+ final SlingBindings bindings = new SlingBindings();
+ final StringWriter sw = new StringWriter();
+ bindings.put("StandaloneScriptExecutionServletOutput", sw);
+ script.eval(bindings);
+
+ response.setContentType("text/plain");
+ response.getWriter().write(sw.toString());
+ }
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/scripting/StringBindingsValuesProvider.java b/src/main/java/org/apache/sling/launchpad/testservices/scripting/StringBindingsValuesProvider.java
index 66236ec..363263e 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/scripting/StringBindingsValuesProvider.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/scripting/StringBindingsValuesProvider.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.launchpad.testservices.scripting;
@@ -20,17 +22,17 @@ import javax.script.Bindings;
import org.apache.sling.scripting.api.BindingsValuesProvider;
import org.osgi.service.component.annotations.Component;
+
/** Example/test BindingsValuesProvider targeting all scripts */
@Component(
- immediate=true,
+ immediate = true,
property = {
- "service.description:String=StringBindingsValuesProvider",
- "service.vendor:String=The Apache Software Foundation"
+ "service.description:String=StringBindingsValuesProvider",
+ "service.vendor:String=The Apache Software Foundation"
})
public class StringBindingsValuesProvider implements BindingsValuesProvider {
public void addBindings(Bindings bindings) {
bindings.put("helloWorld", "Hello World!");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowerRankingStringTransformer.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowerRankingStringTransformer.java
index 497f1f5..cec53cf 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowerRankingStringTransformer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowerRankingStringTransformer.java
@@ -1,32 +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.launchpad.testservices.serversidetests;
import org.apache.sling.launchpad.testservices.exported.StringTransformer;
import org.osgi.service.component.annotations.Component;
-@Component(
- property = {
- "mode:String=lowercase",
- "service.ranking:Integer=-10"
- }
- )
+@Component(property = {"mode:String=lowercase", "service.ranking:Integer=-10"})
public class LowerRankingStringTransformer implements StringTransformer {
public String transform(String str) {
- throw new UnsupportedOperationException("This " + getClass().getSimpleName() + " shouldn't be called in tests due to lower ranking");
+ throw new UnsupportedOperationException(
+ "This " + getClass().getSimpleName() + " shouldn't be called in tests due to lower ranking");
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowercaseStringTransformer.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowercaseStringTransformer.java
index c78a38e..3732a0e 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowercaseStringTransformer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/LowercaseStringTransformer.java
@@ -1,29 +1,27 @@
/*
- * 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.launchpad.testservices.serversidetests;
import org.apache.sling.launchpad.testservices.exported.StringTransformer;
import org.osgi.service.component.annotations.Component;
-@Component(
- property = {
- "mode:String=lowercase"
- }
- )
+@Component(property = {"mode:String=lowercase"})
public class LowercaseStringTransformer implements StringTransformer {
public String transform(String str) {
return str.toLowerCase();
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/MappingEventsTest.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/MappingEventsTest.java
index 2d9a15b..9a647a0 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/MappingEventsTest.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/MappingEventsTest.java
@@ -1,36 +1,35 @@
/*
- * 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.launchpad.testservices.serversidetests;
-import org.apache.sling.launchpad.testservices.exported.MappingsFacade;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
import org.apache.sling.launchpad.testservices.events.EventsCounter;
+import org.apache.sling.launchpad.testservices.exported.MappingsFacade;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,26 +37,29 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
@RunWith(SlingAnnotationsTestRunner.class)
public class MappingEventsTest {
public static final String PROP_REDIRECT_EXTERNAL = "sling:redirect";
-
+
private static final Logger logger = LoggerFactory.getLogger(MappingEventsTest.class);
private static Session session;
private Node mapRoot;
private static List<String> toDelete = new ArrayList<>();
-
+
private static final int N_STEPS = 20;
-
+
@TestReference
private EventsCounter eventsCounter;
-
+
@TestReference
private SlingRepository repository;
-
+
private Node maybeCreateNode(Node parent, String name, String type) throws RepositoryException {
- if(parent.hasNode(name)) {
+ if (parent.hasNode(name)) {
return parent.getNode(name);
} else {
return parent.addNode(name, type);
@@ -66,14 +68,14 @@ public class MappingEventsTest {
@Before
public synchronized void setup() throws Exception {
- // Do the mappings setup only once, and clean it up
+ // Do the mappings setup only once, and clean it up
// after all tests
session = repository.loginAdministrative(null);
final Node rootNode = maybeCreateNode(session.getRootNode(), "content", "nt:unstructured");
session.save();
-
+
assertTrue("toDelete should be empty before test", toDelete.isEmpty());
-
+
mapRoot = maybeCreateNode(session.getRootNode(), "etc", "nt:folder");
final Node map = maybeCreateNode(mapRoot, "map", "sling:Mapping");
final Node http = maybeCreateNode(map, "http", "sling:Mapping");
@@ -83,14 +85,14 @@ public class MappingEventsTest {
toDelete.add(map.getPath());
toDelete.add(rootNode.getPath());
}
-
+
@After
public void deleteTestNodes() throws Exception {
logger.debug("{} test done, deleting test nodes", MappingEventsTest.class.getSimpleName());
-
+
try {
- for(String path : toDelete) {
- if(session.itemExists(path)) {
+ for (String path : toDelete) {
+ if (session.itemExists(path)) {
session.getItem(path).remove();
}
}
@@ -100,40 +102,42 @@ public class MappingEventsTest {
session.logout();
}
}
-
- /**
+
+ /**
* Test SLING-4058 - unexpected timeouts in saveMappings
*
* @throws Exception in case of any problems
*/
- @Test public void testSaveMappings() throws Exception {
+ @Test
+ public void testSaveMappings() throws Exception {
final Node base = mapRoot.getNode("map/https/localhost.443");
final MappingsFacade f = new MappingsFacade(eventsCounter);
try {
int count = N_STEPS;
- while(count-- > 0) {
- base.setProperty(PROP_REDIRECT_EXTERNAL,"http://somehost." + count);
+ while (count-- > 0) {
+ base.setProperty(PROP_REDIRECT_EXTERNAL, "http://somehost." + count);
final String result = f.saveMappings(session);
- if(result != null) {
+ if (result != null) {
fail(result);
}
}
} finally {
- base.setProperty(PROP_REDIRECT_EXTERNAL,"");
+ base.setProperty(PROP_REDIRECT_EXTERNAL, "");
session.save();
}
}
-
- @Test public void testVanityPaths() throws Exception {
+
+ @Test
+ public void testVanityPaths() throws Exception {
final MappingsFacade f = new MappingsFacade(eventsCounter);
final Node vanityTest = maybeCreateNode(session.getRootNode(), "vanityTest", "sling:Folder");
toDelete.add(vanityTest.getPath());
int count = N_STEPS;
- while(count-- > 0) {
- final String [] paths = { "one", "two", "three_" + count };
+ while (count-- > 0) {
+ final String[] paths = {"one", "two", "three_" + count};
vanityTest.setProperty("sling:vanityPath", paths);
final String result = f.saveMappings(session);
- if(result != null) {
+ if (result != null) {
fail(result);
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java
index 1330d16..8fc9d6f 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java
@@ -1,28 +1,27 @@
/*
- * 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.launchpad.testservices.serversidetests;
-import org.apache.sling.launchpad.testservices.exported.MappingsFacade;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -32,11 +31,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.sling.api.resource.NonExistingResource;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -47,6 +41,7 @@ import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
import org.apache.sling.launchpad.testservices.events.EventsCounter;
import org.apache.sling.launchpad.testservices.exported.FakeSlingHttpServletRequest;
+import org.apache.sling.launchpad.testservices.exported.MappingsFacade;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -55,6 +50,13 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
@RunWith(SlingAnnotationsTestRunner.class)
public class ResourceResolverWithVanityBloomFilterTest {
@@ -68,28 +70,28 @@ public class ResourceResolverWithVanityBloomFilterTest {
private String rootPath;
private Node rootNode;
private Node mapRoot;
- private String [] vanity;
+ private String[] vanity;
private static List<String> toDelete = new ArrayList<>();
private static ResourceResolverFactory cleanupResolverFactory;
private MappingsFacade mappingsFacade;
-
+
@TestReference
private EventsCounter eventsCounter;
-
+
@TestReference
- private ResourceResolverFactory resourceResolverFactory;
-
+ private ResourceResolverFactory resourceResolverFactory;
+
private Node maybeCreateNode(Node parent, String name, String type) throws RepositoryException {
- if(parent.hasNode(name)) {
+ if (parent.hasNode(name)) {
return parent.getNode(name);
} else {
return parent.addNode(name, type);
}
}
-
+
private void saveMappings(Session s) throws Exception {
final String saveMappingsError = mappingsFacade.saveMappings(s);
- if(saveMappingsError != null) {
+ if (saveMappingsError != null) {
fail(saveMappingsError);
}
}
@@ -102,13 +104,13 @@ public class ResourceResolverWithVanityBloomFilterTest {
cleanupResolverFactory = resourceResolverFactory;
session = resResolver.adaptTo(Session.class);
mappingsFacade = new MappingsFacade(eventsCounter);
-
- // Do the mappings setup only once, and clean it up
+
+ // Do the mappings setup only once, and clean it up
// after all tests
rootNode = maybeCreateNode(session.getRootNode(), "content", "nt:unstructured");
rootPath = rootNode.getPath();
session.save();
- if(toDelete.isEmpty()) {
+ if (toDelete.isEmpty()) {
final Node mapRoot = maybeCreateNode(session.getRootNode(), "etc", "nt:folder");
final Node map = maybeCreateNode(mapRoot, "map", "sling:Mapping");
final Node http = maybeCreateNode(map, "http", "sling:Mapping");
@@ -118,55 +120,56 @@ public class ResourceResolverWithVanityBloomFilterTest {
toDelete.add(map.getPath());
toDelete.add(rootNode.getPath());
}
-
+
mapRoot = session.getNode("/etc");
session.save();
-
+
// define a vanity path for the rootPath
- vanity = new String[] {"testVanity","testV", "testVanityToUpdate"};
+ vanity = new String[] {"testVanity", "testV", "testVanityToUpdate"};
rootNode.setProperty("sling:vanityPath", vanity);
rootNode.addMixin("sling:VanityPath");
saveMappings(session);
}
-
+
private void closeResolver() {
- if(session != null) {
- if(session.isLive()) {
+ if (session != null) {
+ if (session.isLive()) {
session.logout();
}
session = null;
}
- if (resResolver != null ) {
+ if (resResolver != null) {
resResolver.close();
resResolver = null;
}
-
}
-
- private void setMaxCachedVanityPathEntries(long maxCachedVanityPathEntries) throws Exception{
- //FIXME: enabling bloom filter usage using reflection for now
+
+ private void setMaxCachedVanityPathEntries(long maxCachedVanityPathEntries) throws Exception {
+ // FIXME: enabling bloom filter usage using reflection for now
// we need to have a new mechanism to test different then default OSGi configurations
Field commonFactory = resourceResolverFactory.getClass().getDeclaredField("commonFactory");
commonFactory.setAccessible(true);
- Object commonResourceResolverFactoryImpl = commonFactory.get(resourceResolverFactory);
+ Object commonResourceResolverFactoryImpl = commonFactory.get(resourceResolverFactory);
Field mapEntries = commonResourceResolverFactoryImpl.getClass().getDeclaredField("mapEntries");
mapEntries.setAccessible(true);
- Object mapEntriesObject = mapEntries.get(commonResourceResolverFactoryImpl);
- Field maxCachedVanityPathEntriesField = mapEntriesObject.getClass().getDeclaredField("maxCachedVanityPathEntries");
- maxCachedVanityPathEntriesField.setAccessible(true);
+ Object mapEntriesObject = mapEntries.get(commonResourceResolverFactoryImpl);
+ Field maxCachedVanityPathEntriesField =
+ mapEntriesObject.getClass().getDeclaredField("maxCachedVanityPathEntries");
+ maxCachedVanityPathEntriesField.setAccessible(true);
maxCachedVanityPathEntriesField.setLong(mapEntriesObject, maxCachedVanityPathEntries);
}
@After
public void deleteTestNodes() throws Exception {
- logger.debug("{} test done, deleting test nodes", ResourceResolverWithVanityBloomFilterTest.class.getSimpleName());
+ logger.debug(
+ "{} test done, deleting test nodes", ResourceResolverWithVanityBloomFilterTest.class.getSimpleName());
setMaxCachedVanityPathEntries(-1);
final ResourceResolver resolver = cleanupResolverFactory.getAdministrativeResourceResolver(null);
final Session session = resolver.adaptTo(Session.class);
-
+
try {
- for(String path : toDelete) {
- if(session.itemExists(path)) {
+ for (String path : toDelete) {
+ if (session.itemExists(path)) {
session.getItem(path).remove();
}
}
@@ -177,8 +180,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
resolver.close();
}
}
-
- @Test public void test_clone_based_on_anonymous() throws Exception {
+
+ @Test
+ public void test_clone_based_on_anonymous() throws Exception {
final ResourceResolver anon0 = this.resourceResolverFactory.getResourceResolver((Map<String, Object>) null);
final Session anon0Session = anon0.adaptTo(Session.class);
assertEquals("anonymous", anon0.getUserID());
@@ -187,8 +191,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
final ResourceResolver anon1 = anon0.clone(null);
final Session anon1Session = anon1.adaptTo(Session.class);
assertEquals(anon0.getUserID(), anon1.getUserID());
- assertEquals(anon0Session.getWorkspace().getName(),
- anon1Session.getWorkspace().getName());
+ assertEquals(
+ anon0Session.getWorkspace().getName(),
+ anon1Session.getWorkspace().getName());
anon1.close();
// same workspace but admin user
@@ -198,8 +203,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
final ResourceResolver admin0 = anon0.clone(admin0Cred);
final Session admin0Session = admin0.adaptTo(Session.class);
assertEquals("admin", admin0.getUserID());
- assertEquals(anon0Session.getWorkspace().getName(),
- admin0Session.getWorkspace().getName());
+ assertEquals(
+ anon0Session.getWorkspace().getName(),
+ admin0Session.getWorkspace().getName());
admin0.close();
// same user but different workspace
@@ -219,8 +225,10 @@ public class ResourceResolverWithVanityBloomFilterTest {
anon0.close();
}
- @Test public void test_clone_based_on_admin() throws Exception {
- final ResourceResolver admin0 = this.resourceResolverFactory.getAdministrativeResourceResolver((Map<String, Object>) null);
+ @Test
+ public void test_clone_based_on_admin() throws Exception {
+ final ResourceResolver admin0 =
+ this.resourceResolverFactory.getAdministrativeResourceResolver((Map<String, Object>) null);
final Session admin0Session = admin0.adaptTo(Session.class);
assertEquals("admin", admin0.getUserID());
@@ -228,8 +236,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
final ResourceResolver admin1 = admin0.clone(null);
final Session admin1Session = admin1.adaptTo(Session.class);
assertEquals(admin0.getUserID(), admin1.getUserID());
- assertEquals(admin0Session.getWorkspace().getName(),
- admin1Session.getWorkspace().getName());
+ assertEquals(
+ admin0Session.getWorkspace().getName(),
+ admin1Session.getWorkspace().getName());
admin1.close();
// same workspace but anonymous user
@@ -238,8 +247,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
final ResourceResolver anon0 = admin0.clone(anon0Cred);
final Session anon0Session = anon0.adaptTo(Session.class);
assertEquals("anonymous", anon0.getUserID());
- assertEquals(admin0Session.getWorkspace().getName(),
- anon0Session.getWorkspace().getName());
+ assertEquals(
+ admin0Session.getWorkspace().getName(),
+ anon0Session.getWorkspace().getName());
anon0.close();
// same user but different workspace
@@ -325,7 +335,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
session1.logout();
}*/
- @Test public void test_attributes_from_authInfo() throws Exception {
+ @Test
+ public void test_attributes_from_authInfo() throws Exception {
final Map<String, Object> authInfo = new HashMap<>();
authInfo.put(ResourceResolverFactory.USER, "admin");
authInfo.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
@@ -335,8 +346,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
final Session s = rr.adaptTo(Session.class);
try {
- assertEquals("Expect 3 session attributes", 3,
- s.getAttributeNames().length);
+ assertEquals("Expect 3 session attributes", 3, s.getAttributeNames().length);
assertEquals("AStringValue", s.getAttribute("testAttributeString"));
assertEquals(999, s.getAttribute("testAttributeNumber"));
assertEquals("admin", s.getAttribute(ResourceResolverFactory.USER));
@@ -356,20 +366,19 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertTrue(validNames.remove(names.next()));
assertTrue(validNames.remove(names.next()));
assertFalse("Expect no more names", names.hasNext());
- assertTrue("Expect validNames set to be empty now",
- validNames.isEmpty());
+ assertTrue("Expect validNames set to be empty now", validNames.isEmpty());
} finally {
rr.close();
}
}
- @Test public void testGetResource() throws Exception {
+ @Test
+ public void testGetResource() throws Exception {
// existing resource
Resource res = resResolver.getResource(rootPath);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -380,14 +389,14 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertNull(res);
}
- @Test public void testResolveResource() throws Exception {
+ @Test
+ public void testResolveResource() throws Exception {
// existing resource
HttpServletRequest request = new FakeSlingHttpServletRequest(rootPath);
Resource res = resResolver.resolve(request, rootPath);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -406,8 +415,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
res = resResolver.resolve(new FakeSlingHttpServletRequest(path), path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -421,14 +429,11 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals(Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
}
-
-
- @Test public void testResolveResourceExternalRedirect() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+ @Test
+ public void testResolveResourceExternalRedirect() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
- localhost443.setProperty(PROP_REDIRECT_EXTERNAL,
- "http://localhost");
+ localhost443.setProperty(PROP_REDIRECT_EXTERNAL, "http://localhost");
try {
saveMappings(session);
@@ -437,28 +442,26 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals(rootPath, res.getPath());
assertEquals("sling:redirect", res.getResourceType());
assertNotNull(res.adaptTo(ValueMap.class));
- assertEquals("http://localhost" + rootPath,
- res.adaptTo(ValueMap.class).get("sling:target", String.class));
+ assertEquals(
+ "http://localhost" + rootPath, res.adaptTo(ValueMap.class).get("sling:target", String.class));
} finally {
localhost443.getProperty(PROP_REDIRECT_EXTERNAL).remove();
session.save();
}
}
- @Test public void testResolveResourceInternalRedirectUrl() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+ @Test
+ public void testResolveResourceInternalRedirectUrl() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
- localhost443.setProperty(PROP_REDIRECT_INTERNAL,
- "http://localhost");
+ localhost443.setProperty(PROP_REDIRECT_INTERNAL, "http://localhost");
try {
saveMappings(session);
Resource res = resResolver.resolve(request, rootPath);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -468,17 +471,14 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveResourceInternalRedirectPath() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+ @Test
+ public void testResolveResourceInternalRedirectPath() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
- Node toContent = localhost443.addNode("_playground_designground_",
- "sling:Mapping");
- toContent.setProperty("sling:match",
- "(playground|designground)");
- toContent.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/$1");
+ Node toContent = localhost443.addNode("_playground_designground_", "sling:Mapping");
+ toContent.setProperty("sling:match", "(playground|designground)");
+ toContent.setProperty(PROP_REDIRECT_INTERNAL, "/content/$1");
try {
saveMappings(session);
Resource res = resResolver.resolve(request, "/playground.html");
@@ -497,31 +497,31 @@ public class ResourceResolverWithVanityBloomFilterTest {
session.save();
}
}
-
- @Test public void testResolveResourceInternalRedirectPathAndVanityPath() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+
+ @Test
+ public void testResolveResourceInternalRedirectPathAndVanityPath() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
- localhost443.setProperty(PROP_REDIRECT_INTERNAL,
- "/example");
+ localhost443.setProperty(PROP_REDIRECT_INTERNAL, "/example");
try {
saveMappings(session);
Resource res = resResolver.resolve(request, vanity[0]);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
-
- //see SLING-3428
+
+ // see SLING-3428
res = resResolver.resolve(request, vanity[1]);
assertNotNull(res);
- assertEquals("/example/"+vanity[1], res.getPath());
+ assertEquals("/example/" + vanity[1], res.getPath());
} finally {
localhost443.getProperty(PROP_REDIRECT_INTERNAL).remove();
session.save();
- }
+ }
}
- @Test public void testResolveResourceInternalRedirectPathUpdate() throws Exception {
+ @Test
+ public void testResolveResourceInternalRedirectPathUpdate() throws Exception {
HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
Node toContent = localhost443.addNode("_playground_designground_", "sling:Mapping");
@@ -563,14 +563,13 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveResourceInternalRedirectExact() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+ @Test
+ public void testResolveResourceInternalRedirectExact() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
Node toContent = localhost443.addNode("virtual", "sling:Mapping");
toContent.setProperty("sling:match", "virtual$");
- toContent.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/virtual.html");
+ toContent.setProperty(PROP_REDIRECT_INTERNAL, "/content/virtual.html");
try {
saveMappings(session);
@@ -599,21 +598,18 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveResourceInternalRedirectDepthFirst()
- throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- null, -1, rootPath);
+ @Test
+ public void testResolveResourceInternalRedirectDepthFirst() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", null, -1, rootPath);
// map anything
Node localhost443 = mapRoot.getNode("map/https/localhost.443");
- localhost443.setProperty(PROP_REDIRECT_INTERNAL,
- "/content2");
+ localhost443.setProperty(PROP_REDIRECT_INTERNAL, "/content2");
// map only ../virtual
Node toContent = localhost443.addNode("virtual", "sling:Mapping");
toContent.setProperty("sling:match", "virtual$");
- toContent.setProperty(PROP_REDIRECT_INTERNAL,
- "/content2/virtual.html");
+ toContent.setProperty(PROP_REDIRECT_INTERNAL, "/content2/virtual.html");
try {
saveMappings(session);
@@ -635,13 +631,11 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttp80() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest(null,
- "virtual.host.com", -1, rootPath);
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(
- "virtual.host.com.80", "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/virtual");
+ @Test
+ public void testResolveVirtualHostHttp80() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest(null, "virtual.host.com", -1, rootPath);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode("virtual.host.com.80", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, "/content/virtual");
try {
saveMappings(session);
@@ -649,8 +643,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertNotNull(res0);
assertEquals("/content/virtual/playground.html", res0.getPath());
- final Resource res1 = resResolver.resolve(request,
- "/playground/en.html");
+ final Resource res1 = resResolver.resolve(request, "/playground/en.html");
assertNotNull(res1);
assertEquals("/content/virtual/playground/en.html", res1.getPath());
@@ -669,7 +662,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttp80Multiple() throws Exception {
+ @Test
+ public void testResolveVirtualHostHttp80Multiple() throws Exception {
final String de = "de";
final String en = "en";
@@ -678,28 +672,21 @@ public class ResourceResolverWithVanityBloomFilterTest {
final String contentDE = "/content/" + de;
final String contentEN = "/content/" + en;
- Node virtualhost80a = mapRoot.getNode("map/http").addNode(
- hostDE + ".80", "sling:Mapping");
- virtualhost80a.setProperty(PROP_REDIRECT_INTERNAL,
- contentDE);
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80",
- "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- contentEN);
+ Node virtualhost80a = mapRoot.getNode("map/http").addNode(hostDE + ".80", "sling:Mapping");
+ virtualhost80a.setProperty(PROP_REDIRECT_INTERNAL, contentDE);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, contentEN);
try {
saveMappings(session);
-
+
// de content mapping
- final HttpServletRequest requestDE = new FakeSlingHttpServletRequest(
- null, hostDE, -1, rootPath);
- final Resource resDE0 = resResolver.resolve(requestDE,
- "/playground.html");
+ final HttpServletRequest requestDE = new FakeSlingHttpServletRequest(null, hostDE, -1, rootPath);
+ final Resource resDE0 = resResolver.resolve(requestDE, "/playground.html");
assertNotNull(resDE0);
assertEquals(contentDE + "/playground.html", resDE0.getPath());
- final Resource resDE1 = resResolver.resolve(requestDE,
- "/playground/index.html");
+ final Resource resDE1 = resResolver.resolve(requestDE, "/playground/index.html");
assertNotNull(resDE1);
assertEquals(contentDE + "/playground/index.html", resDE1.getPath());
@@ -715,15 +702,12 @@ public class ResourceResolverWithVanityBloomFilterTest {
// en content mapping
- final HttpServletRequest requestEN = new FakeSlingHttpServletRequest(
- null, hostEN, -1, rootPath);
- final Resource resEN0 = resResolver.resolve(requestEN,
- "/playground.html");
+ final HttpServletRequest requestEN = new FakeSlingHttpServletRequest(null, hostEN, -1, rootPath);
+ final Resource resEN0 = resResolver.resolve(requestEN, "/playground.html");
assertNotNull(resEN0);
assertEquals(contentEN + "/playground.html", resEN0.getPath());
- final Resource resEN1 = resResolver.resolve(requestEN,
- "/playground/index.html");
+ final Resource resEN1 = resResolver.resolve(requestEN, "/playground/index.html");
assertNotNull(resEN1);
assertEquals(contentEN + "/playground/index.html", resEN1.getPath());
@@ -743,7 +727,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttp80MultipleRoot() throws Exception {
+ @Test
+ public void testResolveVirtualHostHttp80MultipleRoot() throws Exception {
final String de = "de";
final String en = "en";
@@ -752,28 +737,21 @@ public class ResourceResolverWithVanityBloomFilterTest {
final String hostEN = en + ".host.com";
final String hostFR = fr + ".host.com";
- Node virtualhost80a = mapRoot.getNode("map/http").addNode(
- hostDE + ".80", "sling:Mapping");
- virtualhost80a.setProperty(PROP_REDIRECT_INTERNAL,
- "/");
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80",
- "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- "/");
+ Node virtualhost80a = mapRoot.getNode("map/http").addNode(hostDE + ".80", "sling:Mapping");
+ virtualhost80a.setProperty(PROP_REDIRECT_INTERNAL, "/");
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, "/");
try {
saveMappings(session);
-
+
// de content mapping
- final HttpServletRequest requestDE = new FakeSlingHttpServletRequest(
- null, hostDE, -1, rootPath);
- final Resource resDE0 = resResolver.resolve(requestDE,
- "/playground.html");
+ final HttpServletRequest requestDE = new FakeSlingHttpServletRequest(null, hostDE, -1, rootPath);
+ final Resource resDE0 = resResolver.resolve(requestDE, "/playground.html");
assertNotNull(resDE0);
assertEquals("/playground.html", resDE0.getPath());
- final Resource resDE1 = resResolver.resolve(requestDE,
- "/playground/index.html");
+ final Resource resDE1 = resResolver.resolve(requestDE, "/playground/index.html");
assertNotNull(resDE1);
assertEquals("/playground/index.html", resDE1.getPath());
@@ -789,15 +767,12 @@ public class ResourceResolverWithVanityBloomFilterTest {
// en content mapping
- final HttpServletRequest requestEN = new FakeSlingHttpServletRequest(
- null, hostEN, -1, rootPath);
- final Resource resEN0 = resResolver.resolve(requestEN,
- "/playground.html");
+ final HttpServletRequest requestEN = new FakeSlingHttpServletRequest(null, hostEN, -1, rootPath);
+ final Resource resEN0 = resResolver.resolve(requestEN, "/playground.html");
assertNotNull(resEN0);
assertEquals("/playground.html", resEN0.getPath());
- final Resource resEN1 = resResolver.resolve(requestEN,
- "/playground/index.html");
+ final Resource resEN1 = resResolver.resolve(requestEN, "/playground/index.html");
assertNotNull(resEN1);
assertEquals("/playground/index.html", resEN1.getPath());
@@ -823,10 +798,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
final String mappedEN11 = resResolver.map(requestEN, resEN1.getPath());
assertEquals("/playground/index.html", mappedEN11);
- final HttpServletRequest requestFR = new FakeSlingHttpServletRequest(
- null, hostFR, -1, rootPath);
- final Resource resFR1 = resResolver.resolve(requestFR,
- "/playground/index.html");
+ final HttpServletRequest requestFR = new FakeSlingHttpServletRequest(null, hostFR, -1, rootPath);
+ final Resource resFR1 = resResolver.resolve(requestFR, "/playground/index.html");
assertNotNull(resFR1);
assertEquals("/playground/index.html", resFR1.getPath());
@@ -848,13 +821,11 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttp8080() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest(null,
- "virtual.host.com", 8080, rootPath);
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(
- "virtual.host.com.8080", "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/virtual");
+ @Test
+ public void testResolveVirtualHostHttp8080() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest(null, "virtual.host.com", 8080, rootPath);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode("virtual.host.com.8080", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, "/content/virtual");
try {
saveMappings(session);
@@ -862,8 +833,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertNotNull(res0);
assertEquals("/content/virtual/playground.html", res0.getPath());
- final Resource res1 = resResolver.resolve(request,
- "/playground/en.html");
+ final Resource res1 = resResolver.resolve(request, "/playground/en.html");
assertNotNull(res1);
assertEquals("/content/virtual/playground/en.html", res1.getPath());
@@ -873,8 +843,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals("/playground.html", mapped01);
final String mapped10 = resResolver.map(res1.getPath());
- assertEquals("http://virtual.host.com:8080/playground/en.html",
- mapped10);
+ assertEquals("http://virtual.host.com:8080/playground/en.html", mapped10);
final String mapped11 = resResolver.map(request, res1.getPath());
assertEquals("/playground/en.html", mapped11);
} finally {
@@ -883,13 +852,11 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttp8080Root() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest(null,
- "virtual.host.com", 8080, rootPath);
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(
- "virtual.host.com.8080", "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- "/");
+ @Test
+ public void testResolveVirtualHostHttp8080Root() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest(null, "virtual.host.com", 8080, rootPath);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode("virtual.host.com.8080", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, "/");
try {
saveMappings(session);
@@ -897,8 +864,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertNotNull(res0);
assertEquals("/playground.html", res0.getPath());
- final Resource res1 = resResolver.resolve(request,
- "/playground/en.html");
+ final Resource res1 = resResolver.resolve(request, "/playground/en.html");
assertNotNull(res1);
assertEquals("/playground/en.html", res1.getPath());
@@ -908,8 +874,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals("/playground.html", mapped01);
final String mapped10 = resResolver.map(res1.getPath());
- assertEquals("http://virtual.host.com:8080/playground/en.html",
- mapped10);
+ assertEquals("http://virtual.host.com:8080/playground/en.html", mapped10);
final String mapped11 = resResolver.map(request, res1.getPath());
assertEquals("/playground/en.html", mapped11);
} finally {
@@ -918,13 +883,11 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttps443() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- "virtual.host.com", -1, rootPath);
- Node virtualhost443 = mapRoot.getNode("map/https").addNode(
- "virtual.host.com.443", "sling:Mapping");
- virtualhost443.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/virtual");
+ @Test
+ public void testResolveVirtualHostHttps443() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", "virtual.host.com", -1, rootPath);
+ Node virtualhost443 = mapRoot.getNode("map/https").addNode("virtual.host.com.443", "sling:Mapping");
+ virtualhost443.setProperty(PROP_REDIRECT_INTERNAL, "/content/virtual");
try {
saveMappings(session);
@@ -932,8 +895,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertNotNull(res0);
assertEquals("/content/virtual/playground.html", res0.getPath());
- final Resource res1 = resResolver.resolve(request,
- "/playground/en.html");
+ final Resource res1 = resResolver.resolve(request, "/playground/en.html");
assertNotNull(res1);
assertEquals("/content/virtual/playground/en.html", res1.getPath());
@@ -952,22 +914,19 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttps4443() throws Exception {
- HttpServletRequest request = new FakeSlingHttpServletRequest("https",
- "virtual.host.com", 4443, rootPath);
- Node virtualhost4443 = mapRoot.getNode("map/https").addNode(
- "virtual.host.com.4443", "sling:Mapping");
- virtualhost4443.setProperty(PROP_REDIRECT_INTERNAL,
- "/content/virtual");
-
+ @Test
+ public void testResolveVirtualHostHttps4443() throws Exception {
+ HttpServletRequest request = new FakeSlingHttpServletRequest("https", "virtual.host.com", 4443, rootPath);
+ Node virtualhost4443 = mapRoot.getNode("map/https").addNode("virtual.host.com.4443", "sling:Mapping");
+ virtualhost4443.setProperty(PROP_REDIRECT_INTERNAL, "/content/virtual");
+
try {
saveMappings(session);
final Resource res0 = resResolver.resolve(request, "/playground.html");
assertNotNull(res0);
assertEquals("/content/virtual/playground.html", res0.getPath());
- final Resource res1 = resResolver.resolve(request,
- "/playground/en.html");
+ final Resource res1 = resResolver.resolve(request, "/playground/en.html");
assertNotNull(res1);
assertEquals("/content/virtual/playground/en.html", res1.getPath());
@@ -977,8 +936,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals("/playground.html", mapped01);
final String mapped10 = resResolver.map(res1.getPath());
- assertEquals("https://virtual.host.com:4443/playground/en.html",
- mapped10);
+ assertEquals("https://virtual.host.com:4443/playground/en.html", mapped10);
final String mapped11 = resResolver.map(request, res1.getPath());
assertEquals("/playground/en.html", mapped11);
} finally {
@@ -987,44 +945,37 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveVirtualHostHttpVsHttps() throws Exception {
+ @Test
+ public void testResolveVirtualHostHttpVsHttps() throws Exception {
final String host0 = "www.host.com";
final String host1 = "secure.host.com";
final String content = "/content/page";
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(host0 + ".80",
- "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- content);
- Node virtualhost443 = mapRoot.getNode("map/https").addNode(
- host0 + ".443", "sling:Mapping");
- virtualhost443.setProperty(PROP_REDIRECT_INTERNAL,
- content);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode(host0 + ".80", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, content);
+ Node virtualhost443 = mapRoot.getNode("map/https").addNode(host0 + ".443", "sling:Mapping");
+ virtualhost443.setProperty(PROP_REDIRECT_INTERNAL, content);
// HTTP request
try {
saveMappings(session);
- final HttpServletRequest requestHttp0 = new FakeSlingHttpServletRequest(
- null, host0, -1, rootPath);
+ final HttpServletRequest requestHttp0 = new FakeSlingHttpServletRequest(null, host0, -1, rootPath);
final Resource resHttp0 = resResolver.resolve(requestHttp0, "/playground.html");
assertNotNull(resHttp0);
assertEquals(content + "/playground.html", resHttp0.getPath());
- final Resource resHttp1 = resResolver.resolve(requestHttp0,
- "/playground/index.html");
+ final Resource resHttp1 = resResolver.resolve(requestHttp0, "/playground/index.html");
assertNotNull(resHttp1);
assertEquals(content + "/playground/index.html", resHttp1.getPath());
// HTTPS request
- final HttpServletRequest requestHttps0 = new FakeSlingHttpServletRequest(
- "https", host0, -1, rootPath);
+ final HttpServletRequest requestHttps0 = new FakeSlingHttpServletRequest("https", host0, -1, rootPath);
final Resource resHttps0 = resResolver.resolve(requestHttps0, "/playground.html");
assertNotNull(resHttps0);
assertEquals(content + "/playground.html", resHttps0.getPath());
- final Resource resHttps1 = resResolver.resolve(requestHttps0,
- "/playground/index.html");
+ final Resource resHttps1 = resResolver.resolve(requestHttps0, "/playground/index.html");
assertNotNull(resHttps1);
assertEquals(content + "/playground/index.html", resHttps1.getPath());
@@ -1042,10 +993,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
// HTTPS Mapping
- final HttpServletRequest requestHttp1 = new FakeSlingHttpServletRequest(
- null, host1, -1, rootPath);
- final HttpServletRequest requestHttps1 = new FakeSlingHttpServletRequest(
- "https", host1, -1, rootPath);
+ final HttpServletRequest requestHttp1 = new FakeSlingHttpServletRequest(null, host1, -1, rootPath);
+ final HttpServletRequest requestHttps1 = new FakeSlingHttpServletRequest("https", host1, -1, rootPath);
final String mappedHttps00 = resResolver.map(resHttps0.getPath());
assertEquals("http://" + host0 + "/playground.html", mappedHttps00);
@@ -1071,41 +1020,36 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveResourceAlias() throws Exception {
+ @Test
+ public void testResolveResourceAlias() throws Exception {
// define an alias for the rootPath
String alias = "testAlias";
rootNode.setProperty("sling:alias", alias);
try {
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -1115,78 +1059,68 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testResolveResourceAliasWithUpdate() throws Exception {
+ @Test
+ public void testResolveResourceAliasWithUpdate() throws Exception {
// define an alias for the rootPath
- String [] alias = {"testAlias","testAliasToUpdate"};
+ String[] alias = {"testAlias", "testAliasToUpdate"};
rootNode.setProperty("sling:alias", alias);
try {
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias[1] + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias[1] + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias[1] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias[1] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- //update alias
- String [] aliasUpdated = {"testAlias","testAliasUpdated"};
+ // update alias
+ String[] aliasUpdated = {"testAlias", "testAliasUpdated"};
rootNode.setProperty("sling:alias", aliasUpdated);
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + aliasUpdated[1] + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + aliasUpdated[1] + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + aliasUpdated[1] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(
+ ResourceUtil.getParent(rootPath) + "/" + aliasUpdated[1] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -1196,114 +1130,103 @@ public class ResourceResolverWithVanityBloomFilterTest {
session.save();
}
}
-
- @Test public void testResolveRemovedResourceAlias() throws Exception {
+
+ @Test
+ public void testResolveRemovedResourceAlias() throws Exception {
// define an alias for the rootPath
String alias = "testAlias";
rootNode.setProperty("sling:alias", alias);
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- //remove alias property
+ // remove alias property
rootNode.getProperty("sling:alias").remove();
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
- assertEquals("/"+alias+".print.html", res.getPath());
-
- //create new child with alias
+ assertEquals("/" + alias + ".print.html", res.getPath());
+
+ // create new child with alias
String childNodeName = "rootChildAlias";
Node childNode = maybeCreateNode(rootNode, childNodeName, "nt:unstructured");
childNode.setProperty("sling:alias", "childAlias");
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)+ "/"+ rootPath
- + "/childAlias.print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + rootPath + "/childAlias.print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
- assertEquals(rootPath+"/"+childNodeName, res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootPath + "/" + childNodeName, res.getPath());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)+ "/"+ rootPath + "/childAlias" +
- ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(
+ ResourceUtil.getParent(rootPath) + "/" + rootPath + "/childAlias" + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
- assertEquals(rootPath+"/"+childNodeName, res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootPath + "/" + childNodeName, res.getPath());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
-
- //remove the child node with the alias
+ // remove the child node with the alias
childNode.remove();
saveMappings(session);
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)+ "/"+ rootPath + "/childAlias" +
- ".print.html");
+
+ path = ResourceUtil.normalize(
+ ResourceUtil.getParent(rootPath) + "/" + rootPath + "/childAlias" + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
-
+
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
- assertEquals (rootPath + "/childAlias.print.html", res.getPath());
+ assertEquals(rootPath + "/childAlias.print.html", res.getPath());
}
-
- @Test public void testResolveResourceAliasJcrContent() throws Exception {
+
+ @Test
+ public void testResolveResourceAliasJcrContent() throws Exception {
// define an alias for the rootPath in the jcr:content child node
String alias = "testAlias";
Node content = rootNode.addNode("jcr:content", "nt:unstructured");
@@ -1311,43 +1234,38 @@ public class ResourceResolverWithVanityBloomFilterTest {
try {
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + "/" + alias + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/" + alias + ".print.html");
res = resResolver.resolve(request, path);
- assertEquals("GET request resolution does not go up the path",
- Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
+ assertEquals(
+ "GET request resolution does not go up the path",
+ Resource.RESOURCE_TYPE_NON_EXISTING,
+ res.getResourceType());
Node child = rootNode.addNode("child", "nt:unstructured");
child.setProperty("sling:alias", alias);
@@ -1364,82 +1282,71 @@ public class ResourceResolverWithVanityBloomFilterTest {
content.remove();
session.save();
}
-
}
- @Test public void testResolveResourceAliasJcrContentWithUpdate() throws Exception {
+ @Test
+ public void testResolveResourceAliasJcrContentWithUpdate() throws Exception {
// define an alias for the rootPath in the jcr:content child node
- String [] alias = {"testAlias","testAliasToUpdate"};
+ String[] alias = {"testAlias", "testAliasToUpdate"};
Node content = rootNode.addNode("jcr:content", "nt:unstructured");
content.setProperty("sling:alias", alias);
try {
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias[1] + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias[1] + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias[1] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias[1] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- //update alias
- String [] aliasUpdated = {"testAlias","testAliasUpdated"};
+ // update alias
+ String[] aliasUpdated = {"testAlias", "testAliasUpdated"};
content.setProperty("sling:alias", aliasUpdated);
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + aliasUpdated[1] + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + aliasUpdated[1] + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + aliasUpdated[1] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(
+ ResourceUtil.getParent(rootPath) + "/" + aliasUpdated[1] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
@@ -1448,10 +1355,10 @@ public class ResourceResolverWithVanityBloomFilterTest {
content.remove();
session.save();
}
-
}
-
- @Test public void testResolveRemovedesourceAliasJcrContent() throws Exception {
+
+ @Test
+ public void testResolveRemovedesourceAliasJcrContent() throws Exception {
// define an alias for the rootPath in the jcr:content child node
String alias = "testAlias";
Node content = rootNode.addNode("jcr:content", "nt:unstructured");
@@ -1459,395 +1366,352 @@ public class ResourceResolverWithVanityBloomFilterTest {
try {
saveMappings(session);
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + alias + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + "/" + alias + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/" + alias + ".print.html");
res = resResolver.resolve(request, path);
- assertEquals("GET request resolution does not go up the path",
- Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
+ assertEquals(
+ "GET request resolution does not go up the path",
+ Resource.RESOURCE_TYPE_NON_EXISTING,
+ res.getResourceType());
- //remove alias property
+ // remove alias property
content.getProperty("sling:alias").remove();
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias + ".print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
-
+
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
- assertEquals("/"+alias+".print.html", res.getPath());
+ assertEquals("/" + alias + ".print.html", res.getPath());
} finally {
content.remove();
session.save();
}
-
}
-
-
- @Test public void testResolveVanityPath() throws Exception {
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + vanity[0] + ".print.html");
+
+ @Test
+ public void testResolveVanityPath() throws Exception {
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[0] + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + vanity[0] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[0] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + vanity[1] + ".print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[1] + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + vanity[1] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[1] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
}
-
- @Test public void testResolveVanityPathWithUpdate() throws Exception {
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + vanity[2] + ".print.html");
+
+ @Test
+ public void testResolveVanityPathWithUpdate() throws Exception {
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[2] + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + vanity[2] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[2] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
-
- //update vanityPath
- String [] vanityPathUpdated = new String[] {"testVanity","testV", "testVanityUpdated"};
+
+ // update vanityPath
+ String[] vanityPathUpdated = new String[] {"testVanity", "testV", "testVanityUpdated"};
rootNode.setProperty("sling:vanityPath", vanityPathUpdated);
saveMappings(session);
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + vanityPathUpdated[2] + ".print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanityPathUpdated[2] + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/"
- + vanityPathUpdated[2] + ".print.html/suffix.pdf");
+ path = ResourceUtil.normalize(
+ ResourceUtil.getParent(rootPath) + "/" + vanityPathUpdated[2] + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html/suffix.pdf",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
-
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + vanity[2] + ".print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + vanity[2] + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
- assertEquals("/"+vanity[2]+".print.html", res.getPath());
+ assertEquals("/" + vanity[2] + ".print.html", res.getPath());
}
-
- @Ignore //see SLING-3558
- @Test public void testResolveRemovedMixinVanityPath() throws Exception {
+
+ @Ignore // see SLING-3558
+ @Test
+ public void testResolveRemovedMixinVanityPath() throws Exception {
Node childNode = null;
-
- try {
- //create new child with vanity path without mixin
+
+ try {
+ // create new child with vanity path without mixin
childNode = maybeCreateNode(rootNode, "rootChild", "nt:unstructured");
childNode.setProperty("sling:vanityPath", "childVanity");
saveMappings(session);
-
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
assertEquals("/childVanity.print.html", res.getPath());
-
- //add mixin
+
+ // add mixin
childNode.addMixin("sling:VanityPath");
saveMappings(session);
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
-
- //remove mixin
+
+ // remove mixin
childNode.removeMixin("sling:VanityPath");
saveMappings(session);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
assertEquals("/childVanity.print.html", res.getPath());
} finally {
- if (childNode != null){
+ if (childNode != null) {
childNode.remove();
saveMappings(session);
}
}
}
-
- @Test public void testResolveVanityPathWithVanityOrder() throws Exception {
+
+ @Test
+ public void testResolveVanityPathWithVanityOrder() throws Exception {
Node childNode = null;
Node childNode2 = null;
-
- try {
- //create new child with vanity path
+
+ try {
+ // create new child with vanity path
childNode = maybeCreateNode(rootNode, "rootChild", "nt:unstructured");
childNode.setProperty("sling:vanityPath", "childVanity");
childNode.addMixin("sling:VanityPath");
saveMappings(session);
-
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
-
- //create another child with the same vanity path
+
+ // create another child with the same vanity path
childNode2 = maybeCreateNode(rootNode, "rootChild2", "nt:unstructured");
childNode2.setProperty("sling:vanityPath", "childVanity");
childNode2.addMixin("sling:VanityPath");
saveMappings(session);
-
+
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
-
- //add vanityOrder to childNode2
+
+ // add vanityOrder to childNode2
childNode2.setProperty("sling:vanityOrder", 100);
saveMappings(session);
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
-
+
assertNotNull(res);
assertEquals(childNode2.getPath(), res.getPath());
- assertEquals(childNode2.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(childNode2.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode2.isSame(res.adaptTo(Node.class)));
-
- //add vanityOrder to childNode higher than childNode2
+
+ // add vanityOrder to childNode higher than childNode2
childNode.setProperty("sling:vanityOrder", 1000);
saveMappings(session);
-
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/childVanity.print.html");
+
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
- assertEquals(childNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
- assertEquals(".print.html",
- res.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
-
+
} finally {
- if (childNode != null){
- childNode.remove();
+ if (childNode != null) {
+ childNode.remove();
}
- if (childNode2 != null){
- childNode2.remove();
+ if (childNode2 != null) {
+ childNode2.remove();
}
session.save();
- }
+ }
}
-
- @Test public void testGetDoesNotGoUp() throws Exception {
+ @Test
+ public void testGetDoesNotGoUp() throws Exception {
final String path = rootPath + "/nothing";
{
- final Resource res = resResolver.resolve(
- new FakeSlingHttpServletRequest(path, "POST"), path);
+ final Resource res = resResolver.resolve(new FakeSlingHttpServletRequest(path, "POST"), path);
assertNotNull(res);
- assertEquals("POST request resolution does not go up the path",
- Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
+ assertEquals(
+ "POST request resolution does not go up the path",
+ Resource.RESOURCE_TYPE_NON_EXISTING,
+ res.getResourceType());
}
{
- final Resource res = resResolver.resolve(
- new FakeSlingHttpServletRequest(path, "GET"), path);
+ final Resource res = resResolver.resolve(new FakeSlingHttpServletRequest(path, "GET"), path);
assertNotNull(res);
- assertEquals("GET request resolution does not go up the path",
- Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
+ assertEquals(
+ "GET request resolution does not go up the path",
+ Resource.RESOURCE_TYPE_NON_EXISTING,
+ res.getResourceType());
}
}
- @Test public void testGetRemovesExtensionInResolution() throws Exception {
+ @Test
+ public void testGetRemovesExtensionInResolution() throws Exception {
final String path = rootPath + ".whatever";
- final Resource res = resResolver.resolve(
- new FakeSlingHttpServletRequest(path, "GET"), path);
+ final Resource res = resResolver.resolve(new FakeSlingHttpServletRequest(path, "GET"), path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
- assertEquals(rootNode.getPrimaryNodeType().getName(),
- res.getResourceType());
+ assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
}
- @Test public void testStarResourcePlain() throws Exception {
+ @Test
+ public void testStarResourcePlain() throws Exception {
final String path = rootPath + "/" + System.currentTimeMillis() + "/*";
testStarResourceHelper(path, "GET");
testStarResourceHelper(path, "POST");
@@ -1855,25 +1719,26 @@ public class ResourceResolverWithVanityBloomFilterTest {
testStarResourceHelper(path, "DELETE");
}
- @Test public void testStarResourceExtension() throws Exception {
- final String path = rootPath + "/" + System.currentTimeMillis()
- + "/*.html";
+ @Test
+ public void testStarResourceExtension() throws Exception {
+ final String path = rootPath + "/" + System.currentTimeMillis() + "/*.html";
testStarResourceHelper(path, "GET");
testStarResourceHelper(path, "POST");
testStarResourceHelper(path, "PUT");
testStarResourceHelper(path, "DELETE");
}
- @Test public void testStarResourceSelectorExtension() throws Exception {
- final String path = rootPath + "/" + System.currentTimeMillis()
- + "/*.print.a4.html";
+ @Test
+ public void testStarResourceSelectorExtension() throws Exception {
+ final String path = rootPath + "/" + System.currentTimeMillis() + "/*.print.a4.html";
testStarResourceHelper(path, "GET");
testStarResourceHelper(path, "POST");
testStarResourceHelper(path, "PUT");
testStarResourceHelper(path, "DELETE");
}
- @Test public void testSlingFolder() throws Exception {
+ @Test
+ public void testSlingFolder() throws Exception {
// create a folder
String folderPath = "folder";
@@ -1906,7 +1771,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMap() throws Exception {
+ @Test
+ public void testMap() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -1927,19 +1793,18 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapURLEscaping() throws Exception {
+ @Test
+ public void testMapURLEscaping() throws Exception {
final String mapHostInternal = "internal.host.com";
final String mapRootInternal = "/content/internal";
- Node internalRedirect = mapRoot.getNode("map/http").addNode(
- mapHostInternal + ".80", "sling:Mapping");
- internalRedirect.setProperty(
- PROP_REDIRECT_INTERNAL, mapRootInternal);
+ Node internalRedirect = mapRoot.getNode("map/http").addNode(mapHostInternal + ".80", "sling:Mapping");
+ internalRedirect.setProperty(PROP_REDIRECT_INTERNAL, mapRootInternal);
try {
saveMappings(session);
-
+
final String path = "/sample with spaces";
final String escapedPath = "/sample%20with%20spaces";
@@ -1953,15 +1818,14 @@ public class ResourceResolverWithVanityBloomFilterTest {
// b) test map(HttpServletRequest, String) with "localhost"
// => return full URL, escaped
- mapped = resResolver.map(new FakeSlingHttpServletRequest(rootPath),
- mapRootInternal + path);
+ mapped = resResolver.map(new FakeSlingHttpServletRequest(rootPath), mapRootInternal + path);
assertEquals("http://" + mapHostInternal + escapedPath, mapped);
// c) test map(HttpServletRequest, String) with "internal.host.com"
// => only return path, escaped, because request host/port matches (cut
// off host part)
- mapped = resResolver.map(new FakeSlingHttpServletRequest(null,
- mapHostInternal, -1, rootPath), mapRootInternal + path);
+ mapped = resResolver.map(
+ new FakeSlingHttpServletRequest(null, mapHostInternal, -1, rootPath), mapRootInternal + path);
assertEquals(escapedPath, mapped);
// ---------------------------------------------------------------------
@@ -1975,47 +1839,41 @@ public class ResourceResolverWithVanityBloomFilterTest {
assertEquals(unmappedRoot + escapedPath, mapped);
// b) test map(HttpServletRequest, String)
- mapped = resResolver.map(new FakeSlingHttpServletRequest(rootPath),
- unmappedRoot + path);
+ mapped = resResolver.map(new FakeSlingHttpServletRequest(rootPath), unmappedRoot + path);
assertEquals(unmappedRoot + escapedPath, mapped);
} finally {
internalRedirect.remove();
session.save();
}
-
}
- @Test public void testMapNamespaceMangling() throws Exception {
+ @Test
+ public void testMapNamespaceMangling() throws Exception {
final String mapHost = "virtual.host.com";
final String mapRootPath = "/content/virtual";
final String contextPath = "/context";
- Node virtualhost80 = mapRoot.getNode("map/http").addNode(
- mapHost + ".80", "sling:Mapping");
- virtualhost80.setProperty(PROP_REDIRECT_INTERNAL,
- mapRootPath);
+ Node virtualhost80 = mapRoot.getNode("map/http").addNode(mapHost + ".80", "sling:Mapping");
+ virtualhost80.setProperty(PROP_REDIRECT_INTERNAL, mapRootPath);
try {
saveMappings(session);
-
+
// ---------------------------------------------------------------------
// tests expecting paths without context
- final HttpServletRequest virtualRequest = new FakeSlingHttpServletRequest(
- null, mapHost, -1, rootPath);
+ final HttpServletRequest virtualRequest = new FakeSlingHttpServletRequest(null, mapHost, -1, rootPath);
// simple mapping - cut off prefix and add host
final String pathv0 = "/sample";
- final String mappedv0 = resResolver.map(virtualRequest, mapRootPath
- + pathv0);
+ final String mappedv0 = resResolver.map(virtualRequest, mapRootPath + pathv0);
assertEquals("Expect unmangled path", pathv0, mappedv0);
// expected name mangling without host prefix
final String pathv1 = "/sample/jcr:content";
final String mangledv1 = "/sample/_jcr_content";
- final String mappedv1 = resResolver.map(virtualRequest, mapRootPath
- + pathv1);
+ final String mappedv1 = resResolver.map(virtualRequest, mapRootPath + pathv1);
assertEquals("Expect mangled path", mangledv1, mappedv1);
// ---------------------------------------------------------------------
@@ -2025,35 +1883,29 @@ public class ResourceResolverWithVanityBloomFilterTest {
// simple mapping - cut off prefix and add host
final String pathvc0 = "/sample";
- final String mappedvc0 = resResolver.map(virtualRequest, mapRootPath
- + pathvc0);
+ final String mappedvc0 = resResolver.map(virtualRequest, mapRootPath + pathvc0);
assertEquals("Expect unmangled path", contextPath + pathv0, mappedvc0);
// expected name mangling without host prefix
final String pathvc1 = "/sample/jcr:content";
final String mangledvc1 = "/sample/_jcr_content";
- final String mappedvc1 = resResolver.map(virtualRequest, mapRootPath
- + pathvc1);
+ final String mappedvc1 = resResolver.map(virtualRequest, mapRootPath + pathvc1);
assertEquals("Expect mangled path", contextPath + mangledvc1, mappedvc1);
// ---------------------------------------------------------------------
// tests expecting absolute URLs without context
- final HttpServletRequest foreignRequest = new FakeSlingHttpServletRequest(
- null, "foreign.host.com", -1, rootPath);
+ final HttpServletRequest foreignRequest =
+ new FakeSlingHttpServletRequest(null, "foreign.host.com", -1, rootPath);
final String pathf0 = "/sample";
- final String mappedf0 = resResolver.map(foreignRequest, mapRootPath
- + pathf0);
- assertEquals("Expect unmangled absolute URI", "http://" + mapHost
- + pathf0, mappedf0);
+ final String mappedf0 = resResolver.map(foreignRequest, mapRootPath + pathf0);
+ assertEquals("Expect unmangled absolute URI", "http://" + mapHost + pathf0, mappedf0);
final String pathf1 = "/sample/jcr:content";
final String mangledf1 = "/sample/_jcr_content";
- final String mappedf1 = resResolver.map(foreignRequest, mapRootPath
- + pathf1);
- assertEquals("Expect mangled absolute URI", "http://" + mapHost
- + mangledf1, mappedf1);
+ final String mappedf1 = resResolver.map(foreignRequest, mapRootPath + pathf1);
+ assertEquals("Expect mangled absolute URI", "http://" + mapHost + mangledf1, mappedf1);
// ---------------------------------------------------------------------
// tests expecting absolute URLs with context "/context"
@@ -2061,24 +1913,21 @@ public class ResourceResolverWithVanityBloomFilterTest {
((FakeSlingHttpServletRequest) foreignRequest).setContextPath(contextPath);
final String pathfc0 = "/sample";
- final String mappedfc0 = resResolver.map(foreignRequest, mapRootPath
- + pathfc0);
- assertEquals("Expect unmangled absolute URI", "http://" + mapHost
- + contextPath + pathfc0, mappedfc0);
+ final String mappedfc0 = resResolver.map(foreignRequest, mapRootPath + pathfc0);
+ assertEquals("Expect unmangled absolute URI", "http://" + mapHost + contextPath + pathfc0, mappedfc0);
final String pathfc1 = "/sample/jcr:content";
final String mangledfc1 = "/sample/_jcr_content";
- final String mappedfc1 = resResolver.map(foreignRequest, mapRootPath
- + pathfc1);
- assertEquals("Expect mangled absolute URI", "http://" + mapHost
- + contextPath + mangledfc1, mappedfc1);
+ final String mappedfc1 = resResolver.map(foreignRequest, mapRootPath + pathfc1);
+ assertEquals("Expect mangled absolute URI", "http://" + mapHost + contextPath + mangledfc1, mappedfc1);
} finally {
virtualhost80.remove();
session.save();
}
}
- @Test public void testMapContext() throws Exception {
+ @Test
+ public void testMapContext() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2099,7 +1948,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapExtension() throws Exception {
+ @Test
+ public void testMapExtension() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2121,7 +1971,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapSelectorsExtension() throws Exception {
+ @Test
+ public void testMapSelectorsExtension() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2143,7 +1994,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapExtensionSuffix() throws Exception {
+ @Test
+ public void testMapExtensionSuffix() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2165,7 +2017,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapFragment() throws Exception {
+ @Test
+ public void testMapFragment() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2187,7 +2040,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapQuery() throws Exception {
+ @Test
+ public void testMapQuery() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2209,7 +2063,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapFragmentQuery() throws Exception {
+ @Test
+ public void testMapFragmentQuery() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2231,12 +2086,14 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapEmptyPath() throws Exception {
+ @Test
+ public void testMapEmptyPath() throws Exception {
String mapped = resResolver.map("");
assertEquals("/", mapped);
}
- @Test public void testMapExtensionFragmentQuery() throws Exception {
+ @Test
+ public void testMapExtensionFragmentQuery() throws Exception {
String path = rootNode.getPath();
String mapped = resResolver.map(path);
assertEquals(path, mapped);
@@ -2258,34 +2115,34 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void testMapResourceAlias() throws Exception {
+ @Test
+ public void testMapResourceAlias() throws Exception {
// define an alias for the rootPath
String alias = "testAlias";
rootNode.setProperty("sling:alias", alias);
saveMappings(session);
try {
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias);
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias);
String mapped = resResolver.map(rootNode.getPath());
assertEquals(path, mapped);
Node child = rootNode.addNode("child");
session.save();
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias+"/child");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/child");
mapped = resResolver.map(child.getPath());
assertEquals(path, mapped);
} finally {
rootNode.getProperty("sling:alias").remove();
- if ( rootNode.hasNode("child") ) {
+ if (rootNode.hasNode("child")) {
rootNode.getNode("child").remove();
}
session.save();
}
- }
+ }
- @Test public void testMapResourceAliasJcrContent() throws Exception {
+ @Test
+ public void testMapResourceAliasJcrContent() throws Exception {
// define an alias for the rootPath in the jcr:content child node
String alias = "testAlias";
Node content = rootNode.addNode("jcr:content", "nt:unstructured");
@@ -2293,21 +2150,18 @@ public class ResourceResolverWithVanityBloomFilterTest {
saveMappings(session);
try {
- String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias);
+ String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias);
String mapped = resResolver.map(rootNode.getPath());
assertEquals(path, mapped);
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias+"/_jcr_content");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/_jcr_content");
mapped = resResolver.map(content.getPath());
assertEquals(path, mapped);
Node child = content.addNode("child");
session.save();
- path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
- + "/" + alias+"/_jcr_content/child");
+ path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/_jcr_content/child");
mapped = resResolver.map(child.getPath());
assertEquals(path, mapped);
} finally {
@@ -2316,7 +2170,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void test_resolve() throws Exception {
+ @Test
+ public void test_resolve() throws Exception {
Node child = rootNode.addNode("child");
session.save();
@@ -2330,8 +2185,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/child",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/child", res.getResourceMetadata().getResolutionPath());
assertEquals("", res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2351,8 +2206,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/child/grandchild",
- resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/child/grandchild",
+ resEnkel.getResourceMetadata().getResolutionPath());
assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
@@ -2364,7 +2220,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void test_resolve_extension() throws Exception {
+ @Test
+ public void test_resolve_extension() throws Exception {
final String selExt = ".html";
@@ -2380,8 +2237,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/child",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/child", res.getResourceMetadata().getResolutionPath());
assertEquals(selExt, res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2400,10 +2257,10 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/child/grandchild",
- resEnkel.getResourceMetadata().getResolutionPath());
- assertEquals(selExt,
- resEnkel.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(
+ rootNode.getPath() + "/child/grandchild",
+ resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(selExt, resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
assertNotNull(resNodeEnkel);
@@ -2414,7 +2271,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void test_resolve_selectors_extension() throws Exception {
+ @Test
+ public void test_resolve_selectors_extension() throws Exception {
final String selExt = ".sel1.sel2.html";
@@ -2430,8 +2288,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/child",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/child", res.getResourceMetadata().getResolutionPath());
assertEquals(selExt, res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2450,10 +2308,10 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/child/grandchild",
- resEnkel.getResourceMetadata().getResolutionPath());
- assertEquals(selExt,
- resEnkel.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(
+ rootNode.getPath() + "/child/grandchild",
+ resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(selExt, resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
assertNotNull(resNodeEnkel);
@@ -2464,7 +2322,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void test_resolve_extension_suffix() throws Exception {
+ @Test
+ public void test_resolve_extension_suffix() throws Exception {
final String selExt = ".html/some/suffx.pdf";
@@ -2489,7 +2348,8 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
}
- @Test public void test_resolve_with_sling_alias() throws Exception {
+ @Test
+ public void test_resolve_with_sling_alias() throws Exception {
Node child = rootNode.addNode("child");
child.setProperty("sling:alias", "kind");
@@ -2504,8 +2364,7 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/kind",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(rootNode.getPath() + "/kind", res.getResourceMetadata().getResolutionPath());
assertEquals("", res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2526,8 +2385,9 @@ public class ResourceResolverWithVanityBloomFilterTest {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/kind/enkel",
- resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/kind/enkel",
+ resEnkel.getResourceMetadata().getResolutionPath());
assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
@@ -2540,62 +2400,62 @@ public class ResourceResolverWithVanityBloomFilterTest {
}
/*@Test public void test_resolve_with_sling_alias_limited_access() throws Exception {
- Principal testUserPrincipal = AccessControlUtil.getPrincipalManager(session).getPrincipal("testuser");
-
- Node child = rootNode.addNode("child");
- child.setProperty("sling:alias", "kind");
- AccessControlUtil.replaceAccessControlEntry(session, child.getPath(), testUserPrincipal, null, new String[] {"jcr:all"}, null, "last");
- session.save();
-try {
- Session testUserSession = getRepository().login(new SimpleCredentials("testuser", "test".toCharArray()));
- final Map<String, Object> authInfo = new HashMap<String, Object>();
- authInfo.put(ResourceResolverFactory.USER, "admin");
- authInfo.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
- authInfo.put("testAttributeString", "AStringValue");
- authInfo.put("testAttributeNumber", 999);
- ResourceResolver testUserResolver = resFac.getResourceResolver(authInfo);
-
- try {
- // expect child due to the aliased not not being visible and no parent
- // due to mapping the rootPath onto root
- String path = "/child";
- String mapped = testUserResolver.map(child.getPath());
- assertEquals(path, mapped);
-
- Resource res = testUserResolver.resolve(null, path);
- assertNotNull(res);
- assertTrue(res instanceof NonExistingResource);
- assertEquals("/child",
- res.getResourceMetadata().getResolutionPath());
- // TODO - is this correct?
- assertEquals(null, res.getResourceMetadata().getResolutionPathInfo());
+ Principal testUserPrincipal = AccessControlUtil.getPrincipalManager(session).getPrincipal("testuser");
- // second level alias
- Node grandchild = child.addNode("grandchild");
- grandchild.setProperty("sling:alias", "enkel");
- AccessControlUtil.replaceAccessControlEntry(session, grandchild.getPath(), testUserPrincipal, new String[] { "jcr:all" }, null, null, "first");
+ Node child = rootNode.addNode("child");
+ child.setProperty("sling:alias", "kind");
+ AccessControlUtil.replaceAccessControlEntry(session, child.getPath(), testUserPrincipal, null, new String[] {"jcr:all"}, null, "last");
session.save();
+ try {
+ Session testUserSession = getRepository().login(new SimpleCredentials("testuser", "test".toCharArray()));
+ final Map<String, Object> authInfo = new HashMap<String, Object>();
+ authInfo.put(ResourceResolverFactory.USER, "admin");
+ authInfo.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
+ authInfo.put("testAttributeString", "AStringValue");
+ authInfo.put("testAttributeNumber", 999);
+ ResourceResolver testUserResolver = resFac.getResourceResolver(authInfo);
- // expect /child/enkel due to parent node not being
- // visible to the test user and no parent due to mapping
- // the rootPath onto root
- String pathEnkel = "/child/enkel";
- String mappedEnkel = testUserResolver.map(grandchild.getPath());
- assertEquals(pathEnkel, mappedEnkel);*/
-
- //TODO already commented
- /*
- Resource resEnkel = testUserResolver.resolve(null, pathEnkel);
- assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/kind/enkel",
- resEnkel.getResourceMetadata().getResolutionPath());
- assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
+ try {
+ // expect child due to the aliased not not being visible and no parent
+ // due to mapping the rootPath onto root
+ String path = "/child";
+ String mapped = testUserResolver.map(child.getPath());
+ assertEquals(path, mapped);
+
+ Resource res = testUserResolver.resolve(null, path);
+ assertNotNull(res);
+ assertTrue(res instanceof NonExistingResource);
+ assertEquals("/child",
+ res.getResourceMetadata().getResolutionPath());
+ // TODO - is this correct?
+ assertEquals(null, res.getResourceMetadata().getResolutionPathInfo());
+
+ // second level alias
+ Node grandchild = child.addNode("grandchild");
+ grandchild.setProperty("sling:alias", "enkel");
+ AccessControlUtil.replaceAccessControlEntry(session, grandchild.getPath(), testUserPrincipal, new String[] { "jcr:all" }, null, null, "first");
+ session.save();
- Node resNodeEnkel = resEnkel.adaptTo(Node.class);
- assertNotNull(resNodeEnkel);
- assertEquals(grandchild.getPath(), resNodeEnkel.getPath());
- */
- /*} finally {
+ // expect /child/enkel due to parent node not being
+ // visible to the test user and no parent due to mapping
+ // the rootPath onto root
+ String pathEnkel = "/child/enkel";
+ String mappedEnkel = testUserResolver.map(grandchild.getPath());
+ assertEquals(pathEnkel, mappedEnkel);*/
+
+ // TODO already commented
+ /*
+ Resource resEnkel = testUserResolver.resolve(null, pathEnkel);
+ assertNotNull(resEnkel);
+ assertEquals(rootNode.getPath() + "/kind/enkel",
+ resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
+
+ Node resNodeEnkel = resEnkel.adaptTo(Node.class);
+ assertNotNull(resNodeEnkel);
+ assertEquals(grandchild.getPath(), resNodeEnkel.getPath());
+ */
+ /*} finally {
testUserSession.logout();
}
} finally {
@@ -2604,15 +2464,15 @@ try {
}
}*/
- @Test public void test_resolve_with_sling_alias_multi_value() throws Exception {
+ @Test
+ public void test_resolve_with_sling_alias_multi_value() throws Exception {
Node child = rootNode.addNode("child");
- child.setProperty("sling:alias", new String[] {
- "kind", "enfant" });
+ child.setProperty("sling:alias", new String[] {"kind", "enfant"});
try {
saveMappings(session);
-
+
// expect kind due to alias and no parent due to mapping
// the rootPath onto root
String path = "/kind";
@@ -2621,8 +2481,7 @@ try {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/kind",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(rootNode.getPath() + "/kind", res.getResourceMetadata().getResolutionPath());
assertEquals("", res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2638,8 +2497,9 @@ try {
Resource resEnfant = resResolver.resolve(null, pathEnfant);
assertNotNull(resEnfant);
- assertEquals(rootNode.getPath() + "/enfant",
- resEnfant.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/enfant",
+ resEnfant.getResourceMetadata().getResolutionPath());
assertEquals("", resEnfant.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnfant = resEnfant.adaptTo(Node.class);
@@ -2660,8 +2520,9 @@ try {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/kind/enkel",
- resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/kind/enkel",
+ resEnkel.getResourceMetadata().getResolutionPath());
assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
@@ -2676,8 +2537,9 @@ try {
Resource resEnfantEnkel = resResolver.resolve(null, pathEnfantEnkel);
assertNotNull(resEnfantEnkel);
- assertEquals(rootNode.getPath() + "/enfant/enkel",
- resEnfantEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(
+ rootNode.getPath() + "/enfant/enkel",
+ resEnfantEnkel.getResourceMetadata().getResolutionPath());
assertEquals("", resEnfantEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnfantEnkel = resEnfantEnkel.adaptTo(Node.class);
@@ -2689,7 +2551,8 @@ try {
}
}
- @Test public void test_resolve_with_sling_alias_extension() throws Exception {
+ @Test
+ public void test_resolve_with_sling_alias_extension() throws Exception {
final String selExt = ".html";
@@ -2698,7 +2561,7 @@ try {
try {
saveMappings(session);
-
+
// expect kind due to alias and no parent due to mapping
// the rootPath onto root
String path = "/kind" + selExt;
@@ -2707,8 +2570,7 @@ try {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/kind",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(rootNode.getPath() + "/kind", res.getResourceMetadata().getResolutionPath());
assertEquals(selExt, res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2728,10 +2590,10 @@ try {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/kind/enkel",
- resEnkel.getResourceMetadata().getResolutionPath());
- assertEquals(selExt,
- resEnkel.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(
+ rootNode.getPath() + "/kind/enkel",
+ resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(selExt, resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
assertNotNull(resNodeEnkel);
@@ -2742,8 +2604,8 @@ try {
}
}
- @Test public void test_resolve_with_sling_alias_selectors_extension()
- throws Exception {
+ @Test
+ public void test_resolve_with_sling_alias_selectors_extension() throws Exception {
final String selExt = ".sel1.sel2.html";
@@ -2752,7 +2614,7 @@ try {
try {
saveMappings(session);
-
+
// expect kind due to alias and no parent due to mapping
// the rootPath onto root
String path = "/kind" + selExt;
@@ -2761,8 +2623,7 @@ try {
Resource res = resResolver.resolve(null, path);
assertNotNull(res);
- assertEquals(rootNode.getPath() + "/kind",
- res.getResourceMetadata().getResolutionPath());
+ assertEquals(rootNode.getPath() + "/kind", res.getResourceMetadata().getResolutionPath());
assertEquals(selExt, res.getResourceMetadata().getResolutionPathInfo());
Node resNode = res.adaptTo(Node.class);
@@ -2782,10 +2643,10 @@ try {
Resource resEnkel = resResolver.resolve(null, pathEnkel);
assertNotNull(resEnkel);
- assertEquals(rootNode.getPath() + "/kind/enkel",
- resEnkel.getResourceMetadata().getResolutionPath());
- assertEquals(selExt,
- resEnkel.getResourceMetadata().getResolutionPathInfo());
+ assertEquals(
+ rootNode.getPath() + "/kind/enkel",
+ resEnkel.getResourceMetadata().getResolutionPath());
+ assertEquals(selExt, resEnkel.getResourceMetadata().getResolutionPathInfo());
Node resNodeEnkel = resEnkel.adaptTo(Node.class);
assertNotNull(resNodeEnkel);
@@ -2796,8 +2657,8 @@ try {
}
}
- @Test public void test_resolve_with_sling_alias_extension_suffix()
- throws Exception {
+ @Test
+ public void test_resolve_with_sling_alias_extension_suffix() throws Exception {
final String selExt = ".html/some/suffx.pdf";
@@ -2806,7 +2667,7 @@ try {
try {
saveMappings(session);
-
+
// expect kind due to alias and no parent due to mapping
// the rootPath onto root
String path = "/kind" + selExt;
@@ -2827,8 +2688,7 @@ try {
// ---------- internal
private void testStarResourceHelper(final String path, final String method) {
- final Resource res = resResolver.resolve(
- new FakeSlingHttpServletRequest(path, method), path);
+ final Resource res = resResolver.resolve(new FakeSlingHttpServletRequest(path, method), path);
assertNotNull(res);
assertTrue(ResourceUtil.isStarResource(res));
assertEquals("sling:syntheticStarResource", res.getResourceType());
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/UppercaseStringTransformer.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/UppercaseStringTransformer.java
index ce6cabd..b9fd09c 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/UppercaseStringTransformer.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/UppercaseStringTransformer.java
@@ -1,29 +1,27 @@
/*
- * 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.launchpad.testservices.serversidetests;
import org.apache.sling.launchpad.testservices.exported.StringTransformer;
import org.osgi.service.component.annotations.Component;
-@Component(
- property = {
- "mode:String=uppercase"
- }
- )
+@Component(property = {"mode:String=uppercase"})
public class UppercaseStringTransformer implements StringTransformer {
public String transform(String str) {
return str.toUpperCase();
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java
index 4692360..9045fac 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java
@@ -1,25 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.serversidetests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import java.util.HashMap;
import org.apache.sling.api.resource.ModifiableValueMap;
@@ -34,24 +32,28 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
/** Test (and demonstrate) the Sling Resource CRUD functionality */
@RunWith(SlingAnnotationsTestRunner.class)
public class WriteableResourcesTest {
@TestReference
private ResourceResolverFactory resourceResolverFactory;
-
+
private ResourceResolver resolver;
private Resource testRoot;
-
+
@SuppressWarnings("serial")
private static class Props extends HashMap<String, Object> {
- Props(String ... keyValue) {
- for(int i=0 ; i< keyValue.length; i+=2) {
- put(keyValue[i], keyValue[i+1]);
+ Props(String... keyValue) {
+ for (int i = 0; i < keyValue.length; i += 2) {
+ put(keyValue[i], keyValue[i + 1]);
}
}
}
-
+
@Before
public void setup() throws Exception {
resolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
@@ -67,44 +69,45 @@ public class WriteableResourcesTest {
resolver.delete(testRoot);
resolver.close();
}
-
- private void assertValueMap(ValueMap m, String ... keyValue) {
+
+ private void assertValueMap(ValueMap m, String... keyValue) {
assertNotNull("Expecting non-null ValueMap", m);
- for(int i=0 ; i< keyValue.length; i+=2) {
+ for (int i = 0; i < keyValue.length; i += 2) {
final String key = keyValue[i];
- final String value = keyValue[i+1];
+ final String value = keyValue[i + 1];
assertEquals("Expecting " + key + "=" + value, value, m.get(key, String.class));
}
}
@Test
public void testSimpleCRUD() throws Exception {
-
+
// Create a child resource of testRoot, with title and text properties
final Props props = new Props("title", "hello", "text", "world");
- final String fullPath = resolver.create(testRoot, "child_" + System.currentTimeMillis(), props).getPath();
+ final String fullPath = resolver.create(testRoot, "child_" + System.currentTimeMillis(), props)
+ .getPath();
resolver.commit();
-
+
{
// Retrieve and check child resource
final Resource r = resolver.getResource(fullPath);
assertNotNull("Expecting Resource at " + fullPath, r);
final ModifiableValueMap m = r.adaptTo(ModifiableValueMap.class);
assertValueMap(m, "title", "hello", "text", "world");
-
+
// Update child resource
m.put("more", "fun");
m.put("title", "changed");
resolver.commit();
}
-
+
{
// Retrieve and check updated resource
final Resource r = resolver.getResource(fullPath);
assertNotNull("Expecting modified Resource at " + fullPath, r);
assertValueMap(r.adaptTo(ValueMap.class), "title", "changed", "more", "fun", "text", "world");
}
-
+
{
// Delete test resource and check that it's gone
final Resource r = resolver.getResource(fullPath);
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/AnonymousAccessConfigServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/AnonymousAccessConfigServlet.java
index 5c34012..13b3dca 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/AnonymousAccessConfigServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/AnonymousAccessConfigServlet.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.servlets;
+import javax.servlet.ServletException;
+
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
-import javax.servlet.ServletException;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -39,18 +41,14 @@ import org.osgi.service.event.EventHandler;
@SuppressWarnings("serial")
@Component(
immediate = true,
- service = {
- org.osgi.service.event.EventHandler.class,
- javax.servlet.Servlet.class
- },
+ service = {org.osgi.service.event.EventHandler.class, javax.servlet.Servlet.class},
property = {
- "service.description:String=Anonymous Access Config Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/AnonymousAccessConfigServlet",
- "sling.servlet.extensions:String=txt",
- "event.topics:String=org/osgi/framework/ServiceEvent/MODIFIED"
- }
- )
+ "service.description:String=Anonymous Access Config Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/AnonymousAccessConfigServlet",
+ "sling.servlet.extensions:String=txt",
+ "event.topics:String=org/osgi/framework/ServiceEvent/MODIFIED"
+ })
public class AnonymousAccessConfigServlet extends SlingAllMethodsServlet implements EventHandler {
private static final String PROP_AUTH_ANNONYMOUS = "auth.annonymous";
@@ -64,10 +62,10 @@ public class AnonymousAccessConfigServlet extends SlingAllMethodsServlet impleme
private int modifiedCounter;
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({"rawtypes", "unchecked"})
@Override
- protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
- IOException {
+ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
response.setContentType(request.getContentType());
String action = request.getParameter("action");
if ("disable".equals(action)) {
@@ -106,8 +104,8 @@ public class AnonymousAccessConfigServlet extends SlingAllMethodsServlet impleme
}
if (modifiedCounter < targetCounter) {
- throw new IllegalStateException("Event counter did not reach " + targetCounter + ", waited " + timeoutMsec
- + " msec");
+ throw new IllegalStateException(
+ "Event counter did not reach " + targetCounter + ", waited " + timeoutMsec + " msec");
}
}
@@ -116,5 +114,4 @@ public class AnonymousAccessConfigServlet extends SlingAllMethodsServlet impleme
modifiedCounter++;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/CustomPostResponseCreatorImpl.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/CustomPostResponseCreatorImpl.java
index 210e713..e202c24 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/CustomPostResponseCreatorImpl.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/CustomPostResponseCreatorImpl.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.servlets.post.AbstractPostResponse;
import org.apache.sling.servlets.post.PostResponse;
@@ -35,20 +37,19 @@ public class CustomPostResponseCreatorImpl implements PostResponseCreator {
public PostResponse createPostResponse(SlingHttpServletRequest req) {
if ("custom".equals(req.getParameter(":responseType"))) {
return new AbstractPostResponse() {
-
+
public void onChange(String type, String... arguments) {
// NO-OP
}
-
+
@Override
protected void doSend(HttpServletResponse response) throws IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
-
+
response.getWriter().write("Thanks!");
response.getWriter().flush();
}
-
};
} else {
return null;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/DomServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/DomServlet.java
index 9f8120c..1c16d84 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/DomServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/DomServlet.java
@@ -1,30 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-import java.io.StringReader;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.StringReader;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -38,12 +40,10 @@ import org.xml.sax.SAXException;
/**
* The <code>DomServlet</code> evaluates a simple XML document using DOM APIs.
- *
+ *
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/dom",
- extensions = "xml")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/dom", extensions = "xml")
public class DomServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@@ -51,8 +51,8 @@ public class DomServlet extends SlingAllMethodsServlet {
private static final String XML_INPUT = "<content><name>DOM</name></content>";
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
- IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -74,5 +74,4 @@ public class DomServlet extends SlingAllMethodsServlet {
throw new ServletException(e);
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExportedPackageServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExportedPackageServlet.java
index 5543573..fdbf5bb 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExportedPackageServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExportedPackageServlet.java
@@ -1,26 +1,28 @@
/*
- * 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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -31,14 +33,14 @@ import org.osgi.service.packageadmin.PackageAdmin;
/** Test servlet for SLING-2808 */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Exported packages Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.selectors:String=EXPORTED_PACKAGES",
- "sling.servlet.extensions:String=txt"
+ "service.description:String=Exported packages Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.selectors:String=EXPORTED_PACKAGES",
+ "sling.servlet.extensions:String=txt"
})
@SuppressWarnings("serial")
public class ExportedPackageServlet extends SlingSafeMethodsServlet {
@@ -46,11 +48,11 @@ public class ExportedPackageServlet extends SlingSafeMethodsServlet {
private PackageAdmin packageAdmin;
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
final String packName = request.getParameter("package");
final ExportedPackage p = packageAdmin.getExportedPackage(packName);
- if(p == null) {
+ if (p == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Package not found: " + packName);
} else {
response.setContentType("text/plain");
@@ -60,4 +62,4 @@ public class ExportedPackageServlet extends SlingSafeMethodsServlet {
response.getWriter().flush();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExtensionServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExtensionServlet.java
index 04d73ea..f1ee3d1 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExtensionServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/ExtensionServlet.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.launchpad.testservices.servlets;
@@ -20,15 +22,14 @@ import org.osgi.service.component.annotations.Component;
/** Example/test Sling Servlet registered with two extensions */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Extension Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.extensions:String=TEST_EXT_1",
- "sling.servlet.extensions:String=TEST_EXT_2"
+ "service.description:String=Extension Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.extensions:String=TEST_EXT_1",
+ "sling.servlet.extensions:String=TEST_EXT_2"
})
@SuppressWarnings("serial")
-public class ExtensionServlet extends TestServlet {
-}
\ No newline at end of file
+public class ExtensionServlet extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/GetConfigServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/GetConfigServlet.java
index df3e3e7..3f56aa1 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/GetConfigServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/GetConfigServlet.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.launchpad.testservices.servlets;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
import java.io.IOException;
import java.util.Dictionary;
import java.util.Enumeration;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.felix.utils.json.JSONWriter;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
@@ -37,10 +39,10 @@ import org.osgi.service.component.annotations.Reference;
@Component(
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=GetConfig Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/GetConfigServlet",
- "sling.servlet.extensions:String=json"
+ "service.description:String=GetConfig Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/GetConfigServlet",
+ "sling.servlet.extensions:String=json"
})
public class GetConfigServlet extends SlingSafeMethodsServlet {
@@ -48,24 +50,24 @@ public class GetConfigServlet extends SlingSafeMethodsServlet {
private ConfigurationAdmin configAdmin;
@Override
- protected void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response)
- throws ServletException,IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
// PID comes from request suffix, like /testing/GetConfigServlet.tidy.json/integrationTestsConfig
String pid = request.getRequestPathInfo().getSuffix();
- if(pid == null || pid.length() == 0) {
+ if (pid == null || pid.length() == 0) {
throw new ServletException("Configuration PID must be provided in request suffix");
}
- if(pid.startsWith("/")) {
+ if (pid.startsWith("/")) {
pid = pid.substring(1);
}
- // Get config and properties. Avoid using configAdmin.getConfiguration(...)
+ // Get config and properties. Avoid using configAdmin.getConfiguration(...)
// to avoid creating a config that does not exist yet, which might cause
// services to restart.
final Configuration cfg = getUniqueConfig(pid);
final Dictionary<?, ?> props = cfg.getProperties();
- if(props == null) {
+ if (props == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Properties of config with pid=" + pid + " not found");
return;
}
@@ -81,35 +83,35 @@ public class GetConfigServlet extends SlingSafeMethodsServlet {
w.key("pid").value(pid);
w.key("properties");
w.object();
- while(keys.hasMoreElements()) {
+ while (keys.hasMoreElements()) {
final Object key = keys.nextElement();
final Object value = props.get(key);
- if(value != null) {
+ if (value != null) {
w.key(key.toString()).value(value.toString());
}
}
w.endObject();
w.endObject();
w.flush();
- } catch(IOException je) {
- throw (IOException)new IOException("JSONException in doGet").initCause(je);
+ } catch (IOException je) {
+ throw (IOException) new IOException("JSONException in doGet").initCause(je);
}
}
-
+
private Configuration getUniqueConfig(String pid) throws ServletException {
final String filter = "(service.pid=" + pid + ")";
- Configuration [] cfg = null;
+ Configuration[] cfg = null;
try {
cfg = configAdmin.listConfigurations(filter);
- } catch(Exception e) {
+ } catch (Exception e) {
throw new ServletException("Error listing configs with filter " + filter, e);
}
- if(cfg == null) {
+ if (cfg == null) {
throw new ServletException("No config found with filter " + filter);
}
- if(cfg.length > 1) {
+ if (cfg.length > 1) {
throw new ServletException("Expected 1 config, found " + cfg.length + " with filter " + filter);
}
return cfg[0];
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlDefaultServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlDefaultServlet.java
index 67a6fa6..602335d 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlDefaultServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlDefaultServlet.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.launchpad.testservices.servlets;
@@ -23,20 +25,19 @@ import org.osgi.service.component.annotations.ConfigurationPolicy;
* Default servlet for the html extension, see SLING-1069.
* This servlet collides with the Default GET Servlet generating proper HTML not
* expected by HtmlDefaultServletTest. For this reason this component is
- * disabled by default and must be enabled (by creating a config) for testing
+ * disabled by default and must be enabled (by creating a config) for testing
* in the HtmlDefaultServletTest class.
*/
@Component(
- immediate=true,
- service = javax.servlet.Servlet.class,
+ immediate = true,
+ service = javax.servlet.Servlet.class,
configurationPolicy = ConfigurationPolicy.REQUIRE,
property = {
- "service.description:String=HTML Default Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.extensions:String=html",
- "sling.servlet.methods:String=GET"
+ "service.description:String=HTML Default Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.extensions:String=html",
+ "sling.servlet.methods:String=GET"
})
@SuppressWarnings("serial")
-public class HtmlDefaultServlet extends TestServlet {
-}
\ No newline at end of file
+public class HtmlDefaultServlet extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlResponseServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlResponseServlet.java
index 0c4f065..9b67ad8 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlResponseServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/HtmlResponseServlet.java
@@ -1,26 +1,28 @@
/*
- * 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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.HtmlResponse;
@@ -29,19 +31,19 @@ import org.osgi.service.component.annotations.Component;
/** Servlet used to test HtmlResponse escaping */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/HtmlResponseServlet"
+ "service.description:String=Paths Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/HtmlResponseServlet"
})
@SuppressWarnings("serial")
public class HtmlResponseServlet extends SlingSafeMethodsServlet {
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException,IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
final HtmlResponse hr = new HtmlResponse();
// Specific status to help recognize this servlet in tests
final int status = HttpServletResponse.SC_GATEWAY_TIMEOUT;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/JakartaJsonServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/JakartaJsonServlet.java
index 25746de..61fe700 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/JakartaJsonServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/JakartaJsonServlet.java
@@ -18,11 +18,15 @@
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
+import java.io.IOException;
+
+import jakarta.json.Json;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonObjectBuilder;
+import jakarta.json.JsonWriter;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -30,34 +34,27 @@ import org.apache.sling.servlets.annotations.SlingServletPathsStrict;
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
-import jakarta.json.Json;
-import jakarta.json.JsonObject;
-import jakarta.json.JsonObjectBuilder;
-import jakarta.json.JsonWriter;
-
/**
- * Serlializes a basic class using the Jakarta JSON API
- *
+ * Serlializes a basic class using the Jakarta JSON API
+ *
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/jakarta",
- extensions = "json")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/jakarta", extensions = "json")
public class JakartaJsonServlet extends SlingSafeMethodsServlet {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
- throws ServletException, IOException {
-
- JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
- objectBuilder.add("greeting", "hello, world");
- JsonObject object = objectBuilder.build();
-
- response.setContentType("application/json");
- try ( JsonWriter writer = Json.createWriter(response.getOutputStream()) ) {
- writer.writeObject(object);
- }
- }
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
+ throws ServletException, IOException {
+
+ JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
+ objectBuilder.add("greeting", "hello, world");
+ JsonObject object = objectBuilder.build();
+
+ response.setContentType("application/json");
+ try (JsonWriter writer = Json.createWriter(response.getOutputStream())) {
+ writer.writeObject(object);
+ }
+ }
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/JaxbServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/JaxbServlet.java
index 58e5738..8efaeeb 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/JaxbServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/JaxbServlet.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.xml.bind.JAXBContext;
@@ -27,6 +25,8 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -35,12 +35,10 @@ import org.osgi.service.component.annotations.Component;
/**
* The <code>JaxbServlet</code> serializes a basic JAXB-annotated class
- *
+ *
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/jaxb",
- extensions = "xml")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/jaxb", extensions = "xml")
public class JaxbServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/MiscUnsafeServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/MiscUnsafeServlet.java
index 4f20d1a..163086b 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/MiscUnsafeServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/MiscUnsafeServlet.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -33,12 +33,10 @@ import org.osgi.service.component.annotations.Component;
* Validates that the <code>sun.misc.Unsafe</code> class can be accessed
*
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/miscUnsafe",
- extensions = "txt")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/miscUnsafe", extensions = "txt")
public class MiscUnsafeServlet extends SlingAllMethodsServlet {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -48,7 +46,11 @@ public class MiscUnsafeServlet extends SlingAllMethodsServlet {
// for the sun.misc package
response.setContentType("text/plain");
try {
- response.getWriter().write(getClass().getClassLoader().loadClass("sun.misc.Unsafe").getCanonicalName());
+ response.getWriter()
+ .write(getClass()
+ .getClassLoader()
+ .loadClass("sun.misc.Unsafe")
+ .getCanonicalName());
} catch (ClassNotFoundException e) {
throw new ServletException("Failed loading Unsafe class", e);
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/NamespaceTestServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/NamespaceTestServlet.java
index 180a88e..6bdcbf7 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/NamespaceTestServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/NamespaceTestServlet.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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -32,15 +34,14 @@ import org.osgi.service.component.annotations.Component;
/**
* Test Servlet which outputs the current namespace mappings.
*/
-@Component(service=Servlet.class)
-@SlingServletPaths(
- value = "/testing/NamespaceTestServlet/output")
+@Component(service = Servlet.class)
+@SlingServletPaths(value = "/testing/NamespaceTestServlet/output")
@SuppressWarnings("serial")
public class NamespaceTestServlet extends SlingSafeMethodsServlet {
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
- IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
try {
response.setContentType("text/plain");
Session session = request.getResourceResolver().adaptTo(Session.class);
@@ -57,5 +58,4 @@ public class NamespaceTestServlet extends SlingSafeMethodsServlet {
throw new ServletException("Unable to output namespace mappings", e);
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServlet.java
index 6ada38a..959fd8f 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServlet.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.launchpad.testservices.servlets;
@@ -20,14 +22,13 @@ import org.osgi.service.component.annotations.Component;
/** Servlet that registers itself for specific paths */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/PathsServlet/foo",
- "sling.servlet.paths:String=/testing/PathsServlet/bar/more/foo.html"
+ "service.description:String=Paths Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/PathsServlet/foo",
+ "sling.servlet.paths:String=/testing/PathsServlet/bar/more/foo.html"
})
@SuppressWarnings("serial")
-public class PathsServlet extends TestServlet {
-}
+public class PathsServlet extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServletNodeServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServletNodeServlet.java
index 4074401..1045c20 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServletNodeServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PathsServletNodeServlet.java
@@ -1,29 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
@@ -39,14 +41,14 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Servlet Node Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/PathsServletNodeServlet"
+ "service.description:String=Paths Servlet Node Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/PathsServletNodeServlet"
})
public class PathsServletNodeServlet extends SlingAllMethodsServlet {
@Override
- protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
- IOException {
+ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
String action = request.getParameter("action");
try {
Session session = request.getResourceResolver().adaptTo(Session.class);
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PlanetResourceRenderingServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PlanetResourceRenderingServlet.java
index f6a6e78..a0bc815 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PlanetResourceRenderingServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PlanetResourceRenderingServlet.java
@@ -1,26 +1,28 @@
/*
- * 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.launchpad.testservices.servlets;
+import javax.servlet.ServletException;
+
import java.io.IOException;
import java.io.PrintWriter;
-import javax.servlet.ServletException;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.ValueMap;
@@ -33,30 +35,31 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=HTML renderer for Planet resources",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/test-services/planet",
- "sling.servlet.extensions:String=html",
- "sling.servlet.methods:String=GET"
+ "service.description:String=HTML renderer for Planet resources",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/test-services/planet",
+ "sling.servlet.extensions:String=html",
+ "sling.servlet.methods:String=GET"
})
@SuppressWarnings("serial")
public class PlanetResourceRenderingServlet extends SlingSafeMethodsServlet {
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
-
+
final ValueMap properties = request.getResource().adaptTo(ValueMap.class);
-
- // TODO should escape output - good enough for our tests
+
+ // TODO should escape output - good enough for our tests
final PrintWriter pw = response.getWriter();
- pw.println(String.format("<html><head><title>Planet at %s</title></head><body>", request.getResource().getPath()));
+ pw.println(String.format(
+ "<html><head><title>Planet at %s</title></head><body>",
+ request.getResource().getPath()));
pw.println(String.format("<p>Name: %s</p>", properties.get("name")));
pw.println(String.format("<p>Distance: %s</p>", properties.get("distance")));
pw.println("</body></html>");
pw.flush();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletMinusOne.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletMinusOne.java
index 37bc6a3..f86e6d7 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletMinusOne.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletMinusOne.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.launchpad.testservices.servlets;
@@ -22,16 +24,15 @@ import org.osgi.service.component.annotations.Component;
* PrefixServletZero overrides PrefixServletMinusOne
*/
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Prefix Test Servlet Minus One",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.prefix:Integer=-1",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.extensions:String=TEST_EXT_3",
- "sling.servlet.extensions:String=TEST_EXT_4"
+ "service.description:String=Prefix Test Servlet Minus One",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.prefix:Integer=-1",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.extensions:String=TEST_EXT_3",
+ "sling.servlet.extensions:String=TEST_EXT_4"
})
@SuppressWarnings("serial")
-public class PrefixServletMinusOne extends TestServlet {
-}
\ No newline at end of file
+public class PrefixServletMinusOne extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletZero.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletZero.java
index 71609d3..a586994 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletZero.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PrefixServletZero.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.launchpad.testservices.servlets;
@@ -22,16 +24,15 @@ import org.osgi.service.component.annotations.Component;
* PrefixServletZero overrides PrefixServletMinusOne
*/
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Prefix Test Servlet Zero",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.prefix:Integer=0",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.extensions:String=TEST_EXT_3",
- "sling.servlet.extensions:String=TEST_EXT_5"
+ "service.description:String=Prefix Test Servlet Zero",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.prefix:Integer=0",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.extensions:String=TEST_EXT_3",
+ "sling.servlet.extensions:String=TEST_EXT_5"
})
@SuppressWarnings("serial")
-public class PrefixServletZero extends TestServlet {
-}
\ No newline at end of file
+public class PrefixServletZero extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PutMethodServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PutMethodServlet.java
index 50e7337..1fd9957 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/PutMethodServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/PutMethodServlet.java
@@ -1,47 +1,49 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * 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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.osgi.service.component.annotations.Component;
/** Example/test Sling Servlet registered for the PUT method
* on a specific resource type
-*/
+ */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Put Method Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.methods:String=PUT",
- "sling.servlet.resourceTypes:String=LAUNCHPAD_TEST_ResourceType"
+ "service.description:String=Put Method Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.methods:String=PUT",
+ "sling.servlet.resourceTypes:String=LAUNCHPAD_TEST_ResourceType"
})
@SuppressWarnings("serial")
public class PutMethodServlet extends TestServlet {
- @Override
- protected void doPut(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
- dumpRequestAsProperties(request, response);
- }
-}
\ No newline at end of file
+ @Override
+ protected void doPut(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ dumpRequestAsProperties(request, response);
+ }
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/R6WhiteboardServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/R6WhiteboardServlet.java
index 38d1898..4809e62 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/R6WhiteboardServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/R6WhiteboardServlet.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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.osgi.service.component.annotations.Component;
/**
@@ -32,15 +34,16 @@ import org.osgi.service.component.annotations.Component;
@Component(
service = javax.servlet.Servlet.class,
property = {
- "osgi.http.whiteboard.servlet.pattern:String=/whiteboard_r6",
- "osgi.http.whiteboard.context.select:String=(osgi.http.whiteboard.context.name=org.apache.sling)"
+ "osgi.http.whiteboard.servlet.pattern:String=/whiteboard_r6",
+ "osgi.http.whiteboard.context.select:String=(osgi.http.whiteboard.context.name=org.apache.sling)"
})
public class R6WhiteboardServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
response.setContentType("text/plain");
response.getWriter().write("R6 OK");
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/RepositoryDescriptorsServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/RepositoryDescriptorsServlet.java
index a1bc7e7..d569477 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/RepositoryDescriptorsServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/RepositoryDescriptorsServlet.java
@@ -1,26 +1,28 @@
/*
- * 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.launchpad.testservices.servlets;
-import java.io.IOException;
-
import javax.jcr.Repository;
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.felix.utils.json.JSONWriter;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
@@ -28,25 +30,25 @@ import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
-/** Test servlet that dumps our repository descriptors */
+/** Test servlet that dumps our repository descriptors */
@SuppressWarnings("serial")
@Component(
immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Repository Descriptors Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=/testing/RepositoryDescriptors",
- "sling.servlet.extensions:String=json"
+ "service.description:String=Repository Descriptors Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=/testing/RepositoryDescriptors",
+ "sling.servlet.extensions:String=json"
})
public class RepositoryDescriptorsServlet extends SlingSafeMethodsServlet {
@Reference
private Repository repository;
-
+
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException,IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
@@ -54,14 +56,14 @@ public class RepositoryDescriptorsServlet extends SlingSafeMethodsServlet {
w.object();
w.key("descriptors");
w.object();
- for(String key : repository.getDescriptorKeys()) {
+ for (String key : repository.getDescriptorKeys()) {
w.key(key).value(repository.getDescriptor(key));
}
w.endObject();
w.endObject();
w.flush();
- } catch(IOException je) {
- throw (IOException)new IOException("JSONException in doGet").initCause(je);
+ } catch (IOException je) {
+ throw (IOException) new IOException("JSONException in doGet").initCause(je);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
index f678c7d..f65dda7 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.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.launchpad.testservices.servlets;
@@ -22,22 +24,22 @@ import org.osgi.service.component.annotations.Component;
/** OptingServlet that uses the RequestURI to opt in */
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Request URI Opting Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.resourceTypes:String=sling/servlet/default",
- "sling.servlet.resourceTypes:String=sling/nonexisting",
- "sling.servlet.methods:String=POST",
- "sling.servlet.methods:String=GET",
+ "service.description:String=Request URI Opting Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.resourceTypes:String=sling/servlet/default",
+ "sling.servlet.resourceTypes:String=sling/nonexisting",
+ "sling.servlet.methods:String=POST",
+ "sling.servlet.methods:String=GET",
})
@SuppressWarnings("serial")
public class RequestUriOptingServlet extends TestServlet implements OptingServlet {
public boolean accepts(SlingHttpServletRequest request) {
// Use a fake selector to opt in. Not really useful, this
- // is just a test of the opting mechanism.
+ // is just a test of the opting mechanism.
return request.getRequestURI().contains(".RequestUriOptingServlet.html");
}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/SaxServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/SaxServlet.java
index db40e93..ac64d84 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/SaxServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/SaxServlet.java
@@ -18,15 +18,15 @@
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-import java.io.StringReader;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import java.io.IOException;
+import java.io.StringReader;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -39,12 +39,10 @@ import org.xml.sax.helpers.DefaultHandler;
/**
* The <code>SaxServlet</code> evaluates a simple XML document using a SAX handler
- *
+ *
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/sax",
- extensions = "xml")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/sax", extensions = "xml")
public class SaxServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@@ -75,7 +73,8 @@ public class SaxServlet extends SlingAllMethodsServlet {
private boolean matched;
@Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
matched = "name".equals(qName);
}
@@ -92,5 +91,4 @@ public class SaxServlet extends SlingAllMethodsServlet {
return value;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/SelectorServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/SelectorServlet.java
index 2f49eeb..8ec8bf8 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/SelectorServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/SelectorServlet.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.launchpad.testservices.servlets;
@@ -22,12 +24,11 @@ import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
import org.osgi.service.component.annotations.Component;
/** Example/test Sling Servlet registered with two selectors */
-@Component(service=Servlet.class)
+@Component(service = Servlet.class)
@SlingServletResourceTypes(
resourceTypes = "sling/servlet/default",
- methods = {"GET","POST"},
- selectors = {"TEST_SEL_1","TEST_SEL_2"},
+ methods = {"GET", "POST"},
+ selectors = {"TEST_SEL_1", "TEST_SEL_2"},
extensions = "txt")
@SuppressWarnings("serial")
-public class SelectorServlet extends TestServlet {
-}
+public class SelectorServlet extends TestServlet {}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
index bba02f1..3829dc9 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
@@ -1,72 +1,74 @@
/*
- * 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.launchpad.testservices.servlets;
+import javax.servlet.ServletException;
+
import java.io.IOException;
import java.util.Date;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.servlet.ServletException;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-/** Base class for test servlets - GET displays easy to parse information
+/** Base class for test servlets - GET displays easy to parse information
* about the servlet and resource
*/
@SuppressWarnings("serial")
class TestServlet extends SlingAllMethodsServlet {
- @Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
- Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, "test JUL message");
- dumpRequestAsProperties(request, response);
- }
-
- @Override
- protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
- dumpRequestAsProperties(request, response);
- }
-
- protected void dumpRequestAsProperties(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
- final Properties props = new Properties();
- response.setContentType("text/plain");
- props.put("servlet.class.name", getClass().getName());
-
- final Resource r = request.getResource();
- props.put("sling.resource.path", r == null ? "" : r.getPath());
- props.put("sling.resource.type", r == null ? "" : r.getResourceType());
- props.put("http.request.method", request.getMethod());
- props.put("http.request.pathInfo", request.getPathInfo());
- props.put("http.request.requestURI", request.getRequestURI());
- props.put("http.request.requestURL", request.getRequestURL().toString());
-
- setCustomProperties(props);
- props.store(response.getOutputStream(), "Data created by " + getClass().getName() + " at " + new Date());
- response.getOutputStream().flush();
- }
-
- /** Hook for additional custom properties */
- void setCustomProperties(Properties props) {
- }
+ @Override
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, "test JUL message");
+ dumpRequestAsProperties(request, response);
+ }
+
+ @Override
+ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ dumpRequestAsProperties(request, response);
+ }
+
+ protected void dumpRequestAsProperties(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws IOException {
+ final Properties props = new Properties();
+ response.setContentType("text/plain");
+ props.put("servlet.class.name", getClass().getName());
+
+ final Resource r = request.getResource();
+ props.put("sling.resource.path", r == null ? "" : r.getPath());
+ props.put("sling.resource.type", r == null ? "" : r.getResourceType());
+ props.put("http.request.method", request.getMethod());
+ props.put("http.request.pathInfo", request.getPathInfo());
+ props.put("http.request.requestURI", request.getRequestURI());
+ props.put("http.request.requestURL", request.getRequestURL().toString());
+
+ setCustomProperties(props);
+ props.store(response.getOutputStream(), "Data created by " + getClass().getName() + " at " + new Date());
+ response.getOutputStream().flush();
+ }
+
+ /** Hook for additional custom properties */
+ void setCustomProperties(Properties props) {}
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/XpathServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/XpathServlet.java
index 02ac98e..799bd48 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/XpathServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/XpathServlet.java
@@ -18,15 +18,15 @@
*/
package org.apache.sling.launchpad.testservices.servlets;
-import java.io.IOException;
-import java.io.StringReader;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import java.io.IOException;
+import java.io.StringReader;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -36,12 +36,10 @@ import org.xml.sax.InputSource;
/**
* The <code>XpathServlet</code> evaluates a simple XML document using an XPath expression
- *
+ *
*/
-@Component(service=Servlet.class)
-@SlingServletPathsStrict(
- paths = "/bin/xpath",
- extensions = "xml")
+@Component(service = Servlet.class)
+@SlingServletPathsStrict(paths = "/bin/xpath", extensions = "xml")
public class XpathServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@@ -62,5 +60,4 @@ public class XpathServlet extends SlingAllMethodsServlet {
throw new ServletException(e.getMessage(), e);
}
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/OriginalResponseServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/OriginalResponseServlet.java
index 96e0de0..2fd8406 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/OriginalResponseServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/OriginalResponseServlet.java
@@ -18,10 +18,10 @@
*/
package org.apache.sling.launchpad.testservices.servlets.requestdispatcher;
-import java.io.IOException;
-
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -32,12 +32,12 @@ import org.osgi.service.component.annotations.Component;
* Simple servlet delivering a static string - used for testing request dispatcher include.
*/
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=" + OriginalResponseServlet.PATH
+ "service.description:String=Paths Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=" + OriginalResponseServlet.PATH
})
@SuppressWarnings("serial")
public class OriginalResponseServlet extends SlingSafeMethodsServlet {
@@ -50,5 +50,4 @@ public class OriginalResponseServlet extends SlingSafeMethodsServlet {
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().write("OriginalResponse");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeBufferedServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeBufferedServlet.java
index 72912e7..1f75487 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeBufferedServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeBufferedServlet.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.launchpad.testservices.servlets.requestdispatcher;
-import java.io.IOException;
-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.request.builder.Builders;
@@ -37,12 +37,12 @@ import org.osgi.service.component.annotations.Component;
* done into a "synthetic response" created via Sling Builders and the output than written to the real response.
*/
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=" + RequestDispatcherIncludeBufferedServlet.PATH
+ "service.description:String=Paths Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=" + RequestDispatcherIncludeBufferedServlet.PATH
})
@SuppressWarnings("serial")
public class RequestDispatcherIncludeBufferedServlet extends SlingSafeMethodsServlet {
@@ -57,7 +57,8 @@ public class RequestDispatcherIncludeBufferedServlet extends SlingSafeMethodsSer
response.getWriter().write("includeBuffered(");
// build "synthetic response"
- SlingHttpServletResponseResult syntheticResponse = Builders.newResponseBuilder().build();
+ SlingHttpServletResponseResult syntheticResponse =
+ Builders.newResponseBuilder().build();
// write output of other servlet to this response to allow to post-process or validate it
RequestDispatcher requestDispatcher = request.getRequestDispatcher(OriginalResponseServlet.PATH);
@@ -68,5 +69,4 @@ public class RequestDispatcherIncludeBufferedServlet extends SlingSafeMethodsSer
response.getWriter().write(")");
}
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeDirectServlet.java b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeDirectServlet.java
index 8261d63..f2656f6 100644
--- a/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeDirectServlet.java
+++ b/src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeDirectServlet.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.launchpad.testservices.servlets.requestdispatcher;
-import java.io.IOException;
-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -33,12 +33,12 @@ import org.osgi.service.component.annotations.Component;
* Servlet using RequestDispatcher.include to include output of another servlet in it's response.
*/
@Component(
- immediate=true,
+ immediate = true,
service = javax.servlet.Servlet.class,
property = {
- "service.description:String=Paths Test Servlet",
- "service.vendor:String=The Apache Software Foundation",
- "sling.servlet.paths:String=" + RequestDispatcherIncludeDirectServlet.PATH
+ "service.description:String=Paths Test Servlet",
+ "service.vendor:String=The Apache Software Foundation",
+ "sling.servlet.paths:String=" + RequestDispatcherIncludeDirectServlet.PATH
})
@SuppressWarnings("serial")
public class RequestDispatcherIncludeDirectServlet extends SlingSafeMethodsServlet {
@@ -57,5 +57,4 @@ public class RequestDispatcherIncludeDirectServlet extends SlingSafeMethodsServl
response.getWriter().write(")");
}
-
}