I have an apiKey.properties file on my classpath that is used in my Spring application, in the spring-security-context. The location is defined as follows:
<beans:property name="apiKeyFileLocation" value="classpath:META-INF/config/apiKey.properties" />
This works just fine. The class that uses the bean can locate the properties file using this path.
I've written a new class that uses the same resource, and wanted to test it. However, the JUnit test for that class can't seem to locate the properties file.
In the context.xml file for the JUnit test, I tried the same thing:
<property name="apiKeyPropertiesPath" value="classpath:META-INF/config/apiKey.properties"/>
However, when I do run the test, I get:
java.lang.IllegalArgumentException: Unable to read properties from specified apiKeyFileLocation [classpath:META-INF/config/apiKey.properties].
Caused by: java.io.FileNotFoundException: classpath:META-INF\config\apiKey.properties (The filename, directory name, or volume label syntax is incorrect)
I've tried several variations of the classpath with no success. How should I obtain this properties file from the unit test?
Aucun commentaire:
Enregistrer un commentaire