Hello,
thanks for helping me !
Here is my testApplicationContext.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<p:beans xmlns:p="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<aop:aspectj-autoproxy />
<p:bean id="aspectClass" class="xx.yyy.zzz.AspectClass" />
<p:bean name="/DeclarationSearchAction" class="xx.yyy.zzz.DeclarationSearchAction" />
<p:bean id="DeclarationSearchActionTest" class="xx.yyy.zzz.DeclarationSearchActionTest" />
</p:beans>
My AspectClass :
Code:
@Aspect
public class DimonaStrutsActionPreExecuteNotifier {
@Pointcut("execution(public * *.test*(..))")
public void printaspect() {
}
@Around("printaspect()")
public Object log(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("aspect for method :" + pjp.getSignature().getName());
Object o = pjp.proceed();
return o;
}
}
And My Junit ( which in fact will be a MockStrutsTestCase test )
Code:
@ContextConfiguration(locations="/testApplicationContext.xml")
public class DeclarationSearchActionTest extends MockStrutsTestCase{
public DeclarationSearchActionTest(String testName) {
super(testName);
}
public DeclarationSearchActionTest(){
}
@Override
protected void setUp() throws Exception {
super.setUp();
setContextDirectory(new File("src/main/webapp/"));
setConfigFile("/WEB-INF/test-struts-config.xml");
// Choose which action we want to test
setRequestPathInfo("/DeclarationSearchAction.do");
}
public void testMultipleresultListForward() {
// FILL TESTDB WITH ONLY 2 OR MORE VALUES
actionPerform();
verifyForward("success");
}
}
My execute method is well advised but not the testMethod.