Announcement Announcement Module
Collapse
No announcement yet.
programmatic AOP? i.e. JUnit? w/ hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Re: programmatic AOP? i.e. JUnit? w/ hibernate

    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?

    Comment


    • #3
      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!

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment

          Working...
          X