I am having an issue with my attempt to unit test my DAO in a webapp. I have my spring configuration all set up to create a dataSource bean using the Sybase JConnect JDBC driver. My problem is that I can only get my bean created when I run the app as a webapp.
In trying to run unit tests, I receive:
java.lang.ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver
To further explain, here is my directory structure:
src
main
-java
- ...java files etc
- resources
-applicationContext.xml
-other config files
- webapp
-WEB-INF
-jconn3.jar <---- putting it here works, but test doesn't have a WEB-INF folder!
-test
-java
-resources
So how do I allow jconn3.jar to be recognized at runtime for my unit tests? I have tried putting it in the main/resources directoru, but this causes the failure regardless of whether I'm running it as webapp or not. I can see that jconn3.jar gets copied to the target/classes directory on build, so why is the jar not found at runtime? It seems the only way to get this to work is to keep it in the WEB-INF directory, but then how do I unit test my DAO that depends on it.
I am using Spring MVC and maven. Note I cannot add a maven dependency since the jar is not in a repository, nor do I have the option to add it to a remote repo.
So to sum up, I need to have the jar on my build path for both running the webapp AND for unit testing since both need the jar for the DAO. How do I achieve this when placing it in the resources folder doesn't seem to help.