Announcement Announcement Module
Collapse
No announcement yet.
JUnit and AspectJ woven classes problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JUnit and AspectJ woven classes problem

    I'm using aspectJ compile time weaving of our own custom Aspect and for @Transactional handling in our spring application. Everything works fine normally but I just noticed the JUnit tests are performing oddly.

    We use the SpringJunit4ClassRunner to instantiate everything in the unit tests and all all our non aspect woven beans operate correctly. For the ones using Aspects however, based on tracing it looks like they are not singletons and being constructed multiple times which causes all kind of weirdness.

    Based on my read of the docs Iíve added explicit bean definitions for both aspects that being used:

    <bean class="org.springframework.transaction.aspectj.Ann otationTransactionAspect" factory-method="aspectOf">
    <property name="transactionManager" ref="txManager"/>
    </bean>

    <bean class="com.path.metrics.MetricsAspect" factory-method="aspectOf">
    <property name="metricsInstance" ref="GlobalMetricsInstance"/>
    </bean>

    But that has had no effect. Does anyone know how to get this type setup to work correctly or have some advice?
    Thanks
    Ben
Working...
X