当前位置: 首页>>代码示例>>Java>>正文


Java MockActionRequest类代码示例

本文整理汇总了Java中org.springframework.mock.web.portlet.MockActionRequest的典型用法代码示例。如果您正苦于以下问题:Java MockActionRequest类的具体用法?Java MockActionRequest怎么用?Java MockActionRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MockActionRequest类属于org.springframework.mock.web.portlet包,在下文中一共展示了MockActionRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDelegationToMockPortletConfigIfSoConfigured

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void testDelegationToMockPortletConfigIfSoConfigured() throws Exception {

	final String BEAN_NAME = "Sixpence None The Richer";

	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();

	PortletWrappingController controller = new PortletWrappingController();
	controller.setPortletClass(MyPortlet.class);
	controller.setUseSharedPortletConfig(false);
	controller.setBeanName(BEAN_NAME);
	controller.afterPropertiesSet();

	request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
	controller.handleActionRequest(request, response);

	String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
	assertEquals(BEAN_NAME, result);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:PortletWrappingControllerTests.java

示例2: delegationToMockPortletConfigIfSoConfigured

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void delegationToMockPortletConfigIfSoConfigured() throws Exception {
	final String BEAN_NAME = "Sixpence None The Richer";

	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();

	PortletWrappingController controller = new PortletWrappingController();
	controller.setPortletClass(MyPortlet.class);
	controller.setUseSharedPortletConfig(false);
	controller.setBeanName(BEAN_NAME);
	controller.afterPropertiesSet();

	request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
	controller.handleActionRequest(request, response);

	assertEquals(BEAN_NAME, response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:PortletWrappingControllerTests.java

示例3: testPrettifyActionRequestActionResponse

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void testPrettifyActionRequestActionResponse() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();

	PortalPropertiesPrettierPortlet portlet = createMockBuilder(
			PortalPropertiesPrettierPortlet.class).addMockedMethod(
			"prettify", PortletRequest.class).createMock();
	String expected = "expected";

	expect(portlet.prettify(request)).andReturn(expected);
	replay(portlet);

	portlet.prettify(request, response);

	Assert.assertEquals(expected,
			request.getAttribute("portalPrettyProperties"));
	verify(portlet);
}
 
开发者ID:tmoreira2020,项目名称:portal-properties-prettier-app,代码行数:20,代码来源:PortalPropertiesPrettierPortletTest.java

示例4: testNonDefaultParameterMappedWhenHandlerMappingProvided

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
public void testNonDefaultParameterMappedWhenHandlerMappingProvided() throws Exception {
	String param = "myParam";
	String value = "someValue";
	ParameterHandlerMapping handlerMapping = new ParameterHandlerMapping();
	handlerMapping.setParameterName(param);
	ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
	interceptor.setParameterName(param);
	Object handler = new Object();
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setParameter(param, value);
	assertNull(response.getRenderParameter(param));
	boolean shouldProceed = interceptor.preHandleAction(request, response, handler);
	assertTrue(shouldProceed);
	assertNull(response.getRenderParameter(ParameterHandlerMapping.DEFAULT_PARAMETER_NAME));
	assertNotNull(response.getRenderParameter(param));
	assertEquals(value, response.getRenderParameter(param));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:ParameterMappingInterceptorTests.java

示例5: testSimpleFormViewWithSessionNoBindOnNewForm

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
public void testSimpleFormViewWithSessionNoBindOnNewForm() throws Exception {
	MockActionRequest actionRequest = new MockActionRequest();
	MockActionResponse actionResponse = new MockActionResponse();
	actionRequest.setSession(new MockPortletSession());
	actionRequest.setParameter("action", "form-session-nobind");
	actionRequest.setParameter("age", "27");
	simpleDispatcherPortlet.processAction(actionRequest, actionResponse);
	Map renderParameters = actionResponse.getRenderParameterMap();

	MockRenderRequest renderRequest = new MockRenderRequest();
	MockRenderResponse renderResponse = new MockRenderResponse();
	renderRequest.setParameters(renderParameters);
	renderRequest.setParameter("action", "form-session-nobind");
	renderRequest.setParameter("age", "30");
	renderRequest.setSession(actionRequest.getPortletSession());
	simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
	assertEquals("finished42", renderResponse.getContentAsString());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:DispatcherPortletTests.java

示例6: testValidActionRequestWithExistingThreadLocalRequestContext

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
public void testValidActionRequestWithExistingThreadLocalRequestContext() throws IOException, PortletException {
		MockActionRequest request = new MockActionRequest();
		MockActionResponse response = new MockActionResponse();
		request.addPreferredLocale(Locale.GERMAN);
		request.setParameter("action", "form");
		request.setParameter("age", "29");

// see RequestContextListener.requestInitialized()
		try {
			LocaleContextHolder.setLocale(request.getLocale());
			RequestContextHolder.setRequestAttributes(new PortletRequestAttributes(request));

			LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
			RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

			simpleDispatcherPortlet.processAction(request, response);

			assertSame(servletLocaleContext, LocaleContextHolder.getLocaleContext());
			assertSame(servletRequestAttrs, RequestContextHolder.getRequestAttributes());
		}
		finally {
			RequestContextHolder.resetRequestAttributes();
			LocaleContextHolder.resetLocaleContext();
		}
	}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:DispatcherPortletTests.java

示例7: testInvalidActionRequestWithExistingThreadLocalRequestContext

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
public void testInvalidActionRequestWithExistingThreadLocalRequestContext() throws IOException, PortletException {
		MockActionRequest request = new MockActionRequest();
		MockActionResponse response = new MockActionResponse();
		request.addPreferredLocale(Locale.GERMAN);

// see RequestContextListener.requestInitialized()
		try {
			LocaleContextHolder.setLocale(request.getLocale());
			RequestContextHolder.setRequestAttributes(new PortletRequestAttributes(request));

			LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
			RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

			request.setParameter("action", "invalid");
			simpleDispatcherPortlet.processAction(request, response);
			String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
			assertNotNull(exceptionParam); // ensure that an exceptional condition occured

			assertSame(servletLocaleContext, LocaleContextHolder.getLocaleContext());
			assertSame(servletRequestAttrs, RequestContextHolder.getRequestAttributes());
		}
		finally {
			RequestContextHolder.resetRequestAttributes();
			LocaleContextHolder.resetLocaleContext();
		}
	}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:DispatcherPortletTests.java

示例8: actionRequest

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void actionRequest() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setParameter("test", "test");

	controller.handleActionRequest(request, response);
	assertEquals("myPortlet-action", response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:PortletWrappingControllerTests.java

示例9: portletName

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletName() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
	controller.handleActionRequest(request, response);
	assertEquals("wrappedPortlet", response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:PortletWrappingControllerTests.java

示例10: portletModeParameterMappingHelp1

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletModeParameterMappingHelp1() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.HELP);
	request.setParameter("action", "help1");
	complexDispatcherPortlet.processAction(request, response);
	String param = response.getRenderParameter("param");
	assertEquals("help1 was here", param);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:DispatcherPortletTests.java

示例11: portletModeParameterMappingHelp2

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletModeParameterMappingHelp2() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.HELP);
	request.setParameter("action", "help2");
	complexDispatcherPortlet.processAction(request, response);
	String param = response.getRenderParameter("param");
	assertEquals("help2 was here", param);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:DispatcherPortletTests.java

示例12: portletModeParameterMappingInvalidHelpActionRequest

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletModeParameterMappingInvalidHelpActionRequest() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.HELP);
	request.setParameter("action", "help3");
	complexDispatcherPortlet.processAction(request, response);
	String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
	assertNotNull(exceptionParam);
	assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:DispatcherPortletTests.java

示例13: portletModeMappingValidEditActionRequest

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletModeMappingValidEditActionRequest() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.EDIT);
	request.addUserRole("role1");
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "not mapped");
	complexDispatcherPortlet.processAction(request, response);
	assertEquals("edit was here", response.getRenderParameter("param"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:DispatcherPortletTests.java

示例14: portletModeMappingEditActionRequestWithUnauthorizedUserRole

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void portletModeMappingEditActionRequestWithUnauthorizedUserRole() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.EDIT);
	request.addUserRole("role3");
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "not mapped");
	complexDispatcherPortlet.processAction(request, response);
	String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
	assertNotNull(exception);
	String name = PortletSecurityException.class.getName();
	assertTrue(exception.startsWith(name));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DispatcherPortletTests.java

示例15: parameterMappingValidActionRequest

import org.springframework.mock.web.portlet.MockActionRequest; //导入依赖的package包/类
@Test
public void parameterMappingValidActionRequest() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setPortletMode(PortletMode.EDIT);
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "test1");
	complexDispatcherPortlet.processAction(request, response);
	assertEquals("test1-action", response.getRenderParameter("result"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:DispatcherPortletTests.java


注:本文中的org.springframework.mock.web.portlet.MockActionRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。