我有以下测试类,但无论我将“ContextConfiguration-locations”设置为什么,它都不会设置我的UserService。而且当我在locations属性中设置不存在的文件时,它也不会抛出任何错误……我做错了什么?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContextTest.xml" })
public class BasicPersistenceTest {
@Autowired
private UserService userService;
@Test
public void testUserLogin() throws Exception {
User result = userService.getUser("stefan", "walkner");
Assert.assertNotNull(result);
}
@Test
public void testLogin() {
User user = userService.getUser("stefan", "walkner");
Assert.assertNull(user);
}
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
Spring版本:2.5.6.SEC01
JUnit版本:4.5
JDK:1.5