Commit 31ac850e authored by acoburn's avatar acoburn
Browse files

Gradle-based integration tests with pax-exam

parent f45aad60
......@@ -56,9 +56,13 @@ sets of related bundles in an OSGi container.
Building
--------
To build this project use
To build, test and install this project use either
./gradlew build
gradle check install
or (in the top level directory):
./gradlew check install
Deploying in OSGi
-----------------
......
......@@ -8,7 +8,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -18,7 +18,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -9,7 +9,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -21,7 +21,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -9,7 +9,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -11,7 +11,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -19,7 +19,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -3,7 +3,7 @@ rest.port=9104
rest.host=localhost
# The fedora baseUrl
fcrepo.baseUrl=localhost:8080/fcrepo/rest
fcrepo.baseUrl=http://localhost:8080/fcrepo/rest
# The location of the XSLT to convert RDF/XML to MODS/XML and DC/XML
mods.xslt=edu/amherst/acdc/exts/serialize/xml/rdf2mods.xsl
......
......@@ -14,7 +14,7 @@
<cm:property name="rest.host" value="localhost"/>
<cm:property name="mods.xslt" value="edu/amherst/acdc/exts/serialize/xml/rdf2mods.xsl"/>
<cm:property name="dc.xslt" value="edu/amherst/acdc/exts/serialize/xml/rdf2dc.xsl"/>
<cm:property name="fcrepo.baseUrl" value="localhost:8080/fcrepo/rest"/>
<cm:property name="fcrepo.baseUrl" value="http://localhost:8080/fcrepo/rest"/>
</cm:default-properties>
</cm:property-placeholder>
......
......@@ -17,7 +17,7 @@ Building
To build this project use
mvn install
gradle install
Deploying in OSGi
-----------------
......
......@@ -4,3 +4,4 @@ Integration Test Suite
This module contains a set of integration tests, running the various services
in an OSGi container along side Fedora. This tests these artifacts in Karaf 4.x.
gradle farmIntegrationTest
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.4.0'
}
}
apply plugin: 'org.akhikhl.gretty'
description = """OSGi Integration tests for repository services"""
def randomPort() {
try {
ServerSocket server = new ServerSocket()
server.setReuseAddress(true)
server.bind(new InetSocketAddress(0))
int port = server.getLocalPort()
server.close()
return port
} catch (IOException e) {
throw new IOException('Failed to find random free port', e)
}
}
repositories {
jcenter()
mavenLocal()
mavenCentral()
}
configurations {
karafDistro {
description = 'Configuration used to isolate the dependency on the Karaf distro'
transitive = false
}
}
ext {
fcrepoWebPort = randomPort()
fcrepoJmsPort = randomPort()
fcrepoStompPort = randomPort()
}
dependencies {
testCompile project(':acrepo-connector-broadcast')
testCompile project(':acrepo-connector-idiomatic')
testCompile project(':acrepo-connector-idiomatic-pgsql')
testCompile project(':acrepo-services-activemq')
testCompile project(':acrepo-services-inference')
testCompile project(':acrepo-services-jsonld')
testCompile project(':acrepo-services-ldcache-file')
testCompile project(':acrepo-services-ldcache')
testCompile project(':acrepo-services-mint')
testCompile project(':acrepo-services-pcdm')
testCompile project(':acrepo-exts-jsonld')
testCompile project(':acrepo-exts-fits')
testCompile project(':acrepo-exts-image')
testCompile project(':acrepo-exts-pcdm')
testCompile project(':acrepo-exts-serialize-xml')
testCompile project(':acrepo-exts-template')
testCompile project(':acrepo-karaf')
testCompile group: 'org.osgi', name: 'org.osgi.core', version: osgiVersion
testCompile group: 'org.osgi', name: 'org.osgi.compendium', version: osgiVersion
testCompile group: 'org.apache.jena', name: 'jena-osgi', version: jenaVersion
testCompile group: 'org.glassfish.hk2.external', name: 'javax.inject', version: hk2Version
testCompile group: 'org.apache.httpcomponents', name: 'httpclient-osgi', version: httpclientVersion
testCompile group: 'org.apache.httpcomponents', name: 'httpcore-osgi', version: httpcoreVersion
testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam', version: paxExamVersion
testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-junit4', version: paxExamVersion
testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-container-karaf', version: paxExamVersion
testCompile group: 'org.apache.karaf.features', name: 'org.apache.karaf.features.core', version: karafVersion
testCompile(group: 'org.fcrepo.camel', name: 'fcrepo-camel', version: fcrepoCamelVersion) {
exclude(module: 'slf4j-log4j12')
}
testCompile group: 'org.apache.camel.karaf', name: 'apache-camel', version: camelVersion, classifier:'features', ext: 'xml'
testCompile group: 'org.apache.activemq', name: 'activemq-karaf', version: activemqVersion, classifier:'features', ext: 'xml'
testCompile group: 'org.apache.karaf.features', name: 'standard', version: karafVersion, classifier:'features', ext: 'xml'
karafDistro group: 'org.apache.karaf', name: 'apache-karaf', version: karafVersion, ext: 'zip'
}
task generateDependsFile {
// This is useful for the org.ops4j.pax.exam.CoreOptions.maven() stuff
File outputFileDir = project.file( 'build/classes/test/META-INF/maven/' )
File outputFile = new File( outputFileDir, 'dependencies.properties' )
outputs.file outputFile
doFirst {
outputFileDir.mkdirs()
Properties properties = new Properties();
// first we add our GAV info
properties.setProperty( "groupId", "${project.group}" );
properties.setProperty( "artifactId", project.name );
properties.setProperty( "version", "${project.version}" );
properties.setProperty( "${project.group}/${project.name}/version", "${project.version}" );
// then for all our deps
project.configurations.testRuntime.resolvedConfiguration.resolvedArtifacts.each {
final String keyBase = it.moduleVersion.id.group + '/' + it.moduleVersion.id.name;
properties.setProperty( "${keyBase}/scope", "compile" )
properties.setProperty( "${keyBase}/type", it.extension )
properties.setProperty( "${keyBase}/version", it.moduleVersion.id.version )
}
FileOutputStream outputStream = new FileOutputStream( outputFile );
try {
properties.store( outputStream, "Generated from Gradle for PaxExam testing" )
}
finally {
outputStream.close()
}
}
}
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
task integrationTest(type: Test) {
systemProperty 'fcrepo.dynamic.test.port', fcrepoWebPort
systemProperty 'fcrepo.dynamic.jms.port', fcrepoJmsPort
systemProperty 'fcrepo.dynamic.stomp.port', fcrepoStompPort
}
test {
systemProperty 'karaf.version', karafVersion
systemProperty 'karaf.ssh.port', randomPort()
systemProperty 'karaf.rmiServer.port', randomPort()
systemProperty 'karaf.rmiRegistry.port', randomPort()
systemProperty 'karaf.template.port', randomPort()
systemProperty 'karaf.metadata.port', randomPort()
systemProperty 'karaf.pcdm.port', randomPort()
systemProperty 'karaf.jsonld.port', randomPort()
systemProperty 'karaf.image.port', randomPort()
systemProperty 'karaf.idiomatic.port', randomPort()
systemProperty 'karaf.fits.port', randomPort()
systemProperty 'fcrepo.dynamic.test.port', fcrepoWebPort
systemProperty 'fcrepo.dynamic.jms.port', fcrepoJmsPort
systemProperty 'fcrepo.dynamic.stomp.port', fcrepoStompPort
}
farm {
port = fcrepoWebPort
integrationTestTask = 'integrationTest'
systemProperty 'fcrepo.home', 'build/tmp/fcrepo-data'
systemProperty 'fcrepo.modeshape.configuration', 'classpath:/config/minimal-default/repository.json'
systemProperty 'fcrepo.dynamic.test.port', fcrepoWebPort
systemProperty 'fcrepo.dynamic.jms.port', fcrepoJmsPort
systemProperty 'fcrepo.dynamic.stomp.port', fcrepoStompPort
systemProperty 'FUSEKI_BASE', 'build/fuseki_home'
webapp "org.fcrepo:fcrepo-webapp:${fcrepoVersion}@war", contextPath: '/fcrepo'
webapp "org.apache.jena:jena-fuseki-war:${fusekiVersion}@war", contextPath: '/fuseki'
}
processTestResources.dependsOn copyTestResources
tasks.test.dependsOn tasks.generateDependsFile
project.afterEvaluate {
tasks.test.dependsOn tasks.farmIntegrationTest
tasks.test.mustRunAfter farmBeforeIntegrationTest
tasks.farmAfterIntegrationTest.mustRunAfter tasks.test
}
rootProject.childProjects.findAll { n, p -> p != project }.each { n, p ->
tasks.test.dependsOn p.tasks.publishToMavenLocal
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-parent</artifactId>
<version>4.5.1</version>
</parent>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-itests</artifactId>
<version>1.0.3-SNAPSHOT</version>
<!--<packaging>pom</packaging>-->
<url>https://acdc.amherst.edu/wiki</url>
<inceptionYear>2015</inceptionYear>
<name>Karaf Integration tests for repository services</name>
<description>A collection of repository services for use with Fedora</description>
<organization>
<name>Amherst College</name>
<url>https://www.amherst.edu/</url>
</organization>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<comments>Copyright (c) 2016 Amherst College</comments>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.copyrightYear>2016</project.copyrightYear>
<activemq.version>5.14.0</activemq.version>
<camel.version>2.17.3</camel.version>
<fcrepo-camel.version>4.4.3</fcrepo-camel.version>
<hk2.version>2.4.0</hk2.version>
<junit.version>4.12</junit.version>
<slf4j.version>1.7.21</slf4j.version>
<jena.version>3.1.0</jena.version>
<jackson.version>2.7.5</jackson.version>
<httpclient.version>4.5.2</httpclient.version>
<httpcore.version>4.4.5</httpcore.version>
<!-- plugins -->
<paxexam.plugin.version>1.2.4</paxexam.plugin.version>
<jetty.plugin.version>9.3.8.v20160314</jetty.plugin.version>
<!-- test gear -->
<fcrepo.version>4.5.1</fcrepo.version>
<karaf.version>4.0.5</karaf.version>
<pax-exam.version>4.9.1</pax-exam.version>
<jena.fuseki.version>2.3.1</jena.fuseki.version>
<logback.version>1.1.7</logback.version>
</properties>
<dependencies>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
<version>${fcrepo-camel.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-connector-idiomatic</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-mint</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-jsonld</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-exts-jsonld</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-ldcache-file</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-ldcache</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-activemq</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-karaf</artifactId>
<version>${project.version}</version>
<type>xml</type>
<classifier>features</classifier>
<scope>test</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-osgi</artifactId>
<version>${jena.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
<version>${hk2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<version>${httpclient.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-osgi</artifactId>
<version>${httpcore.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
<version>${pax-exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>${pax-exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<version>${karaf.version}</version>
<type>zip</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.karaf</groupId>
<artifactId>apache-camel</artifactId>
<version>${camel.version}</version>
<type>xml</type>
<classifier>features</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-karaf</artifactId>
<version>${activemq.version}</version>
<type>xml</type>
<classifier>features</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>standard</artifactId>
<version>${karaf.version}</version>
<type>xml</type>
<classifier>features</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<!-- pax exam -->
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>maven-paxexam-plugin</artifactId>
<version>${paxexam.plugin.version}</version>
<executions>
<execution>
<id>generate-config</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
</plugin>
<!-- reserve network ports for integration testing -->
<!-- add configuration file to artifact set for OSGi deployment -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<portNames>
<portName>fcrepo.dynamic.test.port</portName>
<portName>fcrepo.dynamic.jms.port</portName>
<portName>fcrepo.dynamic.stomp.port</portName>
<portName>karaf.fits.port</portName>
<portName>karaf.idiomatic.port</portName>
<portName>karaf.image.port</portName>
<portName>karaf.jsonld.port</portName>
<portName>karaf.metadata.port</portName>
<portName>karaf.pcdm.port</portName>
<portName>karaf.template.port</portName>
<portName>karaf.rmiRegistry.port</portName>
<portName>karaf.rmiServer.port</portName>
<portName>karaf.ssh.port</portName>
<portName>jetty.dynamic.stop.port</portName>
</portNames>
</configuration>
<executions>
<execution>
<id>reserve-port</id>
<phase>package</phase>
<goals>
<goal>reserve-network-port</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- integration testing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m</argLine>
<systemPropertyVariables>
<fcrepo.dynamic.test.port>${fcrepo.dynamic.test.port}</fcrepo.dynamic.test.port>
<fcrepo.dynamic.jms.port>${fcrepo.dynamic.jms.port}</fcrepo.dynamic.jms.port>
<project.build.outputDirectory>${project.build.outputDirectory}</project.build.outputDirectory>
<karaf.fits.port>${karaf.fits.port}</karaf.fits.port>
<karaf.idiomatic.port>${karaf.idiomatic.port}</karaf.idiomatic.port>
<karaf.image.port>${karaf.image.port}</karaf.image.port>
<karaf.jsonld.port>${karaf.jsonld.port}</karaf.jsonld.port>
<karaf.metadata.port>${karaf.metadata.port}</karaf.metadata.port>
<karaf.pcdm.port>${karaf.pcdm.port}</karaf.pcdm.port>
<karaf.template.port>${karaf.template.port}</karaf.template.port>
<karaf.ssh.port>${karaf.ssh.port}</karaf.ssh.port>
<karaf.rmiRegistry.port>${karaf.rmiRegistry.port}</karaf.rmiRegistry.port>
<karaf.rmiServer.port>${karaf.rmiServer.port}</karaf.rmiServer.port>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter</id>
<phase>generate-resources</phase>