Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void shouldRejectInvalidNotificationAddress() throws Exception {
- String notificationTypes[] = { "internal", "internalProtected", "email" };
- String incorrectAddress = "gayan@gmail";
- for (String notifyType : notificationTypes) {
- MockHttpServletRequest request = new MockHttpServletRequest("POST", "");
- request.setParameter("notification", notifyType);
- request.setParameter("notificationAddress", incorrectAddress);
- HttpServletResponse response = new MockHttpServletResponse();
- ModelAndView modelAndView = controller.handleRequest(request, response);
- OptionsForm optionsForm = (OptionsForm) controller.formBackingObject(request);
- assertEquals(incorrectAddress, optionsForm.getNotificationAddress());
- BeanPropertyBindingResult bindingResult = (BeanPropertyBindingResult) modelAndView.getModel().get(
- "org.springframework.validation.BindingResult.opts");
- org.junit.Assert.assertTrue(bindingResult.hasErrors());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment