File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Struts Action unit tests with AspectJ

 
al agady
Greenhorn
Posts: 7
  • 0
  • 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: 65
1
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic