001/*
002 * Copyright 2002-2009 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.mock.web.portlet;
018
019import javax.portlet.ActionRequest;
020import javax.portlet.PortalContext;
021import javax.portlet.PortletContext;
022import javax.portlet.PortletMode;
023
024/**
025 * Mock implementation of the {@link javax.portlet.ActionRequest} interface.
026 *
027 * @author John A. Lewis
028 * @author Juergen Hoeller
029 * @since 2.0
030 */
031public class MockActionRequest extends MockClientDataRequest implements ActionRequest {
032
033        /**
034         * Create a new MockActionRequest with a default {@link MockPortalContext}
035         * and a default {@link MockPortletContext}.
036         * @see org.springframework.mock.web.portlet.MockPortalContext
037         * @see org.springframework.mock.web.portlet.MockPortletContext
038         */
039        public MockActionRequest() {
040                super();
041        }
042
043        /**
044         * Create a new MockActionRequest with a default {@link MockPortalContext}
045         * and a default {@link MockPortletContext}.
046         * @param actionName the name of the action to trigger
047         */
048        public MockActionRequest(String actionName) {
049                super();
050                setParameter(ActionRequest.ACTION_NAME, actionName);
051        }
052
053        /**
054         * Create a new MockActionRequest with a default {@link MockPortalContext}
055         * and a default {@link MockPortletContext}.
056         * @param portletMode the mode that the portlet runs in
057         */
058        public MockActionRequest(PortletMode portletMode) {
059                super();
060                setPortletMode(portletMode);
061        }
062
063        /**
064         * Create a new MockActionRequest with a default {@link MockPortalContext}.
065         * @param portletContext the PortletContext that the request runs in
066         */
067        public MockActionRequest(PortletContext portletContext) {
068                super(portletContext);
069        }
070
071        /**
072         * Create a new MockActionRequest.
073         * @param portalContext the PortalContext that the request runs in
074         * @param portletContext the PortletContext that the request runs in
075         */
076        public MockActionRequest(PortalContext portalContext, PortletContext portletContext) {
077                super(portalContext, portletContext);
078        }
079
080
081        @Override
082        protected String getLifecyclePhase() {
083                return ACTION_PHASE;
084        }
085
086}