Search in sources :

Example 1 with DataAfterQuoteException

use of org.neo4j.csv.reader.DataAfterQuoteException in project neo4j by neo4j.

the class ImportPanicIT method shouldExitAndThrowExceptionOnPanic.

/**
     * There was this problem where some steps and in particular parallel CSV input parsing that
     * paniced would hang the import entirely.
     */
@Test
public void shouldExitAndThrowExceptionOnPanic() throws Exception {
    // GIVEN
    BatchImporter importer = new ParallelBatchImporter(directory.absolutePath(), fs, Configuration.DEFAULT, NullLogService.getInstance(), ExecutionMonitors.invisible(), AdditionalInitialIds.EMPTY, Config.empty(), StandardV3_0.RECORD_FORMATS);
    Iterable<DataFactory<InputNode>> nodeData = nodeData(data(NO_NODE_DECORATOR, fileAsCharReadable(nodeCsvFileWithBrokenEntries())));
    Input brokenCsvInput = new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData(), defaultFormatRelationshipFileHeader(), IdType.ACTUAL, csvConfigurationWithLowBufferSize(), new BadCollector(new NullOutputStream(), 0, 0), Runtime.getRuntime().availableProcessors());
    // WHEN
    try {
        importer.doImport(brokenCsvInput);
        fail("Should have failed properly");
    } catch (InputException e) {
        // THEN
        assertTrue(e.getCause() instanceof DataAfterQuoteException);
    // and we managed to shut down properly
    }
}
Also used : CsvInput(org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput) Input(org.neo4j.unsafe.impl.batchimport.input.Input) BadCollector(org.neo4j.unsafe.impl.batchimport.input.BadCollector) InputException(org.neo4j.unsafe.impl.batchimport.input.InputException) DataFactory(org.neo4j.unsafe.impl.batchimport.input.csv.DataFactory) CsvInput(org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput) DataAfterQuoteException(org.neo4j.csv.reader.DataAfterQuoteException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DataAfterQuoteException (org.neo4j.csv.reader.DataAfterQuoteException)1 BadCollector (org.neo4j.unsafe.impl.batchimport.input.BadCollector)1 Input (org.neo4j.unsafe.impl.batchimport.input.Input)1 InputException (org.neo4j.unsafe.impl.batchimport.input.InputException)1 CsvInput (org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput)1 DataFactory (org.neo4j.unsafe.impl.batchimport.input.csv.DataFactory)1