Java Code Examples for org.eclipse.rdf4j.repository.RepositoryConnection#getRepository()

The following examples show how to use org.eclipse.rdf4j.repository.RepositoryConnection#getRepository() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testGraphQuery() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub() {

		@Override
		public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI)
				throws MalformedQueryException, RepositoryException {
			assertEquals(SPARQL, ql);
			assertEquals(queryString, query);
			return new GraphQueryStub() {

				@Override
				public void setDataset(Dataset dataset) {
					Set<IRI> contexts = Collections.singleton(context);
					assertEquals(contexts, dataset.getDefaultGraphs());
					super.setDataset(dataset);
				}
			};
		}
	};
	Repository repo = stub.getRepository();
	ContextAwareConnection con = new ContextAwareConnection(repo, stub);
	con.setReadContexts(context);
	con.setQueryLanguage(SERQL);
	con.prepareGraphQuery(SPARQL, queryString, null);
}
 
Example 2
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testQuery() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub() {

		@Override
		public Query prepareQuery(QueryLanguage ql, String query, String baseURI)
				throws MalformedQueryException, RepositoryException {
			assertEquals(SPARQL, ql);
			assertEquals(queryString, query);
			return new QueryStub() {

				@Override
				public void setDataset(Dataset dataset) {
					Set<IRI> contexts = Collections.singleton(context);
					assertEquals(contexts, dataset.getDefaultGraphs());
					super.setDataset(dataset);
				}
			};
		}
	};
	Repository repo = stub.getRepository();
	ContextAwareConnection con = new ContextAwareConnection(repo, stub);
	con.setReadContexts(context);
	con.setQueryLanguage(SERQL);
	con.prepareQuery(SPARQL, queryString, null);
}
 
Example 3
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testTupleQuery() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub() {

		@Override
		public TupleQuery prepareTupleQuery(QueryLanguage ql, String query, String baseURI)
				throws MalformedQueryException, RepositoryException {
			assertEquals(SPARQL, ql);
			assertEquals(queryString, query);
			return new TupleQueryStub() {

				@Override
				public void setDataset(Dataset dataset) {
					Set<IRI> contexts = Collections.singleton(context);
					assertEquals(contexts, dataset.getDefaultGraphs());
					super.setDataset(dataset);
				}
			};
		}
	};
	Repository repo = stub.getRepository();
	ContextAwareConnection con = new ContextAwareConnection(repo, stub);
	con.setReadContexts(context);
	con.setQueryLanguage(SERQL);
	con.prepareTupleQuery(SPARQL, queryString, null);
}
 
Example 4
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testIncludeInferred() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setIncludeInferred(true);
	assertTrue(b.isIncludeInferred());
	assertTrue(a.isIncludeInferred());
}
 
Example 5
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testMaxQueryTime() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setMaxQueryTime(1);
	assertEquals(1, b.getMaxQueryTime());
	assertEquals(1, a.getMaxQueryTime());
}
 
Example 6
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testQueryLanguage() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setQueryLanguage(QueryLanguage.SERQL);
	assertEquals(QueryLanguage.SERQL, b.getQueryLanguage());
	assertEquals(QueryLanguage.SERQL, a.getQueryLanguage());
}
 
Example 7
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testBaseURI() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setBaseURI("http://example.com/");
	assertEquals("http://example.com/", b.getBaseURI());
	assertEquals("http://example.com/", a.getBaseURI());
}
 
Example 8
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testReadContexts() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setReadContexts(context);
	assertEquals(context, b.getReadContexts()[0]);
	assertEquals(context, a.getReadContexts()[0]);
}
 
Example 9
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testRemoveContexts() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setRemoveContexts(context);
	assertEquals(context, b.getRemoveContexts()[0]);
	assertEquals(context, a.getRemoveContexts()[0]);
}
 
Example 10
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testAddContexts() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setAddContexts(context);
	assertEquals(context, b.getAddContexts()[0]);
	assertEquals(context, a.getAddContexts()[0]);
}
 
Example 11
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testArchiveContexts() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setArchiveContexts(context);
	assertEquals(context, b.getArchiveContexts()[0]);
	assertEquals(context, a.getArchiveContexts()[0]);
}
 
Example 12
Source File: ContextAwareConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testInsertContexts() throws Exception {
	RepositoryConnection stub = new RepositoryConnectionStub();
	Repository repo = stub.getRepository();
	ContextAwareConnection a = new ContextAwareConnection(repo, stub);
	ContextAwareConnection b = new ContextAwareConnection(repo, a);
	b.setInsertContext(context);
	assertEquals(context, b.getInsertContext());
	assertEquals(context, a.getInsertContext());
}
 
Example 13
Source File: ContextAwareConnection.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public ContextAwareConnection(RepositoryConnection connection) throws RepositoryException {
	this(connection.getRepository(), connection);
}