-
Oct 4th, 2012, 06:38 PM
#1
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules