我已经写了几Junit4测试,这看起来是这样的:
public class TestCampaignList extends StrutsJUnit4TestCase<Object> {
public static final Logger LOG = Logger.getLogger(TestCampaignList.class.getName());
@Before
public void loginAdmin() throws ServletException, UnsupportedEncodingException {
request.setParameter("email", "nitin.cool4urchat@gmail.com");
request.setParameter("password", "22");
String response = executeAction("/login/admin");
System.out.println("Login Response : " + response);
}
@Test
public void testList() throws Exception {
request.setParameter("iDisplayStart", "0");
request.setParameter("iDisplayLength", "10");
String response = executeAction("/campaign/list");
System.out.println("Reponse : " + response);
}
}
这两项行动返回JSON结果和executeAction
javadoc中说:
For this to work the configured result for the action needs to be FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
好像它无法处理JSON结果,因此,第二动作执行显示累加结果,使得result_for_second_action= result1 concatenate result2
是否有解决方案得到executeAction()
返回实际的JSON响应,而不是以前的所有执行级联的JSON响应。