Commit 3c3e352a authored by acoburn's avatar acoburn
Browse files

add integration tests

parent b0e87a68
......@@ -16,6 +16,7 @@ by making available a REST-based HTTP interface. The intention is that these ext
* [`acrepo-exts-fits`](acrepo-exts-fits): This service will return FITS information associated with a Fedora Binary, in XML format
* [`acrepo-exts-image`](acrepo-exts-image): An image manipulation service
* [`acrepo-exts-ldpath`](acrepo-exts-ldpath): This module extends `fcrepo-ldpath` to support additional Linked Data endpoints (e.g. Getty)
* [`acrepo-exts-ore`](acrepo-exts-ore): This constructs a complete ORE Aggregation graph for Fedora resources
* [`acrepo-exts-pcdm`](acrepo-exts-pcdm): This constructs a complete PCDM object graph for Fedora resources
* [`acrepo-exts-serialize-xml`](acrepo-exts-serialize-xml): This service translates Fedora RDF documents into MODS/XML or DC/XML
* [`acrepo-exts-template`](acrepo-exts-template): A module for converting Fedora resources into some other form, using a [mustache](https://mustache.github.io/) template.
......@@ -27,6 +28,7 @@ These modules provide particular services, independent of Fedora Resources.
* [`acrepo-services-inference`](acrepo-services-inference): An OSGi-based structural typing service using owl inference
* [`acrepo-services-mint`](acrepo-services-mint): This mints random (public) URIs for use with Fedora resources
* [`acrepo-services-ore`](acrepo-services-ore): This makes it easy to work with ORE aggregations
* [`acrepo-services-pcdm`](acrepo-services-pcdm): This makes it easy to work with PCDM objects
Connectors
......@@ -79,12 +81,14 @@ command from its shell:
feature:install acrepo-exts-fits
feature:install acrepo-exts-image
feature:install acrepo-exts-ldpath
feature:install acrepo-exts-ore
feature:install acrepo-exts-pcdm
feature:install acrepo-exts-serialize-xml
feature:install acrepo-exts-template
feature:install acrepo-services-inference
feature:install acrepo-services-mint
feature:install acrepo-services-ore
feature:install acrepo-services-pcdm
More information
......
......@@ -50,9 +50,11 @@ dependencies {
testCompile project(':acrepo-connector-idiomatic-pgsql')
testCompile project(':acrepo-services-inference')
testCompile project(':acrepo-services-mint')
testCompile project(':acrepo-services-ore')
testCompile project(':acrepo-services-pcdm')
testCompile project(':acrepo-exts-fits')
testCompile project(':acrepo-exts-image')
testCompile project(':acrepo-exts-ore')
testCompile project(':acrepo-exts-pcdm')
testCompile project(':acrepo-exts-serialize-xml')
testCompile project(':acrepo-exts-template')
......@@ -137,6 +139,7 @@ test {
systemProperty 'karaf.rmiRegistry.port', randomPort()
systemProperty 'karaf.template.port', randomPort()
systemProperty 'karaf.metadata.port', randomPort()
systemProperty 'karaf.ore.port', randomPort()
systemProperty 'karaf.pcdm.port', randomPort()
systemProperty 'karaf.image.port', randomPort()
systemProperty 'karaf.idiomatic.port', randomPort()
......
/*
* Copyright 2016 Amherst College
*
* Licensed 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 edu.amherst.acdc.itests;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.jena.rdf.model.ModelFactory.createDefaultModel;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.Set;
import org.apache.camel.CamelContext;
import org.apache.jena.rdf.model.Model;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.ConfigurationManager;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.slf4j.Logger;
/**
* @author Aaron Coburn
* @since May 2, 2016
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class AcrepoOreIT extends AbstractOSGiIT {
private static Logger LOGGER = getLogger(AcrepoOreIT.class);
@Configuration
public Option[] config() {
final ConfigurationManager cm = new ConfigurationManager();
final String fcrepoPort = cm.getProperty("fcrepo.dynamic.test.port");
final String oreExtPort = cm.getProperty("karaf.ore.port");
final String rmiRegistryPort = cm.getProperty("karaf.rmiRegistry.port");
final String rmiServerPort = cm.getProperty("karaf.rmiServer.port");
final String fcrepoBaseUrl = "http://localhost:" + fcrepoPort + "/fcrepo/rest";
final String sshPort = cm.getProperty("karaf.ssh.port");
return new Option[] {
karafDistributionConfiguration()
.frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
.version(cm.getProperty("karaf.version")).type("zip"))
.unpackDirectory(new File("build", "exam"))
.useDeployFolder(false),
logLevel(LogLevel.INFO),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
features(maven().groupId("org.apache.karaf.features").artifactId("standard")
.versionAsInProject().classifier("features").type("xml"), "scr"),
features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("org.fcrepo.camel").artifactId("fcrepo-camel")
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(),
"acrepo-exts-ore"),
systemProperty("karaf.ore.port").value(oreExtPort),
systemProperty("fcrepo.port").value(fcrepoPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort),
editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ore.cfg", "fcrepo.baseUrl", fcrepoBaseUrl),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ore.cfg", "rest.port", oreExtPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ore.cfg", "extension.load", "false")
};
}
@Test
public void testInstallation() throws Exception {
assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-core")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("fcrepo-camel")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-ore")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ore")));
}
@Test
public void testOptions() throws Exception {
// make sure that the camel context has started up.
final CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.name=AcrepoExtOre)",
10000);
assertNotNull(ctx);
final String baseUrl = "http://localhost:" + System.getProperty("fcrepo.port") + "/fcrepo/rest";
final String baseSvcUrl = "http://localhost:" + System.getProperty("karaf.ore.port") + "/ore";
assertTrue(options(baseSvcUrl).contains("apix:bindsTo ldp:RDFSource"));
}
@Test
public void testOreObjectTurtle() throws Exception {
// make sure that the camel context has started up.
final CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.name=AcrepoExtOre)",
10000);
assertNotNull(ctx);
final String baseUrl = "http://localhost:" + System.getProperty("fcrepo.port") + "/fcrepo/rest";
final String baseSvcUrl = "http://localhost:" + System.getProperty("karaf.ore.port") + "/ore";
final String oreObj = post(baseUrl, getClass().getResourceAsStream("/aggregation.ttl"), "text/turtle");
final String members = oreObj + "/members";
assertTrue(put(members, getClass().getResourceAsStream("/directcontainer.ttl"), "text/turtle"));
final String page1 = post(members);
final String page2 = post(members);
final String page3 = post(members);
final String page4 = post(members);
final String response = get(baseSvcUrl + "?context=" + oreObj);
final InputStream input = new ByteArrayInputStream(response.getBytes(UTF_8));
final Model model = createDefaultModel();
model.read(input, null, "TTL");
final Set<String> subjects = model.listSubjects().mapWith(x -> x.getURI()).toSet();
assertTrue(subjects.contains(oreObj));
assertTrue(subjects.contains(page1));
assertTrue(subjects.contains(page2));
assertTrue(subjects.contains(page3));
assertTrue(subjects.contains(page4));
assertFalse(subjects.contains(members));
}
@Test
public void testOreJsonLD() throws Exception {
// make sure that the camel context has started up.
final CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.name=AcrepoExtOre)",
10000);
assertNotNull(ctx);
final String baseUrl = "http://localhost:" + System.getProperty("fcrepo.port") + "/fcrepo/rest";
final String baseSvcUrl = "http://localhost:" + System.getProperty("karaf.ore.port") + "/ore";
final String oreObj = post(baseUrl, getClass().getResourceAsStream("/aggregation.ttl"), "text/turtle");
final String members = oreObj + "/members";
assertTrue(put(members, getClass().getResourceAsStream("/directcontainer.ttl"), "text/turtle"));
final String page1 = post(members);
final String page2 = post(members);
final String page3 = post(members);
final String page4 = post(members);
final String response = get(baseSvcUrl + "?context=" + oreObj, "application/ld+json");
final InputStream input = new ByteArrayInputStream(response.getBytes(UTF_8));
final Model model = createDefaultModel();
model.read(input, null, "JSONLD");
final Set<String> subjects = model.listSubjects().mapWith(x -> x.getURI()).toSet();
assertTrue(subjects.contains(oreObj));
assertTrue(subjects.contains(page1));
assertTrue(subjects.contains(page2));
assertTrue(subjects.contains(page3));
assertTrue(subjects.contains(page4));
assertFalse(subjects.contains(members));
}
}
......@@ -57,6 +57,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
final String idiomaticPort = cm.getProperty("karaf.idiomatic.port");
final String metadataPort = cm.getProperty("karaf.metadata.port");
final String templatePort = cm.getProperty("karaf.template.port");
final String orePort = cm.getProperty("karaf.ore.port");
final String pcdmPort = cm.getProperty("karaf.pcdm.port");
final String imagePort = cm.getProperty("karaf.image.port");
final String ldpathPort = cm.getProperty("karaf.ldpath.port");
......@@ -91,6 +92,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
"acrepo-exts-fits",
"acrepo-exts-image",
"acrepo-exts-ldpath",
"acrepo-exts-ore",
"acrepo-exts-pcdm",
"acrepo-exts-serialize-xml",
"acrepo-exts-template",
......@@ -101,6 +103,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
"acrepo-services-inference",
"acrepo-services-mint",
"acrepo-services-ore",
"acrepo-services-pcdm"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.fits.cfg", "rest.port", fitsPort),
......@@ -109,6 +112,8 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
editConfigurationFilePut("etc/edu.amherst.acdc.exts.image.cfg", "extension.load", "false"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ldpath.cfg", "rest.port", ldpathPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ldpath.cfg", "extension.load", "false"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ore.cfg", "rest.port", orePort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.ore.cfg", "extension.load", "false"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.pcdm.cfg", "rest.port", pcdmPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.pcdm.cfg", "extension.load", "false"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.serialize.xml.cfg", "rest.port", metadataPort),
......@@ -131,6 +136,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-fits")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-image")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-ldpath")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-ore")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-pcdm")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-serialize-xml")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-template")));
......@@ -139,6 +145,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-inference")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-mint")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ore")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-pcdm")));
}
}
@prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
@prefix ore: <http://www.openarchives.org/ore/terms/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
<> a ldp:Container ;
skos:prefLabel "Manuscript Title" ;
skos:note "This is a sample manuscript record" ;
dc:identifier "Amherst Manuscript # 681" ;
dcterms:extent "1 volume (420 pages): photographs" ;
dcterms:tableOfContents "First this, then that" ;
dcterms:isPartOf <http://acdc.amherst.edu/> ;
dcterms:rights <http://rightsstatements.org/vocab/NKC/1.0/> ;
dcterms:identifier <doi:123456/12> , <http://acdc.amherst.edu/id/abcdefg> ;
dcterms:created "2001-02-03"^^<http://id.loc.gov/datatypes/edtf/EDTF> ;
dcterms:language <http://id.loc.gov/vocabulary/iso639-2/eng> ;
dcterms:abstract "This is a textual description of the manuscript" ;
dcterms:medium "Pen and ink on linen" ;
dcterms:type <http://id.loc.gov/vocabulary/resourceTypes/txt> , <http://purl.org/dc/dcmitype/StillImage> , <http://vocab.getty.edu/aat/30002491> ;
bf:descriptionLanguage <http://id.loc.gov/vocabulary/iso639-2/eng> ;
bf:heldBy <http://acdc.amherst.edu/> .
@prefix ore: <http://www.openarchives.org/ore/terms/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
<> a ldp:DirectContainer ;
ldp:membershipResource <.> ;
ldp:hasMemberRelation ore:aggregates .
......@@ -76,8 +76,23 @@
<configfile finalname="/etc/edu.amherst.acdc.exts.ldpath.cfg">mvn:edu.amherst.acdc/acrepo-exts-ldpath/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-exts-ore" version="${project.version}">
<details>Installs the ORE extension</details>
<feature version="${camelVersionRange}">camel</feature>
<feature version="${camelVersionRange}">camel-blueprint</feature>
<feature version="${camelVersionRange}">camel-jetty9</feature>
<feature version="${fcrepoCamelVersionRange}">fcrepo-camel</feature>
<feature version="${project.version}">acrepo-services-ore</feature>
<feature version="${project.version}">acrepo-libs-jena</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-exts-ore/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.exts.ore.cfg">mvn:edu.amherst.acdc/acrepo-exts-ore/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-exts-pcdm" version="${project.version}">
<details>Installs the image service</details>
<details>Installs the PCDM extension</details>
<feature version="${camelVersionRange}">camel</feature>
<feature version="${camelVersionRange}">camel-blueprint</feature>
......@@ -101,6 +116,14 @@
<configfile finalname="/etc/edu.amherst.acdc.services.mint.cfg">mvn:edu.amherst.acdc/acrepo-services-mint/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-ore" version="${project.version}">
<details>Installs the ORE Resource service</details>
<feature version="${project.version}">acrepo-libs-jena</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-services-ore/${project.version}</bundle>
</feature>
<feature name="acrepo-services-pcdm" version="${project.version}">
<details>Installs the PCDM Resource service</details>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment