use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestTransactionLifecycle method transaction_r02.
@Test
public void transaction_r02() {
Dataset ds = create();
ds.begin(ReadWrite.READ);
assertTrue(ds.isInTransaction());
ds.commit();
assertFalse(ds.isInTransaction());
ds.end();
assertFalse(ds.isInTransaction());
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestTransactionLifecycle method transaction_pattern_01.
// Patterns.
@Test
public void transaction_pattern_01() {
Dataset ds = create();
read1(ds);
read1(ds);
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestTransactionLifecycle method transaction_err_nontxn_commit_1.
// Cycle misalignment.
// test : commit
// test : abort
// Permit explain .end() - the case of "end" when not sure: begin...end.end.
@Test(expected = JenaTransactionException.class)
public void transaction_err_nontxn_commit_1() {
Dataset ds = create();
ds.commit();
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class TestInMemDatasetAssembler method emptyDataset.
@Test
public void emptyDataset() {
final Model model = createDefaultModel();
final Resource empty = model.createResource("test:empty");
empty.addProperty(type, DatasetAssemblerVocab.tDatasetTxnMem);
Dataset dataset = assemble(empty);
assertFalse(dataset.asDatasetGraph().find().hasNext());
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class TestInMemDatasetAssembler method directDataLinkToQuads.
@Test
public void directDataLinkToQuads() throws IOException {
// first make a file of quads to load later
final Model model = createDefaultModel();
final Path quads = createTempFile("quadExample", ".nq");
final Resource quadsURI = model.createResource(quads.toFile().toURI().toString());
final Resource simpleExample = model.createResource("test:simpleExample");
simpleExample.addProperty(type, DatasetAssemblerVocab.tDatasetTxnMem);
simpleExample.addProperty(data, quadsURI);
final DatasetGraph dsg = createTxnMem().asDatasetGraph();
model.listStatements().mapWith(Statement::asTriple).mapWith(t -> new Quad(quadsURI.asNode(), t)).forEachRemaining(dsg::add);
try (OutputStream out = new FileOutputStream(quads.toFile())) {
write(out, dsg, NQUADS);
}
final Dataset dataset = assemble(simpleExample);
final Model assembledDefaultModel = dataset.getDefaultModel();
final Model assembledNamedModel = dataset.getNamedModel(quadsURI.getURI());
assertTrue(assembledDefaultModel.isEmpty());
assertTrue(assembledNamedModel.contains(assembledNamedModel.createStatement(simpleExample, data, quadsURI)));
}
Aggregations