Java 类org.springframework.mock.web.portlet.MockActionResponse 实例源码

项目:class-guard    文件:PortletWrappingControllerTests.java   
@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);
}
项目:spring4-understanding    文件:PortletWrappingControllerTests.java   
@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));
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierPortletTest.java   
@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);
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
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));
}
项目:class-guard    文件:DispatcherPortletTests.java   
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());
}
项目:class-guard    文件:DispatcherPortletTests.java   
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();
        }
    }
项目:class-guard    文件:DispatcherPortletTests.java   
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();
        }
    }
项目:spring4-understanding    文件:PortletWrappingControllerTests.java   
@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));
}
项目:spring4-understanding    文件:PortletWrappingControllerTests.java   
@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));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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);
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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);
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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()));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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"));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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"));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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);
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void noDetectAllHandlerMappingsWithPortletModeActionRequest() throws Exception {
    DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
    complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
    complexDispatcherPortlet.setNamespace("test");
    complexDispatcherPortlet.setDetectAllHandlerMappings(false);
    complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    complexDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void existingMultipartRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    ComplexPortletApplicationContext.MockMultipartResolver multipartResolver =
            (ComplexPortletApplicationContext.MockMultipartResolver)
                    complexDispatcherPortlet.getPortletApplicationContext().getBean("portletMultipartResolver");
    MultipartActionRequest multipartRequest = multipartResolver.resolveMultipart(request);
    complexDispatcherPortlet.processAction(multipartRequest, response);
    multipartResolver.cleanupMultipart(multipartRequest);
    assertNotNull(request.getAttribute("cleanedUp"));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void multipartResolutionFailed() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    request.addUserRole("role1");
    request.setAttribute("fail", Boolean.TRUE);
    complexDispatcherPortlet.processAction(request, response);
    String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertTrue(exception.startsWith(MaxUploadSizeExceededException.class.getName()));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void actionRequestHandledEvent() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    complexDispatcherPortlet.processAction(request, response);
    ComplexPortletApplicationContext.TestApplicationListener listener =
            (ComplexPortletApplicationContext.TestApplicationListener)
                    complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
    assertEquals(1, listener.counter);
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@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);
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void parameterMappingInterceptorWithCorrectParam() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("interceptingParam", "test1");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("test1", response.getRenderParameter("interceptingParam"));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void parameterMappingInterceptorWithIncorrectParam() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("incorrect", "test1");
    complexDispatcherPortlet.processAction(request, response);
    assertNull(response.getRenderParameter("incorrect"));
    assertNull(response.getRenderParameter("interceptingParam"));
}
项目:spring4-understanding    文件:DispatcherPortletTests.java   
@Test
public void portletHandlerAdapterActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("myParam", "myPortlet");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("myPortlet action called", response.getRenderParameter("result"));
    ComplexPortletApplicationContext.MyPortlet myPortlet =
            (ComplexPortletApplicationContext.MyPortlet) complexDispatcherPortlet.getPortletApplicationContext().getBean("myPortlet");
    assertEquals("complex", myPortlet.getPortletConfig().getPortletName());
    assertEquals(getPortletContext(), myPortlet.getPortletConfig().getPortletContext());
    assertEquals(complexDispatcherPortlet.getPortletContext(), myPortlet.getPortletConfig().getPortletContext());
    complexDispatcherPortlet.destroy();
    assertNull(myPortlet.getPortletConfig());
}
项目:spring4-understanding    文件:PortletUtilsTests.java   
@Test
public void testPassAllParametersToRenderPhase() throws Exception {
    MockActionRequest request = new MockActionRequest();
    request.setParameter("William", "Baskerville");
    request.setParameter("Adso", "Melk");
    MockActionResponse response = new MockActionResponse();
    PortletUtils.passAllParametersToRenderPhase(request, response);
    assertEquals("The render parameters map is obviously not being populated with the request parameters.",
            request.getParameterMap().size(), response.getRenderParameterMap().size());
}
项目:spring4-understanding    文件:PortletUtilsTests.java   
@Test
public void testPassAllParametersToRenderPhaseDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception {
    MockActionRequest request = new MockActionRequest();
    request.setParameter("William", "Baskerville");
    request.setParameter("Adso", "Melk");
    MockActionResponse response = new MockActionResponse() {
        @Override
        public void setRenderParameter(String key, String[] values) {
            throw new IllegalStateException();
        }
    };
    PortletUtils.passAllParametersToRenderPhase(request, response);
    assertEquals("The render parameters map must not be being populated with the request parameters (Action.sendRedirect(..) aleady called).",
            0, response.getRenderParameterMap().size());
}
项目:spring4-understanding    文件:PortletUtilsTests.java   
@Test
public void testClearAllRenderParameters() throws Exception {
    MockActionResponse response = new MockActionResponse();
    response.setRenderParameter("William", "Baskerville");
    response.setRenderParameter("Adso", "Melk");
    PortletUtils.clearAllRenderParameters(response);
    assertEquals("The render parameters map is obviously not being cleared out.",
            0, response.getRenderParameterMap().size());
}
项目:spring4-understanding    文件:PortletUtilsTests.java   
@Test
public void testClearAllRenderParametersDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception {
    MockActionResponse response = new MockActionResponse() {
        @Override
        public void setRenderParameters(Map<String, String[]> parameters) {
            throw new IllegalStateException();
        }
    };
    response.setRenderParameter("William", "Baskerville");
    response.setRenderParameter("Adso", "Melk");
    PortletUtils.clearAllRenderParameters(response);
    assertEquals("The render parameters map must not be cleared if ActionResponse.sendRedirect() has been called (already).",
            2, response.getRenderParameterMap().size());
}
项目:class-guard    文件:PortletWrappingControllerTests.java   
@Test
public void testActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("test", "test");
    controller.handleActionRequest(request, response);
    String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
    assertEquals("myPortlet-action", result);
}
项目:class-guard    文件:PortletWrappingControllerTests.java   
@Test
public void testPortletName() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
    controller.handleActionRequest(request, response);
    String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
    assertEquals("wrappedPortlet", result);
}
项目:class-guard    文件:PortletModeNameViewControllerTests.java   
public void testActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    try {
        controller.handleActionRequest(request, response);
        fail("Should have thrown PortletException");
    }
    catch(PortletException ex) {
        // expected
    }
}
项目:class-guard    文件:ParameterizableViewControllerTests.java   
public void testActionRequestNotHandled() throws Exception {
    ParameterizableViewController controller = new ParameterizableViewController();
    ActionRequest request = new MockActionRequest();
    ActionResponse response = new MockActionResponse();
    try {
        controller.handleActionRequest(request, response);
        fail("should have thrown PortletException");
    }
    catch (PortletException ex) {
        // expected
    }
}
项目:class-guard    文件:CommandControllerTests.java   
public void testActionRequest() throws Exception {
    TestController tc = new TestController();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    tc.handleActionRequest(request, response);
    TestBean command = (TestBean)request.getPortletSession().getAttribute(tc.getRenderCommandSessionAttributeName());
    assertTrue(command.isJedi());
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
public void testDefaultParameterMapped() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = ParameterHandlerMapping.DEFAULT_PARAMETER_NAME;
    String value = "someValue";
    request.setParameter(param, value);
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandleAction(request, response, handler);
    assertTrue(shouldProceed);
    assertNotNull(response.getRenderParameter(param));
    assertEquals(value, response.getRenderParameter(param));
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
public void testNonDefaultParameterNotMapped() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = "myParam";
    String value = "someValue";
    request.setParameter(param, value);
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
    assertNull(response.getRenderParameter(ParameterHandlerMapping.DEFAULT_PARAMETER_NAME));
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
public void testNoParameterValueSetWithDefaultParameterName() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = ParameterHandlerMapping.DEFAULT_PARAMETER_NAME;
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
public void testNoParameterValueSetWithNonDefaultParameterName() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = "myParam";
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
}
项目:class-guard    文件:ParameterMappingInterceptorTests.java   
public void testNoParameterValueSetWithNonDefaultParameterNameWhenHandlerMappingProvided() throws Exception {
    String param = "myParam";
    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();
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
}
项目:class-guard    文件:DispatcherPortletTests.java   
public void testSimpleValidActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("action", "form");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNull(exceptionParam);
    SimplePortletApplicationContext ac = (SimplePortletApplicationContext)simpleDispatcherPortlet.getPortletApplicationContext();
    String commandAttribute = ac.getRenderCommandSessionAttributeName();
    TestBean testBean = (TestBean) request.getPortletSession().getAttribute(commandAttribute);
    assertEquals(39, testBean.getAge());
}
项目:class-guard    文件:DispatcherPortletTests.java   
public void testSimpleInvalidActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("action", "invalid");
    simpleDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}