use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoListInstancesIT method listInstances_hasRyaDetailsTable.
@Test
public void listInstances_hasRyaDetailsTable() throws MongoException, DuplicateInstanceNameException, RyaClientException {
// Install a few instances of Rya using the install command.
final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
final Install install = ryaClient.getInstall();
install.install("instance1_", InstallConfiguration.builder().build());
install.install("instance2_", InstallConfiguration.builder().build());
install.install("instance3_", InstallConfiguration.builder().build());
// Fetch the list and verify it matches what is expected.
final ListInstances listInstances = new MongoListInstances(getMongoClient());
final List<String> instances = listInstances.listInstances();
Collections.sort(instances);
final List<String> expected = Lists.newArrayList("instance1_", "instance2_", "instance3_");
assertEquals(expected, instances);
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoLoadStatementsIT method loadStatements.
/**
* Pass a list of statements to our loadStatement class.
*/
@Test
public void loadStatements() throws Exception {
// 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);
// Create the statements that will be loaded.
final Set<Statement> statements = makeTestStatements();
// Load them.
ryaClient.getLoadStatements().loadStatements(conf.getRyaInstanceName(), statements);
// Fetch the statements that have been stored in Mongo DB.
final Set<Statement> stmtResults = new HashSet<>();
final MongoCursor<Document> triplesIterator = getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection(conf.getTriplesCollectionName()).find().iterator();
while (triplesIterator.hasNext()) {
final Document triple = triplesIterator.next();
stmtResults.add(VF.createStatement(VF.createURI(triple.getString("subject")), VF.createURI(triple.getString("predicate")), VF.createURI(triple.getString("object"))));
}
// Show the discovered statements match the original statements.
assertEquals(statements, stmtResults);
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoUninstallIT method uninstall_instanceDoesNotExists.
@Test(expected = InstanceDoesNotExistException.class)
public void uninstall_instanceDoesNotExists() throws MongoException, RyaClientException {
// Install an instance of Rya.
final String instanceName = "testInstance_";
// Uninstall the instance
final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
final Uninstall uninstall = ryaClient.getUninstall();
uninstall.uninstall(instanceName);
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloAddUserIT method userAddedCanInsert.
/**
* Ensure a user that has been added to the Rya instance can interact with it.
*/
@Test
public void userAddedCanInsert() throws Exception {
final String user = testInstance.createUniqueUser();
final SecurityOperations secOps = super.getConnector().securityOperations();
final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
// Create the user that will not be added to the instance of Rya, but will try to scan it.
secOps.createLocalUser(user, new PasswordToken(user));
// Install the instance of Rya.
userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
// Add the user.
userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
// Try to add a statement to the Rya instance. This should succeed.
Sail sail = null;
SailConnection sailConn = null;
try {
final AccumuloRdfConfiguration userDConf = makeRyaConfig(getRyaInstanceName(), user, user, getInstanceName(), getZookeepers());
sail = RyaSailFactory.getInstance(userDConf);
sailConn = sail.getConnection();
final ValueFactory vf = sail.getValueFactory();
sailConn.begin();
sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
sailConn.close();
} finally {
if (sailConn != null) {
sailConn.close();
}
if (sail != null) {
sail.shutDown();
}
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloAddUserIT method userNotAddedCanNotInsert.
/**
* Ensure a user that has not been added to the Rya instance can not interact with it.
*/
@Test
public void userNotAddedCanNotInsert() throws Exception {
final String user = testInstance.createUniqueUser();
final SecurityOperations secOps = super.getConnector().securityOperations();
final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
// Install the instance of Rya.
userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
// Create the user that will not be added to the instance of Rya, but will try to scan it.
secOps.createLocalUser(user, new PasswordToken(user));
// Try to add a statement the Rya instance with the unauthorized user. This should fail.
boolean securityExceptionThrown = false;
Sail sail = null;
SailConnection sailConn = null;
try {
final AccumuloRdfConfiguration userCConf = makeRyaConfig(getRyaInstanceName(), user, user, getInstanceName(), getZookeepers());
sail = RyaSailFactory.getInstance(userCConf);
sailConn = sail.getConnection();
final ValueFactory vf = sail.getValueFactory();
sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
} catch (final RuntimeException e) {
final Throwable cause = e.getCause();
if (cause instanceof AccumuloSecurityException) {
securityExceptionThrown = true;
}
} finally {
if (sailConn != null) {
sailConn.close();
}
if (sail != null) {
sail.shutDown();
}
}
assertTrue(securityExceptionThrown);
}
Aggregations