Commit a6181d7 clearly shows the burden one has to face when trying to use this library outside a Spring Context test environment.
I think we can ease this process by providing this block of code as an API method with appropriate documentation for its usage:
AspectJProxyFactory componentFactory = new AspectJProxyFactory(component);
componentFactory.addAspect(aspect);
component = componentFactory.getProxy();
Example:
@InjectMocks private MyComponent component;
@InjectMocks private MyService service;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
component = ServiceValidationWrapper.wrap(component);
service = ServiceValidationWrapper.wrap(service);
}
An even simpler case would be (I think we can support both scenarios):
private MyComponent component;
private MyService service;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
component = ServiceValidationWrapper.wrap(MyComponent.class);
service = ServiceValidationWrapper.wrap(MyService.class);
}
Commit a6181d7 clearly shows the burden one has to face when trying to use this library outside a Spring Context test environment.
I think we can ease this process by providing this block of code as an API method with appropriate documentation for its usage:
Example:
An even simpler case would be (I think we can support both scenarios):