spring单元测试
spring3.0.4单位测试,看代码说话吧
测试类:
import java.util.List; import javax.servlet.http.HttpServletRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; import org.springframework.web.HttpRequestHandler;
@ContextConfiguration public class TestUserManager extends AbstractTransactionalJUnit4SpringContextTests { @Autowired UserManager userManager; HttpServletRequest request; @Before public void setUp() { request = new MockHttpServletRequest(); } @Test public void testPageBean() { } } @After public void tearDown() { request = null; } }
配置文件:TestUserManager-context.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- ① 引入清单1定义的Spring配置文件 --> <!--<import resource="classpath:/applicationContext.xml"/>--> <import resource="classpath:/applicationContext-dao.xml"/> <import resource="classpath:/applicationContext-manager.xml"/> <import resource="classpath:/applicationContext-resources.xml"/> <import resource="classpath:/applicationContext-service.xml"/> </beans>
相关推荐
与卿画眉共浮生 2020-10-14
xiyang 2020-08-21
baijinswpu 2020-07-29
leonranri 2020-07-26
zhongliwen 2020-07-05
麋鹿麋鹿迷了路 2020-07-05
zengyu00 2020-07-05
XGQ 2020-07-04
CoderBoy 2020-06-28
whbing 2020-06-28
绝望的乐园 2020-06-27
wellfly 2020-06-26
菇星獨行 2020-06-25
草原孤狼 2020-06-25
坚持着执着 2020-06-16
wcqwcq 2020-06-14
yuanye0 2020-06-14
zhongliwen 2020-06-13
MrFuWen 2020-06-09