use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestAssemblerGroupTracing method testFail.
public void testFail() {
Resource root = resourceInModel("x rdf:type A");
AssemblerGroup g = AssemblerGroup.create();
g.implementWith(resource("A"), new ShantAssemble());
try {
g.open(root);
fail("shouldn't get past exception");
} catch (AssemblerException e) {
AssemblerGroup.Frame frame = new AssemblerGroup.Frame(resource("x"), resource("A"), ShantAssemble.class);
assertEquals(listOfOne(frame), e.getDoing());
}
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class AbstractWholeFileQuadInputFormatTests method writeGoodTuples.
private void writeGoodTuples(OutputStream output, int num) {
Dataset ds = DatasetFactory.createGeneral();
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; i++) {
if (i % 100 == 0) {
ds.addNamedModel("http://example.org/graphs/" + (i / 100), m);
m = ModelFactory.createDefaultModel();
}
if (i % 10 == 0) {
currSubj = m.createResource("http://example.org/subjects/" + (i / 10));
}
m.add(currSubj, predicate, m.createTypedLiteral(i));
}
if (!m.isEmpty()) {
ds.addNamedModel("http://example.org/graphs/extra", m);
}
this.writeTuples(ds, output);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class AbstractCompressedWholeFileQuadInputFormatTests method writeGoodTuples.
private void writeGoodTuples(OutputStream output, int num) {
Dataset ds = DatasetFactory.createGeneral();
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; i++) {
if (i % 100 == 0) {
ds.addNamedModel("http://example.org/graphs/" + (i / 100), m);
m = ModelFactory.createDefaultModel();
}
if (i % 10 == 0) {
currSubj = m.createResource("http://example.org/subjects/" + (i / 10));
}
m.add(currSubj, predicate, m.createTypedLiteral(i));
}
if (!m.isEmpty()) {
ds.addNamedModel("http://example.org/graphs/extra", m);
}
this.writeTuples(ds, output);
}
use of org.apache.jena.rdf.model.Resource 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.Resource in project jena by apache.
the class TestContainers method testCanAsContainer.
public void testCanAsContainer() {
final String seqUri = "http://example.com/#seq";
model.createSeq(seqUri);
final Resource res = model.createResource(seqUri);
Assert.assertTrue(res.canAs(Seq.class));
Assert.assertTrue(res.canAs(Container.class));
}
Aggregations