Is it possible to JUnit test if wiring by Spring is succesfully?
I would like to do this by reflection. Like: get all beans with id *Controller and test if the fields *services are not null?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
build your
ApplicationContexteither viaXmlWebApplicationContext‘s constructor or via the spring JUnit test runner and make your test implementApplicationContextAwareuse the methods of
ApplicationContextto find and verify everything you need, with the help ofReflectionUtilsandReflectionTestUtils. But have in mind that if injection fails, the whole context initialization fails.