私のテストは次のようになります
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 {
しかし、まだ同じ問題
ここで何がうまくいかないのですか?
更新
Myweb.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>