Spring Framework MockRenderResponse - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MockRenderResponse class.

This code example shows how to use the following methods:
	public void testAuthorizedUser() throws Exception {
		UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
		String validRole = "allowed";
		interceptor.setAuthorizedRoles(new String[] {validRole});
		MockRenderRequest request = new MockRenderRequest();
		MockRenderResponse response = new MockRenderResponse();
		Object handler = new Object();
		request.addUserRole(validRole);
		assertTrue(request.isUserInRole(validRole));
		boolean shouldProceed = interceptor.preHandle(request, response, handler);
		assertTrue(shouldProceed);
	} 
 
	public void testAuthorizedUserWithMultipleRoles() throws Exception {
		UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
		String validRole1 = "allowed1";
		String validRole2 = "allowed2";
		interceptor.setAuthorizedRoles(new String[] {validRole1, validRole2});
		MockRenderRequest request = new MockRenderRequest();
		MockRenderResponse response = new MockRenderResponse();
6
CodeRank
This code example shows how to use the following methods:
	public void testRenderRequestWithViewNameSet() throws Exception {
		ParameterizableViewController controller = new ParameterizableViewController();
		String viewName = "testView";
		controller.setViewName(viewName);
		RenderRequest request = new MockRenderRequest();
		RenderResponse response = new MockRenderResponse();
		ModelAndView mav = controller.handleRenderRequest(request, response);
		assertEquals(viewName, mav.getViewName());
	} 
 
	public void testInitApplicationContextWithNoViewNameSet() throws Exception {
		ParameterizableViewController controller = new ParameterizableViewController();
		try { 
			controller.setApplicationContext(new StaticPortletApplicationContext());
			fail("should have thrown IllegalArgumentException");
		} 
		catch (IllegalArgumentException ex) {
			// expected 
		} 
	} 
6
CodeRank
This code example shows how to use the following methods:
 
	@Before 
	public void setUp() { 
		exceptionResolver = new AnnotationMethodHandlerExceptionResolver();
		request = new MockRenderRequest();
		response = new MockRenderResponse();
	} 
 
	@Test
	public void simpleWithIOException() { 
		IOException ex = new IOException();
		SimpleController controller = new SimpleController();
		ModelAndView mav = exceptionResolver.resolveException(request, response, controller, ex);
		assertNotNull("No ModelAndView returned", mav);
		assertEquals("Invalid view name returned", "X:IOException", mav.getViewName());
	} 
 
	@Test
	public void simpleWithSocketException() { 
		SocketException ex = new SocketException();
5
CodeRank
This code example shows how to use the following methods:
	private DefaultFlowUrlHandler urlHandler = new DefaultFlowUrlHandler(); 
	private MockPortletRequest request = new MockPortletRequest(); 
	private MockActionRequest actionRequest = new MockActionRequest(); 
	private MockRenderRequest renderRequest = new MockRenderRequest(); 
	private MockActionResponse actionResponse = new MockActionResponse(); 
	private MockRenderResponse renderResponse = new MockRenderResponse(); 
 
	public void testGetFlowExecutionKey() { 
		request.addParameter("execution", "12345"); 
		assertEquals("12345", urlHandler.getFlowExecutionKey(request)); 
	} 
 
	public void testSetFlowExecutionRenderParameter() { 
		urlHandler.setFlowExecutionRenderParameter("12345", actionResponse); 
		assertEquals("12345", actionResponse.getRenderParameter("execution")); 
	} 
 
	public void testSetFlowExecutionInSession() { 
		urlHandler.setFlowExecutionInSession("12345", renderRequest); 
		assertEquals("12345", renderRequest.getPortletSession().getAttribute("execution")); 
5
CodeRank
This code example shows how to use the following methods:
		portletContext = new MockPortletContext();
		request = new MockActionRequest();
		response = new MockActionResponse();
		context = new PortletExternalContext(portletContext, request, response);
		renderRequest = new MockRenderRequest();
		renderResponse = new MockRenderResponse();
		renderContext = new PortletExternalContext(portletContext, renderRequest, renderResponse);
	} 
 
	public void testGetContextPath() { 
		request.setContextPath("/foo");
		assertEquals("/foo", request.getContextPath());
	} 
 
	public void testRequestParameters() { 
		assertTrue(context.getRequestParameterMap().isEmpty());
	} 
 
	public void testGetNativeObjects() { 
		assertEquals(portletContext, context.getNativeContext());
5
CodeRank