List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:ch.silviowangler.dox.web.DocumentControllerTest.java
@Test public void editDocumentWithParams2() throws DocumentNotFoundException { final DocumentReference documentReference = newDocumentReference("hello.txt").withDocumentClass("test") .withIndex("name", "Wangler").build(); when(documentService.findDocumentReference(1L)).thenReturn(documentReference); when(documentService.updateIndices(documentReference)).thenReturn(documentReference); MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("firstname", "Silvio"); final ModelAndView modelAndView = controller.editDocument(1L, request); assertThat(modelAndView.getViewName(), is("import.successful")); assertThat(modelAndView.getModel().size(), is(1)); assertThat(modelAndView.getModel().containsKey("doc"), is(true)); final DocumentReference doc = (DocumentReference) modelAndView.getModel().get("doc"); assertThat(doc, is(documentReference)); assertThat(doc.getIndices().get(new TranslatableKey("name")).getValue().toString(), is("Wangler")); InOrder order = inOrder(documentService); order.verify(documentService).findDocumentReference(1L); order.verify(documentService, never()).updateIndices(documentReference); order.verifyNoMoreInteractions();/*from w ww .j a v a 2s .c o m*/ }
From source file:alpha.portal.webapp.controller.UserControllerTest.java
/** * Test search.//w ww .j ava 2s . com * * @throws Exception * the exception */ @Test public void testSearch() throws Exception { this.compassGps.index(); final ModelAndView mav = this.c.handleRequest("admin"); final Map m = mav.getModel(); final List results = (List) m.get(Constants.USER_LIST); Assert.assertNotNull(results); Assert.assertTrue(results.size() >= 1); Assert.assertEquals("admin/userList", mav.getViewName()); }
From source file:org.jasig.cas.web.support.ThrottledSubmissionByIpAddressHandlerInterceptorAdapterTests.java
public void testOneFailure() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); final ModelAndView modelAndView = new ModelAndView("casLoginView"); request.setMethod("POST"); request.setRemoteAddr("111.111.111.111"); this.adapter.postHandle(request, new MockHttpServletResponse(), new Object(), modelAndView); assertEquals("casLoginView", modelAndView.getViewName()); }
From source file:ch.silviowangler.dox.web.DocumentControllerTest.java
@Test public void editDocumentWhenThrowsException() throws Exception { when(documentService.findDocumentReference(1L)).thenThrow(new DocumentNotFoundException(1L)); final ModelAndView modelAndView = controller.editDocument(1L, new MockHttpServletRequest()); assertThat(modelAndView.getViewName(), is("modification.doc.failed")); assertThat(modelAndView.getModel().isEmpty(), is(true)); }
From source file:org.glassmaker.spring.web.MirrorTemplate.java
public TimelineItem render(ModelAndView mav) throws Exception { TimelineItem timelineItem = new TimelineItem(); String article = templateMerger.merge(mav.getViewName(), mav.getModelMap()); timelineItem.setHtml(article);/*from ww w . j ava2 s . co m*/ return timelineItem; }
From source file:alpha.portal.webapp.controller.CaseFormControllerTest.java
/** * Test new./*from w w w . j a v a 2s . com*/ * * @throws Exception * the exception */ @Test public void testNew() throws Exception { final MockHttpServletRequest request = this.newGet("/caseform"); request.setRemoteUser("admin"); final HttpServletResponse response = new MockHttpServletResponse(); final ModelAndView mv = this.form.showForm(this.filters, request, response); Assert.assertNotNull(mv); Assert.assertEquals("caseform", mv.getViewName()); Assert.assertEquals(new AlphaCase(), mv.getModel().get("case")); }
From source file:ch.silviowangler.dox.web.DocumentControllerTest.java
@Test public void editDocument() throws DocumentNotFoundException { final DocumentReference documentReference = newDocumentReference("hello.txt").withDocumentClass("test") .build();/*www . j ava 2 s . c o m*/ when(documentService.findDocumentReference(1L)).thenReturn(documentReference); final ModelAndView modelAndView = controller.editDocument(1L, new MockHttpServletRequest()); assertThat(modelAndView.getViewName(), is("import.successful")); assertThat(modelAndView.getModel().size(), is(1)); assertThat(modelAndView.getModel().containsKey("doc"), is(true)); assertThat((DocumentReference) modelAndView.getModel().get("doc"), is(documentReference)); InOrder order = inOrder(documentService); order.verify(documentService).findDocumentReference(1L); order.verifyNoMoreInteractions(); }
From source file:alpha.portal.webapp.controller.CaseFormControllerTest.java
/** * Test edit./*from ww w . ja v a 2 s. c o m*/ * * @throws Exception * the exception */ @Test public void testEdit() throws Exception { MockHttpServletRequest request = this.newGet("/caseform"); request.setParameter("caseId", CaseFormControllerTest.caseId); request.setRemoteUser("admin"); final ModelAndView mv = this.form.showForm(this.filters, request, new MockHttpServletResponse()); Assert.assertEquals("caseform", mv.getViewName()); final AlphaCase aCase = (AlphaCase) mv.getModel().get("case"); AlphaCase dbCase = this.caseManager.get(CaseFormControllerTest.caseId); Assert.assertEquals(dbCase, aCase); Assert.assertEquals(dbCase.getAlphaCards(), mv.getModel().get("cards")); Assert.assertEquals(dbCase.getListOfParticipants(), mv.getModel().get("participants")); request = this.newPost("/caseform"); request.setRemoteUser("admin"); aCase.setName("test case with a new name"); final BindingResult errors = new DataBinder(aCase).getBindingResult(); final String view = this.form.saveCase(aCase, errors, request, new MockHttpServletResponse()); Assert.assertEquals("redirect:/caseform?caseId=" + aCase.getCaseId(), view); Assert.assertFalse(errors.hasErrors()); Assert.assertNotNull(request.getSession().getAttribute("successMessages")); final Locale locale = request.getLocale(); final ArrayList<Object> msgs = (ArrayList<Object>) request.getSession().getAttribute("successMessages"); Assert.assertTrue(msgs.contains(this.form.getText("case.updated", locale))); dbCase = this.caseManager.get(CaseFormControllerTest.caseId); /* FIXME: something is broken (return structure is an empty thing) */ // Assert.assertEquals(dbCase, aCase); }
From source file:org.jasig.cas.web.ServiceValidateControllerTests.java
@Test public void testValidServiceTicketWithBadPgt() throws Exception { this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler()); final String tId = getCentralAuthenticationService() .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword()); final String sId = getCentralAuthenticationService().grantServiceTicket(tId, TestUtils.getService()); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("service", TestUtils.getService().getId()); request.addParameter("ticket", sId); request.addParameter("pgtUrl", "http://www.acs.rutgers.edu"); final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()); assertEquals(CONST_SUCCESS_VIEW, modelAndView.getViewName()); assertNull(modelAndView.getModel().get("pgtIou")); }
From source file:org.jasig.cas.web.ServiceValidateControllerTests.java
@Test public void testValidServiceTicketWithInvalidPgt() throws Exception { this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler()); final String tId = getCentralAuthenticationService() .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword()); final String sId = getCentralAuthenticationService().grantServiceTicket(tId, TestUtils.getService()); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("service", TestUtils.getService().getId()); request.addParameter("ticket", sId); request.addParameter("pgtUrl", "duh"); final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()); assertEquals(CONST_SUCCESS_VIEW, modelAndView.getViewName()); assertNull(modelAndView.getModel().get("pgtIou")); }