@Test public void testShowContactForm() throws Exception { mockMvc.perform(get("/contact").accept(MediaType.APPLICATION_XHTML_XML)) .andExpect(view().name("contact")) .andExpect(model().attributeExists("contactForm")) .andExpect(status().isOk()); }
@RequestMapping(method = RequestMethod.GET) public String showContactForm(Model model) { ContactForm attributeValue = new ContactForm(); model.addAttribute("contactForm", attributeValue); return "contact"; }
ContactController { @RequestMapping(method = RequestMethod.GET) public String showContactForm(Model model) { ContactForm attributeValue = new ContactForm(); model.addAttribute("contactForm", attributeValue); return "contact"; } }
ContactController { @RequestMapping(method = RequestMethod.GET) public String showContactForm(Model model) { ContactForm attributeValue = new ContactForm(); model.addAttribute("contactForm", attributeValue); return "contact"; } @Autowired  ContactController(IMailService mailService); }
ContactController { @RequestMapping(method = RequestMethod.GET) public String showContactForm(Model model) { ContactForm attributeValue = new ContactForm(); model.addAttribute("contactForm", attributeValue); return "contact"; } @Autowired  ContactController(IMailService mailService); @RequestMapping(method = RequestMethod.GET) String showContactForm(Model model); @RequestMapping(method = RequestMethod.POST) String sendEmail(@Valid @ModelAttribute("contactForm") ContactForm contactForm, BindingResult results); }
ContactController { @RequestMapping(method = RequestMethod.GET) public String showContactForm(Model model) { ContactForm attributeValue = new ContactForm(); model.addAttribute("contactForm", attributeValue); return "contact"; } @Autowired  ContactController(IMailService mailService); @RequestMapping(method = RequestMethod.GET) String showContactForm(Model model); @RequestMapping(method = RequestMethod.POST) String sendEmail(@Valid @ModelAttribute("contactForm") ContactForm contactForm, BindingResult results);  }