|
23 | 23 | import org.mockito.Mockito; |
24 | 24 | import reactor.core.publisher.Mono; |
25 | 25 |
|
| 26 | +import static org.assertj.core.api.Assertions.assertThat; |
26 | 27 | import static org.assertj.core.api.Assertions.assertThatCode; |
27 | 28 | import static org.mockito.Mockito.mock; |
28 | 29 | import static org.mockito.Mockito.never; |
@@ -123,5 +124,41 @@ void closeGracefully_should_complete_immediately_if_session_closes_in_5_seconds( |
123 | 124 | verify(mockSession, never()).close(); |
124 | 125 | } |
125 | 126 |
|
| 127 | + @Test |
| 128 | + void shouldExitOnStdinEof_should_return_true_for_production_stack_trace() { |
| 129 | + // Simulate a production stack trace with no test frameworks |
| 130 | + var stackTrace = new StackTraceElement[] { |
| 131 | + new StackTraceElement("com.example.MyApp", "main", "MyApp.java", 10), |
| 132 | + new StackTraceElement("com.example.MyService", "start", "MyService.java", 20), |
| 133 | + new StackTraceElement("java.lang.Thread", "run", "Thread.java", 100) |
| 134 | + }; |
| 135 | + |
| 136 | + boolean result = StdioServerTransportProvider.shouldExitOnStdinEof(stackTrace); |
| 137 | + |
| 138 | + assertThat(result).isTrue(); |
| 139 | + } |
| 140 | + |
| 141 | + @Test |
| 142 | + void shouldExitOnStdinEof_should_return_false_when_junit_in_stack_trace() { |
| 143 | + // Simulate a test stack trace with JUnit |
| 144 | + var stackTrace = new StackTraceElement[] { |
| 145 | + new StackTraceElement("org.junit.jupiter.engine.execution.ExecutableInvoker", "invoke", "ExecutableInvoker.java", 20) |
| 146 | + }; |
| 147 | + |
| 148 | + boolean result = StdioServerTransportProvider.shouldExitOnStdinEof(stackTrace); |
| 149 | + |
| 150 | + assertThat(result).isFalse(); |
| 151 | + } |
| 152 | + |
| 153 | + @Test |
| 154 | + void shouldExitOnStdinEof_should_return_true_for_empty_stack_trace() { |
| 155 | + // Edge case: empty stack trace |
| 156 | + var stackTrace = new StackTraceElement[] {}; |
| 157 | + |
| 158 | + boolean result = StdioServerTransportProvider.shouldExitOnStdinEof(stackTrace); |
| 159 | + |
| 160 | + assertThat(result).isTrue(); |
| 161 | + } |
| 162 | + |
126 | 163 | } |
127 | 164 |
|
0 commit comments