You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2020/04/03 21:16:25 UTC
[sling-org-apache-sling-scripting-bundle-tracker-it] branch master
updated: SLING-9330 - Path registrations override the servlet resources for
parent resource types
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker-it.git
The following commit(s) were added to refs/heads/master by this push:
new 02f3ecf SLING-9330 - Path registrations override the servlet resources for parent resource types
02f3ecf is described below
commit 02f3ecf33b9d8cabf6c06703384cc468372b3942
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Apr 3 23:15:50 2020 +0200
SLING-9330 - Path registrations override the servlet resources for parent resource types
* added teleported tests to verify the servlet resources
---
it/pom.xml | 12 ++
.../tracker/it/AbstractTeleportedTestBase.java | 57 ++++++++++
.../it/ExampleBundleExtend1TeleportedIT.java | 59 ++++++++++
.../it/ExampleBundleExtend2TeleportedIT.java | 106 +++++++++++++++++
.../ExampleBundlePrecompiledJSPTeleportedIT.java | 67 +++++++++++
.../it/ExampleBundlePrecompiledTeleportedIT.java | 95 ++++++++++++++++
.../tracker/it/ExampleBundleTeleportedIT.java | 125 +++++++++++++++++++++
.../scripting/bundle/tracker/it/ITCustomizer.java | 40 +++++++
8 files changed, 561 insertions(+)
diff --git a/it/pom.xml b/it/pom.xml
index 9ab7e61..a69b87a 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -271,11 +271,23 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.teleporter</artifactId>
+ <version>1.0.16</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.clients</artifactId>
<version>1.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.core</artifactId>
+ <version>1.0.26</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/AbstractTeleportedTestBase.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/AbstractTeleportedTestBase.java
new file mode 100644
index 0000000..19b181b
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/AbstractTeleportedTestBase.java
@@ -0,0 +1,57 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+package org.apache.sling.scripting.bundle.tracker.it;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.junit.Rule;
+
+public class AbstractTeleportedTestBase {
+
+ protected static final Map<String, Object> AUTH_MAP;
+
+ static {
+ AUTH_MAP = new HashMap<>();
+ AUTH_MAP.put(ResourceResolverFactory.USER, "admin");
+ AUTH_MAP.put(ResourceResolverFactory.PASSWORD, "admin".toCharArray());
+ }
+
+ @Rule
+ public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "org.apache.sling.scripting.bundle.tracker.it.ITCustomizer");
+
+ protected Set<String> getChildrenForServletResource(String resourceType, String... children) {
+ HashSet<String> rtChildren = new HashSet<>();
+ for (String child : children) {
+ rtChildren.add(resourceType + "/" + child);
+ }
+ return rtChildren;
+ }
+
+ protected Map<String, Resource> collectResourceChildren(Resource resource) {
+ Map<String, Resource> children = new HashMap<>();
+ resource.getChildren().forEach(child -> children.put(child.getPath(), child));
+ return children;
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend1TeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend1TeleportedIT.java
new file mode 100644
index 0000000..f36c986
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend1TeleportedIT.java
@@ -0,0 +1,59 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ExampleBundleExtend1TeleportedIT extends AbstractTeleportedTestBase {
+
+ @Test
+ public void testHello1() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.extend1.hello/1.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertEquals("org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0", main.getResourceSuperType());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(3, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ assertEquals("org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0", children.get("/apps/" + expectedRT + "/html" +
+ ".servlet").getResourceSuperType());
+ }
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
new file mode 100644
index 0000000..1feccbc
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
@@ -0,0 +1,106 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ExampleBundleExtend2TeleportedIT extends AbstractTeleportedTestBase {
+
+ @Test
+ public void testOne() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.extend2.one/1.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertEquals("org.apache.sling.scripting.examplebundle.extend1.hello/1.0.0", main.getResourceSuperType());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(3, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ assertEquals("org.apache.sling.scripting.examplebundle.extend1.hello/1.0.0", children.get("/apps/" + expectedRT + "/html" +
+ ".servlet").getResourceSuperType());
+ }
+ }
+
+ @Test
+ public void testTwo() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.extend2.two/1.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertEquals("org.apache.sling.scripting.examplebundle.extend2.one/1.0.0", main.getResourceSuperType());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(3, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ assertEquals("org.apache.sling.scripting.examplebundle.extend2.one/1.0.0", children.get("/apps/" + expectedRT + "/html" +
+ ".servlet").getResourceSuperType());
+ }
+ }
+
+ @Test
+ public void testThree() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.extend2.three";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertEquals("sling/scripting/examplebundle/hello", main.getResourceSuperType());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(3, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ assertEquals("sling/scripting/examplebundle/hello", children.get("/apps/" + expectedRT + "/html" +
+ ".servlet").getResourceSuperType());
+ }
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledJSPTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledJSPTeleportedIT.java
new file mode 100644
index 0000000..774a75a
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledJSPTeleportedIT.java
@@ -0,0 +1,67 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ExampleBundlePrecompiledJSPTeleportedIT extends AbstractTeleportedTestBase {
+
+ @Test
+ public void testHello() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.precompiled.jsp.hello";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(9, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.jsp",
+ "h.jsp.servlet",
+ "h.html.servlet",
+ "w.jsp",
+ "w.jsp.servlet",
+ "w.html.servlet",
+ "hello.jsp",
+ "hello.jsp.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
new file mode 100644
index 0000000..80436c1
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
@@ -0,0 +1,95 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ExampleBundlePrecompiledTeleportedIT extends AbstractTeleportedTestBase {
+
+ @Test
+ public void testHello1() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(7, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "w.html",
+ "w.html.servlet",
+ "hello.html",
+ "hello.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+
+ @Test
+ public void testHello2() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(7, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "w.html",
+ "w.html.servlet",
+ "hello.html",
+ "hello.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java
new file mode 100644
index 0000000..6e5f506
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java
@@ -0,0 +1,125 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ExampleBundleTeleportedIT extends AbstractTeleportedTestBase {
+
+ @Test
+ public void testHello1() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.hello/1.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(7, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "w.html",
+ "w.html.servlet",
+ "hello.html",
+ "hello.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+
+ @Test
+ public void testHello2() throws LoginException {
+ final String expectedRT = "org.apache.sling.scripting.examplebundle.hello/2.0.0";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(7, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "w.html",
+ "w.html.servlet",
+ "hello.html",
+ "hello.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+
+ @Test
+ public void testAppsHello() throws LoginException {
+ final String expectedRT = "sling/scripting/examplebundle/hello";
+ ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+ try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+ Resource main = resolver.getResource("/apps/" + expectedRT);
+ assertNotNull(main);
+ assertTrue(main.getValueMap().isEmpty());
+ Map<String, Resource> children = collectResourceChildren(main);
+ assertEquals(7, children.size());
+
+ Set<String> expectedChildren = getChildrenForServletResource(
+ "/apps/" + expectedRT,
+ "h.html",
+ "h.html.servlet",
+ "w.html",
+ "w.html.servlet",
+ "hello.html",
+ "hello.html.servlet",
+ "html.servlet"
+ );
+ assertEquals(expectedChildren, children.keySet());
+
+ for (Resource child : children.values()) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
+ }
+ }
+}
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ITCustomizer.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ITCustomizer.java
new file mode 100644
index 0000000..7b788f8
--- /dev/null
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ITCustomizer.java
@@ -0,0 +1,40 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.bundle.tracker.it;
+
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.testing.teleporter.client.ClientSideTeleporter;
+
+public class ITCustomizer implements TeleporterRule.Customizer {
+
+ public static final String BASE_URL_PROP = "launchpad.http.server.url";
+
+ @Override
+ public void customize(TeleporterRule t, String options) {
+ final ClientSideTeleporter cst = (ClientSideTeleporter)t;
+ cst.setBaseUrl(System.getProperty(BASE_URL_PROP, BASE_URL_PROP + "_IS_NOT_SET"));
+ cst.setServerCredentials("admin", "admin");
+ cst.includeDependencyPrefix("org.apache.sling.testing");
+ cst.includeDependencyPrefix("org.ops4j.pax.tinybundles");
+ cst.includeDependencyPrefix("org.apache.sling.scripting.bundle.tracker.it");
+ cst.setTestReadyTimeoutSeconds(20);
+ cst.setPreventToUninstallBundle(true);
+ cst.setEnableLogging(true);
+ }
+}