SnapshotStorageConnectorWithInference extends SnapshotStorageConnector implements InferredStorageConnector { @Override public boolean contains(Resource subject, Property property, RDFNode value, String context) { ensureTransactionalState(); if (context != null) { return ((SnapshotStorageWithInference) storage).getRawNamedGraph(context) .contains(subject, property, value); } else { return ((SnapshotStorageWithInference) storage).getRawDefaultGraph().contains(subject, property, value); } } SnapshotStorageConnectorWithInference(AbstractStorageConnector centralConnector,
                                          Map<String, String> reasonerConfig); @Override List<Statement> find(Resource subject, Property property, RDFNode value, String context); @Override boolean contains(Resource subject, Property property, RDFNode value, String context); @Override List<Statement> findWithInference(Resource subject, Property property, RDFNode value, String context); @Override boolean containsWithInference(Resource subject, Property property, RDFNode value, String context); @Override boolean isConsistent(String context);  }
@Test public void containsUsesOnlyRawDefaultGraph() throws Exception { generateTestData(null); connector.begin(); assertFalse(connector.contains(createResource(SUBJECT), RDF.type, createResource(TYPE_TWO), null)); assertTrue(connector.contains(createResource(SUBJECT), RDF.type, createResource(TYPE_ONE), null)); }
@Test public void containsInContextUsesOnlyRawNamedGraph() throws Exception { generateTestData(NAMED_GRAPH); connector.begin(); assertFalse(connector.contains(createResource(SUBJECT), RDF.type, createResource(TYPE_TWO), NAMED_GRAPH)); assertTrue(connector.contains(createResource(SUBJECT), RDF.type, createResource(TYPE_ONE), NAMED_GRAPH)); }
@Test public void containsOnTDBBackedStorageHandlesTransactionalBehavior() throws Exception { final File storageDir = Files.createTempDirectory("tdb-test").toFile(); try { final DriverConfiguration config = createConfiguration(storageDir.getAbsolutePath()); config.setProperty(JenaConfigParam.STORAGE_TYPE, JenaOntoDriverProperties.TDB); config.setProperty(DriverConfigParam.REASONER_FACTORY_CLASS, RDFSRuleReasonerFactory.class.getName()); this.centralConnector = new SharedStorageConnector(config); this.connector = new SnapshotStorageConnectorWithInference(centralConnector, Collections.emptyMap()); connector.begin(); assertFalse(connector.contains(createResource(SUBJECT), RDF.type, null, null)); } finally { StorageTestUtil.deleteStorageDir(storageDir); } }