This is an automated email from the ASF dual-hosted git repository. olli pushed a commit to branch SLING-9929 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations-it.git
commit 65a06c2aaee54f4365745d9045f9604d03950b87 Author: Oliver Lietz <[email protected]> AuthorDate: Wed Nov 25 22:10:44 2020 +0100 SLING-9929 Use PaxExamServer for HTTP-based integration testing * Use Sling Bundle Parent 40 * Use new base configuration for server mode from Testing PaxExam 4.0.0-SNAPSHOT * Use Pax Logging for OSGi logging --- pom.xml | 21 +++++++++--- .../annotations/AnnotationsTestSupport.java | 39 +++++++--------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 1faad96..4482c0b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,8 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.sling</groupId> - <artifactId>sling</artifactId> - <version>33</version> + <artifactId>sling-bundle-parent</artifactId> + <version>40</version> <relativePath/> </parent> @@ -63,6 +63,7 @@ </execution> </executions> <configuration> + <redirectTestOutputToFile>true</redirectTestOutputToFile> <systemPropertyVariables> <bundle.filename>${bundle.filename}</bundle.filename> <pax.vm.options>${pax.vm.options}</pax.vm.options> @@ -102,7 +103,19 @@ <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> - + <!-- logging --> + <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> <!-- testing dependencies --> <dependency> <groupId>org.apache.sling</groupId> @@ -152,7 +165,7 @@ <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> diff --git a/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java b/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java index f1efd80..d9aeb9d 100644 --- a/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java +++ b/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java @@ -27,9 +27,9 @@ 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 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; @@ -38,7 +38,7 @@ import java.net.URI; public class AnnotationsTestSupport extends TestSupport { - private final static int STARTUP_WAIT_SECONDS = 30; + private final static int STARTUP_WAIT_SECONDS = 60; protected OsgiConsoleClient CLIENT; protected static int httpPort; @@ -46,16 +46,9 @@ public class AnnotationsTestSupport extends TestSupport { @ClassRule public static PaxExamServer serverRule = new PaxExamServer(); - public AnnotationsTestSupport() { - if(httpPort == 0) { - // findFreePort should probably be a static method - httpPort = findFreePort(); - } - } - @Configuration public Option[] configuration() throws Exception { - + httpPort = findFreePort(); final String vmOpt = System.getProperty("pax.vm.options"); VMOption vmOption = null; if (StringUtils.isNotEmpty(vmOpt)) { @@ -68,29 +61,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), + serverBaseConfiguration(), + slingQuickstartOakTar(workingDirectory(), httpPort), testBundle("bundle.filename"), - - 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(); + mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version(versionResolver), + // logging + mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").versionAsInProject(), + mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-logback").versionAsInProject() + ); } @Before
