use of org.neo4j.commandline.admin.RealOutsideWorld in project neo4j by neo4j.
the class CsvImporterTest method writesReportToSpecifiedReportFile.
@Test
public void writesReportToSpecifiedReportFile() throws Exception {
File dbDir = testDir.directory("db");
File logDir = testDir.directory("logs");
File reportLocation = testDir.file("the_report");
File inputFile = testDir.file("foobar.csv");
List<String> lines = Arrays.asList("foo,bar,baz");
Files.write(inputFile.toPath(), lines, Charset.defaultCharset());
try (RealOutsideWorld outsideWorld = new RealOutsideWorld()) {
Config config = Config.defaults().with(additionalConfig()).with(stringMap(DatabaseManagementSystemSettings.database_path.name(), dbDir.getAbsolutePath(), GraphDatabaseSettings.logs_directory.name(), logDir.getAbsolutePath()));
CsvImporter csvImporter = new CsvImporter(Args.parse(String.format("--report-file=%s", reportLocation.getAbsolutePath()), String.format("--nodes=%s", inputFile.getAbsolutePath())), config, outsideWorld);
csvImporter.doImport();
}
assertTrue(reportLocation.exists());
}
use of org.neo4j.commandline.admin.RealOutsideWorld in project neo4j by neo4j.
the class ImportCommandTest method defaultsToCsvWhenModeNotSpecified.
@Test
public void defaultsToCsvWhenModeNotSpecified() throws Exception {
File homeDir = testDir.directory("home");
ImporterFactory mockImporterFactory = mock(ImporterFactory.class);
when(mockImporterFactory.getImporterForMode(eq("csv"), any(Args.class), any(Config.class), any(OutsideWorld.class))).thenReturn(mock(Importer.class));
try (RealOutsideWorld outsideWorld = new RealOutsideWorld()) {
ImportCommand importCommand = new ImportCommand(homeDir.toPath(), testDir.directory("conf").toPath(), outsideWorld, mockImporterFactory);
String[] arguments = { "--database=foo", "--from=bar" };
importCommand.execute(arguments);
verify(mockImporterFactory).getImporterForMode(eq("csv"), any(Args.class), any(Config.class), any(OutsideWorld.class));
}
}
Aggregations