我正在尝试为spring
项目编写一些单元测试。这是我要测试的类和测试:
@Component
public class EmployeeManager implements QuestionDAO {
private Manager manager;
@Autowired
public EmployeeManager(Manager manager) {
this.manager = manager;
}
public Category getSpecificCategory(Employee employee) {
return employee.getCategory();
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:META-INF/config.xml" })
public class EmployeeManagerTest extends MockObjectTestCase {
private EmployeeManager employeeManager;
@Autowired
private Manager manager;
@Override
public void setUp() {
this.manager = mock(Manager.class);
this.employeeManager = new EmployeeManager(manager);
}
@Test
public void testGetSpecificCategory() {
this.employeeManager.getSpecificCategory(new Employee("john","developer"));
}
}
当运行上面的测试时,我得到了
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://xmlns.jcp.org/xml/ns/config]
Offending resource: class path resource [META-INF/config.xml]
在pom.xml
我添加了junit
和spring-test
的依赖关系。
任何想法如何解决这个问题?
答案 0 :(得分:1)
它看起来像你的配置文件'不是spring xml配置:" http://xmlns.jcp.org/xml/ns/config"在此上下文中不是有效的名称空间。