Search code examples
javaspringintegration-testingjunit4

How to handle xml file path given using regular expression to support multiple environment for Integration Testing by Spring?


I have following configuration in my test-appContext.xml file for supporting execution of spring integration testing.

<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>

I am using junit 4.12 with spring 4 for Integration Testing of MVC flow.
How to handle ehcache.xml file path in spring integration testing.

Thanks :)


Solution

  • I got the solution, as expression retrieving value from System Property which jvm.options file in case of Liberty server so i used following code in test case class.

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

    Its working fine.