當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。