use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestTextIndexLuceneAssembler method testLiteralDirectory.
@Test
public void testLiteralDirectory() {
TextIndexLuceneAssembler assembler = new TextIndexLuceneAssembler();
Resource root = SIMPLE_INDEX_SPEC_LITERAL_DIR;
Assembler a = Assembler.general;
// the open method is not supposed to throw exceptions when the directory is
// a literal
TextIndexLucene index = (TextIndexLucene) assembler.open(a, root, /*mode*/
null);
try {
assertNotNull(index);
} finally {
index.close();
}
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestTextIndexLuceneAssembler method testMemDirectory.
@Test
public void testMemDirectory() {
TextIndexLuceneAssembler assembler = new TextIndexLuceneAssembler();
Resource root = SIMPLE_INDEX_SPEC_MEM_DIR;
Assembler a = Assembler.general;
// the open method is not supposed to throw exceptions when the directory is
// a iri resource
TextIndexLucene index = (TextIndexLucene) assembler.open(a, root, /*mode*/
null);
try {
assertTrue(index.getDirectory() instanceof RAMDirectory);
} finally {
index.close();
}
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestInMemDatasetAssembler method directDataLinkForDefaultAndNamedGraphs.
@Test
public void directDataLinkForDefaultAndNamedGraphs() throws IOException {
// first make a file of triples to load later
final Model model = createDefaultModel();
final Path triples = createTempFile("simpleExample", ".nt");
final Resource triplesURI = model.createResource(triples.toFile().toURI().toString());
final Resource simpleExample = model.createResource("test:simpleExample");
simpleExample.addProperty(type, DatasetAssemblerVocab.tDatasetTxnMem);
// add a default graph
simpleExample.addProperty(data, triplesURI);
// add a named graph
final Resource namedGraphDef = model.createResource("test:namedGraphDef");
simpleExample.addProperty(pNamedGraph, namedGraphDef);
final Resource namedGraphName = model.createResource("test:namedGraphExample");
namedGraphDef.addProperty(type, MemoryModel);
namedGraphDef.addProperty(pGraphName, namedGraphName);
namedGraphDef.addProperty(data, triplesURI);
try (OutputStream out = new FileOutputStream(triples.toFile())) {
write(out, model, NTRIPLES);
}
final Dataset dataset = assemble(simpleExample);
final Model assembledDefaultModel = dataset.getDefaultModel();
final Model assembledNamedModel = dataset.getNamedModel(namedGraphName.getURI());
// we put the same triples in each model, so we check for the same triples in each model
for (final Model m : new Model[] { assembledDefaultModel, assembledNamedModel }) {
assertTrue(m.contains(simpleExample, pNamedGraph, namedGraphDef));
assertTrue(m.contains(namedGraphDef, pGraphName, namedGraphName));
assertTrue(m.contains(simpleExample, data, triplesURI));
}
final Iterator<Node> graphNodes = dataset.asDatasetGraph().listGraphNodes();
assertTrue(graphNodes.hasNext());
assertEquals(namedGraphName.asNode(), graphNodes.next());
assertFalse(graphNodes.hasNext());
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestInMemDatasetAssembler method wrongKindOfAssemblerDefinition.
@Test(expected = CannotConstructException.class)
public void wrongKindOfAssemblerDefinition() {
final Model model = createDefaultModel();
final Resource badExample = model.createResource("test:badExample");
assemble(badExample);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class rdflangtest method insertMetaOld.
//OLD meta.
static void insertMetaOld(EarlReport report) {
Model model = report.getModel();
/*
<> foaf:primaryTopic <http://jena.apache.org/#riot> ;
dc:issued "..."^^xsd:dateTime;
foaf:maker who.
*/
// Update the EARL report.
Resource jena = model.createResource().addProperty(FOAF.homepage, model.createResource("http://jena.apache.org/"));
// ARQ is part of Jena.
Resource arq = report.getSystem().addProperty(DCTerms.isPartOf, jena);
// Andy wrote the test software (updates the thing being tested as well as they are the same).
Resource who = model.createResource(FOAF.Person).addProperty(FOAF.name, "Andy Seaborne").addProperty(FOAF.homepage, model.createResource("http://people.apache.org/~andy"));
Resource reporter = report.getReporter();
reporter.addProperty(DC.creator, who);
Resource system = report.getSystem();
system.addProperty(RDF.type, DOAP.Project);
system.addProperty(DOAP.name, name);
system.addProperty(DOAP.homepage, homepage);
system.addProperty(DOAP.maintainer, who);
Resource release = model.createResource(DOAP.Version);
system.addProperty(DOAP.release, release);
Node today_node = NodeFactoryExtra.todayAsDate();
Literal today = model.createTypedLiteral(today_node.getLiteralLexicalForm(), today_node.getLiteralDatatype());
release.addProperty(DOAP.created, today);
// Again
release.addProperty(DOAP.name, releaseName);
}
Aggregations