concept custom URL protocol handler in category java

This is an excerpt from Manning's book JUnit in Action.
7.4.1 Producing a custom URL protocol handler
To implement a custom URL protocol handler, we need to call the URL method setURLStreamHandlerFactory and pass it a custom URLStreamHandlerFactory. The engineers at Tested Data Systems Inc. are using this approach to create their stub implementation of the URL stream handler. Whenever the URL openConnection method is called, the URLStreamHandlerFactory class is called to return a URLStreamHandler. Listing 7.6 shows the code that performs this action. The idea is to call the URL static method setURLStreamHandlerFactory in the JUnit 5 setUp method.

This is an excerpt from Manning's book JUnit in Action, Second Edition.
To implement a custom URL protocol handler, you need to call the URL method setURLStreamHandlerFactory and pass it a custom URLStreamHandlerFactory. Whenever the URL openConnection method is called, the URLStreamHandlerFactory class is called to return a URLStreamHandler. Listing 6.6 shows the code to perform this feat. The idea is to call the URL static method setURLStreamHandlerFactory in the JUnit setUp method. (A better implementation would use a TestSetup class, such that this is performed only once during the whole test suite execution.)