Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Unit/Intergration Testing setup
    primarykey
    data
    text
    <p>I didn't write unit or integration testing but now I am trying. I am having a hard time setting up the environment.</p> <p>I have my application context under WEB-INF/applicationContext*.xml and in my applicationContext.xml, it has a reference to a properties file for DB user/pass, LDAP host, etc </p> <pre class="lang-xml prettyprint-override"><code>&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;/WEB-INF/spring-config/dev.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>I have another properties for log4j config (diff config for DEV/Staging/Production). <code>${webapp.root}</code> is defined in web.xml</p> <pre class="lang-xml prettyprint-override"><code> &lt;!-- log4j setting --&gt; &lt;bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt; &lt;property name="targetClass" value="org.springframework.util.Log4jConfigurer" /&gt; &lt;property name="targetMethod" value="initLogging" /&gt; &lt;property name="arguments"&gt; &lt;list&gt; &lt;value&gt;${webapp.root}/${log4j.properties.location}&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>And now I am trying to put the following in a test class.</p> <pre><code>@Override protected String[] getConfigLocations() { return new String[]{ "file:trunk/code/web/WEB-INF/applicationContext.xml", }; } </code></pre> <p>This references my xml correctly, but all the properties are screwed up.</p> <p>I want to know the following:</p> <ul> <li>Is there a way to set up in the test class properly? If not, should I move these classes? </li> <li>How can I set up Log4j if there is a reference to webroot which only exist in a container?! </li> <li>What is the best practice of Spring config location?</li> </ul> <p>Please Advise</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload