Guest User

Untitled

a guest
Apr 12th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. @Test
  2. public void shouldRejectInvalidNotificationAddress() throws Exception {
  3. String notificationTypes[] = { "internal", "internalProtected", "email" };
  4. String incorrectAddress = "gayan@gmail";
  5.  
  6. for (String notifyType : notificationTypes) {
  7. MockHttpServletRequest request = new MockHttpServletRequest("POST", "");
  8. request.setParameter("notification", notifyType);
  9. request.setParameter("notificationAddress", incorrectAddress);
  10.  
  11. HttpServletResponse response = new MockHttpServletResponse();
  12. ModelAndView modelAndView = controller.handleRequest(request, response);
  13.  
  14. OptionsForm optionsForm = (OptionsForm) controller.formBackingObject(request);
  15. assertEquals(incorrectAddress, optionsForm.getNotificationAddress());
  16.  
  17. BeanPropertyBindingResult bindingResult = (BeanPropertyBindingResult) modelAndView.getModel().get(
  18. "org.springframework.validation.BindingResult.opts");
  19. org.junit.Assert.assertTrue(bindingResult.hasErrors());
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment