shubhluck commented on code in PR #11495:
URL: https://github.com/apache/nifi/pull/11495#discussion_r3888037982


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutFile.java:
##########
@@ -244,6 +249,42 @@ public void testReplaceAndMaxFileLimitReach() throws 
IOException {
         assertEquals("Another file", new String(content));
     }
 
+    @Test
+    public void testPutFileFromLocalFile() throws Exception {
+        final TestRunner runner = TestRunners.newTestRunner(new PutFile());
+        runner.setProperty(PutFile.DIRECTORY, targetDir.getAbsolutePath());
+        runner.setProperty(PutFile.CONFLICT_RESOLUTION, 
PutFile.REPLACE_RESOLUTION);
+
+        final String attributeName = "file.path";
+        final String serviceId = FileResourceService.class.getSimpleName();
+        final FileResourceService service = new StandardFileResourceService();
+        runner.addControllerService(serviceId, service);
+        runner.setProperty(service, StandardFileResourceService.FILE_PATH, 
String.format("${%s}", attributeName));
+        runner.enableControllerService(service);
+
+        
runner.setProperty(ResourceTransferProperties.RESOURCE_TRANSFER_SOURCE, 
ResourceTransferSource.FILE_RESOURCE_SERVICE.getValue());
+        runner.setProperty(ResourceTransferProperties.FILE_RESOURCE_SERVICE, 
serviceId);
+
+        final byte[] fileData = "0123456789".getBytes(StandardCharsets.UTF_8);
+        final Path tempFilePath = 
Files.createTempFile("PutFile_testPutFileFromLocalFile_", "");

Review Comment:
   Switched to a @TempDir Path sourceDir method parameter and dropped the 
try/finally cleanup



-- 
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]

Reply via email to