org.eclipse.rdf4j.sail.memory.MemoryStore Java Examples

The following examples show how to use org.eclipse.rdf4j.sail.memory.MemoryStore. 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: ClassBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void noShacl() {

	SailRepository repository = new SailRepository(new MemoryStore());

	repository.init();

	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 #2
Source File: RepositoryFederatedServiceIntegrationTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Before
public void before() {
	serviceRepo = new SailRepository(new MemoryStore());
	serviceRepo.init();

	federatedService = new RepositoryFederatedService(serviceRepo);

	localRepo = new SailRepository(new MemoryStore());
	localRepo.setFederatedServiceResolver(new FederatedServiceResolver() {

		@Override
		public FederatedService getService(String serviceUrl) throws QueryEvaluationException {
			return federatedService;
		}
	});
	localRepo.init();
}
 
Example #3
Source File: NotMaxCountBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void noShacl() {

	SailRepository repository = new SailRepository(new MemoryStore());

	repository.init();

	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 #4
Source File: TargetNodeMinCountEdgeCaseTests.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test(expected = ShaclSailValidationException.class)
public void testMinCountWithInvalidInitialDataset3() 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(new StringReader(shaclShapes), "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH);
		connection.commit();
	} catch (Exception e) {
		throw e.getCause();
	}

}
 
Example #5
Source File: BalanaPDPTest.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();
    try {
        jaxbContext = JAXBContext.newInstance("com.mobi.security.policy.api.xacml.jaxb");
    } catch (JAXBException e) {
        throw new MobiException(e);
    }
    MockitoAnnotations.initMocks(this);
    when(pip.findAttribute(any(AttributeDesignator.class), any(Request.class))).thenReturn(Collections.emptyList());
    when(policyManager.getRepository()).thenReturn(repo);

    entries = new ArrayList<>();
    when(policyCache.getPolicyCache()).thenReturn(Optional.of(cache));
    when(cache.spliterator()).thenReturn(entries.spliterator());
    prp = new BalanaPRP();
    prp.setVf(VALUE_FACTORY);
    prp.setPolicyCache(policyCache);
    prp.setPolicyManager(policyManager);
    pdp = new BalanaPDP();
    pdp.addPIP(pip);
    pdp.setBalanaPRP(prp);
    pdp.setVf(VALUE_FACTORY);
    pdp.setUp();
}
 
Example #6
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 #7
Source File: OrderingTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testSelect() {
	MemoryStore repository = new MemoryStore();
	repository.init();

	try (SailConnection connection = repository.getConnection()) {
		connection.begin(IsolationLevels.NONE);
		connection.addStatement(RDFS.RESOURCE, RDF.TYPE, RDFS.RESOURCE);
		connection.addStatement(RDFS.CLASS, RDF.TYPE, RDFS.RESOURCE);
		connection.addStatement(RDFS.SUBCLASSOF, RDF.TYPE, RDFS.RESOURCE);
		connection.commit();

		Select select = new Select(connection, "?a <" + RDF.TYPE + "> []", "*");
		List<Tuple> tuples = new MockConsumePlanNode(select).asList();

		String actual = Arrays.toString(tuples.toArray());

		Collections.sort(tuples);

		String expected = Arrays.toString(tuples.toArray());

		assertEquals(expected, actual);
	}
}
 
Example #8
Source File: CustomFederationConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testSize() throws Exception {
	Federation federation = new Federation();

	SailRepository repository = new SailRepository(new MemoryStore());
	federation.addMember(repository);

	federation.initialize();
	try {
		try (SailConnection connection = federation.getConnection()) {
			assertEquals("Should get size", 0, connection.size());

			connection.begin();
			assertEquals("Should get size", 0, connection.size());

			connection.addStatement(OWL.CLASS, RDFS.COMMENT, RDF.REST);
			assertEquals("Should get size", 1, connection.size());

			connection.commit();
			assertEquals("Should get size", 1, connection.size());
		}
	} finally {
		federation.shutDown();
	}
}
 
Example #9
Source File: InferredContextTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testInferrecContextNoNull() {
	SchemaCachingRDFSInferencer sail = new SchemaCachingRDFSInferencer(new MemoryStore());

	sail.initialize();
	sail.setAddInferredStatementsToDefaultContext(false);

	try (SchemaCachingRDFSInferencerConnection connection = sail.getConnection()) {
		connection.begin();
		connection.addStatement(bNode, RDF.TYPE, type, context);
		connection.commit();

		assertTrue(connection.hasStatement(bNode, RDF.TYPE, RDFS.RESOURCE, true, context));

		try (CloseableIteration<? extends Statement, SailException> statements = connection.getStatements(bNode,
				RDF.TYPE, RDFS.RESOURCE, true)) {
			while (statements.hasNext()) {
				Statement next = statements.next();
				assertEquals("Context should be equal", context, next.getContext());
			}
		}
	}

}
 
Example #10
Source File: ShutdownTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private ExecutorService[] startShaclSailAndTask()
		throws InterruptedException, NoSuchFieldException, IllegalAccessException {
	ShaclSail shaclSail = new ShaclSail(new MemoryStore());
	shaclSail.initialize();

	Future<Object> objectFuture = shaclSail.submitRunnableToExecutorService(getSleepingCallable());

	try {
		objectFuture.get(100, TimeUnit.MILLISECONDS);
	} catch (ExecutionException | TimeoutException ignored) {
	}

	Class<?> c = ShaclSail.class;
	Field field = c.getDeclaredField("executorService");
	field.setAccessible(true);

	return (ExecutorService[]) field.get(shaclSail);

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

	MemoryStore memoryStore = new MemoryStore();
	memoryStore.initialize();

	try (NotifyingSailConnection connection = memoryStore.getConnection()) {
		connection.begin(IsolationLevels.valueOf(isolationLevel));

		statementList.forEach(
				st -> connection.addStatement(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()));

		long count = 0;
		for (int i = 0; i < 10; i++) {
			try (CloseableIteration<? extends Statement, SailException> statements = connection.getStatements(null,
					null, null, false)) {
				count += statements.next().toString().length();
			}
		}

		connection.commit();

		return count;
	}

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

	SailRepository repository = new SailRepository(new MemoryStore());

	repository.init();

	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 #13
Source File: TargetNodeMinCountEdgeCaseTests.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test(expected = ShaclSailValidationException.class)
public void testMinCountWithInvalidInitialDataset2() 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.commit();

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

}
 
Example #14
Source File: MemoryStoreFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	MemoryStore memoryStore = new MemoryStore();

	if (config instanceof MemoryStoreConfig) {
		MemoryStoreConfig memConfig = (MemoryStoreConfig) config;

		memoryStore.setPersist(memConfig.getPersist());
		memoryStore.setSyncDelay(memConfig.getSyncDelay());

		if (memConfig.getIterationCacheSyncThreshold() > 0) {
			memoryStore.setIterationCacheSyncThreshold(memConfig.getIterationCacheSyncThreshold());
		}

		EvaluationStrategyFactory evalStratFactory = memConfig.getEvaluationStrategyFactory();
		if (evalStratFactory != null) {
			memoryStore.setEvaluationStrategyFactory(evalStratFactory);
		}
	}

	return memoryStore;
}
 
Example #15
Source File: MaxCountBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void noShacl() {

	SailRepository repository = new SailRepository(new MemoryStore());

	repository.init();

	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 #16
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 #17
Source File: ReasoningBenchmark.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);
		addAllDataSingleTransaction(connection);

		connection.commit();
	}

	checkSize(sail);
}
 
Example #18
Source File: ReasoningBenchmark.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 forwardChainingRDFSInferencerMultipleTransactions() throws IOException {
	SailRepository sail = new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore()));

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

		connection.begin();
		connection.add(resourceAsStream("schema.ttl"), "", RDFFormat.TURTLE);
		connection.commit();

		addAllDataMultipleTransactions(connection);

	}
}
 
Example #19
Source File: ReasoningBenchmark.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 noReasoningMultipleTransactions() throws IOException {
	SailRepository sail = new SailRepository(new MemoryStore());

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

		connection.begin();
		connection.add(resourceAsStream("schema.ttl"), "", RDFFormat.TURTLE);
		connection.commit();

		addAllDataMultipleTransactions(connection);

	}
}
 
Example #20
Source File: BasicBenchmarks.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void cantInvoke() throws IOException {
	NotifyingSail baseSail = new MemoryStore();
	DedupingInferencer deduper = new DedupingInferencer(baseSail);
	NotifyingSail rdfsInferencer = new SchemaCachingRDFSInferencer(deduper);
	SpinSail spinSail = new SpinSail(rdfsInferencer);
	SailRepository repo = new SailRepository(spinSail);
	repo.init();
	try (SailRepositoryConnection conn = repo.getConnection()) {

		loadRDF("/schema/spif.ttl", conn);
		BooleanQuery bq = conn.prepareBooleanQuery(QueryLanguage.SPARQL,
				"prefix spif: <http://spinrdf.org/spif#> "
						+ "ask where {filter(spif:canInvoke(spif:indexOf, 'foobar', 2))}");
		assertFalse(bq.evaluate());

	}

	repo.shutDown();

}
 
Example #21
Source File: TriGParserTestCase.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(TriGParserTestCase.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);

	parsePositiveTriGSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);
	parseNegativeTriGSyntaxTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE,
			w3cCon);
	parsePositiveTriGEvalTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE, w3cCon);
	parseNegativeTriGEvalTests(suite, TEST_W3C_FILE_BASE_PATH, TESTS_W3C_BASE_URL, TEST_W3C_TEST_URI_BASE, w3cCon);

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

	return suite;
}
 
Example #22
Source File: BasicBenchmarks.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void cantInvokeOldReasoner() throws IOException {
	NotifyingSail baseSail = new MemoryStore();
	DedupingInferencer deduper = new DedupingInferencer(baseSail);
	NotifyingSail rdfsInferencer = new ForwardChainingRDFSInferencer(deduper);
	SpinSail spinSail = new SpinSail(rdfsInferencer);
	SailRepository repo = new SailRepository(spinSail);
	repo.init();
	try (SailRepositoryConnection conn = repo.getConnection()) {

		loadRDF("/schema/spif.ttl", conn);
		BooleanQuery bq = conn.prepareBooleanQuery(QueryLanguage.SPARQL,
				"prefix spif: <http://spinrdf.org/spif#> "
						+ "ask where {filter(spif:canInvoke(spif:indexOf, 'foobar', 2))}");
		assertFalse(bq.evaluate());

	}

	repo.init();
}
 
Example #23
Source File: BasicBenchmarks.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void addRemoveAllWithoutConstraintValidations() {
	SpinSail spinSail = new SpinSail(new MemoryStore());
	spinSail.setValidateConstraints(false);

	SailRepository sail = new SailRepository(spinSail);
	sail.init();

	try (SailRepositoryConnection connection = sail.getConnection()) {
		connection.begin();
		connection.add(bob, name, nameBob);
		connection.add(alice, name, nameAlice);

		connection.commit();

		connection.remove((Resource) null, null, null);

	}
	spinSail.shutDown();

}
 
Example #24
Source File: TestExploreServlet.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @throws RepositoryException      if an issue occurs making the connection
 * @throws MalformedQueryException  if an issue occurs inserting data
 * @throws UpdateExecutionException if an issue occurs inserting data
 */
@Before
public void setUp() throws RepositoryException, MalformedQueryException, UpdateExecutionException {
	Repository repo = new SailRepository(new MemoryStore());
	repo.initialize();
	connection = repo.getConnection();
	servlet = new ExploreServlet();
	ValueFactory factory = connection.getValueFactory();
	foo = factory.createIRI("http://www.test.com/foo");
	bar = factory.createIRI("http://www.test.com/bar");
	bang = factory.createIRI("http://www.test.com/bang");
	foos = new IRI[128];
	for (int i = 0; i < foos.length; i++) {
		foos[i] = factory.createIRI("http://www.test.com/foo/" + i);
	}
	builder = mock(TupleResultBuilder.class);
}
 
Example #25
Source File: UniqueLangBenchmarkEmpty.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
public void noShacl() {

	SailRepository repository = new SailRepository(new MemoryStore());

	repository.init();

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

	repository.shutDown();

}
 
Example #26
Source File: MemoryBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Benchmark
public long duplicatesAndNewStatementsIteratorMatchesNothing() {

	MemoryStore memoryStore = new MemoryStore();
	memoryStore.initialize();

	try (NotifyingSailConnection connection = memoryStore.getConnection()) {
		connection.begin(IsolationLevels.valueOf(isolationLevel));

		statementList.forEach(
				st -> connection.addStatement(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()));

		connection.commit();

		connection.begin(IsolationLevels.valueOf(isolationLevel));

		statementList.forEach(
				st -> connection.addStatement(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()));

		ValueFactory vf = memoryStore.getValueFactory();
		connection.addStatement(vf.createBNode(), RDFS.LABEL, vf.createLiteral("label"));

		long count = 0;
		for (int i = 0; i < 10; i++) {
			try (Stream<? extends Statement> stream = connection.getStatements(vf.createBNode(), null, null, false)
					.stream()) {
				count += stream.count();
			}
		}

		connection.commit();

		return count;
	}

}
 
Example #27
Source File: BasicBenchmarks.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Benchmark
public void spinSailInit() {

	SpinSail spinSail = new SpinSail(new MemoryStore());
	spinSail.initialize();
	spinSail.shutDown();

}
 
Example #28
Source File: ImportsResolverImplTest.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception{
    MockitoAnnotations.initMocks(this);
    mf = getModelFactory();
    vf = getValueFactory();
    resolver = new ImportsResolverImpl();

    headCommitIRI = vf.createIRI("urn:headCommit");
    catalogIRI = vf.createIRI("urn:catalog");
    recordIRI = vf.createIRI("urn:recordIRI");
    ontologyIRI = vf.createIRI("urn:ontologyIRI");

    when(transformer.mobiModel(any(org.eclipse.rdf4j.model.Model.class))).thenAnswer(i -> Values.mobiModel(i.getArgumentAt(0, org.eclipse.rdf4j.model.Model.class)));
    when(transformer.mobiIRI(any(org.eclipse.rdf4j.model.IRI.class))).thenAnswer(i -> Values.mobiIRI(i.getArgumentAt(0, org.eclipse.rdf4j.model.IRI.class)));
    when(transformer.sesameModel(any(Model.class))).thenAnswer(i -> Values.sesameModel(i.getArgumentAt(0, Model.class)));
    when(transformer.sesameStatement(any(Statement.class))).thenAnswer(i -> Values.sesameStatement(i.getArgumentAt(0, Statement.class)));

    localModel = Models.createModel(getClass().getResourceAsStream("/Ontology.ttl"), transformer);

    repo = spy(new SesameRepositoryWrapper(new SailRepository(new MemoryStore())));
    repo.initialize();
    when(repo.getConfig()).thenReturn(repositoryConfig);
    when(repositoryConfig.id()).thenReturn("repoCacheId");

    when(masterBranch.getHead_resource()).thenReturn(Optional.of(headCommitIRI));

    when(configProvider.getLocalCatalogIRI()).thenReturn(catalogIRI);
    when(catalogManager.getMasterBranch(eq(catalogIRI), eq(recordIRI))).thenReturn(masterBranch);
    when(ontologyManager.getOntologyRecordResource(any(Resource.class))).thenReturn(Optional.empty());
    when(ontologyManager.getOntologyRecordResource(eq(ontologyIRI))).thenReturn(Optional.of(recordIRI));
    when(ontologyManager.getOntologyRecordResource(eq(vf.createIRI("urn:localOntology")))).thenReturn(Optional.of(recordIRI));

    when(catalogManager.getCompiledResource(eq(headCommitIRI))).thenReturn(localModel);

    resolver.setModelFactory(mf);
    resolver.setTransformer(transformer);
    resolver.setCatalogConfigProvider(configProvider);
    resolver.setCatalogManager(catalogManager);
    resolver.activate(Collections.singletonMap("userAgent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0"));
}
 
Example #29
Source File: SpinSailTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Before
public void setup() throws RepositoryException {
	NotifyingSail baseSail = new MemoryStore();
	DedupingInferencer deduper = new DedupingInferencer(baseSail);
	SchemaCachingRDFSInferencer rdfsInferencer = new SchemaCachingRDFSInferencer(deduper, false);
	SpinSail spinSail = new SpinSail(rdfsInferencer);
	repo = new SailRepository(spinSail);
	repo.initialize();
	conn = repo.getConnection();
}
 
Example #30
Source File: InferredContextTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testDefaultBehaviour() {
	SchemaCachingRDFSInferencer sail = new SchemaCachingRDFSInferencer(new MemoryStore());

	assertFalse("Current default behaviour should be to add all statements to default context",
			sail.isAddInferredStatementsToDefaultContext());

}