Results 1 to 5 of 5

Thread: programmatic AOP? i.e. JUnit? w/ hibernate

  1. #1

    Default programmatic AOP? i.e. JUnit? w/ hibernate

    I am using Spring with Hibernate, and using AOP to create a proxy to handle my transaction / session management. Lets say that proxy is at the DAO level. So instead of injecting the DAO bean into a business logic class, I inject the interceptor proxy.

    How can I test this outside the Spring framework? i.e. for a Junit test to test something that requires the AOP presence?

    Even if I use the xml bean factory to get the interceptor proxt bean (to the DAO), I cannot programmatically pass a the proxy class into the setter for the DAO.

    Am I missing a key concept here?

    n00b dan =)

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default Re: programmatic AOP? i.e. JUnit? w/ hibernate

    Quote Originally Posted by dlevine
    How can I test this outside the Spring framework? i.e. for a Junit test to test something that requires the AOP presence?
    Are you sure that it requires the AOP presence? Can you just inject the DAO bean itself?
    --Jing Xue

  3. #3

    Default

    I am new to Spring and AOP, but I think that it is required. I am using the AOP method of interaction with Hibernate to open sessions instead of instead of using Hibernate Templates.

    Reference at section 4 of http://www.hibernate.org/110.html

    So throught the context of Spring I am passing a ProxyFactoryBean in to a setDAO method, but how can I test that outside of the app server context?

    Thanks for the reply!

  4. #4
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    But, unless you are doing something unusual, it's not actually an instance of ProxyFactoryBean passed to setDAO(), but rather a proxy instance created by ProxyFactoryBean and implementing the same DAO interface as your own DAO class implements, so you should be able to just pass an instance of your DAO to setDAO() instead of the proxy.
    --Jing Xue

  5. #5

    Default

    Again, thank you for the reply.

    I want to pass in the "proxy instance created by ProxyFactoryBean and implementing the same DAO interface" but I dont know how to get that. I want to test the functionality of the injection, so I want to get the proxied version programatically and inject that version in to my DAO.

Similar Threads

  1. Replies: 5
    Last Post: Dec 27th, 2005, 07:00 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. JUnit and Hibernate Session
    By darkit in forum Container
    Replies: 3
    Last Post: Mar 13th, 2005, 02:11 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

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