@ -17,14 +17,9 @@
package org.springframework.boot.launchscript ;
package org.springframework.boot.launchscript ;
import java.io.File ;
import java.io.File ;
import java.net.URI ;
import java.nio.file.Paths ;
import java.time.Duration ;
import java.time.Duration ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.function.Predicate ;
import java.util.function.Predicate ;
import org.assertj.core.api.Condition ;
import org.assertj.core.api.Condition ;
@ -52,16 +47,6 @@ import static org.hamcrest.Matchers.containsString;
* /
* /
abstract class AbstractLaunchScriptIntegrationTests {
abstract class AbstractLaunchScriptIntegrationTests {
private static final Map < Architecture , URI > JAVA_DOWNLOAD_URLS ;
static {
Map < Architecture , URI > urls = new HashMap < > ( ) ;
urls . put ( Architecture . AMD64 ,
URI . create ( "https://download.bell-sw.com/java/8u382+6/bellsoft-jdk8u382+6-linux-amd64.tar.gz" ) ) ;
urls . put ( Architecture . AARCH64 ,
URI . create ( "https://download.bell-sw.com/java/8u382+6/bellsoft-jdk8u382+6-linux-aarch64.tar.gz" ) ) ;
JAVA_DOWNLOAD_URLS = Collections . unmodifiableMap ( urls ) ;
}
protected static final char ESC = 27 ;
protected static final char ESC = 27 ;
private final String scriptsDir ;
private final String scriptsDir ;
@ -115,9 +100,7 @@ abstract class AbstractLaunchScriptIntegrationTests {
private static final class LaunchScriptTestContainer extends GenericContainer < LaunchScriptTestContainer > {
private static final class LaunchScriptTestContainer extends GenericContainer < LaunchScriptTestContainer > {
private LaunchScriptTestContainer ( String os , String version , String scriptsDir , String testScript ) {
private LaunchScriptTestContainer ( String os , String version , String scriptsDir , String testScript ) {
super ( new ImageFromDockerfile ( "spring-boot-launch-script/" + os . toLowerCase ( ) + "-" + version )
super ( createImage ( os , version ) ) ;
. withDockerfile ( Paths . get ( "src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile" ) )
. withBuildArg ( "JAVA_DOWNLOAD_URL" , getJavaDownloadUrl ( ) ) ) ;
withCopyFileToContainer ( MountableFile . forHostPath ( findApplication ( ) . getAbsolutePath ( ) ) , "/app.jar" ) ;
withCopyFileToContainer ( MountableFile . forHostPath ( findApplication ( ) . getAbsolutePath ( ) ) , "/app.jar" ) ;
withCopyFileToContainer (
withCopyFileToContainer (
MountableFile . forHostPath ( "src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh" ) ,
MountableFile . forHostPath ( "src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh" ) ,
@ -130,14 +113,15 @@ abstract class AbstractLaunchScriptIntegrationTests {
withStartupCheckStrategy ( new OneShotStartupCheckStrategy ( ) . withTimeout ( Duration . ofMinutes ( 5 ) ) ) ;
withStartupCheckStrategy ( new OneShotStartupCheckStrategy ( ) . withTimeout ( Duration . ofMinutes ( 5 ) ) ) ;
}
}
private static String getJavaDownloadUrl ( ) {
private static ImageFromDockerfile createImage ( String os , String version ) {
Architecture architecture = Architecture . current ( ) ;
ImageFromDockerfile image = new ImageFromDockerfile (
Assert . notNull ( architecture ,
"spring-boot-launch-script/" + os . toLowerCase ( ) + "-" + version ) ;
( ) - > String . format ( "Failed to find current architecture. Value of os.arch is: '%s'" ,
image . withFileFromFile ( "Dockerfile" ,
System . getProperty ( "os.arch" ) ) ) ;
new File ( "src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile" ) ) ;
URI uri = JAVA_DOWNLOAD_URLS . get ( architecture ) ;
for ( File file : new File ( "build/downloads/jdk/bellsoft" ) . listFiles ( ) ) {
Assert . notNull ( uri , ( ) - > String . format ( "No JDK download URL for architecture %s found" , architecture ) ) ;
image . withFileFromFile ( "downloads/" + file . getName ( ) , file ) ;
return uri . toString ( ) ;
}
return image ;
}
}
private static File findApplication ( ) {
private static File findApplication ( ) {
@ -149,30 +133,4 @@ abstract class AbstractLaunchScriptIntegrationTests {
}
}
private enum Architecture {
AMD64 , AARCH64 ;
/ * *
* Returns the current architecture .
* @return the current architecture or { @code null }
* /
static Architecture current ( ) {
String arch = System . getProperty ( "os.arch" ) ;
if ( arch = = null ) {
return null ;
}
switch ( arch ) {
case "amd64" :
case "x86_64" :
return AMD64 ;
case "aarch64" :
return AARCH64 ;
default :
return null ;
}
}
}
}
}