You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2019/12/20 16:26:11 UTC

[sling-org-apache-sling-servlets-resolver] 01/02: SLING-8936 - pax exam testing setup

This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch issue/SLING-8936
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git

commit 2b3dc835169afc09770219b6eed9017c3fc050f9
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Dec 20 15:50:19 2019 +0100

    SLING-8936 - pax exam testing setup
---
 pom.xml                                            | 81 +++++++++++++++++++++-
 .../servlets/resolver/it/DefaultServletIT.java     | 49 +++++++++++++
 .../resolver/it/ServletResolverTestSupport.java    | 40 +++++++++++
 3 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index d9f4507..81c06ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,6 +69,10 @@
                         <Provide-Capability>
                             osgi.extender;osgi.extender="org.apache.sling.servlets.resolver";version:Version="1.0"
                         </Provide-Capability>
+                        <Include-Resource>
+                            <!-- for SLING-7351 -->
+                            META-INF/maven/dependencies.properties=-${project.build.outputDirectory}/META-INF/maven/dependencies.properties,{maven-resources}
+                        </Include-Resource>
                     </instructions>
                 </configuration>
             </plugin>
@@ -104,6 +108,39 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-test</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                    <systemProperties>
+                        <property>
+                        <name>bundle.filename</name>
+                        <value>${basedir}/target/${project.build.finalName}.jar</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <dependencies>
@@ -132,7 +169,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.21.0</version>
+            <version>2.20.0</version>
             <scope>provided</scope>
         </dependency>
         <!-- for ServiceUserMapped (SLING-4312) -->
@@ -219,5 +256,47 @@
             <version>16.0.2</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-cm</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.paxexam</artifactId>
+            <version>3.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>6.0.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/DefaultServletIT.java b/src/test/java/org/apache/sling/servlets/resolver/it/DefaultServletIT.java
new file mode 100644
index 0000000..accf90e
--- /dev/null
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/DefaultServletIT.java
@@ -0,0 +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
+ *
+ *   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.servlets.resolver.it;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.inject.Inject;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.BundleContext;
+
+/** Using the SlingRequestProcessor for testing requests would be
+ *  better, but this module has a number of specific settings
+ *  in its pom for the sling.engine module that I prefer not touching
+ *  now as I'm just adding these tests.
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class DefaultServletIT extends ServletResolverTestSupport {
+    @Inject
+    private BundleContext bundleContext;
+
+    @Test
+    public void testDefaultServlet() {
+        // TODO for now this just tests the pax exam setup
+        assertTrue(bundleContext.getBundles().length > 0);
+    }
+
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java b/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java
new file mode 100644
index 0000000..9cd7084
--- /dev/null
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.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.servlets.resolver.it;
+
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+
+public class ServletResolverTestSupport extends TestSupport {
+    protected final int httpPort = findFreePort();
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[]{
+            baseConfiguration(),
+            slingQuickstartOakTar(workingDirectory(), httpPort),
+            testBundle("bundle.filename"),
+            junitBundles()
+        };
+    }
+}