Hi Friends,
I'm new to MVC
Test
From below code i got the error while Autowiring the "WebApplicationContext" and other autowired fields,
how can we define those beans in äpplciationContext.xml" file ?
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration
(
{
"classpath:applicationContext.xml"
}
)
public class ComplianceControllerTest {
@Autowired
WebApplicationContext wac; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpSession session; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpServletRequest request; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpServletResponse response; //Not able to create Object (Couldn't be autowired)
@Autowired
ComplianceDelegate complianceDelegate;
private MockMvc mockMvc;
@Autowired
private TermSessionBean termSessionBean;
@Before
public void setup() {
log.info("webAppContext setup.");
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void testComplianceProcess() throws Exception {
System.out.println("Hello..");
log.info("Hello");
termSessionBean.setAccountTypeCd("05");
termSessionBean.getCustomerSessionBean().setCustomerTypeCd("P");
termSessionBean = buildSession();
this.mockMvc.perform(
get("/Compliance").session(
(MockHttpSession) termSessionBean).accept(
MediaType.TEXT_HTML)).andExpect(status().isOk())
.andExpect(view().name("test"));
}
One more question, from the above code i'm going to call Controller, here my question i "I'm define the TermSessionBean in this test class
, it will be avaliable in Controller and is this termssionbean also avaliable in Delegate class?"
Thanks for advance..