SearchController { @RequestMapping(value="/page", method=RequestMethod.GET) @PreAuthorize("permitAll") public String findPages(@RequestParam("q") String searchText, @RequestParam(value="p", required=false) Integer page, Authentication authentication, Model model) throws IOException { if (page == null) { page = 1; } if (authentication == null) { authentication = authenticationFactory.create(UserStore.ANONYMOUS_USER_LOGIN_NAME); } try { SearchResult result = pageIndex.findPages(searchText, page, authentication); model.addAttribute("searchText", searchText); model.addAttribute("searchResult", result); model.addAttribute("page", page); } catch (ParseException e) { log.warn(StringUtils.EMPTY, e); } catch (TimeoutException e) { return ErrorController.timeout(); } return "/search/result"; }  @RequestMapping(value="/page", method=RequestMethod.GET) @PreAuthorize("permitAll") String findPages(@RequestParam("q") String searchText, @RequestParam(value="p", required=false) Integer page,
			Authentication authentication, Model model); @RequestMapping(value="/tags/json", method=RequestMethod.GET) @ResponseBody @PreAuthorize("permitAll") Set<String> getAllTags(Authentication authentication);  }
@Test public void findPages() throws IOException, ParseException, TimeoutException { when(pageIndex.findPages("text", 1, authentication)).thenReturn(searchResult); String view = searchController.findPages("text", 1, authentication, model); assertEquals("/search/result", view); verify(model).addAttribute("searchText", "text"); verify(model).addAttribute("searchResult", searchResult); verify(model).addAttribute("page", 1); }