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

bdelacretaz pushed a commit to branch SLING-10216/verify-its
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 2d705b6b2aceee77304ed720d76b0e7eb15581cb
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Tue Mar 16 11:17:26 2021 +0100

    SLING-10216 - fix ITs for Java 11
---
 src/it/annotations-it/pom.xml                      | 17 +++++-
 .../annotations/AnnotationsTestSupport.java        | 64 ++++++----------------
 2 files changed, 33 insertions(+), 48 deletions(-)

diff --git a/src/it/annotations-it/pom.xml b/src/it/annotations-it/pom.xml
index 2c3e253..6aed5a6 100644
--- a/src/it/annotations-it/pom.xml
+++ b/src/it/annotations-it/pom.xml
@@ -57,6 +57,9 @@
                     </execution>
                 </executions>
                 <configuration>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                    <!-- pax exam bug, often times out at exit -->
+                    
<forkedProcessExitTimeoutInSeconds>1</forkedProcessExitTimeoutInSeconds>
                     <systemPropertyVariables>
                         <bundle.filename>${bundle.filename}</bundle.filename>
                         <pax.vm.options>${pax.vm.options}</pax.vm.options>
@@ -155,7 +158,19 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.paxexam</artifactId>
-            <version>3.1.0</version>
+            <version>4.0.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-api</artifactId>
+            <version>2.0.6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-logback</artifactId>
+            <version>2.0.6</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
 
b/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
index 49137b9..8ea94ae 100644
--- 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
+++ 
b/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
@@ -17,59 +17,37 @@
 package org.apache.sling.servlets.annotations;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.servlets.annotations.services.PathBoundService;
 import org.apache.sling.testing.clients.osgi.OsgiConsoleClient;
 import org.apache.sling.testing.paxexam.TestSupport;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
+import org.junit.BeforeClass;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExamServer;
 import org.ops4j.pax.exam.options.extra.VMOption;
 
-import static org.apache.sling.testing.paxexam.SlingOptions.logback;
+import org.apache.sling.servlets.annotations.services.PathBoundService;
+
 import static 
org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
-import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
+import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.net.URI;
-import java.net.ServerSocket;
 
 public class AnnotationsTestSupport extends TestSupport {
 
-    private final static int STARTUP_WAIT_SECONDS = 30;
-
+    private final static int STARTUP_WAIT_SECONDS = 60;
     protected static OsgiConsoleClient CLIENT;
-    protected static int httpPort;
+    protected static int httpPort = findFreePort();
 
     @ClassRule
-    public static PaxExamServer serverRule = new PaxExamServer() {
-        @Override
-        protected void before() throws Exception {
-            // Use a different port for each OSGi framework instance
-            // that's started - they can overlap if the previous one
-            // is not fully stopped when the next one starts.
-            setHttpPort();
-            super.before();
-        }
-    };
-
-    /** TODO this duplicates TestSupport.findFreePort, which is not static */
-    static void setHttpPort() {
-        try {
-            final ServerSocket serverSocket = new ServerSocket(0);
-            httpPort = serverSocket.getLocalPort();
-            serverSocket.close();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
+    public static PaxExamServer serverRule = new PaxExamServer();
 
     @Configuration
     public Option[] configuration() throws Exception {
-
         final String vmOpt = System.getProperty("pax.vm.options");
         VMOption vmOption = null;
         if (StringUtils.isNotEmpty(vmOpt)) {
@@ -82,29 +60,21 @@ public class AnnotationsTestSupport extends TestSupport {
             jacocoCommand = new VMOption(jacocoOpt);
         }
 
-        final String workingDirectory = workingDirectory();
-
-        return composite(
-            // TODO not sure why the below list of bundles is different from
-            // running tests with PaxExam.class - but this setup works
-            //super.baseConfiguration(),
-
+        return options(
             when(vmOption != null).useOptions(vmOption),
             when(jacocoCommand != null).useOptions(jacocoCommand),
 
             // For some reason, Jetty starts first on port 8080 without this
             
systemProperty("org.osgi.service.http.port").value(String.valueOf(httpPort)),
 
-            slingQuickstartOakTar(workingDirectory, httpPort),
-            testBundle("bundle.filename"),
+            serverBaseConfiguration(),
+            slingQuickstartOakTar(workingDirectory(), httpPort),
 
-            logback(),
-            
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.log").version("1.2.4"),
-            
mavenBundle().groupId("log4j").artifactId("log4j").version("1.2.17"),
-            
mavenBundle().groupId("org.apache.aries.spifly").artifactId("org.apache.aries.spifly.dynamic.framework.extension").version("1.3.2"),
-            
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version("2.1.0")
-            
-        ).getOptions();
+            testBundle("bundle.filename"),
+            
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version(versionResolver),
+            
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").versionAsInProject(),
+            
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-logback").versionAsInProject()
+        );
     }
 
     @BeforeClass
@@ -120,4 +90,4 @@ public class AnnotationsTestSupport extends TestSupport {
             Thread.sleep(100);
         }
     }
-}
+}
\ No newline at end of file

Reply via email to