use of org.apache.jena.rdf.model.Model in project jena by apache.
the class AbstractCompressedWholeFileTripleInputFormatTests method generateMixedTuples.
@Override
protected final void generateMixedTuples(OutputStream output, int num) throws IOException {
// Write good data
Model m = ModelFactory.createDefaultModel();
Resource currSubj = m.createResource("http://example.org/subjects/0");
Property predicate = m.createProperty("http://example.org/predicate");
for (int i = 0; i < num / 2; i++) {
if (i % 10 == 0) {
currSubj = m.createResource("http://example.org/subjects/" + (i / 10));
}
m.add(currSubj, predicate, m.createTypedLiteral(i));
}
this.writeTuples(m, output);
// Write junk data
byte[] junk = "junk data\n".getBytes(utf8);
for (int i = 0; i < num / 2; i++) {
output.write(junk);
}
output.flush();
output.close();
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestQuery method query_describe_01.
@Test
public void query_describe_01() {
String query = "DESCRIBE ?s WHERE {?s ?p ?o}";
try (QueryExecution qExec = QueryExecutionFactory.sparqlService(serviceQuery(), query)) {
Model result = qExec.execDescribe();
assertFalse(result.isEmpty());
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestQuery method query_construct_02.
@Test
public void query_construct_02() {
String query = " CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}";
try (QueryExecution qExec = QueryExecutionFactory.sparqlService(serviceQuery(), query)) {
Model result = qExec.execConstruct();
assertEquals(1, result.size());
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestQuery method query_describe_conneg.
@Test
public void query_describe_conneg() throws IOException {
try (CloseableHttpClient client = HttpOp.createPoolingHttpClient()) {
String query = "DESCRIBE ?s WHERE {?s ?p ?o}";
for (MediaType type : rdfOfferTest.entries()) {
String contentType = type.toHeaderString();
try (QueryEngineHTTP qExec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery(), query)) {
qExec.setModelContentType(contentType);
qExec.setClient(client);
Model m = qExec.execDescribe();
String x = qExec.getHttpResponseContentType();
assertEquals(contentType, x);
assertFalse(m.isEmpty());
}
}
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestDatasetAccessorHTTP method post_01.
@Test
public void post_01() {
DatasetAccessor du = connectToService();
du.putModel(model1);
// POST appends
du.add(model2);
Model graph = du.getModel();
Model graph3 = ModelFactory.createDefaultModel();
graph3.add(model1);
graph3.add(model2);
assertFalse(graph.isIsomorphicWith(model1));
assertFalse(graph.isIsomorphicWith(model2));
assertTrue(graph.isIsomorphicWith(graph3));
// Empty it.
du.deleteDefault();
graph = du.getModel();
assertTrue(graph.isEmpty());
}
Aggregations