I am writing an integrated test for one of my Spring controllers. Test includes a configuration file(data-access-configuration.xml
) that has DataSource
configured using JNDI. When I am running this test I am getting an error error creating bean with name dataSource
nested exception NoIntialContextException
. Below is my Test class & Configuration file
Configuration:
<jee:jndi-lookup jndi-name="jobportal_db" id="dataSource"
expected-type="javax.sql.DataSource">
</jee:jndi-lookup>
Test
@RunWith(value=SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = { "file:WebContent/WEB-INF/dispatcher-servlet.xml",
"classpath:com/zerosolutions/configuration/service-configuration.xml",
"classpath:com/zerosolutions/configuration/security-configuration.xml",
"classpath:com/zerosolutions/configuration/data-access-configuration.xml",
"classpath:com/zerosolutions/configuration/view-configuration.xml"})
public class TestingFrontController {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setUp(){
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void getLoginSignupPage() throws Exception{
mockMvc.perform(get("/login"))
.andExpect(status().isOk())
.andExpect(forwardedUrl("login"));
}
}
How can I fix it ?