use of org.openrdf.repository.Repository in project incubator-rya by apache.
the class RyaAccumuloSailFactoryTest method testCreateFromTemplateName.
@Test
public void testCreateFromTemplateName() throws Exception {
LocalRepositoryManager repoman = new LocalRepositoryManager(Files.createTempDir());
repoman.initialize();
try (InputStream templateStream = RepositoryConfig.class.getResourceAsStream("RyaAccumuloSail.ttl")) {
String template = IOUtils.toString(templateStream);
final ConfigTemplate configTemplate = new ConfigTemplate(template);
final Map<String, String> valueMap = ImmutableMap.<String, String>builder().put("Repository ID", "RyaAccumuloSail").put("Repository title", "RyaAccumuloSail Store").put("Rya Accumulo user", "root").put("Rya Accumulo password", "").put("Rya Accumulo instance", "dev").put("Rya Accumulo zookeepers", "zoo1,zoo2,zoo3").put("Rya Accumulo is mock", "true").build();
final String configString = configTemplate.render(valueMap);
// final Repository systemRepo = this.state.getManager().getSystemRepository();
final Graph graph = new LinkedHashModel();
final RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
rdfParser.setRDFHandler(new StatementCollector(graph));
rdfParser.parse(new StringReader(configString), RepositoryConfigSchema.NAMESPACE);
final Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RepositoryConfigSchema.REPOSITORY);
final RepositoryConfig repConfig = RepositoryConfig.create(graph, repositoryNode);
repConfig.validate();
repoman.addRepositoryConfig(repConfig);
Repository r = repoman.getRepository("RyaAccumuloSail");
r.initialize();
}
}
use of org.openrdf.repository.Repository in project incubator-rya by apache.
the class RyaAccumuloSailFactoryTest method testAddStatement.
@Ignore
@Test
public void testAddStatement() throws Exception {
SailRepositoryFactory f = new SailRepositoryFactory();
Repository r = f.getRepository(getConfig());
r.initialize();
RepositoryConnection rc = r.getConnection();
ValueFactory vf = rc.getValueFactory();
Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
assertFalse(rc.hasStatement(s, false));
rc.add(s);
Assert.assertTrue(rc.hasStatement(s, false));
rc.close();
}
use of org.openrdf.repository.Repository in project incubator-rya by apache.
the class RyaAccumuloSailFactoryTest method testCreateAccumuloSail.
@Ignore
@Test
public void testCreateAccumuloSail() throws Exception {
SailRepositoryFactory f = new SailRepositoryFactory();
Repository r = f.getRepository(getConfig());
r.initialize();
RepositoryConnection rc = r.getConnection();
rc.close();
}
use of org.openrdf.repository.Repository in project incubator-rya by apache.
the class ConformanceTest method run.
@Override
public int run(final String[] args) throws Exception {
// Validate command
if (args.length < 1 || args.length > 2) {
System.out.println("Usage:\n");
System.out.println("\tConformanceTest [configuration options] " + "<test-file> <temp-dir>\n");
System.out.println("to load test data from an RDF file " + "(configuration property " + MRUtils.FORMAT_PROP + " specifies the format, default RDF/XML); or\n");
System.out.println("\tConformanceTest [configuration options] <temp-dir>\n");
System.out.println("to load test data from a Rya instance (specified " + "using standard configuration properties).\n");
System.out.println("For each test given, run the reasoner over the " + "premise ontology using a temporary Mini Accumulo instance " + "at <temp-dir>, then report conformance results.");
System.exit(1);
}
final Set<Value> conformanceTestURIs = new HashSet<>();
Collection<OwlTest> conformanceTests = new LinkedList<>();
final List<OwlTest> successes = new LinkedList<>();
final List<OwlTest> failures = new LinkedList<>();
final Configuration conf = getConf();
Repository repo;
File workingDir;
// If tests are in a file, stick them in a repository for querying
if (args.length == 2) {
workingDir = new File(PathUtils.clean(args[1]));
RDFFormat inputFormat = RDFFormat.RDFXML;
final String formatString = conf.get(MRUtils.FORMAT_PROP);
if (formatString != null) {
inputFormat = RDFFormat.valueOf(formatString);
}
repo = new SailRepository(new MemoryStore());
repo.initialize();
final RepositoryConnection conn = repo.getConnection();
FileInputStream fileInput = new FileInputStream(PathUtils.clean(args[0]));
conn.add(fileInput, "", inputFormat);
fileInput.close();
conn.close();
} else // Otherwise, get a Rya repository
{
workingDir = new File(PathUtils.clean(args[0]));
repo = MRReasoningUtils.getRepository(conf);
repo.initialize();
}
// Query for the tests we're interested in
final RepositoryConnection conn = repo.getConnection();
conformanceTestURIs.addAll(getTestURIs(conn, TEST_INCONSISTENCY));
conformanceTestURIs.addAll(getTestURIs(conn, TEST_CONSISTENCY));
conformanceTestURIs.addAll(getTestURIs(conn, TEST_ENTAILMENT));
conformanceTestURIs.addAll(getTestURIs(conn, TEST_NONENTAILMENT));
conformanceTests = getTests(conn, conformanceTestURIs);
conn.close();
repo.shutDown();
// Set up a MiniAccumulo cluster and set up conf to connect to it
final String username = "root";
final String password = "root";
final MiniAccumuloCluster mini = new MiniAccumuloCluster(workingDir, password);
mini.start();
conf.set(MRUtils.AC_INSTANCE_PROP, mini.getInstanceName());
conf.set(MRUtils.AC_ZK_PROP, mini.getZooKeepers());
conf.set(MRUtils.AC_USERNAME_PROP, username);
conf.set(MRUtils.AC_PWD_PROP, password);
conf.setBoolean(MRUtils.AC_MOCK_PROP, false);
conf.set(MRUtils.TABLE_PREFIX_PROPERTY, "temp_");
// Run the conformance tests
int result;
for (final OwlTest test : conformanceTests) {
System.out.println(test.uri);
result = runTest(conf, args, test);
if (result != 0) {
return result;
}
if (test.success) {
successes.add(test);
System.out.println("(SUCCESS)");
} else {
failures.add(test);
System.out.println("(FAIL)");
}
}
mini.stop();
System.out.println("\n" + successes.size() + " successful tests:");
for (final OwlTest test : successes) {
System.out.println("\t[SUCCESS] " + test.type() + " " + test.name);
}
System.out.println("\n" + failures.size() + " failed tests:");
for (final OwlTest test : failures) {
System.out.println("\t[FAIL] " + test.type() + " " + test.name);
System.out.println("\t\t(" + test.description + ")");
for (final Statement triple : test.error) {
if (test.types.contains(TEST_ENTAILMENT)) {
System.out.println("\t\tExpected: " + triple);
} else if (test.types.contains(TEST_NONENTAILMENT)) {
System.out.println("\t\tUnexpected: " + triple);
}
}
}
return 0;
}
use of org.openrdf.repository.Repository in project stanbol by apache.
the class SesameYardComponent method addingService.
@Override
public Object addingService(ServiceReference serviceReference) {
Repository repo = (Repository) bundleContext.getService(serviceReference);
if (repo == null) {
log.error("could not retrieve Sesame Repository for ServiceRefernece {} " + "(repository name: {})", serviceReference, repoId);
} else {
if (repoServiceReference != null) {
// check if the added service reference has a higher ranking
if (serviceReference.compareTo(repoServiceReference) > 0) {
log.info("re-regsiter SesameYard because ServiceReference {} " + "has a higher ranking as the currently used one {}!", serviceReference, repoServiceReference);
unregisterSesameYard();
registerSesameYard(serviceReference, repo);
}
// else the added reference has a lower ranking ... nothing todo
} else {
// first service is registered
registerSesameYard(serviceReference, repo);
}
}
return repo;
}
Aggregations