Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MVC 미션 1단계] 오리(오현서) 미션 제출합니다. #355

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
서블릿 학습 테스트 코드 개선
  • Loading branch information
kang-hyungu committed Sep 11, 2023
commit e7c21ab067b56fde67900cb4088c2a8ca3bf4016
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,5 @@ Temporary Items

tomcat.*
tomcat.*/**

**/WEB-INF/classes/**
1 change: 1 addition & 0 deletions study/src/main/java/servlet/com/example/TomcatStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void await() {
public void stop() {
try {
tomcat.stop();
tomcat.destroy();
} catch (LifecycleException e) {
throw new RuntimeException(e);
}
Expand Down
7 changes: 4 additions & 3 deletions study/src/test/java/servlet/com/example/FilterTest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package servlet.com.example;

import org.junit.jupiter.api.Test;
import support.HttpUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static servlet.com.example.KoreanServlet.인코딩;

class FilterTest {

@Test
void testFilter() throws Exception {
void testFilter() {
// 톰캣 서버 시작
final var tomcatStarter = TestHttpUtils.createTomcatStarter();
final var tomcatStarter = new TomcatStarter("src/main/webapp/");
tomcatStarter.start();

final var response = TestHttpUtils.send("/korean");
final var response = HttpUtils.send("/korean");

// 톰캣 서버 종료
tomcatStarter.stop();
Expand Down
23 changes: 13 additions & 10 deletions study/src/test/java/servlet/com/example/ServletTest.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package servlet.com.example;

import org.junit.jupiter.api.Test;
import support.HttpUtils;

import static org.assertj.core.api.Assertions.assertThat;

class ServletTest {

private final String WEBAPP_DIR_LOCATION = "src/main/webapp/";

@Test
void testSharedCounter() throws Exception {
void testSharedCounter() {
// 톰캣 서버 시작
final var tomcatStarter = TestHttpUtils.createTomcatStarter();
final var tomcatStarter = new TomcatStarter(WEBAPP_DIR_LOCATION);
tomcatStarter.start();

// shared-counter 페이지를 3번 호출한다.
final var PATH = "/shared-counter";
TestHttpUtils.send(PATH);
TestHttpUtils.send(PATH);
final var response = TestHttpUtils.send(PATH);
HttpUtils.send(PATH);
HttpUtils.send(PATH);
final var response = HttpUtils.send(PATH);

// 톰캣 서버 종료
tomcatStarter.stop();
Expand All @@ -29,16 +32,16 @@ void testSharedCounter() throws Exception {
}

@Test
void testLocalCounter() throws Exception {
void testLocalCounter() {
// 톰캣 서버 시작
final var tomcatStarter = TestHttpUtils.createTomcatStarter();
final var tomcatStarter = new TomcatStarter(WEBAPP_DIR_LOCATION);
tomcatStarter.start();

// local-counter 페이지를 3번 호출한다.
final var PATH = "/local-counter";
TestHttpUtils.send(PATH);
TestHttpUtils.send(PATH);
final var response = TestHttpUtils.send(PATH);
HttpUtils.send(PATH);
HttpUtils.send(PATH);
final var response = HttpUtils.send(PATH);

// 톰캣 서버 종료
tomcatStarter.stop();
Expand Down
28 changes: 0 additions & 28 deletions study/src/test/java/servlet/com/example/TestHttpUtils.java

This file was deleted.