VIVO-469 run the URL Finders from an RDFService, not an OntModel
This commit is contained in:
parent
5af822f7ab
commit
5d19e746e1
6 changed files with 149 additions and 53 deletions
|
@ -0,0 +1,65 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public class QueryUtilsTest extends AbstractTestClass {
|
||||
private QuerySolutionMap bindings = new QuerySolutionMap();
|
||||
|
||||
@Test
|
||||
public void bindResource() {
|
||||
bindings.add("uri", ResourceFactory.createResource("http://my.uri"));
|
||||
assertBoundQueryEquals("a resource ?uri", "a resource <http://my.uri>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindPlainLiteral() {
|
||||
bindings.add("plain", ResourceFactory.createPlainLiteral("too easy"));
|
||||
assertBoundQueryEquals("This is ?plain ?plain",
|
||||
"This is \"too easy\" \"too easy\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindTypedLiteral() {
|
||||
bindings.add("typed", ResourceFactory.createTypedLiteral(100L));
|
||||
assertBoundQueryEquals("take this ?typed number",
|
||||
"take this \"100\"^^<http://www.w3.org/2001/XMLSchema#long> number");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindLanguageLiteral() {
|
||||
Literal l = ModelFactory.createDefaultModel().createLiteral("Spanish",
|
||||
"es-ES");
|
||||
bindings.add("lang", l);
|
||||
assertBoundQueryEquals("speak my ?lang?", "speak my \"Spanish\"@es-ES?");
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void bindAnon() {
|
||||
fail("bindAnon not implemented");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private void assertBoundQueryEquals(String template, String expected) {
|
||||
String actual = QueryUtils.bindVariables(template, bindings);
|
||||
assertEquals("bounding results", expected, actual);
|
||||
}
|
||||
}
|
|
@ -15,9 +15,13 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
|||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
|
||||
public class AdditionalURIsForObjectPropertiesTest {
|
||||
|
||||
Model model;
|
||||
RDFService rdfService;
|
||||
|
||||
String testNS = "http://example.com/test#";
|
||||
String n3 = "" +
|
||||
|
@ -39,11 +43,12 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
public void setUp() throws Exception {
|
||||
model = ModelFactory.createDefaultModel();
|
||||
model.read(new StringReader(n3 ), null , "N3");
|
||||
rdfService = new RDFServiceModel(model);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeOfRdfsLabel() {
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(model);
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
|
@ -66,7 +71,7 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
@Test
|
||||
public void testChangeOfObjPropStmt() {
|
||||
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(model);
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
|
@ -88,7 +93,7 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
|
||||
@Test
|
||||
public void testOfDataPropChange() {
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(model);
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
|
@ -107,8 +112,9 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
model.read(new StringReader( n3ForNIHVIVO_2902 ), null , "N3");
|
||||
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(model);
|
||||
RDFService rdfService = new RDFServiceModel(model);
|
||||
|
||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue