Search in sources :

Example 31 with InstallConfiguration

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()));
    }
}
Also used : ExecuteSparqlQuery(org.apache.rya.api.client.ExecuteSparqlQuery) Statement(org.openrdf.model.Statement) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Test(org.junit.Test)

Example 32 with InstallConfiguration

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));
}
Also used : InstanceExists(org.apache.rya.api.client.InstanceExists) ArrayList(java.util.ArrayList) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Aggregations

InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)32 RyaClient (org.apache.rya.api.client.RyaClient)26 Test (org.junit.Test)26 Install (org.apache.rya.api.client.Install)20 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)6 Statement (org.openrdf.model.Statement)5 CreatePCJ (org.apache.rya.api.client.CreatePCJ)4 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)4 RyaDetails (org.apache.rya.api.instance.RyaDetails)4 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)4 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 DuplicateInstanceNameException (org.apache.rya.api.client.Install.DuplicateInstanceNameException)3 InstanceExists (org.apache.rya.api.client.InstanceExists)3 RyaClientException (org.apache.rya.api.client.RyaClientException)3 AccumuloCreatePCJ (org.apache.rya.api.client.accumulo.AccumuloCreatePCJ)3 ValueFactory (org.openrdf.model.ValueFactory)3 Sail (org.openrdf.sail.Sail)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3