Skip to content

Commit 993ba47

Browse files
committed
Add FoundResponse
1 parent c57afe3 commit 993ba47

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package httpserver.response;
2+
3+
import httpserver.header.Header;
4+
5+
public class FoundResponse extends Response {
6+
public FoundResponse(String location) {
7+
super.setHeader(new Header("Location", location));
8+
}
9+
10+
@Override
11+
public int getStatusCode() {
12+
return 302;
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package httpserver.response;
2+
3+
import httpserver.header.Header;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
public class FoundResponseTest {
9+
@Test
10+
public void hasStatusCode302() throws Exception {
11+
FoundResponse foundResponse = new FoundResponse("example");
12+
13+
Header[] expected = new Header[]{new Header("Location", "example")};
14+
assertEquals(302, foundResponse.getStatusCode());
15+
assertEquals(expected, foundResponse.getHeaders());
16+
}
17+
}

0 commit comments

Comments
 (0)