1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.action;
17
18 import static org.easymock.EasyMock.createMock;
19 import static org.easymock.EasyMock.replay;
20
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.seasar.cubby.mock.MockActionContext;
27
28 public class SendErrorTest {
29
30 private HttpServletRequest request;
31
32 private HttpServletResponse response;
33
34 @Before
35 public void setupMock() {
36 request = createMock(HttpServletRequest.class);
37 response = createMock(HttpServletResponse.class);
38 }
39
40 @Test
41 public void sendError() throws Exception {
42 response.sendError(HttpServletResponse.SC_NOT_FOUND);
43 replay(request, response);
44
45 SendError sendError = new SendError(HttpServletResponse.SC_NOT_FOUND);
46 ActionContext actionContext = new MockActionContext(null, null, null);
47 sendError.execute(actionContext, request, response);
48 }
49
50 @Test
51 public void sendErrorWithMessage() throws Exception {
52 response.sendError(HttpServletResponse.SC_NOT_FOUND, "NOT FOUND");
53 replay(request, response);
54
55 SendError sendError = new SendError(HttpServletResponse.SC_NOT_FOUND,
56 "NOT FOUND");
57 ActionContext actionContext = new MockActionContext(null, null, null);
58 sendError.execute(actionContext, request, response);
59 }
60 }