List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerTests.java
@Test public void testApprovalNeeded() throws Exception { setResponse(Collections.<String, Object>singletonMap("options", "{}"), null, HttpStatus.OK); ModelAndView result = controller.startAuthorization(request, parameters, model, headers, principal); assertEquals("access_confirmation", result.getViewName()); }
From source file:alpha.portal.webapp.controller.UserControllerTest.java
/** * Test handle request./* www . j a v a 2s. c om*/ * * @throws Exception * the exception */ @Test public void testHandleRequest() throws Exception { final ModelAndView mav = this.c.handleRequest(null); final Map m = mav.getModel(); Assert.assertNotNull(m.get(Constants.USER_LIST)); Assert.assertEquals("admin/userList", mav.getViewName()); }
From source file:se.vgregion.pubsub.admin.controller.AdminControllerTest.java
@Test public void editPolledPublisher() throws Exception { UUID id = UUID.randomUUID(); PolledPublisher publisher = mock(PolledPublisher.class); when(adminService.getPolledPublishers(id)).thenReturn(publisher); ModelAndView mav = controller.editPolledPublisher(id); Assert.assertEquals("admin/polled-edit", mav.getViewName()); Assert.assertEquals(publisher, mav.getModel().get("publisher")); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerTests.java
@Test public void testCookieSentWithoutAttributes() throws Exception { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("Set-Cookie", "JSESSIONID=FOO; Path=/; HttpOnly"); setResponse(Collections.<String, Object>singletonMap("options", "{}"), responseHeaders, HttpStatus.OK); ModelAndView result = controller.startAuthorization(request, parameters, model, headers, principal); assertEquals("access_confirmation", result.getViewName()); assertEquals("JSESSIONID=FOO", model.get("cookie")); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerTests.java
@Test public void testMultipleCookies() throws Exception { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("Set-Cookie", "__VCAP_ID__=BAR"); responseHeaders.add("Set-Cookie", "JSESSIONID=FOO; Path=/; HttpOnly"); setResponse(Collections.<String, Object>singletonMap("options", "{}"), responseHeaders, HttpStatus.OK); ModelAndView result = controller.startAuthorization(request, parameters, model, headers, principal); assertEquals("access_confirmation", result.getViewName()); assertEquals("__VCAP_ID__=BAR;JSESSIONID=FOO", model.get("cookie")); }
From source file:se.vgregion.pubsub.admin.controller.AdminControllerTest.java
@Test public void updatePolledPublisher() throws Exception { ModelAndView mav = controller.updatePolledPublisher(ID, TOPIC, null); Assert.assertEquals("redirect:../..", mav.getViewName()); Mockito.verify(adminService).updatePolledPublishers(ID, TOPIC); }
From source file:com.kodgemisi.common.thymeleaf.ThymeleafLayoutInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView == null || !modelAndView.hasView()) { return;//from w w w.j a v a 2s . co m } String originalViewName = modelAndView.getViewName(); if (shouldDecorationAvoided(originalViewName)) { return; } // When using custom login page with Spring-Security, login page's controller is of type ParameterizableViewController // We'd better render it without any layout as it's just the login page. // Note that this behavior is project dependent. if (!(handler instanceof HandlerMethod)) { return; } String layoutName = getLayoutName(handler); modelAndView.setViewName(layoutName); modelAndView.addObject(this.viewAttributeName, originalViewName); }
From source file:de.topicmapslab.majortom.server.admin.interceptor.LayoutInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { super.postHandle(request, response, handler, modelAndView); if (modelAndView == null) return;/*from w w w . j a va 2s . com*/ String originalView = modelAndView.getViewName(); if (originalView != null) { includeLayout(modelAndView, originalView); } }
From source file:no.dusken.common.plugin.velocity.RenderPluginDirective.java
private void renderPlugin(InternalContextAdapter context, Writer writer, PluginContentMapping plugin) { Map<String, Object> currentContext = getCurrentContext(context); try {//from w w w . ja va 2 s. com ModelAndView mav = plugin.handleContentMapping(currentContext); String view = mav.getViewName(); if (!view.endsWith(".vm")) { view = view.concat(".vm"); } Template template = velocityEngine.getTemplate(view); template.merge(addToContext(context, mav.getModel()), writer); } catch (Exception e) { log.error("Error when merging template", e); } }
From source file:se.vgregion.urlservice.controllers.BookmarkControllerTest.java
@Test public void shortenLongUrlWithKeywords() throws IOException { List<Keyword> keywords = urlServiceService.getAllKeywords(); List<String> keywordNames = Arrays.asList(keywords.get(0).getName(), keywords.get(1).getName()); String keywordNameString = StringUtils.join(keywordNames, " "); ModelAndView mav = controller.create(LONG_URL, "slug", keywordNameString, authentication); Assert.assertEquals("redirect:/u/roblu/b/slug/edit", mav.getViewName()); }