[
https://issues.apache.org/jira/browse/NIFI-5245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493407#comment-16493407
]
ASF GitHub Bot commented on NIFI-5245:
--------------------------------------
Github user MikeThomsen commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2745#discussion_r191389134
--- Diff:
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestCSVRecordLookupService.java
---
@@ -66,4 +66,30 @@ public void testSimpleCsvFileLookupService() throws
InitializationException, IOE
assertEquals(EMPTY_RECORD, property3);
}
+ @Test
+ public void testSimpleCsvFileLookupServiceWithCharset() throws
InitializationException, IOException, LookupFailureException {
+ final TestRunner runner =
TestRunners.newTestRunner(TestProcessor.class);
+ final CSVRecordLookupService service = new
CSVRecordLookupService();
+
+ runner.addControllerService("csv-file-lookup-service", service);
+ runner.setProperty(service, CSVRecordLookupService.CSV_FILE,
"src/test/resources/test_Windows-31J.csv");
+ runner.setProperty(service, CSVRecordLookupService.CSV_FORMAT,
"RFC4180");
+ runner.setProperty(service, CSVRecordLookupService.CHARSET,
"Windows-31J");
+ runner.setProperty(service,
CSVRecordLookupService.LOOKUP_KEY_COLUMN, "key");
+ runner.enableControllerService(service);
+ runner.assertValid(service);
+
+ final CSVRecordLookupService lookupService =
+ (CSVRecordLookupService) runner.getProcessContext()
+ .getControllerServiceLookup()
+ .getControllerService("csv-file-lookup-service");
+
+ assertThat(lookupService, instanceOf(LookupService.class));
+
+ final Optional<Record> property1 =
lookupService.lookup(Collections.singletonMap("key", "property.1"));
+ assertEquals("this is property \uff11",
property1.get().getAsString("value"));
--- End diff --
I would recommend adding `assertTrue(property1.isPresent())`.
> SimpleCSVFileLookupService should take account of charset.
> ------------------------------------------------------------
>
> Key: NIFI-5245
> URL: https://issues.apache.org/jira/browse/NIFI-5245
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.6.0
> Environment: Windows 10
> Reporter: Seiji Sogabe
> Priority: Critical
>
> If charset of csv file is not default encoding on platform,
> SimpleCSVFileLookupService will lead to garbled characters.
> CSVRecordLookupService also has the same problem.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)