ftpmock | Test your FTP calls offline | FTP library
kandi X-RAY | ftpmock Summary
kandi X-RAY | ftpmock Summary
Test your FTP calls offline.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- This method is called when a connection is logged in the connection .
- Convert string to string
- Logs the login to the database .
- Write the contents of the remote file .
- Raise an error if the local file is not available
- Reads from the cached file .
- Sets a connection to the host .
- Store a link to the remote file .
- Returns the path for the given path
- Get the text from the remote file .
ftpmock Key Features
ftpmock Examples and Code Snippets
Community Discussions
Trending Discussions on ftpmock
QUESTION
In fact, my question is divided into two parts.
- How do I isolate my test from outside but still make sure that the functionality works?
- How can I mock the apache commons FtpClient class using Mockito? When I mock it, I get null at:
InputStream inputStream = ftpClient.retrieveFileStream(ftpParameters.getSourceFileName());
Here's the test class:
...ANSWER
Answered 2017-Feb-03 at 09:27To answer that part that can be answered so far - you have to learn how to write testable code; a good starting point would be these videos.
There is already a misunderstanding on your side: It seems mocked FtpClient object is not suitable for making real thing.
Exactly. A mock is a mock, an empty test stub. It doesn't do anything real. That is the whole point of using mocks. They are empty shells that do nothing but provide the behavior that you specify for them. What I mean: the object created by Mockito is not a true FtpClient. It is just a mock that "looks" like an FtpClient. It doesn't have any connection to the "real" FtpClient" class. In other words: yes, you can call the methods on it that FtpClient has, but they are all empty. They do nothing (well, they do what you specify them to do their).
The point is: you use mocks to decouple you completely from an external implementation. By giving a mock to your code under test, you simply can ignore everything that the "real" class is doing.
Looking at your code and the "actual" problem:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ftpmock
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page