struts2 测试

可是说struts2的测试基本脱离了web容器
可以像测试普通类一样去测试了
我扩展了一下spring的AbstractTransactionalDataSourceSpringContextTests来测试strtus2的action 如下
public class CustomerListActionTest extends DaoTestCase {
	private CustomerListAction customerListAction;
	
	public void testExecute(){
		customerListAction.execute();
		assertNotNull( customerListAction.getPage() );
		assertEquals(2, customerListAction.getPage().getList().size());
	}


	public void setCustomerListAction(CustomerListAction customerListAction) {
		this.customerListAction = customerListAction;
	}
}
public class DaoTestCase extends AbstractTransactionalDataSourceSpringContextTests{
	
	@Override
	protected String[] getConfigLocations() {
		//this.setAutowireMode();
		return new String[]{"classpath*:resources/spring/applicationContext.xml"};
	}
}

相当的爽 完全脱离了web容器

你可能感兴趣的:(spring,Web,xml)