spiros.blog()
Spiros Tzavellas’s blog, mostly on software development and Java.
Browse: Home / Java / Testing Spring AOP code

Testing Spring AOP code

By spiros on February 23, 2006

In Using the Spring AOP Framework with EJB Components, Eugene Kuleshov presents a really nice way to test Spring AOP configuration code and advices. When you use Spring AOP use can easily test your target objects with unit tests, but how do you test the weaved code?

In the above article Eugene Kuleshov uses unit tests that reference the Spring ApplicationContext that has the AOP configuration code. Then at the setup method of the TestCase class he registers a custom BeanPostProcessor that provides mock implementations for the target objects. At the test methods he trains the mock objects and tests the all the AOP code except the target objects.

I really liked the trick with the custom BeanPostProcessor to provide the mock objects. I’ll probably start using this trick in my tests really soon.

BTW Using the Spring AOP Framework with EJB Components also provides lots of information on how to effectively use Spring in a EJB 2.x environment. If you are maintaining EJB 2.x applications and you want to make your applications more testable over time you should probably read this article.

Posted in Java | Tagged aop, spring framework

« Previous Next »

Pages

  • About
  • Projects

Categories

  • .Net
  • Agile
  • architecture
  • Databases
  • Firefox
  • Java
  • Javascript
  • Linux/Unix
  • Programming
  • Scala
  • Startups
  • Web

Tags

aop architecture aws book C# C/C++ caching circuit-breaker cloud clustering Databases dependency injection design patterns distributed eclipse EclipseLink ejb fp gc guice gwt hibernate Java javaee jhug jpa junit jvm maven mysql oop php podcast ruby Scala scalability scrum seam spring framework struts tools transactions web services wireless xml

Copyright © 2012 spiros.blog().

Powered by WordPress and Hybrid.