[
https://issues.apache.org/jira/browse/NIFI-5245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493411#comment-16493411
]
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_r191389306
--- Diff:
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestSimpleCsvFileLookupService.java
---
@@ -64,4 +64,28 @@ public void testSimpleCsvFileLookupService() throws
InitializationException, IOE
assertEquals(EMPTY_STRING, property3);
}
+ @Test
+ public void testSimpleCsvFileLookupServiceWithCharset() throws
InitializationException, IOException, LookupFailureException {
+ final TestRunner runner =
TestRunners.newTestRunner(TestProcessor.class);
+ final SimpleCsvFileLookupService service = new
SimpleCsvFileLookupService();
+
+ runner.addControllerService("csv-file-lookup-service", service);
+ runner.setProperty(service, SimpleCsvFileLookupService.CSV_FILE,
"src/test/resources/test_Windows-31J.csv");
+ runner.setProperty(service, SimpleCsvFileLookupService.CSV_FORMAT,
"RFC4180");
+ runner.setProperty(service, SimpleCsvFileLookupService.CHARSET,
"Windows-31J");
+ runner.setProperty(service,
SimpleCsvFileLookupService.LOOKUP_KEY_COLUMN, "key");
+ runner.setProperty(service,
SimpleCsvFileLookupService.LOOKUP_VALUE_COLUMN, "value");
+ runner.enableControllerService(service);
+ runner.assertValid(service);
+
+ final SimpleCsvFileLookupService lookupService =
+ (SimpleCsvFileLookupService) runner.getProcessContext()
+ .getControllerServiceLookup()
+ .getControllerService("csv-file-lookup-service");
+
+ assertThat(lookupService, instanceOf(LookupService.class));
+
+ final Optional<String> property1 =
lookupService.lookup(Collections.singletonMap("key", "property.1"));
+ assertEquals(Optional.of("this is property \uff11"), property1);
--- End diff --
Add `assertTrue(property1.isPresent())` so the test will cleanly fail the
evaluation if it's not present.
> 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)