Thus, the component that performs the loading and the component that processes the page must be separate. Every time you have a problem testing part of the code, this is a sign that you can try to do too much in one component.
After you have done this, you will test part of the processing, however, it makes sense. Ask the processor component to take an InputStream or even just type String.
As for the download part, you probably need an integration test. Integration tests are often much more active and require setting up a local web server (maven can do this), or at least using a file: URL.
source share