org.springframework.web.servlet.view.InternalResourceView Java Examples
The following examples show how to use
org.springframework.web.servlet.view.InternalResourceView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #2
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void portletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception { MockRenderRequest request = new MockRenderRequest(); MockRenderResponse response = new MockRenderResponse(); request.setPortletMode(PortletMode.VIEW); request.addUserRole("role3"); request.setParameter("action", "not mapped"); request.setParameter("myParam", "not mapped"); complexDispatcherPortlet.doDispatch(request, response); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Exception exception = (Exception) model.get("exception"); assertNotNull(exception); assertTrue(exception.getClass().equals(PortletSecurityException.class)); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-default-1", view.getBeanName()); }
Example #3
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void noDetectAllHandlerMappingsWithParameterRenderRequest() throws Exception { DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet(); complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class); complexDispatcherPortlet.setNamespace("test"); complexDispatcherPortlet.setDetectAllHandlerMappings(false); complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex")); MockRenderRequest request = new MockRenderRequest(); MockRenderResponse response = new MockRenderResponse(); request.setParameter("myParam", "test1"); complexDispatcherPortlet.doDispatch(request, response); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Exception exception = (Exception) model.get("exception"); assertTrue(exception.getClass().equals(NoHandlerFoundException.class)); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-unavailable", view.getBeanName()); }
Example #4
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #5
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #6
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #7
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #8
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #9
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #10
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #11
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #12
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #13
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #14
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #15
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void shouldShowPagedSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(50); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(238900, 50)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles?max=238900&count=50")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #16
Source File: SpittleControllerTest.java From Project with Apache License 2.0 | 6 votes |
@Test public void houldShowRecentSpittles() throws Exception { List<Spittle> expectedSpittles = createSpittleList(20); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findSpittles(Long.MAX_VALUE, 20)) .thenReturn(expectedSpittles); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller) .setSingleView(new InternalResourceView("/WEB-INF/views/spittles.jsp")) .build(); mockMvc.perform(get("/spittles")) .andExpect(view().name("spittles")) .andExpect(model().attributeExists("spittleList")) .andExpect(model().attribute("spittleList", hasItems(expectedSpittles.toArray()))); }
Example #17
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void illegalAccessExceptionInMappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception1"); request.addParameter("access", "illegal"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-exception", view.getBeanName()); }
Example #18
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void portletRequestBindingExceptionInMappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception1"); request.addParameter("binding", "should fail"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-exception", view.getBeanName()); }
Example #19
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void portletRequestBindingExceptionInUnmappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception2"); request.addParameter("binding", "should fail"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-binding", view.getBeanName()); }
Example #20
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void illegalArgumentExceptionInMappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception1"); request.addParameter("unknown", ""); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-runtime", view.getBeanName()); }
Example #21
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void illegalArgumentExceptionInUnmappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception2"); request.addParameter("unknown", ""); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-default-1", view.getBeanName()); }
Example #22
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void illegalAccessExceptionInUnmappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception2"); request.addParameter("access", "illegal"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-illegalaccess", view.getBeanName()); }
Example #23
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void exceptionInMappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception1"); request.addParameter("generic", "123"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-exception", view.getBeanName()); }
Example #24
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void unknownHandlerRenderRequest() throws Exception { MockRenderRequest request = new MockRenderRequest(); MockRenderResponse response = new MockRenderResponse(); request.setParameter("myParam", "unknown"); complexDispatcherPortlet.doDispatch(request, response); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Exception exception = (Exception)model.get("exception"); assertTrue(exception.getClass().equals(PortletException.class)); assertTrue(exception.getMessage().indexOf("No adapter for handler") != -1); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-default-1", view.getBeanName()); }
Example #25
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void exceptionInUnmappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception2"); request.addParameter("generic", "123"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-default-1", view.getBeanName()); }
Example #26
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void runtimeExceptionInMappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception1"); request.addParameter("runtime", "true"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-runtime", view.getBeanName()); }
Example #27
Source File: DispatcherPortletTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void runtimeExceptionInUnmappedHandler() throws Exception { MockRenderRequest request = new MockRenderRequest(); request.setPortletMode(PortletMode.HELP); request.addParameter("myParam", "exception2"); request.addParameter("runtime", "true"); MockRenderResponse response = new MockRenderResponse(); complexDispatcherPortlet.doDispatch(request, response); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); assertEquals("failed-default-1", view.getBeanName()); }
Example #28
Source File: FreeMarkerViewTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void freeMarkerViewResolver() throws Exception { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setConfiguration(new TestConfiguration()); StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); wac.getBeanFactory().registerSingleton("configurer", configurer); wac.refresh(); FreeMarkerViewResolver vr = new FreeMarkerViewResolver(); vr.setPrefix("prefix_"); vr.setSuffix("_suffix"); vr.setApplicationContext(wac); View view = vr.resolveViewName("test", Locale.CANADA); assertEquals("Correct view class", FreeMarkerView.class, view.getClass()); assertEquals("Correct URL", "prefix_test_suffix", ((FreeMarkerView) view).getUrl()); view = vr.resolveViewName("non-existing", Locale.CANADA); assertNull(view); view = vr.resolveViewName("redirect:myUrl", Locale.getDefault()); assertEquals("Correct view class", RedirectView.class, view.getClass()); assertEquals("Correct URL", "myUrl", ((RedirectView) view).getUrl()); view = vr.resolveViewName("forward:myUrl", Locale.getDefault()); assertEquals("Correct view class", InternalResourceView.class, view.getClass()); assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl()); }
Example #29
Source File: VelocityViewResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testVelocityViewResolver() throws Exception { VelocityConfig vc = new VelocityConfig() { @Override public VelocityEngine getVelocityEngine() { return new TestVelocityEngine("prefix_test_suffix", new Template()); } }; StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.getBeanFactory().registerSingleton("configurer", vc); wac.refresh(); VelocityViewResolver vr = new VelocityViewResolver(); vr.setPrefix("prefix_"); vr.setSuffix("_suffix"); vr.setApplicationContext(wac); View view = vr.resolveViewName("test", Locale.CANADA); assertEquals("Correct view class", VelocityView.class, view.getClass()); assertEquals("Correct URL", "prefix_test_suffix", ((VelocityView) view).getUrl()); view = vr.resolveViewName("non-existing", Locale.CANADA); assertNull(view); view = vr.resolveViewName("redirect:myUrl", Locale.getDefault()); assertEquals("Correct view class", RedirectView.class, view.getClass()); assertEquals("Correct URL", "myUrl", ((RedirectView) view).getUrl()); view = vr.resolveViewName("forward:myUrl", Locale.getDefault()); assertEquals("Correct view class", InternalResourceView.class, view.getClass()); assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl()); }
Example #30
Source File: ViewMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void returnView() throws Exception { InternalResourceView view = new InternalResourceView("testView"); this.handler.handleReturnValue(view, createReturnValueParam("view"), this.mavContainer, this.webRequest); assertSame(view, this.mavContainer.getView()); }