Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -100,8 +100,8 @@ abstract class AbstractLaunchScriptIntegrationTests {
|
||||
|
||||
private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) {
|
||||
super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version)
|
||||
.withFileFromFile("Dockerfile",
|
||||
new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile")));
|
||||
.withFileFromFile("Dockerfile",
|
||||
new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile")));
|
||||
withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar");
|
||||
withCopyFileToContainer(
|
||||
MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati
|
||||
String output = doTest(os, version, "status-when-killed.sh");
|
||||
assertThat(output).contains("Status: 1");
|
||||
assertThat(output)
|
||||
.has(coloredString(AnsiColor.RED, "Not running (process " + extractPid(output) + " not found)"));
|
||||
.has(coloredString(AnsiColor.RED, "Not running (process " + extractPid(output) + " not found)"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@@ -133,16 +133,16 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati
|
||||
@MethodSource("parameters")
|
||||
void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-missing-log-folder.sh");
|
||||
assertThat(output).has(
|
||||
coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
|
||||
assertThat(output)
|
||||
.has(coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@MethodSource("parameters")
|
||||
void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-missing-pid-folder.sh");
|
||||
assertThat(output).has(
|
||||
coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
|
||||
assertThat(output)
|
||||
.has(coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,16 +54,19 @@ class LoaderIntegrationTests {
|
||||
try (GenericContainer<?> container = createContainer(javaRuntime)) {
|
||||
container.start();
|
||||
System.out.println(this.output.toUtf8String());
|
||||
assertThat(this.output.toUtf8String()).contains(">>>>> 287649 BYTES from").doesNotContain("WARNING:")
|
||||
.doesNotContain("illegal").doesNotContain("jar written to temp");
|
||||
assertThat(this.output.toUtf8String()).contains(">>>>> 287649 BYTES from")
|
||||
.doesNotContain("WARNING:")
|
||||
.doesNotContain("illegal")
|
||||
.doesNotContain("jar written to temp");
|
||||
}
|
||||
}
|
||||
|
||||
private GenericContainer<?> createContainer(JavaRuntime javaRuntime) {
|
||||
return javaRuntime.getContainer().withLogConsumer(this.output)
|
||||
.withCopyFileToContainer(MountableFile.forHostPath(findApplication().toPath()), "/app.jar")
|
||||
.withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5)))
|
||||
.withCommand("java", "-jar", "app.jar");
|
||||
return javaRuntime.getContainer()
|
||||
.withLogConsumer(this.output)
|
||||
.withCopyFileToContainer(MountableFile.forHostPath(findApplication().toPath()), "/app.jar")
|
||||
.withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5)))
|
||||
.withCommand("java", "-jar", "app.jar");
|
||||
}
|
||||
|
||||
private File findApplication() {
|
||||
@@ -116,7 +119,7 @@ class LoaderIntegrationTests {
|
||||
|
||||
static JavaRuntime oracleJdk17() {
|
||||
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk-17")
|
||||
.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/Dockerfile"));
|
||||
.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/Dockerfile"));
|
||||
return new JavaRuntime("Oracle JDK 17", JavaVersion.SEVENTEEN, () -> new GenericContainer<>(image));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,16 +82,17 @@ class EmbeddedServerContainerInvocationContextProvider
|
||||
@Override
|
||||
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
|
||||
EmbeddedServletContainerTest annotation = context.getRequiredTestClass()
|
||||
.getAnnotation(EmbeddedServletContainerTest.class);
|
||||
return CONTAINERS.stream().map((container) -> getApplication(annotation, container))
|
||||
.flatMap((builder) -> provideTestTemplateInvocationContexts(annotation, builder));
|
||||
.getAnnotation(EmbeddedServletContainerTest.class);
|
||||
return CONTAINERS.stream()
|
||||
.map((container) -> getApplication(annotation, container))
|
||||
.flatMap((builder) -> provideTestTemplateInvocationContexts(annotation, builder));
|
||||
}
|
||||
|
||||
private Stream<EmbeddedServletContainerInvocationContext> provideTestTemplateInvocationContexts(
|
||||
EmbeddedServletContainerTest annotation, Application application) {
|
||||
return Stream.of(annotation.launchers())
|
||||
.map((launcherClass) -> getAbstractApplicationLauncher(application, launcherClass))
|
||||
.map((launcher) -> provideTestTemplateInvocationContext(application, launcher));
|
||||
.map((launcherClass) -> getAbstractApplicationLauncher(application, launcherClass))
|
||||
.map((launcher) -> provideTestTemplateInvocationContext(application, launcher));
|
||||
}
|
||||
|
||||
private EmbeddedServletContainerInvocationContext provideTestTemplateInvocationContext(Application application,
|
||||
@@ -186,8 +187,8 @@ class EmbeddedServerContainerInvocationContextProvider
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
|
||||
RestTemplate rest = new RestTemplate(new HttpComponentsClientHttpRequestFactory(HttpClients.custom()
|
||||
.setRetryStrategy(new DefaultHttpRequestRetryStrategy(10, TimeValue.of(1, TimeUnit.SECONDS)))
|
||||
.build()));
|
||||
.setRetryStrategy(new DefaultHttpRequestRetryStrategy(10, TimeValue.of(1, TimeUnit.SECONDS)))
|
||||
.build()));
|
||||
rest.setErrorHandler(new ResponseErrorHandler() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ class EmbeddedServletContainerJarPackagingIntegrationTests {
|
||||
@TestTemplate
|
||||
void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) {
|
||||
ResponseEntity<String> entity = rest
|
||||
.getForEntity("/BOOT-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
|
||||
.getForEntity("/BOOT-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ class EmbeddedServletContainerWarDevelopmentIntegrationTests {
|
||||
ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(readLines(entity.getBody()))
|
||||
.noneMatch((resourcePath) -> resourcePath.startsWith("/org/springframework/boot/loader"));
|
||||
.noneMatch((resourcePath) -> resourcePath.startsWith("/org/springframework/boot/loader"));
|
||||
}
|
||||
|
||||
private List<String> readLines(String input) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,7 +74,7 @@ class EmbeddedServletContainerWarPackagingIntegrationTests {
|
||||
@TestTemplate
|
||||
void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) {
|
||||
ResponseEntity<String> entity = rest
|
||||
.getForEntity("/WEB-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
|
||||
.getForEntity("/WEB-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ class EmbeddedServletContainerWarPackagingIntegrationTests {
|
||||
ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(readLines(entity.getBody()))
|
||||
.noneMatch((resourcePath) -> resourcePath.startsWith("/org/springframework/boot/loader"));
|
||||
.noneMatch((resourcePath) -> resourcePath.startsWith("/org/springframework/boot/loader"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void conditionalOnWarDeploymentBeanIsNotAvailableForEmbeddedServer(RestTemplate rest) {
|
||||
assertThat(rest.getForEntity("/always", String.class).getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(rest.getForEntity("/conditionalOnWar", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
private List<String> readLines(String input) {
|
||||
|
||||
Reference in New Issue
Block a user