Solved

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

Posted on 2014-11-02
5
448 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

690 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