use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoExecuteSparqlQueryIT method ExecuteSparqlQuery_exec.
@Test
public void ExecuteSparqlQuery_exec() throws MongoException, DuplicateInstanceNameException, RyaClientException {
// Install an instance of Rya.
final MongoConnectionDetails connectionDetails = getConnectionDetails();
final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableEntityCentricIndex(false).setEnableFreeTextIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(false).setEnableGeoIndex(false).build();
ryaClient.getInstall().install(conf.getRyaInstanceName(), installConfig);
// Load some statements into that instance.
final List<Statement> statements = makeTestStatements();
ryaClient.getLoadStatements().loadStatements(conf.getRyaInstanceName(), statements);
// Execute the SPARQL against the Rya instance.
final ExecuteSparqlQuery executeSparql = ryaClient.getExecuteSparqlQuery();
final String sparql = "SELECT * where { ?a ?b ?c }";
final String results = executeSparql.executeSparqlQuery(conf.getRyaInstanceName(), sparql);
// Show the result matches what is expected.
assertTrue("result has header.", results.startsWith("Query Result:"));
assertTrue("result has column headings.", results.contains("a,b,c"));
assertTrue("result has footer.", results.contains("Retrieved 3 results in"));
for (final Statement expect : statements) {
assertTrue("All results should contain expected subjects:", results.contains(expect.getSubject().stringValue()));
assertTrue("All results should contain expected predicates:", results.contains(expect.getPredicate().stringValue()));
assertTrue("All results should contain expected objects:", results.contains(expect.getObject().stringValue()));
}
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoInstallIT method install.
@Test
public void install() throws DuplicateInstanceNameException, RyaClientException {
// Install an instance of Rya.
final String ryaInstance = conf.getMongoDBName();
// Setup the connection details that were used for the embedded Mongo DB instance we are testing with.
final MongoConnectionDetails connectionDetails = getConnectionDetails();
// Check that the instance does not exist.
final InstanceExists instanceExists = new MongoInstanceExists(getMongoClient());
assertFalse(instanceExists.exists(ryaInstance));
// Install an instance of Rya with all the valid options turned on.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).build();
final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
final Install install = ryaClient.getInstall();
install.install(ryaInstance, installConfig);
// Check that the instance exists.
assertTrue(instanceExists.exists(ryaInstance));
// Show that the expected collections were created within the database.
final List<String> expected = Arrays.asList(INSTANCE_DETAILS_COLLECTION_NAME, "rya_triples");
int count = 0;
final List<String> found = new ArrayList<>();
for (final String collection : getMongoClient().getDatabase(conf.getMongoDBName()).listCollectionNames()) {
count += expected.contains(collection) ? 1 : 0;
found.add(collection);
}
assertTrue("Tables missing from:" + expected + " actual:" + found, expected.size() == count);
assertTrue("Instance should exist.", instanceExists.exists(ryaInstance));
}
Aggregations