Book Image

Spring 2.5 Aspect Oriented Programming

Book Image

Spring 2.5 Aspect Oriented Programming

Overview of this book

Developing powerful web applications with clean, manageable code makes the maintenance process much easier. Aspect-Oriented Programming (AOP) is the easiest and quickest way to achieve such results. Spring is the only Java framework to offer AOP features. The combined power of Spring and AOP gives a powerful and flexible platform to develop and maintain feature-rich web applications quickly. This book will help you to write clean, manageable code for your Java applications quickly, utilizing the combined power of Spring and AOP. You will master the concepts of AOP by developing several real-life AOP-based applications with the Spring Framework, implementing the basic components of Spring AOP: Advice, Joinpoint, Pointcut, and Advisor. This book will teach you everything you need to know to use AOP with Spring. It starts by explaining the AOP features of Spring and then moves ahead with configuring Spring AOP and using its core classes, with lot of examples. It moves on to explain the AspectJ support in Spring. Then you will develop a three-layered example web application designed with Domain-Driven Design (DDD) and built with Test-Driven Development methodology using the full potential of AOP for security, concurrency, caching, and transactions.
Table of Contents (13 chapters)

Test


Now that we've seen the implementation, let's look at the tests.

As a testing framework we use JUnit 4.5 with the use of annotations and for the preparation of repositories before and after tests we employ DbUnit. (For details about JUnit see: http://www.junit.org, for details about DbUnit see: http://dbunit.sourceforge.net.)

The main class is AllTests, marked with @RunWith(Suite.class) to act as TestSuite.

In the @SuiteClasses annotation, we put the classes that contain the tests.

The annotated setup method with @BeforeClass contains the initialization of Spring applicationContext; the annotated tearDown method with @AfterClass destroys the ApplicationContext and closes the DbUnit connection.

The folders that contain the tests have packages identical to the classes. This is to have access to the classes that have visibility only for the package, so that the test classes can test their targets.

We have three main classes to perform the tests: first, the unit tests; second, the integration...