如何处理使用正则表达式指定的xml文件路径,以支持Spring进行集成测试的多个环境?

问题描述 投票:0回答:1

我在test-appContext.xml文件中具有以下配置,以支持执行Spring集成测试。

<bean id="cacheManagerConfig" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> 
    <property name="configLocation" value="file:/web/${websphere.env}/${websphere.Domain}/${websphere.Name}/myportal/config/ehcache.xml"/>
</bean>

我正在将带有弹簧4的junit 4.12用于MVC流的集成测试。在Spring集成测试中如何处理ehcache.xml文件路径。

谢谢:)

java spring integration-testing junit4
1个回答
0
投票

[我得到了解决方案,作为从系统属性中检索值的表达式,在Liberty服务器的情况下,该属性是jvm.options文件,因此我在测试用例类中使用了以下代码。

static {
        System.setProperty("websphere.env", "test");
        System.setProperty("websphere.Domain", "mytestdomain");
        System.setProperty("websphere.Name", "mytestdomain");

    }

工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.