|
23 | 23 | import java.util.List;
|
24 | 24 | import java.util.concurrent.ConcurrentLinkedDeque;
|
25 | 25 | import org.junit.jupiter.api.Test;
|
| 26 | +import org.junit.jupiter.api.condition.EnabledOnOs; |
| 27 | +import org.junit.jupiter.api.condition.OS; |
26 | 28 | import org.junit.jupiter.api.extension.RegisterExtension;
|
27 | 29 | import org.slf4j.event.Level;
|
28 | 30 | import testutils.LogTester;
|
29 | 31 |
|
30 | 32 | import static org.assertj.core.api.Assertions.assertThat;
|
31 | 33 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
| 34 | +import static org.sonarsource.scanner.lib.internal.facade.forked.JavaRunner.JRE_VERSION_ERROR; |
32 | 35 |
|
33 | 36 | class JavaRunnerTest {
|
34 | 37 |
|
@@ -84,4 +87,24 @@ void execute_shouldReturnFalseWhenNonZeroExitCode() {
|
84 | 87 | assertThat(runner.execute(command, null, stdOut::add)).isFalse();
|
85 | 88 | }
|
86 | 89 |
|
| 90 | + @Test |
| 91 | + @EnabledOnOs(OS.WINDOWS) |
| 92 | + void execute_shouldLogUnsupportedClassVersionError_whenOsIsWindows() { |
| 93 | + JavaRunner runner = new JavaRunner(Paths.get("cmd.exe"), JreCacheHit.DISABLED); |
| 94 | + List<String> command = List.of("/c", "echo UnsupportedClassVersionError 1>&2"); |
| 95 | + |
| 96 | + assertThat(runner.execute(command, null, stdOut::add)).isTrue(); |
| 97 | + assertThat(logTester.logs(Level.ERROR)).contains(JRE_VERSION_ERROR); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + @EnabledOnOs(OS.LINUX) |
| 102 | + void execute_shouldLogUnsupportedClassVersionError_whenOsIsLinux() { |
| 103 | + JavaRunner runner = new JavaRunner(Paths.get("sh"), JreCacheHit.DISABLED); |
| 104 | + List<String> command = List.of("-c", " >&2 echo UnsupportedClassVersionError"); |
| 105 | + |
| 106 | + assertThat(runner.execute(command, null, stdOut::add)).isTrue(); |
| 107 | + assertThat(logTester.logs(Level.ERROR)).contains(JRE_VERSION_ERROR); |
| 108 | + } |
| 109 | + |
87 | 110 | }
|
0 commit comments