use of org.eclipse.rdf4j.model.impl.TreeModel in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testRemoveFromSystemRepository.
@Test
public void testRemoveFromSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
con.begin();
con.clear(RepositoryConfigUtil.getContext(con, config.getID()));
con.commit();
}
assertFalse(manager.hasRepositoryConfig(config.getID()));
}
use of org.eclipse.rdf4j.model.impl.TreeModel in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testAddToSystemRepository.
@Test
public void testAddToSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
}
use of org.eclipse.rdf4j.model.impl.TreeModel in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testModifySystemRepository.
@Test
public void testModifySystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setTitle("Changed");
config.export(model, con.getValueFactory().createBNode());
Resource ctx = RepositoryConfigUtil.getContext(con, config.getID());
con.begin();
con.clear(ctx);
con.add(model, ctx == null ? con.getValueFactory().createBNode() : ctx);
con.commit();
}
assertEquals("Changed", manager.getRepositoryConfig(TEST_REPO).getTitle());
}
use of org.eclipse.rdf4j.model.impl.TreeModel in project rdf4j by eclipse.
the class StatementsTest method testMultipleContexts.
@Test
public void testMultipleContexts() {
Resource c1 = vf.createIRI("urn:c1");
Resource c2 = vf.createIRI("urn:c1");
Resource c3 = vf.createIRI("urn:c1");
Model m = Statements.create(vf, FOAF.AGE, RDF.TYPE, RDF.PROPERTY, new TreeModel(), c1, c2, null, c3);
assertFalse(m.isEmpty());
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, (Resource) null));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c1));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c2));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c3));
}
use of org.eclipse.rdf4j.model.impl.TreeModel in project rdf4j by eclipse.
the class RDFCollectionsTest method testRemove.
@Test
public void testRemove() {
Resource head = vf.createBNode();
Model m = RDFCollections.asRDF(values, head, new TreeModel());
// add something to the model that is not part of the RDF collection.
m.add(RDF.TYPE, RDF.TYPE, RDF.PROPERTY);
// remove the entire collection
RDFCollections.extract(m, head, st -> m.remove(st));
assertFalse(m.contains(null, RDF.FIRST, a));
assertFalse(m.contains(null, RDF.FIRST, b));
assertFalse(m.contains(null, RDF.FIRST, c));
assertFalse(m.contains(head, null, null));
assertTrue(m.contains(RDF.TYPE, RDF.TYPE, RDF.PROPERTY));
}
Aggregations