learn java
The moose likes Struts and the fly likes Writing Struts Action unit tests with AspectJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Writing Struts Action unit tests with AspectJ" Watch "Writing Struts Action unit tests with AspectJ" New topic

Writing Struts Action unit tests with AspectJ

al agady

Joined: Feb 07, 2004
Posts: 7
I am trying to create Struts unit test using AspectJ. I installed AJDT plugin in Eclipse, and created an easy aspect. There are only two pointcuts and two advices in the aspect. The first advice gets applied, and the second does not get applied because it doesn't find right match (can not find a match for Action "execute" method. I can not figure out why. Did someone had similar problems with applying advice to "execute" method :

Here is my code (advice highligted in green, gets applied, advice hightligted in red does not get applied):

public aspect ErrorLookupAspect {

pointcut errorLookupTest(ErrorLookupActionTest actionTest):
execution(public void ErrorLookupActionTest+.test*())
&& this(actionTest);

pointcut actionExecute()
: execution(public ActionForward ErrorLookupAction.execute(..));

before(ErrorLookupActionTest actionTest)
: errorLookupTest(actionTest){
System.out.println("Before Test");

before(): actionExecute(){
Emil Jennings
Ranch Hand

Joined: Jul 09, 2010
Posts: 59
Can you include the classes that you are trying to apply the aspect to? It will make it easier to compare to the join points in the aspect.
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: Writing Struts Action unit tests with AspectJ