01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.spring;
17:
18: import org.directwebremoting.WebContextFactory.WebContextBuilder;
19: import org.directwebremoting.servlet.UrlProcessor;
20: import org.easymock.EasyMock;
21: import org.junit.Ignore;
22: import org.junit.Test;
23: import org.springframework.beans.factory.BeanFactory;
24: import org.springframework.mock.web.MockHttpServletRequest;
25: import org.springframework.mock.web.MockHttpServletResponse;
26: import org.springframework.mock.web.MockServletConfig;
27: import org.springframework.mock.web.MockServletContext;
28:
29: /**
30: * @author Bram Smeets
31: * @author Joe Walker [joe at getahead dot ltd dot uk]
32: */
33: public class DwrSpringServletTest {
34: @Ignore
35: @Test
36: public void doPost() throws Exception {
37: DwrSpringServlet servlet = new DwrSpringServlet();
38:
39: MockServletConfig config = new MockServletConfig(
40: new MockServletContext());
41: servlet.setIncludeDefaultConfig(false);
42: servlet.init(config);
43:
44: MockHttpServletRequest request = new MockHttpServletRequest();
45: MockHttpServletResponse response = new MockHttpServletResponse();
46: servlet.doPost(request, response);
47: }
48:
49: @Ignore
50: @Test
51: public void mockPost() throws Exception {
52: BeanFactory factory = EasyMock.createMock(BeanFactory.class);
53:
54: UrlProcessor processor = new UrlProcessor();
55: WebContextBuilder builder = EasyMock
56: .createMock(WebContextBuilder.class);
57:
58: EasyMock.expect(factory.getBean(UrlProcessor.class.getName()))
59: .andReturn(processor);
60: EasyMock.expect(
61: factory.getBean(WebContextBuilder.class.getName()))
62: .andReturn(builder);
63:
64: MockHttpServletRequest request = new MockHttpServletRequest();
65: MockHttpServletResponse response = new MockHttpServletResponse();
66: processor.handle(request, response);
67:
68: EasyMock.replay(factory);
69:
70: EasyMock.verify(factory);
71: }
72: }
|