Skip to content

Commit

Permalink
refactor: 테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jjongwa committed Sep 11, 2023
1 parent 51ca60f commit f53d16f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static ResponseBody extractFile(final String resource) throws IOException

private static ResponseBody extractHtmlFile(final String resource) throws IOException {
final URL url = CLASSLOADER.getResource(STATIC + resource + ExtensionType.HTML.getExtension());
if (url == null) {
return ResponseBody.html("Hello world!");
}
return ResponseBody.of(ExtensionType.HTML.getExtension(), makeBodyContent(url));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import nextstep.jwp.exception.NotAllowedMethodException;
import nextstep.jwp.exception.NotAllowedExtensionException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -31,7 +31,7 @@ void from_emptyExtension() {

// when & then
assertThatThrownBy(() -> ExtensionType.from(extension))
.isInstanceOf(NotAllowedMethodException.class)
.hasMessage("해당하는 Method가 존재하지 않습니다.");
.isInstanceOf(NotAllowedExtensionException.class)
.hasMessage("해당하는 Extension이 존재하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import org.apache.catalina.RequestMapping;
import org.junit.jupiter.api.Test;
import support.StubSocket;

Expand All @@ -15,7 +16,7 @@ class Http11ProcessorTest {
void process() {
// given
final var socket = new StubSocket();
final var processor = new Http11Processor(socket);
final var processor = new Http11Processor(socket, new RequestMapping());

// when
processor.process(socket);
Expand All @@ -34,15 +35,15 @@ void process() {
@Test
void index() throws IOException {
// given
final String httpRequest= String.join("\r\n",
final String httpRequest = String.join("\r\n",
"GET /index.html HTTP/1.1 ",
"Host: localhost:8080 ",
"Connection: keep-alive ",
"",
"");

final var socket = new StubSocket(httpRequest);
final Http11Processor processor = new Http11Processor(socket);
final Http11Processor processor = new Http11Processor(socket, new RequestMapping());

// when
processor.process(socket);
Expand All @@ -52,7 +53,7 @@ void index() throws IOException {
var expected = "HTTP/1.1 200 OK \r\n" +
"Content-Type: text/html;charset=utf-8 \r\n" +
"Content-Length: 5564 \r\n" +
"\r\n"+
"\r\n" +
new String(Files.readAllBytes(new File(resource.getFile()).toPath()));

assertThat(socket.output()).isEqualTo(expected);
Expand Down

0 comments on commit f53d16f

Please sign in to comment.