Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video teaches viewers about errors in exception handling.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

932 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

9 Experts available now in Live!

Get 1:1 Help Now