Author: olli
Date: Thu Jun 23 21:32:19 2016
New Revision: 1750023
URL: http://svn.apache.org/viewvc?rev=1750023&view=rev
Log:
SLING-5692 Add Integration Tests for Scripting FreeMarker
use Pax Exam Options instead of Karaf Features
Modified:
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/pom.xml
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/src/test/java/org/apache/sling/scripting/freemarker/it/FreemarkerTestSupport.java
Modified:
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/pom.xml?rev=1750023&r1=1750022&r2=1750023&view=diff
==============================================================================
---
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/pom.xml
(original)
+++
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/pom.xml
Thu Jun 23 21:32:19 2016
@@ -39,7 +39,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sling.java.version>7</sling.java.version>
- <org.apache.karaf.version>4.0.5</org.apache.karaf.version>
<org.ops4j.pax.exam.version>4.9.1</org.ops4j.pax.exam.version>
</properties>
@@ -57,19 +56,25 @@
<version>1</version>
<scope>provided</scope>
</dependency>
- <!-- Apache Karaf -->
+ <!-- OSGi -->
<dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>apache-karaf</artifactId>
- <type>tar.gz</type>
- <version>${org.apache.karaf.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.client</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>6.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>6.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- Apache Felix -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>5.4.0</version>
+ <scope>test</scope>
</dependency>
<!-- Apache Sling -->
<dependency>
@@ -82,33 +87,19 @@
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.auth.core</artifactId>
<version>1.3.12</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.engine</artifactId>
<version>2.4.6</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
<version>2.3.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad.karaf-features</artifactId>
- <version>0.1.1-SNAPSHOT</version>
- <type>xml</type>
- <classifier>features</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
-
<artifactId>org.apache.sling.launchpad.karaf-integration-tests</artifactId>
- <version>0.1.1-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -120,21 +111,20 @@
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.freemarker</artifactId>
<version>1.0.0-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
- <!-- bnd -->
<dependency>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- <version>2.4.1</version>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.paxexam</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <!-- javassist -->
+ <!-- -->
<dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.20.0-GA</version>
- <scope>test</scope>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.jaxp-api-1.4</artifactId>
+ <version>2.7.0</version>
+ <scope>provided</scope>
</dependency>
<!-- jsoup -->
<dependency>
@@ -169,7 +159,13 @@
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-karaf</artifactId>
+ <artifactId>pax-exam-cm</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-forked</artifactId>
<version>${org.ops4j.pax.exam.version}</version>
<scope>test</scope>
</dependency>
@@ -179,6 +175,12 @@
<version>${org.ops4j.pax.exam.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified:
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/src/test/java/org/apache/sling/scripting/freemarker/it/FreemarkerTestSupport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/src/test/java/org/apache/sling/scripting/freemarker/it/FreemarkerTestSupport.java?rev=1750023&r1=1750022&r2=1750023&view=diff
==============================================================================
---
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/src/test/java/org/apache/sling/scripting/freemarker/it/FreemarkerTestSupport.java
(original)
+++
sling/trunk/contrib/scripting/org.apache.sling.scripting.freemarker.it/src/test/java/org/apache/sling/scripting/freemarker/it/FreemarkerTestSupport.java
Thu Jun 23 21:32:19 2016
@@ -19,23 +19,40 @@
package org.apache.sling.scripting.freemarker.it;
import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.util.Dictionary;
import javax.inject.Inject;
import javax.script.ScriptEngineFactory;
+import org.apache.sling.api.servlets.ServletResolver;
import org.apache.sling.auth.core.AuthenticationSupport;
import org.apache.sling.engine.SlingRequestProcessor;
-import org.apache.sling.launchpad.karaf.testing.KarafTestSupport;
+import org.apache.sling.testing.paxexam.SlingOptions;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.OptionUtils;
import org.ops4j.pax.exam.util.Filter;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.http.HttpService;
+import static
org.apache.sling.testing.paxexam.SlingOptions.slingExtensionModels;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingJcrOak;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOak;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingScripting;
+import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackage;
import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.keepCaches;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static
org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.CoreOptions.workingDirectory;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
-public abstract class FreemarkerTestSupport extends KarafTestSupport {
+public abstract class FreemarkerTestSupport {
+
+ @Inject
+ protected ServletResolver servletResolver;
@Inject
protected SlingRequestProcessor slingRequestProcessor;
@@ -44,25 +61,74 @@ public abstract class FreemarkerTestSupp
protected AuthenticationSupport authenticationSupport;
@Inject
+ protected HttpService httpService;
+
+ @Inject
@Filter(value = "(names=freemarker)")
protected ScriptEngineFactory scriptEngineFactory;
+ @Inject
+ protected ConfigurationAdmin configurationAdmin;
+
+ protected static synchronized int findFreePort() {
+ try {
+ final ServerSocket serverSocket = new ServerSocket(0);
+ final int port = serverSocket.getLocalPort();
+ serverSocket.close();
+ return port;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected int httpPort() throws IOException {
+ final Dictionary<String, Object> properties =
configurationAdmin.getConfiguration("org.apache.felix.http").getProperties();
+ return
Integer.parseInt(properties.get("org.osgi.service.http.port").toString());
+ }
+
@Configuration
public Option[] configuration() {
+ final String workingDirectory = String.format("target/paxexam/%s",
getClass().getSimpleName());
final String filename = System.getProperty("bundle.filename");
final File file = new File(filename);
- return OptionUtils.combine(baseConfiguration(),
- editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg",
"log4j.rootLogger", "ERROR, out, sift, osgi:*"),
+ return new Option[]{
+ keepCaches(),
+ workingDirectory(workingDirectory),
+ launchpad(workingDirectory),
+ // test app bundle
bundle(file.toURI().toString()),
- addSlingFeatures(
- "sling-launchpad-oak-tar",
- "sling-scripting",
- "sling-extension-models"
- ),
+ // FreeMarker
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.freemarker").versionAsInProject(),
-
mavenBundle().groupId("org.javassist").artifactId("javassist").versionAsInProject(),
+
mavenBundle().groupId("org.apache.servicemix.specs").artifactId("org.apache.servicemix.specs.jaxp-api-1.4").versionAsInProject(),
+ bootDelegationPackage("javax.swing.*"),
+ // testing
mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
-
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject()
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
+ junitBundles()
+ };
+ }
+
+ protected static Option launchpad(final String workingDirectory) {
+ final int httpPort = findFreePort();
+ final String slingHome = String.format("%s/sling", workingDirectory);
+ final String repositoryHome = String.format("%s/repository",
slingHome);
+ final String localIndexDir = String.format("%s/index", repositoryHome);
+ return composite(
+ slingJcrOak(), // TODO if slingJcrOak() is called elsewhere,
ResourceResolverFactory will not be created
+ slingLaunchpadOak(),
+ slingExtensionModels(),
+ slingScripting(),
+ newConfiguration("org.apache.felix.http")
+ .put("org.osgi.service.http.port", httpPort)
+ .asOption(),
+
newConfiguration("org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService")
+ .put("repository.home", repositoryHome)
+ .put("name", "Default NodeStore")
+ .asOption(),
+
newConfiguration("org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProviderService")
+ .put("localIndexDir", localIndexDir)
+ .asOption(),
+
mavenBundle().groupId("org.apache.jackrabbit").artifactId("oak-segment").version(SlingOptions.versionResolver)
);
}