Fix files delete tests - #5465
Conversation
Signed-off-by: sumittlearnbay <sumit.learnbay@gmail.com>
Signed-off-by: sumittlearnbay <sumit.learnbay@gmail.com>
322ac5b to
3fe9c2b
Compare
|
I had the same problem on Windows 11. After looking into the root cause, I found that the following line was written incorrectly in the first place: According to the Mockito javadoc, it is recommended to always use doReturn() for spies: However, even if you update the code to use doReturn(), the test still fails (and now it fails on macOS as well): This is because, ItemWriter's close() method actually deletes the file using Files.delete(). Therefore, in my opinion, instead of acquiring a lock with RandomAccessFile, mocking Files.delete() would be a better approach. Here is my sample code: |
|
Thank you for the explanation and suggestion. I updated both AbstractFileItemWriterTests and StaxEventItemWriterTests to mock Files.delete() using MockedStatic instead of File.delete(), following your recommendation. I verified the updated tests locally and pushed the changes to this PR. Please let me know if you see anything else that should be adjusted. |
|
Oh, and it's no big deal, but the filename AbstractFileItemWriterTest.java is missing an 's'. |
Thank you for taking time to contribute this pull request!
You might have already read the contributor guide, but as a reminder, please make sure to:
mainbranch and squash your commitsFor more details, please check the contributor guide.
Thank you upfront!