I want to reference a resource file, which is a keystore file, inside a Java test class. This property is normally loaded from a properties file which points to the JDK running either locally or remotely.
When Maven executes a build as part of my deploy process it is first built on a build server. I want to be able place the keystore file on the classpath so i dont have to put a hard dependency on the build server (whereby i would place the keystore on the build server)
When i wire up the unit test locally it works fine with this configuration however this path fails when i execute the build on the build server. Can anyone shed some light on why this is failing? and what i can do to resolve? I think i know the why but clarification would be great.
Current configuration
<bean id="httpClient"
class="myapp.HTTPClient">
<property name="trustStoreLocation" value="..\\mywebapp\\target\\test-classes\\truststore" />
<property name="trustStorePass" value="mypass" />
</bean>
For resource files, I prefer following the standard directory structure for Maven. Please read (http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) for more reference. Placing a file like (.cfg or .jks or .properties) in src/test/resources and src/main/resources automatically makes the available in the class path upon build. Further, it give you the ability to isolate your test and main resource files.
For example, my pom.xml looks like this:
Now, a simple way to verify if your file has been copied properly is to tabulate the jar and check for the file you want.
Then do: