문제

My goal is to launch my integration tests contained within my Play app.

To do so, I used to launch them through Intellij. Those tests needs Spring aspectJ weaving, thus I precised in my Intellij test conf this VM argument:

-javaagent:/Users/myName/.ivy2/cache/org.springframework/spring-instrument/jars/spring-instrument-3.2.2.RELEASE.jar

The whole works.

Now I want to be able to launch them through command-line using the simple play command following by test-only command.

First I read this post dealing with the way to add any javaagent to Play app.

Thus, I modify my Play's build file like this, adding the Spring's javaagent:

java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M ${JAVA_OPTS} -javaagent:/Users/myName/.ivy2/cache/org.springframework/spring-instrument/jars/spring-instrument-3.2.2.RELEASE.jar -Dfile.encoding=UTF-8 -Dplay.version="${PLAY_VERSION}" -Dsbt.ivy.home=`dirname $0`/../repository -Dplay.home=`dirname $0` -Dsbt.boot.properties=`dirname $0`/sbt/sbt.boot.properties -jar `dirname $0`/sbt/sbt-launch.jar "$@"

However, my test merely fails.. complaining about the missing Spring's aspectJ weaving. But it's surely logic since test-only launches another process...

Is there a way to make my test care about aspectJ weaving using javaagent?

도움이 되었습니까?

해결책

Thanks to the link provided by @Igor Romanov in the above comment, here my solution:

val myApp = play.Project(appName, appVersion, appDependencies).settings(
    Keys.javaOptions in (Test) +=
     "-javaagent:/Users/myName/.ivy2/cache/org.springframework/spring-instrument/jars/spring-instrument-3.2.2.RELEASE.jar",
    // code remaining 

This allows to apply load-time weaving for class dealing with Spring's aspectj.

The whole works pretty well :) (tested with SBT 0.12.3, Scala 2.10 and Play 2.1)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top