Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Struts Action unit tests with AspectJ

 
al agady
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(){
System.out.println("Executing");
}
}
 
Emil Jennings
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic