2010-08-19 4 views
0

Struts 2.1.8.1에서 주석 기반 유효성 검사를 사용하고 있습니다.스트럿츠 2에 대한 단위 테스트를 어떻게 작성합니까?

이제 jUnit 4를 사용하여 단위 테스트를 작성하려고하지만이를 수행하는 방법에 대한 단서가 없습니다. http://bloodredsun.blog.com/2009/10/21/unit-testing-struts2-actions-with-annotation-based-validation/

사람이 방법을 발견했습니다 :

나는 스트럿츠 2.1.6에서 근무하지만 더 이상 스트럿츠 2.1.8.1에서 몇 가지 링크를 찾았나요?

감사합니다.

답변

0
@TransactionConfiguration(transactionManager = "transactionManager") 
public class MyTestCase extends StrutsSpringTestCase { 
    @Override 
    protected String getContextLocations() { 
     return "classpath*:applicationContext-test.xml"; 
    } 
} 


@Test 
    public void testMyActionMapping() { 
     final ActionMapping mapping = this.getActionMapping("/uriMap"); 
     Assert.assertNotNull(mapping); 
     Assert.assertEquals("/uriMap", mapping.getNamespace()); 
     Assert.assertEquals("uriMap", mapping.getName()); 

     final ActionProxy proxy = this.getActionProxy("/uriMap"); 

     final MyAction action = MyAction.class.cast(proxy); 
    } 
관련 문제