Announcement Announcement Module
Collapse
No announcement yet.
AOP and unit testing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP and unit testing

    Hi,

    Is there a way to unit test an advice with JUnit ? I have a problem when I unit test my invoke(MethodInvocation invocation) method, I am not able to create a mock for the object MethodInvocation. Any guess ?

  • #2
    I would guess creating a proxy object in the unit test would be the easiest approach:

    Code:
    ProxyFactory proxyFactory = new ProxyFactory(myTarget);
    proxyFactory.addAdvise(myMethodInterceptor);
    MyInterface proxy = (MyInterface)proxyFactory.getProxy();

    Comment


    • #3
      yes I am going to work something around that, I don't need any mock, I am just going to use the spring API. Thanks

      Comment

      Working...
      X