Results 1 to 3 of 3

Thread: AOP and unit testing

  1. #1
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default 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. #2
    Join Date
    Oct 2004
    Location
    Antwerp, Belgium
    Posts
    96

    Default

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

  3. #3
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •