File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
main/java/httpserver/response
test/java/httpserver/response Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package httpserver .response ;
2+
3+ import httpserver .Header ;
4+
5+ public class UnauthorizedResponse implements Response {
6+ @ Override
7+ public int getStatusCode () {
8+ return 401 ;
9+ }
10+
11+ @ Override
12+ public byte [] getPayload () {
13+ return new byte [0 ];
14+ }
15+
16+ @ Override
17+ public Header [] getHeaders () {
18+ return new Header [0 ];
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package httpserver .response ;
2+
3+ import httpserver .Header ;
4+ import org .junit .Test ;
5+
6+ import java .util .Arrays ;
7+
8+ import static org .junit .Assert .*;
9+
10+ public class UnauthorizedResponseTest {
11+ private final UnauthorizedResponse unauthorizedResponse ;
12+
13+ public UnauthorizedResponseTest () {
14+ unauthorizedResponse = new UnauthorizedResponse ();
15+ }
16+
17+ @ Test
18+ public void hasStatusCode405 () throws Exception {
19+ assertEquals (401 , unauthorizedResponse .getStatusCode ());
20+ }
21+
22+ @ Test
23+ public void hasEmptyPayload () throws Exception {
24+ assertTrue (Arrays .equals (new byte [0 ], unauthorizedResponse .getPayload ()));
25+ }
26+
27+ @ Test
28+ public void hasNoHeaders () throws Exception {
29+ assertTrue (Arrays .equals (new Header [0 ], unauthorizedResponse .getHeaders ()));
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments