File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ launch-templates:
6
6
SERVICES_HOST : " "
7
7
LANG : C.UTF-8
8
8
JAVA_HOME : /usr/lib/jvm/java-17-openjdk-amd64
9
+ PATH : /usr/lib/jvm/java-17-openjdk-amd64/bin:/usr/local/bin:/usr/bin:/bin
9
10
resource-class : ' docker_linux_amd64/extra_large+'
10
11
image : ' ubuntu22.04-node20.11-v10'
11
12
init-steps :
Original file line number Diff line number Diff line change 21
21
import java .util .concurrent .TimeUnit ;
22
22
23
23
import org .junit .jupiter .api .Test ;
24
+ import org .junit .jupiter .api .condition .EnabledIf ;
24
25
25
26
import org .springframework .util .FileCopyUtils ;
26
27
35
36
class SampleAntApplicationIT {
36
37
37
38
@ Test
39
+ @ EnabledIf ("isJavaExecutableAvailable" )
38
40
void runJar () throws Exception {
39
41
File libs = new File ("build/ant/libs" );
40
42
String javaExecutable = findJavaExecutable ();
@@ -61,4 +63,19 @@ private String findJavaExecutable() {
61
63
return "java" ;
62
64
}
63
65
66
+ boolean isJavaExecutableAvailable () {
67
+ try {
68
+ String javaExecutable = findJavaExecutable ();
69
+ if (!javaExecutable .equals ("java" )) {
70
+ return new File (javaExecutable ).exists ();
71
+ }
72
+ // Try to execute java to see if it's available in PATH
73
+ ProcessBuilder pb = new ProcessBuilder ("java" , "-version" );
74
+ Process process = pb .start ();
75
+ return process .waitFor () == 0 ;
76
+ } catch (Exception e ) {
77
+ return false ;
78
+ }
79
+ }
80
+
64
81
}
You can’t perform that action at this time.
0 commit comments