ekovacs commented on a change in pull request #3282: NIFI-5983: handling parse 
problems in recordReader implementations
URL: https://github.com/apache/nifi/pull/3282#discussion_r253915705
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/csv/ITApacheCSVRecordReader.java
 ##########
 @@ -71,4 +80,30 @@ public void testParserPerformance() throws IOException, 
MalformedRecordException
             assertEquals(NUM_LINES, numRecords);
         }
     }
+
+    @Test
+    public void testExceptionThrownOnParseProblem() throws IOException, 
MalformedRecordException {
+        CSVFormat csvFormat = 
CSVFormat.DEFAULT.withFirstRecordAsHeader().withQuoteMode(QuoteMode.ALL).withTrim().withDelimiter(',');
+        final int NUM_LINES = 25;
+        StringBuilder sb = new StringBuilder("\"id\",\"name\",\"balance\"");
+        for (int i = 0; i < NUM_LINES; i++) {
+            sb.append(String.format("\"%s\",\"John Doe\",\"4750.89D\"\n", i));
+        }
+        // cause a parse problem
+        sb.append(String.format("\"%s\"dieParser,\"John Doe\",\"4750.89D\"\n", 
NUM_LINES ));
+        sb.append(String.format("\"%s\",\"John Doe\",\"4750.89D\"\n", 
NUM_LINES + 1));
+        final RecordSchema schema = new 
SimpleRecordSchema(createStringFields(new String[] {"id", "name", "balance"}));
+
+        try (final InputStream bais = new 
ByteArrayInputStream(sb.toString().getBytes());
+             final CSVRecordReader reader = new CSVRecordReader(bais, 
Mockito.mock(ComponentLog.class), schema, csvFormat, true, false,
+                     RecordFieldType.DATE.getDefaultFormat(), 
RecordFieldType.TIME.getDefaultFormat(), 
RecordFieldType.TIMESTAMP.getDefaultFormat(), "UTF-8")) {
+
+            @SuppressWarnings("unused")
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to