Skip to content

Create an AspectJ Proxy wrapper #18

@samuelgrigolato

Description

@samuelgrigolato

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions