zhtk commented on code in PR #9874:
URL: https://github.com/apache/nifi/pull/9874#discussion_r2079799538
##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/test/java/org/apache/nifi/excel/TestExcelRecordReader.java:
##########
@@ -318,17 +328,47 @@ void testPasswordProtected() throws Exception {
assertEquals(DATA.length, records.size());
}
+ @Test
+ void testPasswordProtectedOlderExcelFormat() throws Exception {
+ RecordSchema schema = getPasswordProtectedSchema();
+ ExcelRecordReaderConfiguration configuration = new
ExcelRecordReaderConfiguration.Builder()
+ .withSchema(schema)
+ .withPassword(PASSWORD)
+ .withAvoidTempFiles(true)
+ .withInputFileType(InputFileType.XLS)
+ .build();
+
+ InputStream inputStream = new
ByteArrayInputStream(PASSWORD_PROTECTED_OLDER_EXCEL.toByteArray());
+ ExcelRecordReader recordReader = new ExcelRecordReader(configuration,
inputStream, logger);
+ List<Record> records = getRecords(recordReader, false, false);
+
+ assertEquals(DATA.length, records.size());
+ }
Review Comment:
Changed
##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/test/java/org/apache/nifi/excel/TestExcelRecordReader.java:
##########
@@ -318,17 +328,47 @@ void testPasswordProtected() throws Exception {
assertEquals(DATA.length, records.size());
}
+ @Test
+ void testPasswordProtectedOlderExcelFormat() throws Exception {
+ RecordSchema schema = getPasswordProtectedSchema();
+ ExcelRecordReaderConfiguration configuration = new
ExcelRecordReaderConfiguration.Builder()
+ .withSchema(schema)
+ .withPassword(PASSWORD)
+ .withAvoidTempFiles(true)
+ .withInputFileType(InputFileType.XLS)
+ .build();
+
+ InputStream inputStream = new
ByteArrayInputStream(PASSWORD_PROTECTED_OLDER_EXCEL.toByteArray());
+ ExcelRecordReader recordReader = new ExcelRecordReader(configuration,
inputStream, logger);
+ List<Record> records = getRecords(recordReader, false, false);
+
+ assertEquals(DATA.length, records.size());
+ }
+
@Test
void testPasswordProtectedWithoutPassword() {
RecordSchema schema = getPasswordProtectedSchema();
ExcelRecordReaderConfiguration configuration = new
ExcelRecordReaderConfiguration.Builder()
.withSchema(schema)
+ .withInputFileType(InputFileType.XLS)
.build();
InputStream inputStream = new
ByteArrayInputStream(PASSWORD_PROTECTED.toByteArray());
assertThrows(Exception.class, () -> new
ExcelRecordReader(configuration, inputStream, logger));
}
+ @Test
+ void testPasswordProtectedOlderExcelWithoutPassword() {
+ RecordSchema schema = getPasswordProtectedSchema();
+ ExcelRecordReaderConfiguration configuration = new
ExcelRecordReaderConfiguration.Builder()
+ .withSchema(schema)
+ .withInputFileType(InputFileType.XLS)
+ .build();
+
+ InputStream inputStream = new
ByteArrayInputStream(PASSWORD_PROTECTED_OLDER_EXCEL.toByteArray());
+ assertThrows(Exception.class, () -> new
ExcelRecordReader(configuration, inputStream, logger));
+ }
Review Comment:
Changed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]