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


Java MockActionRequest.setParameter方法代码示例

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


在下文中一共展示了MockActionRequest.setParameter方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: unknownHandlerActionRequest

import org.springframework.mock.web.portlet.MockActionRequest; //导入方法依赖的package包/类
@Test
public void unknownHandlerActionRequest() throws Exception {
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setParameter("myParam", "unknown");
	complexDispatcherPortlet.processAction(request, response);
	String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
	assertNotNull(exceptionParam);
	assertTrue(exceptionParam.startsWith(PortletException.class.getName()));
	assertTrue(exceptionParam.indexOf("No adapter for handler") != -1);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:DispatcherPortletTests.java

示例15: publishEventsOff

import org.springframework.mock.web.portlet.MockActionRequest; //导入方法依赖的package包/类
@Test
public void publishEventsOff() throws Exception {
	complexDispatcherPortlet.setPublishEvents(false);
	MockActionRequest request = new MockActionRequest();
	MockActionResponse response = new MockActionResponse();
	request.setParameter("action", "checker");
	complexDispatcherPortlet.processAction(request, response);
	ComplexPortletApplicationContext.TestApplicationListener listener =
			(ComplexPortletApplicationContext.TestApplicationListener)
					complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
	assertEquals(0, listener.counter);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DispatcherPortletTests.java


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