开发者

test case by Junit, how to read web.xml

I'm trying to use web.xml in test case. but, I cannot...

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

error message:

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

header of 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">

What can i do?


The @ContextConfiguration is looking for Spring application context configuration files. web.xml is not a Spring configuration file, but rather a file that configures a web application in a servlet container.

Spring application context files describe your Spring managed beans and dependencies. See: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/testing.html

Your test is failing because Spring is trying to parse the web.xml file according to the schema for Spring application context files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜