-
Notifications
You must be signed in to change notification settings - Fork 388
[4단계 - Tomcat 구현하기] 비토(오상훈) 미션 제출합니다 #768
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fed02f6
fix: remove implementation logback-classic on gradle (#501)
geoje 7e91356
fix: add threads min-spare configuration on properties (#502)
geoje 44fc288
Merge branch 'unifolio0' of https://github.com/unifolio0/java-http in…
unifolio0 d67f1c1
Merge remote-tracking branch 'origin/unifolio0' into unifolio0
unifolio0 c385367
Merge remote-tracking branch 'origin/unifolio0' into unifolio0
unifolio0 cdf7788
test: Connector 테스트 추가
unifolio0 2897be3
test: 에러 종류 수정
unifolio0 d6327b2
test: 메소드명 수정
unifolio0 2a1ad79
test: 변수 수정
unifolio0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tomcat/src/test/java/org/apache/catalina/connector/ConnectorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package org.apache.catalina.connector; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| import java.net.ConnectException; | ||
| import java.net.Socket; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.ThreadPoolExecutor; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class ConnectorTest { | ||
|
|
||
| @DisplayName("서버를 종료하면 더 이상 클라이언트를 받을 수 없다") | ||
| @Test | ||
| void stop() { | ||
| Connector connector = new Connector(); | ||
| connector.start(); | ||
| connector.stop(); | ||
|
|
||
| assertThatThrownBy(() -> { | ||
| try (Socket clientSocket = new Socket("localhost", 8080)) {} | ||
| }).isInstanceOf(ConnectException.class); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 단순 예외가 발생한다 보다 의미 전달이 명확해서 시원하네요! |
||
| } | ||
|
|
||
| @DisplayName("스레드 풀의 크기는 250이다") | ||
| @Test | ||
| void testServerStop() { | ||
| final var executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Connector.DEFAULT_MAX_THREADS); | ||
| for (int i = 0; i < 350; i++) { | ||
| executor.submit(threadSleep()); | ||
| } | ||
| final int expectedPoolSize = Connector.DEFAULT_MAX_THREADS; | ||
| final int expectedQueueSize = 100; | ||
|
|
||
| assertThat(expectedPoolSize).isEqualTo(executor.getPoolSize()); | ||
| assertThat(expectedQueueSize).isEqualTo(executor.getQueue().size()); | ||
| } | ||
|
|
||
| private Runnable threadSleep() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍 |
||
| return () -> { | ||
| try { | ||
| Thread.sleep(1000); | ||
| } catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 좋네요