01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.controller.chain.command;
16:
17: import static org.easymock.EasyMock.expect;
18:
19: import javax.servlet.http.HttpServletRequest;
20:
21: import org.apache.struts.chain.contexts.ServletActionContext;
22: import org.strecks.preprocess.RequestPreprocessor;
23: import org.testng.annotations.Test;
24:
25: /**
26: * @author Phil Zoio
27: */
28: public class TestPreprocess extends AbstractTestChain {
29: @Test
30: public void testPopulateActionForm() throws Exception {
31: ServletActionContext sac = getActionContext();
32: RequestPreprocessor requestPreprocessor = newMock(RequestPreprocessor.class);
33: Preprocess preprocess = getPreprocess(requestPreprocessor);
34: HttpServletRequest request = newMock(HttpServletRequest.class);
35:
36: expect(sac.getRequest()).andReturn(request);
37: requestPreprocessor.preprocessRequest(request);
38:
39: replayMocks();
40: preprocess.execute(sac);
41: verifyMocks();
42: }
43:
44: public Preprocess getPreprocess(
45: final RequestPreprocessor preprocessor) {
46: return new Preprocess() {
47: protected RequestPreprocessor newRequestPreprocessor() {
48: return preprocessor;
49: }
50: };
51: }
52: }
|