Skip to content

Commit

Permalink
Merge pull request #51 from sanhee/fix-content-length
Browse files Browse the repository at this point in the history
Fix content length
  • Loading branch information
sanhee authored Aug 30, 2021
2 parents 06950c8 + c198b5e commit 8d86d07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/test/java/webserver/FileForTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package webserver;

import java.io.File;

public class FileForTest {
public static final File INDEX_HTML = new File("./webapp/index.html");
public static final File FORM_HTML = new File("./webapp/index.html");
}
10 changes: 6 additions & 4 deletions src/test/java/webserver/RequestHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import model.User;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -24,6 +25,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static webserver.FileForTest.*;

class RequestHandlerTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down Expand Up @@ -96,9 +98,9 @@ static Stream<Arguments> run() throws IOException {
"" + System.lineSeparator(),
"HTTP/1.1 200 OK" + System.lineSeparator() +
"Content-Type: text/html;charset=utf-8" + System.lineSeparator() +
"Content-Length: 6903" + System.lineSeparator() +
"Content-Length: " + INDEX_HTML.length() + System.lineSeparator() +
"" + System.lineSeparator() +
Files.lines(new File("./webapp/index.html").toPath())
Files.lines(INDEX_HTML.toPath())
.collect(Collectors.joining(System.lineSeparator()))
), Arguments.arguments(
"GET /index2.html HTTP/1.1" + System.lineSeparator() +
Expand All @@ -115,9 +117,9 @@ static Stream<Arguments> run() throws IOException {
"" + System.lineSeparator(),
"HTTP/1.1 200 OK" + System.lineSeparator() +
"Content-Type: text/html;charset=utf-8" + System.lineSeparator() +
"Content-Length: 5169" + System.lineSeparator() +
"Content-Length: " + FORM_HTML.length() + System.lineSeparator() +
"" + System.lineSeparator() +
Files.lines(new File("./webapp/user/form.html").toPath())
Files.lines(FORM_HTML.toPath())
.collect(Collectors.joining(System.lineSeparator()))
), Arguments.arguments(
"POST /user/create HTTP/1.1" + System.lineSeparator() +
Expand Down

0 comments on commit 8d86d07

Please sign in to comment.