use of uk.gov.gchq.gaffer.accumulostore.AccumuloStore in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJob.
private void shouldReturnCorrectDataToMapReduceJob(final Schema schema, final KeyPackage kp, final List<Element> data, final View view, final User user, final String instanceName, final Set<String> expectedResults) throws Exception {
final AccumuloStore store = new MockAccumuloStore();
final AccumuloProperties properties = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
switch(kp) {
case BYTE_ENTITY_KEY_PACKAGE:
properties.setKeyPackageClass(ByteEntityKeyPackage.class.getName());
properties.setInstance(instanceName + "_BYTE_ENTITY");
break;
case CLASSIC_KEY_PACKAGE:
properties.setKeyPackageClass(ClassicKeyPackage.class.getName());
properties.setInstance(instanceName + "_CLASSIC");
}
try {
store.initialise(schema, properties);
} catch (StoreException e) {
fail("StoreException thrown: " + e);
}
setupGraph(store, data);
// Set up local conf
final JobConf conf = new JobConf();
conf.set("fs.default.name", "file:///");
conf.set("mapred.job.tracker", "local");
final FileSystem fs = FileSystem.getLocal(conf);
// Update configuration with instance, table name, etc.
store.updateConfiguration(conf, view, user);
// Run Driver
final File outputFolder = testFolder.newFolder();
FileUtils.deleteDirectory(outputFolder);
final Driver driver = new Driver(outputFolder.getAbsolutePath());
driver.setConf(conf);
driver.run(new String[] {});
// Read results and check correct
final SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(outputFolder + "/part-m-00000"), conf);
final Text text = new Text();
final Set<String> results = new HashSet<>();
while (reader.next(text)) {
results.add(text.toString());
}
reader.close();
assertEquals(expectedResults, results);
FileUtils.deleteDirectory(outputFolder);
}
use of uk.gov.gchq.gaffer.accumulostore.AccumuloStore in project Gaffer by gchq.
the class TableUtilsTest method shouldThrowExceptionIfTableNameIsNotSpecified.
@Test(expected = AccumuloRuntimeException.class)
public void shouldThrowExceptionIfTableNameIsNotSpecified() throws StoreException {
// Given
final Schema schema = new Schema.Builder().type("int", Integer.class).type("string", String.class).type("boolean", Boolean.class).edge("EDGE", new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("boolean").build()).build();
final AccumuloProperties properties = new AccumuloProperties();
properties.setStoreClass(SingleUseMockAccumuloStore.class.getName());
final AccumuloStore store = new AccumuloStore();
store.initialise(schema, properties);
// When
TableUtils.ensureTableExists(store);
fail("The expected exception was not thrown.");
}
Aggregations