001/*
002 * Copyright 2002-2012 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.Event;
020import javax.portlet.EventRequest;
021import javax.portlet.PortalContext;
022import javax.portlet.PortletContext;
023
024/**
025 * Mock implementation of the {@link javax.portlet.EventRequest} interface.
026 *
027 * @author Juergen Hoeller
028 * @since 3.0
029 */
030public class MockEventRequest extends MockPortletRequest implements EventRequest {
031
032        private final Event event;
033
034        private String method;
035
036
037        /**
038         * Create a new MockEventRequest with a default {@link MockPortalContext}
039         * and a default {@link MockPortletContext}.
040         * @param event the event that this request wraps
041         * @see MockEvent
042         */
043        public MockEventRequest(Event event) {
044                super();
045                this.event = event;
046        }
047
048        /**
049         * Create a new MockEventRequest with a default {@link MockPortalContext}.
050         * @param event the event that this request wraps
051         * @param portletContext the PortletContext that the request runs in
052         * @see MockEvent
053         */
054        public MockEventRequest(Event event, PortletContext portletContext) {
055                super(portletContext);
056                this.event = event;
057        }
058
059        /**
060         * Create a new MockEventRequest.
061         * @param event the event that this request wraps
062         * @param portalContext the PortletContext that the request runs in
063         * @param portletContext the PortletContext that the request runs in
064         */
065        public MockEventRequest(Event event, PortalContext portalContext, PortletContext portletContext) {
066                super(portalContext, portletContext);
067                this.event = event;
068        }
069
070
071        @Override
072        protected String getLifecyclePhase() {
073                return EVENT_PHASE;
074        }
075
076        @Override
077        public Event getEvent() {
078                return this.event;
079        }
080
081        public void setMethod(String method) {
082                this.method = method;
083        }
084
085        @Override
086        public String getMethod() {
087                return this.method;
088        }
089
090}