You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "dan-s1 (via GitHub)" <gi...@apache.org> on 2024/09/04 18:41:34 UTC
Re: [PR] NIFI-13579 Ensured whenever a timezone is specified in the timestamp pattern that it is taken into account when reading and writing. [nifi]
dan-s1 commented on code in PR #9196:
URL: https://github.com/apache/nifi/pull/9196#discussion_r1744260415
##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateRecord.java:
##########
@@ -593,6 +599,47 @@ public void testValidateMaps() throws IOException, InitializationException, Malf
}
}
+ @ParameterizedTest
+ @MethodSource("getLocales")
+ void testTimeZoneWithTimeStamp(Locale locale) throws Exception {
+ Locale originalLocale = Locale.getDefault();
+ Locale.setDefault(locale);
+ final String timestampWithTimeZonePattern = "dd/MM/yyyy HH:mm:ssZ";
+ final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/TestValidateRecord/timestampWithTimeZone.avsc")), "UTF-8");
+ final CSVReader csvReader = new CSVReader();
+ runner.addControllerService("reader", csvReader);
+ runner.setProperty(csvReader, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
+ runner.setProperty(csvReader, SchemaAccessUtils.SCHEMA_TEXT, schema);
+ runner.setProperty(csvReader, CSVUtils.FIRST_LINE_IS_HEADER, "true");
+ runner.setProperty(csvReader, CSVUtils.VALUE_SEPARATOR, "◆");
+ runner.setProperty(csvReader, DateTimeUtils.TIMESTAMP_FORMAT, timestampWithTimeZonePattern);
+ runner.enableControllerService(csvReader);
+
+ final CSVRecordSetWriter csvWriter = new CSVRecordSetWriter();
+ runner.addControllerService("writer", csvWriter);
+ runner.setProperty(csvWriter, "Schema Write Strategy", "full-schema-attribute");
+ runner.setProperty(csvWriter, DateTimeUtils.TIMESTAMP_FORMAT, timestampWithTimeZonePattern);
+ runner.enableControllerService(csvWriter);
+
+ runner.setProperty(ValidateRecord.RECORD_READER, "reader");
+ runner.setProperty(ValidateRecord.RECORD_WRITER, "writer");
+ runner.setProperty(ValidateRecord.ALLOW_EXTRA_FIELDS, "false");
+ runner.setProperty(ValidateRecord.MAX_VALIDATION_DETAILS_LENGTH, "4000");
+ runner.setProperty(ValidateRecord.VALIDATION_DETAILS_ATTRIBUTE_NAME, "valDetails");
+ final String timestampWithTimezone = "24/09/2024 15:04:23+0630";
+ final String content = "apache_date◆apache_ip_source◆apache_method◆apache_path◆apache_query_string◆apache_response_code◆apache_referer◆apache_user_agent\n" +
+ timestampWithTimezone + "◆10.4.3.20◆GET◆/path◆?test=toto◆200◆-◆";
+
+ runner.enqueue(content);
+ runner.run();
+
+ runner.assertTransferCount(ValidateRecord.REL_VALID, 1);
+ final MockFlowFile validFlowFile = runner.getFlowFilesForRelationship(ValidateRecord.REL_VALID).getFirst();
+ //Validate timezone is taken into account
+ assertFalse(validFlowFile.getContent().contains(timestampWithTimezone));
Review Comment:
@exceptionfactory I see you have been very busy the last couple of days. If you have time can you please review my changes and see if this is what you had in mind? Thanks!
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org