Being a big fan of Unit Testing I was determined not to let a little thing like JNDI stop me from getting all green on my JUnit test results.
My first step was to separate out some of my applicationContext.xml logic into 2 files. One for the "real" application that will run under GlassFish - let's call it my-jndi.xml. And the other for running unit tests - let's call it my-jndi-test.xml.
my-jndi.xml had the following:
Then in my web.xml I had the following:
contextConfigLocation
/WEB-INF/my-jndi.xml
/WEB-INF/my-application.xml
my-jndi-test.xml had the following:
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
classpath:test.properties
true
Then in my base test class I had the following:
protected String[] getConfigLocations() {
return new String[] {
"file:web/WEB-INF/nexus-jndi-test.xml",
"file:web/WEB-INF/nexus-application.xml"
};
No comments:
Post a Comment