2011-09-06 3 views
4

테스트 케이스에서 web.xml을 사용하려고합니다. 하지만, 나는 할 수 없습니다 ...Junit의 테스트 케이스, web.xml을 읽는 방법

@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/web.xml", 
    "/integration/restful/*.xml"}  
public class RestfulTest { } 

오류 메시지 : web.xml 파일의

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://java.sun.com/xml/ns/javaee] Offending resource: URL [file:src/main/webapp/WEB-INF/web.xml] 

헤더 :

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 

내가 무엇을 할 수 있습니까?

답변

3

@ContextConfiguration은 Spring 응용 프로그램 컨텍스트 구성 파일을 찾고 있습니다. web.xml은 Spring 구성 파일이 아니라 서블릿 컨테이너에서 웹 애플리케이션을 구성하는 파일입니다.

스프링 애플리케이션 컨텍스트 파일은 스프링 관리 빈과 의존성을 설명합니다. 참조 : http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/testing.html

Spring은 Spring 응용 프로그램 컨텍스트 파일의 스키마에 따라 web.xml 파일을 구문 분석하려고하므로 테스트에 실패합니다.

관련 문제