Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

how to write spring Junit that tests data access(DAO) layer in Java?

I want to run Junit tests for Spring DAO Implementation classes that will connect to the Data base and returns me result.
How can i do that.
0
jgdvishnu
Asked:
jgdvishnu
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Is the Junit test in the same project as the DAO, or a separate one?  

Are you using beans to configure the Spring DAO?
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
Yes junit is in same project under src/test .

Yes I m using spring beans to configure dao.

Also I am using eh cache manager factory to run the query.
0
 
Bob LearnedCommented:
If the unit tests are in the same project, you will have access to the Spring beans.  I will need a little more information, in order to provide the help that you need.  I have created JUnit tests, with auto-wired helpers in test classes, that can access the DAO members.
0
 
jgdvishnuSoftware ArchitectAuthor Commented:
i was able to make it work through integration test.
0
 
Bob LearnedCommented:
Can you show me what you did differently to accomplish that?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now