我的测试看起来像
public class ITCache extends AbstractIntegrationTest {
@Test
public void readCache() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
assertNotNull(applicationContext);
final SimpleCacheManager simpleCacheManager = (SimpleCacheManager) applicationContext.getBean("cacheManager");
System.out.println("cacheName:" + simpleCacheManager.getCacheNames().toString());
System.out.println(simpleCacheManager.getCache("genders").toString());
}
}
我使用插件部署我的项目maven-cargo
,并且可以查看内容并applicationContext.xml
找到
➜ comma git:(S120297) ✗ jar -tvf integration/target/cargo/configurations/tomcat7x/webapps/common.war | grep app
2342 Wed Jul 16 20:28:32 PDT 2014 WEB-INF/classes/applicationContext.xml
➜ comma git:(S120297) ✗
但是当我运行测试时,我将失败视为
Tests in error:
readCache(com.org.comma.integration.ITCache): IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
我还尝试将我的测试注释为
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration (locations = "classpath*:/applicationContext*.xml")
public class ITCache extends AbstractIntegrationTest {
但仍然是同样的问题
这里出了什么问题?
更新
我web.xml
的条目如下
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>