Want to inject a dao that has a configured data source injected into it.. not a fan of annotation because it makes code ugly, i want a pure XML solution.
the test cases are in subfolders in test folder, which is at the same level as the src folder
src
com
name
dao
ProductDao
test
com
name
dao
ProductDaoTest
ProductDaoTest needs to have ProductDao injected in it. tried to do that, spring injects it ok, but the ProductDao depenedencies arenot being injected, and I am facing NPE.
thought about moving test classes into src folder, but I dont think I should have to do that. the other alternative that I am thinking of is running the test cases via the browse through controller calls (but wont be unit testing anymore), so I am stuck trying to figure out the right thing to do.
thank you!
p.s. tests are junit, tomcat, spring 3.1
What methods in the DAO do you want to unit test? Are you not actually trying to test the DB connectivity?
Otherwise I agree with @duffymo.
Edit: To elaborate a bit, try to adapt the following code chunk to your test class needs:
and see if that doesn’t do the trick for the Dao dependency beans.
Cheers,