This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests.git
The following commit(s) were added to refs/heads/master by this push:
new 6991c41 SLING-12600 ensure most app scripts are uploaded to unique
folder with unique resource type (#34)
6991c41 is described below
commit 6991c418edc3196623724cbf7b257b9b4b761311
Author: Stefan Seifert <[email protected]>
AuthorDate: Tue Nov 25 08:59:15 2025 +0100
SLING-12600 ensure most app scripts are uploaded to unique folder with
unique resource type (#34)
to avoid flakyness when running integration tests on windows
---
.../webapp/integrationtest/ForwardTest.java | 5 ++-
.../webapp/integrationtest/GetWithSuffixTest.java | 6 +++-
.../webapp/integrationtest/IncludeTest.java | 5 ++-
.../webapp/integrationtest/JspForwardTest.java | 5 ++-
.../NodeTypeBasedRenderingTest.java | 3 +-
.../integrationtest/NodetypeRenderingTest.java | 5 ++-
.../integrationtest/RequestAttributeTest.java | 17 ++++++----
.../integrationtest/util/UniqueResourceType.java | 37 ++++++++++++++++++++++
8 files changed, 70 insertions(+), 13 deletions(-)
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ForwardTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ForwardTest.java
index fa48793..825d7e4 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ForwardTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ForwardTest.java
@@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.sling.commons.testing.integration.HttpTestBase;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
import org.apache.sling.servlets.post.SlingPostConstants;
/** Test the {link ScriptHelper#forward) functionality */
@@ -48,12 +49,14 @@ public class ForwardTest extends HttpTestBase {
// Create the test nodes under a path that's specific to this class to
// allow collisions
+ UniqueResourceType urt = new UniqueResourceType();
final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() +
"/" + System.currentTimeMillis()
+ SlingPostConstants.DEFAULT_CREATE_SUFFIX;
final Map<String, String> props = new HashMap<String, String>();
// Create two test nodes and store their paths
testTextA = "Text A " + System.currentTimeMillis();
+ props.put("sling:resourceType", urt.getResourceType());
props.put("text", testTextA);
nodeUrlA = testClient.createNode(url, props);
String pathToInclude = nodeUrlA.substring(HTTP_BASE_URL.length());
@@ -87,7 +90,7 @@ public class ForwardTest extends HttpTestBase {
toDelete.add(uploadTestScript(scriptPath, "forward-forced.esp",
"html.esp"));
// The main rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
toDelete.add(uploadTestScript(scriptPath, "forward-test.esp",
"html.esp"));
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GetWithSuffixTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GetWithSuffixTest.java
index f1268b9..3b8967b 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GetWithSuffixTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GetWithSuffixTest.java
@@ -24,6 +24,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
+
/** GET requests with a suffix should fail with a 404, otherwise
* we get a lot of extra possible URLs which point to the same
* content.
@@ -38,13 +40,15 @@ public class GetWithSuffixTest extends RenderingTestBase {
testText = "This is a test " + System.currentTimeMillis();
// create the test node, under a path that's specific to this class to
allow collisions
+ UniqueResourceType urt = new UniqueResourceType();
final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() +
"_" + System.currentTimeMillis();
final Map<String, String> props = new HashMap<String, String>();
+ props.put("sling:resourceType", urt.getResourceType());
props.put("text", testText);
displayUrl = testClient.createNode(url, props);
// the rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/IncludeTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/IncludeTest.java
index 83fd029..e0e9978 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/IncludeTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/IncludeTest.java
@@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.sling.commons.testing.integration.HttpTestBase;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
import org.apache.sling.servlets.post.SlingPostConstants;
/** Test the {link ScriptHelper#include) functionality */
@@ -52,7 +53,9 @@ public class IncludeTest extends HttpTestBase {
final Map<String, String> props = new HashMap<String, String>();
// Create two test nodes and store their paths
+ UniqueResourceType urt = new UniqueResourceType();
testTextA = "Text A " + System.currentTimeMillis();
+ props.put("sling:resourceType", urt.getResourceType());
props.put("text", testTextA);
nodeUrlA = testClient.createNode(url, props);
String pathToInclude = nodeUrlA.substring(HTTP_BASE_URL.length());
@@ -86,7 +89,7 @@ public class IncludeTest extends HttpTestBase {
toDelete.add(uploadTestScript(scriptPath, "include-forced.esp",
"html.esp"));
// The main rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
toDelete.add(uploadTestScript(scriptPath, "include-test.esp",
"html.esp"));
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java
index 9cd09ba..6dc8dbb 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java
@@ -28,6 +28,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.commons.testing.junit.RetryRule;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
import org.apache.sling.servlets.post.SlingPostConstants;
import org.junit.After;
import org.junit.Before;
@@ -68,7 +69,9 @@ public class JspForwardTest {
final Map<String, String> props = new HashMap<String, String>();
// Create two test nodes and store their paths
+ UniqueResourceType urt = new UniqueResourceType();
testTextA = "Text A " + System.currentTimeMillis();
+ props.put("sling:resourceType", urt.getResourceType());
props.put("text", testTextA);
nodeUrlA = H.getTestClient().createNode(url, props);
String pathToInclude =
nodeUrlA.substring(HttpTest.HTTP_BASE_URL.length());
@@ -108,7 +111,7 @@ public class JspForwardTest {
toDelete.add(H.uploadTestScript(scriptPath, "forward-forced.jsp",
"html.jsp"));
// The main rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
H.getTestClient().mkdirs(HttpTest.WEBDAV_BASE_URL, scriptPath);
toDelete.add(H.uploadTestScript(scriptPath, "forward-test.jsp",
"html.jsp"));
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodeTypeBasedRenderingTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodeTypeBasedRenderingTest.java
index 274880e..8cf2c05 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodeTypeBasedRenderingTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodeTypeBasedRenderingTest.java
@@ -27,7 +27,8 @@ import java.util.concurrent.atomic.AtomicInteger;
/** Test rendering resources based on their JCR node type */
public class NodeTypeBasedRenderingTest extends RenderingTestBase {
- public static final String TEST_PATH = "/testing/" +
NodeTypeBasedRenderingTest.class.getSimpleName();
+ public static final String TEST_PATH =
+ "/testing/" + NodeTypeBasedRenderingTest.class.getSimpleName() +
"/" + System.currentTimeMillis();
private String testNodeUrl;
private List<String> toDelete = new ArrayList<String>();
private static AtomicInteger counter = new AtomicInteger();
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
index e84e430..fb1f75c 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
import org.apache.sling.servlets.post.SlingPostConstants;
/** Test creating a Node and rendering it using scripts in
@@ -40,15 +41,17 @@ public class NodetypeRenderingTest extends
RenderingTestBase {
testText = "This is a test " + System.currentTimeMillis();
// create the test node, under a path that's specific to this class to
allow collisions
+ UniqueResourceType urt = new UniqueResourceType();
secondFolderOfContentPath = "" + System.currentTimeMillis();
final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() +
"/" + secondFolderOfContentPath
+ SlingPostConstants.DEFAULT_CREATE_SUFFIX;
final Map<String, String> props = new HashMap<String, String>();
+ props.put("sling:resourceType", urt.getResourceType());
props.put("text", testText);
displayUrl = testClient.createNode(url, props);
// the rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RequestAttributeTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RequestAttributeTest.java
index fbb7078..fbb5116 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RequestAttributeTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RequestAttributeTest.java
@@ -27,6 +27,7 @@ import java.util.Properties;
import java.util.Set;
import org.apache.sling.commons.testing.integration.HttpTestBase;
+import
org.apache.sling.launchpad.webapp.integrationtest.util.UniqueResourceType;
import org.apache.sling.servlets.post.SlingPostConstants;
/**
@@ -36,6 +37,8 @@ import org.apache.sling.servlets.post.SlingPostConstants;
*/
public class RequestAttributeTest extends HttpTestBase {
+ private UniqueResourceType urt = new UniqueResourceType();
+
private String nodeUrlA;
private String nodeUrlB;
@@ -57,16 +60,16 @@ public class RequestAttributeTest extends HttpTestBase {
// Create two test nodes and store their paths
props.put("text", "texta");
- props.put("jcr:primaryType", "nt:unstructured");
+ props.put("sling:resourceType", urt.getResourceType());
nodeUrlA = testClient.createNode(url, props);
props.clear();
props.put("text", "textb");
- props.put("jcr:primaryType", "nt:unstructured");
+ props.put("sling:resourceType", urt.getResourceType());
nodeUrlB = testClient.createNode(nodeUrlA + "/child", props);
// The main rendering script goes under /apps in the repository
- scriptPath = "/apps/nt/unstructured";
+ scriptPath = urt.getScriptPath();
testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
toDelete.add(uploadTestScript(scriptPath,
"request-attribute-test.esp", "txt.esp"));
toDelete.add(uploadTestScript(scriptPath,
"request-attribute-test-sel1.esp", "sel1.txt.esp"));
@@ -98,17 +101,17 @@ public class RequestAttributeTest extends HttpTestBase {
assertEquals("Request Resource 1 is null", "null",
props.get("resource01"));
// this is from sel1.txt.esp, included by txt.esp
- assertEquals("Request Servlet 10", "/apps/nt/unstructured/txt.esp",
props.get("servlet10"));
+ assertEquals("Request Servlet 10", urt.getScriptPath() + "/txt.esp",
props.get("servlet10"));
assertEquals("Request Resource 10", pA, props.get("resource10"));
- assertEquals("Request Servlet 11", "/apps/nt/unstructured/txt.esp",
props.get("servlet11"));
+ assertEquals("Request Servlet 11", urt.getScriptPath() + "/txt.esp",
props.get("servlet11"));
assertEquals("Request Resource 11", pA, props.get("resource11"));
// this is from sel2.txt.esp, included by txt.esp
- assertEquals("Request Servlet 20", "/apps/nt/unstructured/txt.esp",
props.get("servlet20"));
+ assertEquals("Request Servlet 20", urt.getScriptPath() + "/txt.esp",
props.get("servlet20"));
assertEquals("Request Resource 20", pA, props.get("resource20"));
// this is from sel3.txt.esp, included by sel1.txt.esp
- assertEquals("Request Servlet 30",
"/apps/nt/unstructured/sel1.txt.esp", props.get("servlet30"));
+ assertEquals("Request Servlet 30", urt.getScriptPath() +
"/sel1.txt.esp", props.get("servlet30"));
assertEquals("Request Resource 30", pB, props.get("resource30"));
}
}
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/UniqueResourceType.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/UniqueResourceType.java
new file mode 100644
index 0000000..2c92eb4
--- /dev/null
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/UniqueResourceType.java
@@ -0,0 +1,37 @@
+/*
+ * 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.webapp.integrationtest.util;
+
+import java.util.UUID;
+
+/**
+ * Use a unique resource type for each unit test to avoid interference
(SLING-12600).
+ */
+public class UniqueResourceType {
+
+ private final String uid = UUID.randomUUID().toString();
+
+ public String getResourceType() {
+ return "test/rt-" + uid;
+ }
+
+ public String getScriptPath() {
+ return "/apps/" + getResourceType();
+ }
+}