org.eclipse.rdf4j.repository.sail.SailRepository Java Examples

The following examples show how to use org.eclipse.rdf4j.repository.sail.SailRepository. 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: TransactionsPerSecondForceSyncBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Setup(Level.Iteration)
public void beforeClass() {
	if (connection != null) {
		connection.close();
		connection = null;
	}
	i = 0;
	file = Files.newTemporaryFolder();

	NativeStore sail = new NativeStore(file, "spoc,ospc,psoc");
	sail.setForceSync(true);
	repository = new SailRepository(sail);
	connection = repository.getConnection();

	System.gc();

}
 
Example #2
Source File: ElasticsearchStoreTransactionsTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testRollbackClearSimple() {
	SailRepository elasticsearchStore = new SailRepository(this.elasticsearchStore);
	try (SailRepositoryConnection connection = elasticsearchStore.getConnection()) {

		BNode context = vf.createBNode();

		connection.begin(IsolationLevels.READ_COMMITTED);
		connection.add(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE);
		connection.add(RDF.TYPE, RDF.TYPE, RDF.PROPERTY, context);
		connection.commit();

		connection.begin();
		connection.clear();
		assertEquals(0, connection.size());
		connection.rollback();

		assertEquals(2, connection.size());

	}

}
 
Example #3
Source File: NoReificationTest.java    From inception with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp()
{
    kb = new KnowledgeBase();
    kb.setDefaultLanguage("en");
    kb.setType(RepositoryType.LOCAL);
    kb.setFullTextSearchIri(null);
    kb.setMaxResults(1000);
    
    initRdfsMapping();
    
    // Local in-memory store - this should be used for most tests because we can
    // a) rely on its availability
    // b) import custom test data
    LuceneSail lucenesail = new LuceneSail();
    lucenesail.setParameter(LuceneSail.LUCENE_RAMDIR_KEY, "true");
    lucenesail.setBaseSail(new MemoryStore());
    rdf4jLocalRepo = new SailRepository(lucenesail);
    rdf4jLocalRepo.init();
    
    sut = new NoReification();
}
 
Example #4
Source File: AbstractNTriplesParserTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public TestSuite createTestSuite() throws Exception {
	// Create test suite
	TestSuite suite = new TestSuite(this.getClass().getName());

	// Add the manifest for W3C test cases to a repository and query it
	Repository w3cRepository = new SailRepository(new MemoryStore());
	w3cRepository.initialize();
	RepositoryConnection w3cCon = w3cRepository.getConnection();

	InputStream inputStream = this.getClass().getResourceAsStream(TEST_W3C_MANIFEST_URL);
	w3cCon.add(inputStream, TEST_W3C_MANIFEST_URI_BASE, RDFFormat.TURTLE);

	parsePositiveNTriplesSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TEST_W3C_TEST_URI_BASE, w3cCon);
	parseNegativeNTriplesSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TEST_W3C_TEST_URI_BASE, w3cCon);

	w3cCon.close();
	w3cRepository.shutDown();

	return suite;
}
 
Example #5
Source File: DatatypeBenchmarkSerializableEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
	public void shacl() throws Exception {

		SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("shaclDatatype.ttl"));

//		((ShaclSail) repository.getSail()).setIgnoreNoShapesLoadedException(true);
//		((ShaclSail) repository.getSail()).disableValidation();

		try (SailRepositoryConnection connection = repository.getConnection()) {
			connection.begin(IsolationLevels.SERIALIZABLE);
			connection.commit();
		}

		try (SailRepositoryConnection connection = repository.getConnection()) {
			for (List<Statement> statements : allStatements) {
				connection.begin(IsolationLevels.SERIALIZABLE);
				connection.add(statements);
				connection.commit();
			}
		}

		repository.shutDown();

	}
 
Example #6
Source File: ShaclSail.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
List<NodeShape> refreshShapes(SailRepositoryConnection shapesRepoConnection) throws SailException {

		SailRepository shapesRepoCache = new SailRepository(new MemoryStore());
		shapesRepoCache.init();
		List<NodeShape> shapes;

		try (SailRepositoryConnection shapesRepoCacheConnection = shapesRepoCache.getConnection()) {
			shapesRepoCacheConnection.begin(IsolationLevels.NONE);
			try (RepositoryResult<Statement> statements = shapesRepoConnection.getStatements(null, null, null, false)) {
				shapesRepoCacheConnection.add(statements);
			}

			runInferencingSparqlQueries(shapesRepoCacheConnection);
			shapesRepoCacheConnection.commit();

			shapes = NodeShape.Factory.getShapes(shapesRepoCacheConnection, this);
		}

		shapesRepoCache.shutDown();
		return shapes;
	}
 
Example #7
Source File: TurtleParserTestCase.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public TestSuite createTestSuite() throws Exception {
	// Create test suite
	TestSuite suite = new TestSuite(TurtleParserTestCase.class.getName());

	// Add the manifest for W3C test cases to a repository and query it
	Repository w3cRepository = new SailRepository(new MemoryStore());
	w3cRepository.initialize();
	RepositoryConnection w3cCon = w3cRepository.getConnection();

	InputStream inputStream = this.getClass().getResourceAsStream(TEST_W3C_MANIFEST_URL);
	w3cCon.add(inputStream, TEST_W3C_MANIFEST_URI_BASE, RDFFormat.TURTLE);

	parsePositiveTurtleSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);
	parseNegativeTurtleSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);
	parsePositiveTurtleEvalTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);
	parseNegativeTurtleEvalTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);

	w3cCon.close();
	w3cRepository.shutDown();

	return suite;
}
 
Example #8
Source File: TargetNodeMinCountEdgeCaseTests.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testMinCountWithValidInitialDataset() throws Throwable {

	SailRepository sailRepository = new SailRepository(new ShaclSail(new MemoryStore()));

	try (SailRepositoryConnection connection = sailRepository.getConnection()) {
		connection.begin();
		connection.add(validPerson1, ssn, value1);
		connection.add(validPerson1, ssn, value2);
		connection.add(validPerson2, ssn, value1);
		connection.add(validPerson2, ssn, value2);
		connection.commit();

		connection.begin();
		connection.add(new StringReader(shaclShapes), "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH);
		connection.commit();
	} catch (Exception e) {
		throw e.getCause();
	}

}
 
Example #9
Source File: ElasticsearchStoreTransactionsTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testNamespace() {

	SailRepository elasticsearchStore = new SailRepository(this.elasticsearchStore);

	try (SailRepositoryConnection connection = elasticsearchStore.getConnection()) {
		connection.begin();
		connection.setNamespace(SHACL.PREFIX, SHACL.NAMESPACE);
		connection.commit();
	}

	try (SailRepositoryConnection connection = elasticsearchStore.getConnection()) {
		String namespace = connection.getNamespace(SHACL.PREFIX);
		assertEquals(SHACL.NAMESPACE, namespace);
	}
}
 
Example #10
Source File: MinCountBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void shacl() throws Exception {

	SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("shacl.ttl"));

	try (SailRepositoryConnection connection = repository.getConnection()) {
		connection.begin();
		connection.commit();
	}

	try (SailRepositoryConnection connection = repository.getConnection()) {
		for (List<Statement> statements : allStatements) {
			connection.begin();
			connection.add(statements);
			connection.commit();
		}
	}
	repository.shutDown();

}
 
Example #11
Source File: MaxCountBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void shacl() throws Exception {

	SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("shaclMaxCountBenchmark.ttl"));

	try (SailRepositoryConnection connection = repository.getConnection()) {
		connection.begin();
		connection.commit();
	}

	try (SailRepositoryConnection connection = repository.getConnection()) {
		for (List<Statement> statements : allStatements) {
			connection.begin();
			connection.add(statements);
			connection.commit();
		}
	}
	repository.shutDown();

}
 
Example #12
Source File: TransactionParallelBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Setup(Level.Trial)
public void beforeClass() throws IOException, InterruptedException {
	// JMH does not correctly set JAVA_HOME. Change the JAVA_HOME below if you the following error:
	// [EmbeddedElsHandler] INFO p.a.t.e.ElasticServer - could not find java; set JAVA_HOME or ensure java is in
	// PATH
	embeddedElastic = TestHelpers.startElasticsearch(installLocation,
			"/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home");

	repository = new SailRepository(
			new ElasticsearchStore("localhost", embeddedElastic.getTransportTcpPort(), "cluster1", "testindex"));
	try (SailRepositoryConnection connection = repository.getConnection()) {
		connection.begin(IsolationLevels.NONE);
		connection.add(getResourceAsStream("benchmarkFiles/datagovbe-valid.ttl"), "", RDFFormat.TURTLE);
		connection.commit();
	}

	System.gc();

}
 
Example #13
Source File: SimpleProvenanceServiceTest.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    repo = new SesameRepositoryWrapper(new SailRepository(new MemoryStore()));
    repo.initialize();

    activityIRI = VALUE_FACTORY.createIRI("http://test.com/activity");

    MockitoAnnotations.initMocks(this);
    when(registry.getFactoriesOfType(Activity.class)).thenReturn(Collections.singletonList(activityFactory));

    service = new SimpleProvenanceService();
    injectOrmFactoryReferencesIntoService(service);
    service.setRepo(repo);
    service.setVf(VALUE_FACTORY);
    service.setMf(MODEL_FACTORY);
    service.setFactoryRegistry(registry);
}
 
Example #14
Source File: MongoGeoTemporalIndexIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void ensureInEventStore_Test() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepository repo = new SailRepository(sail);
    try(final MongoGeoTemporalIndexer indexer = new MongoGeoTemporalIndexer()) {
        indexer.setConf(conf);
        indexer.init();

        addStatements(repo.getConnection());
        final EventStorage events = indexer.getEventStorage();
        final RyaIRI subject = new RyaIRI("urn:event1");
        final Optional<Event> event = events.get(subject);
        assertTrue(event.isPresent());
    } finally {
        sail.shutDown();
    }
}
 
Example #15
Source File: ReasoningUpdateBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void forwardChainingSchemaCachingRDFSInferencer() throws IOException {
	SailRepository sail = new SailRepository(new SchemaCachingRDFSInferencer(new MemoryStore()));

	try (SailRepositoryConnection connection = sail.getConnection()) {
		connection.begin();
		connection.add(resourceAsStream("schema.ttl"), "", RDFFormat.TURTLE, schemaGraph);
		connection.commit();

		addAllDataMultipleTransactions(connection);

	}

	checkSize(sail);
}
 
Example #16
Source File: TempTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test(expected = RepositoryException.class)
public void testShapeWithoutTargetClassRemove() throws Exception {

	SailRepository shaclRepository = Utils.getInitializedShaclRepository("shacleNoTargetClass.ttl", true);
	shaclRepository.init();

	try (SailRepositoryConnection connection = shaclRepository.getConnection()) {

		connection.begin();
		connection.add(RDFS.CLASS, RDFS.LABEL, connection.getValueFactory().createLiteral("class1"));
		connection.add(RDFS.CLASS, RDF.TYPE, RDFS.RESOURCE);
		connection.commit();

		connection.begin();
		connection.remove(RDFS.CLASS, RDFS.LABEL, connection.getValueFactory().createLiteral("class1"));
		connection.commit();

	}

}
 
Example #17
Source File: ModifyShapesPostInitTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test()
public void checkForNoExceptionWithEmptyTransaction() {

	SailRepository sailRepository = new SailRepository(new ShaclSail(new MemoryStore()));
	sailRepository.init();

	try (SailRepositoryConnection connection = sailRepository.getConnection()) {
		connection.begin();
		connection.commit();
	}

}
 
Example #18
Source File: GenerateFullAxioms.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	MemoryStore baseSail = new MemoryStore();
	DedupingInferencer deduper = new DedupingInferencer(baseSail);
	SchemaCachingRDFSInferencer rdfsInferencer = new SchemaCachingRDFSInferencer(deduper);
	SpinSail spinSail = new SpinSail(rdfsInferencer);
	Repository repo = new SailRepository(spinSail);
	repo.initialize();
	try (FileWriter writer = new FileWriter("spin-full.ttl")) {
		try (RepositoryConnection conn = repo.getConnection()) {
			conn.exportStatements(null, null, null, true, Rio.createWriter(RDFFormat.TURTLE, writer));
		}
	}
	repo.shutDown();
}
 
Example #19
Source File: UnknownShapesTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testComplexPath() throws IOException {
	ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory
			.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);

	MyAppender newAppender = new MyAppender();
	root.addAppender(newAppender);

	SailRepository shaclRepository = Utils.getInitializedShaclRepository("complexPath.ttl", false);

	try (SailRepositoryConnection connection = shaclRepository.getConnection()) {
		connection.begin();
		connection.add(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE);
		connection.commit();
	}

	Set<String> relevantLog = newAppender.logged.stream()
			.filter(m -> m.startsWith("Unsupported SHACL feature"))
			.map(s -> s.replaceAll("\r\n|\r|\n", " "))
			.map(String::trim)
			.collect(Collectors.toSet());

	Set<String> expected = new HashSet<>(Arrays.asList(
			"Unsupported SHACL feature with complex path. Only single predicate paths are supported. <http://example.com/ns#PersonPropertyShape> shape has been deactivated!  @prefix sh: <http://www.w3.org/ns/shacl#> .  <http://example.com/ns#PersonPropertyShape> sh:path [       sh:inversePath <http://example.com/ns#inverseThis>     ] .",
			"Unsupported SHACL feature with complex path. Only single predicate paths are supported. <http://example.com/ns#PersonPropertyShape2> shape has been deactivated!  @prefix sh: <http://www.w3.org/ns/shacl#> .  <http://example.com/ns#path> sh:inversePath <http://example.com/ns#inverseThis> .  <http://example.com/ns#PersonPropertyShape2> sh:path <http://example.com/ns#path> .",
			"Unsupported SHACL feature with complex path. Only single predicate paths are supported. <http://example.com/ns#PersonPropertyShape3> shape has been deactivated!  @prefix sh: <http://www.w3.org/ns/shacl#> .  <http://example.com/ns#pathList> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>     \"one\";   <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .  <http://example.com/ns#PersonPropertyShape3> sh:path <http://example.com/ns#pathList> ."));

	assertEquals(expected, relevantLog);
}
 
Example #20
Source File: KnowledgeBaseServiceImpl.java    From inception with Apache License 2.0 5 votes vote down vote up
@Override
public void rebuildFullTextIndex(KnowledgeBase aKB) throws Exception
{
    if (!RepositoryType.LOCAL.equals(aKB.getType())) {
        throw new IllegalArgumentException("Reindexing is only supported on local KBs");
    }
    
    boolean reindexSupported = false;
    
    // Handle re-indexing of local repos that use a Lucene FTS
    if (repoManager.getRepository(aKB.getRepositoryId()) instanceof SailRepository) {
        SailRepository sailRepo = (SailRepository) repoManager
            .getRepository(aKB.getRepositoryId());
        if (sailRepo.getSail() instanceof LuceneSail) {
            reindexSupported = true;
            LuceneSail luceneSail = (LuceneSail) (sailRepo.getSail());
            try (RepositoryConnection conn = getConnection(aKB)) {
                luceneSail.reindex();
                conn.commit();
            }
        }
    }
    
    if (!reindexSupported) {
        throw new IllegalArgumentException(
                aKB + "] does not support rebuilding its full text index.");
    }
}
 
Example #21
Source File: Utils.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void loadShapeData(SailRepository repo, URL resourceName)
		throws RDF4JException, UnsupportedRDFormatException, IOException {
	((ShaclSail) repo.getSail()).disableValidation();

	try (RepositoryConnection conn = repo.getConnection()) {
		conn.begin();
		conn.add(resourceName, resourceName.toString(), RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH);

		conn.commit();
	}
	((ShaclSail) repo.getSail()).enableValidation();

}
 
Example #22
Source File: MongoDbRyaSailFactoryLoadFilesIT.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Shuts the repository down, releasing any resources that it keeps hold of.
 * Once shut down, the repository can no longer be used until it is
 * re-initialized.
 * @param repository the {@link SailRepository} to close.
 */
private static void close(final SailRepository repository) {
    if (repository != null) {
        try {
            repository.shutDown();
        } catch (final RepositoryException e) {
            log.error("Encountered an error while closing Sail Repository", e);
        }
    }
}
 
Example #23
Source File: ReasoningBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private SailRepository createSchema() throws IOException {
	SailRepository schema = new SailRepository(new MemoryStore());
	schema.initialize();

	try (SailRepositoryConnection schemaConnection = schema.getConnection()) {
		schemaConnection.begin();
		schemaConnection.add(resourceAsStream("schema.ttl"), "", RDFFormat.TURTLE);
		schemaConnection.commit();
	}
	return schema;
}
 
Example #24
Source File: MongoRyaDirectExample.java    From rya with Apache License 2.0 5 votes vote down vote up
private static void closeQuietly(final SailRepository repository) {
    if (repository != null) {
        try {
            repository.shutDown();
        } catch (final RepositoryException e) {
            // quietly absorb this exception
        }
    }
}
 
Example #25
Source File: BasicBenchmarks.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Benchmark
public void remove() {
	SailRepository spinSail = new SailRepository(new SpinSail(new MemoryStore()));
	spinSail.init();

	try (SailRepositoryConnection connection = spinSail.getConnection()) {
		connection.remove(bob, name, nameBob);
		connection.remove(alice, null, null);
	}

	spinSail.shutDown();

}
 
Example #26
Source File: ElasticsearchStoreTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testGetSailRepositoryConneciton() {
	SailRepository elasticsearchStore = new SailRepository(
			new ElasticsearchStore("localhost", embeddedElastic.getTransportTcpPort(), "cluster1", "testindex"));
	try (SailRepositoryConnection connection = elasticsearchStore.getConnection()) {
	}
	elasticsearchStore.shutDown();
}
 
Example #27
Source File: RyaDirectExample.java    From rya with Apache License 2.0 5 votes vote down vote up
private static void closeQuietly(final SailRepository repository) {
	if (repository != null) {
		try {
			repository.shutDown();
		} catch (final RepositoryException e) {
			// quietly absorb this exception
		}
	}
}
 
Example #28
Source File: TrackAddedStatementsTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testAdd() throws Exception {

	SailRepository shaclRepository = Utils.getInitializedShaclRepository("empty.ttl", false);
	((ShaclSail) shaclRepository.getSail()).setIgnoreNoShapesLoadedException(true);
	shaclRepository.init();

	try (SailRepositoryConnection connection = shaclRepository.getConnection()) {
		connection.begin();
		// System.out.println(size(connection));

		connection.add(RDFS.RESOURCE, RDF.TYPE, RDFS.RESOURCE);
		// System.out.println(size(connection));

		connection.remove(RDFS.RESOURCE, RDF.TYPE, RDFS.RESOURCE);
		// System.out.println(size(connection));

		connection.add(RDFS.RESOURCE, RDF.TYPE, RDFS.RESOURCE);
		// System.out.println(size(connection));

		ShaclSailConnection shaclSailConnection = (ShaclSailConnection) connection.getSailConnection();
		shaclSailConnection.fillAddedAndRemovedStatementRepositories();
		try (ConnectionsGroup connectionsGroup = shaclSailConnection.getConnectionsGroup()) {

			assertEquals(1, size(connectionsGroup.getAddedStatements()));
			assertEquals(0, size(connectionsGroup.getRemovedStatements()));
		}

		connection.commit();

		System.out.println(size(connection));

	}
}
 
Example #29
Source File: AccumuloRyaSailFactoryLoadFilesIT.java    From rya with Apache License 2.0 5 votes vote down vote up
private static void addTriples(final SailRepository repo, final InputStream triplesStream, final RDFFormat rdfFormat) throws RDFParseException, RepositoryException, IOException {
    SailRepositoryConnection conn = null;
    try {
        conn = repo.getConnection();
        conn.begin();
        conn.add(triplesStream, "", rdfFormat);
        conn.commit();
    } finally {
        closeQuietly(conn);
    }
}
 
Example #30
Source File: MongoEntityIndexIT.java    From rya with Apache License 2.0 5 votes vote down vote up
@Test
public void partialQuery_Test() throws Exception {
    final Sail sail = RyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    conn.begin();

    try(MongoEntityIndexer indexer = new MongoEntityIndexer()) {
        indexer.setConf(conf);
        indexer.init();

        setupTypes(indexer);
        addStatements(conn);
        conn.commit();

        final String query = "SELECT * WHERE { " +
                "<urn:george> <" + RDF.TYPE + "> <urn:person> ."+
                "<urn:george> <urn:name> ?name . " +
                "<urn:george> <urn:eye> ?eye . " +
                "}";

        final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
        final Set<BindingSet> results = new HashSet<>();
        while(rez.hasNext()) {
            final BindingSet bs = rez.next();
            System.out.println(bs);
            results.add(bs);
        }
        final MapBindingSet expected = new MapBindingSet();
        //expected.addBinding("name", VF.createIRI("http://www.w3.org/2001/SMLSchema#string", "George"));
        expected.addBinding("name", VF.createLiteral("George"));
        expected.addBinding("eye", VF.createLiteral("blue"));

        assertEquals(1, results.size());
        assertEquals(expected, results.iterator().next());
    } finally {
        conn.close();
    }
}