Skip to content

Commit

Permalink
test: 종료 코드로 종료하는 것을 검증
Browse files Browse the repository at this point in the history
  • Loading branch information
joon6093 committed Nov 23, 2024
1 parent ad6ec1a commit ac96c24
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/src/test/java/io/jeyong/test/unit/SystemTerminatorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.jeyong.test.unit;

import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
import static io.jeyong.handler.SignalHandlerRegistrar.EXIT_CODE;
import static org.assertj.core.api.Assertions.assertThat;

import io.jeyong.handler.SystemTerminator;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import sun.misc.SignalHandler;

@DisplayName("SystemTerminator Unit Test")
public class SystemTerminatorTest {

@Test
@DisplayName("System.exit should be called with the expected status code")
void testHandleTerminationCallsSystemExit() throws Exception {
// given
SystemTerminator terminator = new SystemTerminator();
int expectedStatusCode = EXIT_CODE;
SignalHandler handler = terminator.handleTermination(expectedStatusCode);

// when
int actualExitCode = catchSystemExit(() -> handler.handle(null));

// then
assertThat(actualExitCode).isEqualTo(expectedStatusCode);
}
}

0 comments on commit ac96c24

Please sign in to comment.