Testing @Configurable using the Maven Surefire plugin
I am using the @Configurable annotation to inject dependencies using AspectJ load time weaving and I still want to be able to unit test my code using the Maven Surefire plugin.
The following plugin configuration ensures the spring-agent dependency downloaded to my local Maven repository and configures the command line for the JVM.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-javaagent:${user.home}/.m2/repository/org/springframework/spring-agent/${org.springframework.version}/spring-agent-${org.springframework.version}.jar</argLine> </configuration> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-agent</artifactId> <version>${org.springframework.version}</version> </dependency> </dependencies> </plugin>
I used ${org.springframework.version} to reduce the probability missing something when I upgrade to a later version of Spring.
<properties> <org.springframework.version>2.5.5</org.springframework.version> </properties>
Tagged as aspectj, junit, maven, spring, surefire, tdd + Categorized as Development, Test Driven Development