This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch SLING-12098
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-core.git
The following commit(s) were added to refs/heads/SLING-12098 by this push:
new e912512 Migrate to Sling Testing paxexam 4.0
e912512 is described below
commit e912512f2c81b920f9c31c8c5be76bea53d260e1
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Sun Oct 15 09:40:34 2023 +0200
Migrate to Sling Testing paxexam 4.0
---
.gitignore | 1 +
pom.xml | 42 +++--------------
.../core/impl/helper/ProtectedBindings.java | 2 +-
.../sling/scripting/core/it/HtmlScriptingIT.java | 5 +-
.../sling/scripting/core/it/SLING_10147IT.java | 32 ++-----------
.../core/it/ScriptingCoreTestSupport.java | 55 ++++++++++++----------
6 files changed, 43 insertions(+), 94 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5b783ed..d4bfe7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.vscode
/target
.idea
.classpath
diff --git a/pom.xml b/pom.xml
index 2e8e38c..0ef9eb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -174,7 +174,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.paxexam</artifactId>
- <version>3.1.0</version>
+ <version>4.0.0</version>
<scope>test</scope>
</dependency>
<!-- OSGi -->
@@ -236,7 +236,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>6.0.3</version>
+ <version>7.0.5</version>
<scope>test</scope>
</dependency>
@@ -289,13 +289,13 @@
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
- <version>4.0.1</version>
+ <version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
- <version>1.3_1</version>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -328,35 +328,5 @@
<version>${org.ops4j.pax.exam.version}</version>
<scope>test</scope>
</dependency>
-
- <!--
- temporary until a new release of org.apache.sling.testing.paxexam will
provide:
- * o.a.s.resourceresolver >= 1.6.16
- * o.a.s.servlets.resolver >= 2.6.0
- -->
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.resourceresolver</artifactId>
- <version>1.6.16</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.servlets.resolver</artifactId>
- <version>2.8.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.johnzon</artifactId>
- <version>1.2.6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
-
<artifactId>org.apache.sling.extensions.webconsolesecurityprovider</artifactId>
- <version>1.2.4</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git
a/src/main/java/org/apache/sling/scripting/core/impl/helper/ProtectedBindings.java
b/src/main/java/org/apache/sling/scripting/core/impl/helper/ProtectedBindings.java
index a2f8790..02b8326 100644
---
a/src/main/java/org/apache/sling/scripting/core/impl/helper/ProtectedBindings.java
+++
b/src/main/java/org/apache/sling/scripting/core/impl/helper/ProtectedBindings.java
@@ -28,7 +28,7 @@ import javax.script.Bindings;
import org.apache.sling.api.scripting.LazyBindings;
import org.jetbrains.annotations.NotNull;
-public class ProtectedBindings extends LazyBindings implements Bindings {
+public class ProtectedBindings extends LazyBindings {
private static final long serialVersionUID = -5988579857015221345L;
diff --git
a/src/test/java/org/apache/sling/scripting/core/it/HtmlScriptingIT.java
b/src/test/java/org/apache/sling/scripting/core/it/HtmlScriptingIT.java
index 0fbcf17..c6475b7 100644
--- a/src/test/java/org/apache/sling/scripting/core/it/HtmlScriptingIT.java
+++ b/src/test/java/org/apache/sling/scripting/core/it/HtmlScriptingIT.java
@@ -19,7 +19,7 @@
package org.apache.sling.scripting.core.it;
import static
org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
-import static
org.apache.sling.testing.paxexam.SlingOptions.slingScriptingSightly;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingScriptingHtl;
import static
org.apache.sling.testing.paxexam.SlingOptions.slingScriptingThymeleaf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -28,7 +28,6 @@ import static org.ops4j.pax.exam.CoreOptions.options;
import static
org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
import java.io.IOException;
-
import javax.inject.Inject;
import javax.script.ScriptEngineFactory;
@@ -90,7 +89,7 @@ public class HtmlScriptingIT extends ScriptingCoreTestSupport
{
return options(
composite(
super.baseConfiguration(),
- slingScriptingSightly(),
+ slingScriptingHtl(),
slingScriptingThymeleaf(),
slingQuickstartOakTar(workingDirectory, httpPort),
factoryConfiguration("org.apache.sling.resource.presence.internal.ResourcePresenter")
diff --git
a/src/test/java/org/apache/sling/scripting/core/it/SLING_10147IT.java
b/src/test/java/org/apache/sling/scripting/core/it/SLING_10147IT.java
index 4312e36..30306d6 100644
--- a/src/test/java/org/apache/sling/scripting/core/it/SLING_10147IT.java
+++ b/src/test/java/org/apache/sling/scripting/core/it/SLING_10147IT.java
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static
org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
import java.io.IOException;
@@ -61,8 +60,6 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.ModifiableCompositeOption;
-import org.ops4j.pax.exam.options.extra.VMOption;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.osgi.framework.BundleContext;
@@ -172,39 +169,17 @@ public class SLING_10147IT {
@Configuration
public Option[] configuration() {
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.api");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.resourceresolver");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.servlets.resolver");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.scripting.api");
-
- final Option webconsolesecurityprovider =
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.extensions.webconsolesecurityprovider").versionAsInProject();
return composite(
+ baseConfiguration(),
slingQuickstartOakTar(String.format("target/%s",
getClass().getSimpleName()), httpPort),
slingScriptingJavascript(),
slingAuthForm(),
- baseConfiguration(),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").version(versionResolver),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi").version(versionResolver),
- webconsolesecurityprovider,
- optionalRemoteDebug()
- ).remove(
- scriptingCore // remove the old version
+ webconsolesecurityprovider()
).getOptions();
}
- /**
- * Optionally configure remote debugging on the port supplied by the
"debugPort"
- * system property.
- */
- protected ModifiableCompositeOption optionalRemoteDebug() {
- VMOption option = null;
- String property = System.getProperty("debugPort");
- if (property != null) {
- option =
vmOption(String.format("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s",
property));
- }
- return composite(option);
- }
-
protected void checkContentType(CloseableHttpResponse response ,String
expected) {
// Remove whatever follows semicolon in content-type
HttpEntity entity = response.getEntity();
@@ -321,9 +296,8 @@ public class SLING_10147IT {
@Override
public Option[] configuration() {
// remove the security provider bundle from the configuration
- final Option webconsolesecurityprovider =
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.extensions.webconsolesecurityprovider").versionAsInProject();
return composite(super.configuration())
- .remove(webconsolesecurityprovider)
+ .remove(webconsolesecurityprovider())
.getOptions();
}
diff --git
a/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
b/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
index 4b5156a..d63cb25 100644
---
a/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
+++
b/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
@@ -18,70 +18,75 @@
*/
package org.apache.sling.scripting.core.it;
-import java.util.Objects;
-
import org.apache.sling.testing.paxexam.TestSupport;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.ModifiableCompositeOption;
-import org.ops4j.pax.exam.options.OptionalCompositeOption;
import org.ops4j.pax.exam.options.extra.VMOption;
import static org.apache.sling.testing.paxexam.SlingOptions.awaitility;
import static
org.apache.sling.testing.paxexam.SlingOptions.slingResourcePresence;
import static org.apache.sling.testing.paxexam.SlingOptions.slingScripting;
import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
+import static org.apache.sling.testing.paxexam.SlingOptions.webconsole;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
public class ScriptingCoreTestSupport extends TestSupport {
final int httpPort = findFreePort();
- final Option scriptingCore =
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.core").version(versionResolver);
+ final Option scriptingCore = mavenBundle()
+ .groupId("org.apache.sling")
+ .artifactId("org.apache.sling.scripting.core")
+ .version(versionResolver);
public ModifiableCompositeOption baseConfiguration() {
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.api");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.resourceresolver");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.servlets.resolver");
- versionResolver.setVersionFromProject("org.apache.sling",
"org.apache.sling.scripting.api");
+ versionResolver.setVersionFromProject("org.awaitility", "awaitility");
return composite(
super.baseConfiguration(),
- // Sling Scripting
- slingScripting(),
newConfiguration("org.apache.felix.http")
.put("org.osgi.service.http.port", httpPort)
.asOption(),
+ // Sling Scripting
+ slingScripting(),
// Sling Scripting Core
testBundle("bundle.filename"),
// debugging
-
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.inventory").version(versionResolver),
+ webconsole(),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version(versionResolver),
// testing
slingResourcePresence(),
mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
-
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
-
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.compiler").versionAsInProject(),
-
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.johnzon").versionAsInProject(),
-
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.spi").versionAsInProject(),
junitBundles(),
awaitility(),
- jacoco() // remove with Testing PaxExam 4.0
- ).add(
-
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.converter").version("1.0.12")
// new Sling API dependency
+
mavenBundle().groupId("org.hamcrest").artifactId("hamcrest").versionAsInProject(),
+ optionalRemoteDebug()
).remove(
- scriptingCore
+ scriptingCore,
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").version(versionResolver)
);
}
- // remove with Testing PaxExam 4.0
- protected OptionalCompositeOption jacoco() {
- final String jacocoCommand = System.getProperty("jacoco.command");
- final VMOption option = Objects.nonNull(jacocoCommand) &&
!jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
- return when(Objects.nonNull(option)).useOptions(option);
+ /**
+ * Optionally configure remote debugging on the port supplied by the
"debugPort"
+ * system property.
+ */
+ protected ModifiableCompositeOption optionalRemoteDebug() {
+ VMOption option = null;
+ String property = System.getProperty("debugPort");
+ if (property != null) {
+ option =
vmOption(String.format("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s",
property));
+ }
+ return composite(option);
}
+ protected Option webconsolesecurityprovider() {
+ return mavenBundle()
+ .groupId("org.apache.sling")
+
.artifactId("org.apache.sling.extensions.webconsolesecurityprovider")
+ .version("1.2.8");
+ }
}