1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts2.interceptor;
22
23 import javax.servlet.http.HttpServletRequest;
24
25 import org.apache.struts2.ServletActionContext;
26 import org.apache.struts2.StrutsTestCase;
27 import org.jmock.Mock;
28 import org.jmock.core.constraint.IsEqual;
29 import org.jmock.core.matcher.InvokeOnceMatcher;
30
31 import com.opensymphony.xwork2.mock.MockActionInvocation;
32
33 /***
34 * Test case for CreateSessionInterceptor.
35 *
36 */
37 public class CreateSessionInterceptorTest extends StrutsTestCase {
38
39 public void testCreateSession() throws Exception {
40 Mock httpServletRequestMock = new Mock(HttpServletRequest.class);
41 httpServletRequestMock.expects(new InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.TRUE));
42 HttpServletRequest request = (HttpServletRequest) httpServletRequestMock.proxy();
43
44 ServletActionContext.setRequest(request);
45
46 CreateSessionInterceptor interceptor = new CreateSessionInterceptor();
47 interceptor.intercept(new MockActionInvocation());
48
49 httpServletRequestMock.verify();
50 }
51 }