01: /*
02: * $Id: $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.portlet.interceptor;
22:
23: import java.util.HashMap;
24: import java.util.Map;
25:
26: import javax.portlet.PortletRequest;
27:
28: import junit.framework.TestCase;
29:
30: import org.apache.struts2.portlet.PortletActionConstants;
31: import org.easymock.EasyMock;
32:
33: import com.opensymphony.xwork2.ActionContext;
34: import com.opensymphony.xwork2.ActionInvocation;
35:
36: public class PortletAwareInterceptorTest extends TestCase implements
37: PortletActionConstants {
38:
39: private PortletAwareInterceptor interceptor;
40:
41: protected void setUp() throws Exception {
42: super .setUp();
43: interceptor = new PortletAwareInterceptor();
44: }
45:
46: protected void tearDown() throws Exception {
47: super .tearDown();
48: }
49:
50: public void testPortletRequestIsSet() throws Exception {
51: PortletRequest request = EasyMock
52: .createMock(PortletRequest.class);
53: Map<String, Object> ctx = new HashMap<String, Object>();
54: ctx.put(REQUEST, request);
55: PortletRequestAware action = EasyMock
56: .createMock(PortletRequestAware.class);
57: action.setPortletRequest(request);
58:
59: ActionInvocation invocation = EasyMock
60: .createNiceMock(ActionInvocation.class);
61: EasyMock.expect(invocation.getInvocationContext()).andReturn(
62: new ActionContext(ctx));
63: EasyMock.expect(invocation.getAction()).andReturn(action);
64:
65: EasyMock.replay(action);
66: EasyMock.replay(invocation);
67:
68: interceptor.intercept(invocation);
69:
70: EasyMock.verify(action);
71: }
72: }
|