Solved

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

Posted on 2014-11-02
5
385 Views
Last Modified: 2014-12-02
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
Comment
Question by:jgdvishnu
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40440266
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
 

Author Comment

by:jgdvishnu
ID: 40445759
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
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40450046
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
 

Author Comment

by:jgdvishnu
ID: 40477344
i was able to make it work through integration test.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40477351
Can you show me what you did differently to accomplish that?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now