Solved

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

Posted on 2014-11-02
5
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

733 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