Skip to Content
Sep 02, 2020 at 06:15 AM

How to set Application context for the integration test ?

45 Views Last edit Sep 02, 2020 at 06:16 AM 2 rev

Hello there,

I have been working in the sitemap and I need to write integration tests for code coverage.

if you refer this class "AbstractSiteMapGenerator" it has created an instance using the following line and the application context is not anywhere injected, however during runtime the object applicationContext is created fine and the code works fine.

But when the same snippet called from, my integration test class this application context is coming as null and ends up with null pointer exception.

Could you please advise how to set this applicationContext in the junit integration tests ,to avoid the null pointer ?

Appreciate your help on this.

final SiteMapContext siteMapContext = (SiteMapContext) applicationContext.getBean("siteMapContext");