use of org.openrdf.repository.manager.LocalRepositoryManager 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();
}
}
Aggregations