You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2019/07/01 17:44:30 UTC
[sling-org-apache-sling-testing-paxexam] 02/02: SLING-8547 Provide
Testcontainers Option
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-paxexam.git
commit 0452edcc4b4db6b1ffcfe8af88022f09beaed440
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jul 1 19:35:50 2019 +0200
SLING-8547 Provide Testcontainers Option
---
README.md | 1 +
.../apache/sling/testing/paxexam/SlingOptions.java | 9 ++++
.../testing/paxexam/SlingVersionResolver.java | 2 +
src/main/resources/templates/SlingOptions.hbs | 9 ++++
.../resources/templates/SlingVersionResolver.hbs | 2 +
.../it/tests/SlingOptionsTestcontainersIT.java | 48 ++++++++++++++++++++++
6 files changed, 71 insertions(+)
diff --git a/README.md b/README.md
index 4d96d17..1887ab8 100644
--- a/README.md
+++ b/README.md
@@ -21,3 +21,4 @@ See Testing PaxExam's [documentation page](https://sling.apache.org/documentatio
* Overriding of versions
* Adjusting of provided Options (`ModifiableCompositeOption`s)
* Build bundles with test content and OSGi DS services on-the-fly (no need for extra modules)
+* Start Docker containers via [Testcontainers](https://www.testcontainers.org/)
diff --git a/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java b/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
index e835017..1e59c0a 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
@@ -26,6 +26,7 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemPackages;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
@@ -166,6 +167,14 @@ public class SlingOptions {
);
}
+ public static ModifiableCompositeOption testcontainers() {
+ return composite(
+ paxUrlWrap(),
+ wrappedBundle(mavenBundle().groupId("org.rnorth.duct-tape").artifactId("duct-tape").version(versionResolver)),
+ wrappedBundle(mavenBundle().groupId("org.testcontainers").artifactId("testcontainers").version(versionResolver))
+ );
+ }
+
public static ModifiableCompositeOption sling() {
return composite(
config(),
diff --git a/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java b/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
index 08f3bfe..22b55c0 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
@@ -67,8 +67,10 @@ public class SlingVersionResolver implements VersionResolver {
versions.put("org.osgi:org.osgi.util.function", "1.1.0");
versions.put("org.osgi:org.osgi.util.promise", "1.1.0");
versions.put("org.ow2.asm:asm", "7.1");
+ versions.put("org.rnorth.duct-tape:duct-tape", "1.0.8");
versions.put("org.slf4j:slf4j-api", "1.7.26");
versions.put("org.slf4j:jcl-over-slf4j", "1.7.26");
+ versions.put("org.testcontainers:testcontainers", "1.11.3");
versions.put("ch.qos.logback:logback-core", "1.2.3");
versions.put("ch.qos.logback:logback-classic", "1.2.3");
versions.put("biz.aQute.bnd:biz.aQute.bndlib", "3.5.0");
diff --git a/src/main/resources/templates/SlingOptions.hbs b/src/main/resources/templates/SlingOptions.hbs
index 6ba4b18..9599ade 100644
--- a/src/main/resources/templates/SlingOptions.hbs
+++ b/src/main/resources/templates/SlingOptions.hbs
@@ -26,6 +26,7 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemPackages;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
@@ -163,6 +164,14 @@ public class SlingOptions {
config()
);
}
+
+ public static ModifiableCompositeOption testcontainers() {
+ return composite(
+ paxUrlWrap(),
+ wrappedBundle(mavenBundle().groupId("org.rnorth.duct-tape").artifactId("duct-tape").version(versionResolver)),
+ wrappedBundle(mavenBundle().groupId("org.testcontainers").artifactId("testcontainers").version(versionResolver))
+ );
+ }
{{#each features}}
public static ModifiableCompositeOption {{javaName}}() {
return composite({{#each features}}
diff --git a/src/main/resources/templates/SlingVersionResolver.hbs b/src/main/resources/templates/SlingVersionResolver.hbs
index d746d69..528b168 100644
--- a/src/main/resources/templates/SlingVersionResolver.hbs
+++ b/src/main/resources/templates/SlingVersionResolver.hbs
@@ -67,8 +67,10 @@ public class SlingVersionResolver implements VersionResolver {
versions.put("org.osgi:org.osgi.util.function", "1.1.0");
versions.put("org.osgi:org.osgi.util.promise", "1.1.0");
versions.put("org.ow2.asm:asm", "7.1");
+ versions.put("org.rnorth.duct-tape:duct-tape", "1.0.8");
versions.put("org.slf4j:slf4j-api", "1.7.26");
versions.put("org.slf4j:jcl-over-slf4j", "1.7.26");
+ versions.put("org.testcontainers:testcontainers", "1.11.3");
versions.put("ch.qos.logback:logback-core", "1.2.3");
versions.put("ch.qos.logback:logback-classic", "1.2.3");
versions.put("biz.aQute.bnd:biz.aQute.bndlib", "3.5.0");
diff --git a/src/test/java/org/apache/sling/testing/paxexam/it/tests/SlingOptionsTestcontainersIT.java b/src/test/java/org/apache/sling/testing/paxexam/it/tests/SlingOptionsTestcontainersIT.java
new file mode 100644
index 0000000..6dbaac4
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/paxexam/it/tests/SlingOptionsTestcontainersIT.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * 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.testing.paxexam.it.tests;
+
+import org.apache.sling.testing.paxexam.it.SlingOptionsTestSupport;
+import org.junit.Test;
+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.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.testcontainers;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class SlingOptionsTestcontainersIT extends SlingOptionsTestSupport {
+
+ @Configuration
+ public Option[] configuration() {
+ return new Option[]{
+ baseConfiguration(),
+ testcontainers()
+ };
+ }
+
+ @Test
+ public void test() {
+ }
+
+}