Plugin to run JUnit with maven
Mocking
a handler calls several remote services during the handling
must mock remote calls
the handler uses Guice to wiring up the objects
in order to test DI setup, wish to use production code bootstrap process - using Guice - instead of instantiating class with all-args-constructor and provide fakes
So to summarise - need to create the handler as if in production, with Guice wiring up everything in behind, but somehow intercept the remote calls
Guice configuration uses Modules.
In a maven setup, just create a Module class with the same package and class name in test folder - so to override the same class in main folder. This is a simple and sure way to replace a class with a mock.
To intercept network, just provide a mock http client through the replaced module.
PowerMock:
yes it can intercept object construction
however when involves a complex graph - interfaces, extends and abstract classes, it does not work. Guess is maybe the constructor is not attached to the implementation class but to the parent (abstract) class.