Skip to content

Commit

Permalink
Merge branch '2.4.x' into 2.5.x
Browse files Browse the repository at this point in the history
Closes gh-28484
  • Loading branch information
wilkinsona committed Oct 29, 2021
2 parents 07ed7ab + 22d85e6 commit 7fe6f48
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private void configureTestConventions(Project project) {
project.getTasks().withType(Test.class, (test) -> {
test.useJUnitPlatform();
test.setMaxHeapSize("1024M");
test.setMaxParallelForks(project.getGradle().getStartParameter().getMaxWorkerCount());
project.getTasks().withType(Checkstyle.class, (checkstyle) -> test.mustRunAfter(checkstyle));
project.getTasks().withType(CheckFormat.class, (checkFormat) -> test.mustRunAfter(checkFormat));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;

Expand All @@ -43,15 +43,15 @@ abstract class AbstractApplicationLauncher implements BeforeEachCallback {

private final Application application;

private final BuildOutput buildOutput;
private final File outputLocation;

private Process process;

private int httpPort;

protected AbstractApplicationLauncher(Application application, BuildOutput buildOutput) {
protected AbstractApplicationLauncher(Application application, File outputLocation) {
this.application = application;
this.buildOutput = buildOutput;
this.outputLocation = outputLocation;
}

@Override
Expand All @@ -71,6 +71,7 @@ void destroyProcess() {
Thread.currentThread().interrupt();
}
}
FileSystemUtils.deleteRecursively(this.outputLocation);
}

final int getHttpPort() {
Expand All @@ -85,7 +86,7 @@ final int getHttpPort() {

private Process startApplication() throws Exception {
File workingDirectory = getWorkingDirectory();
File serverPortFile = new File(this.buildOutput.getRootLocation(), "server.port");
File serverPortFile = new File(this.outputLocation, "server.port");
serverPortFile.delete();
File archive = new File("build/spring-boot-server-tests-app/build/libs/spring-boot-server-tests-app-"
+ this.application.getContainer() + "." + this.application.getPackaging());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StreamUtils;
Expand All @@ -43,9 +42,9 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher {

private final File exploded;

BootRunApplicationLauncher(Application application, BuildOutput buildOutput) {
super(application, buildOutput);
this.exploded = new File(buildOutput.getRootLocation(), "run");
BootRunApplicationLauncher(Application application, File outputLocation) {
super(application, outputLocation);
this.exploded = new File(outputLocation, "run");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.context.embedded;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
Expand All @@ -26,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Stream;

import org.apache.http.impl.client.HttpClients;
Expand Down Expand Up @@ -109,7 +111,8 @@ private AbstractApplicationLauncher getAbstractApplicationLauncher(Application a
if (this.launcherCache.containsKey(cacheKey)) {
return this.launcherCache.get(cacheKey);
}
AbstractApplicationLauncher launcher = ReflectionUtils.newInstance(launcherClass, application, buildOutput);
AbstractApplicationLauncher launcher = ReflectionUtils.newInstance(launcherClass, application,
new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID()));
this.launcherCache.put(cacheKey, launcher);
return launcher;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.function.Supplier;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StreamUtils;

Expand All @@ -38,16 +36,16 @@
*/
class ExplodedApplicationLauncher extends AbstractApplicationLauncher {

private final Supplier<File> exploded;
private final File exploded;

ExplodedApplicationLauncher(Application application, BuildOutput buildOutput) {
super(application, buildOutput);
this.exploded = () -> new File(buildOutput.getRootLocation(), "exploded");
ExplodedApplicationLauncher(Application application, File outputLocation) {
super(application, outputLocation);
this.exploded = new File(outputLocation, "exploded");
}

@Override
protected File getWorkingDirectory() {
return this.exploded.get();
return this.exploded;
}

@Override
Expand All @@ -61,21 +59,20 @@ protected List<String> getArguments(File archive, File serverPortFile) {
: "org.springframework.boot.loader.JarLauncher");
try {
explodeArchive(archive);
return Arrays.asList("-cp", this.exploded.get().getAbsolutePath(), mainClass,
serverPortFile.getAbsolutePath());
return Arrays.asList("-cp", this.exploded.getAbsolutePath(), mainClass, serverPortFile.getAbsolutePath());
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
}

private void explodeArchive(File archive) throws IOException {
FileSystemUtils.deleteRecursively(this.exploded.get());
FileSystemUtils.deleteRecursively(this.exploded);
JarFile jarFile = new JarFile(archive);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = entries.nextElement();
File extracted = new File(this.exploded.get(), jarEntry.getName());
File extracted = new File(this.exploded, jarEntry.getName());
if (jarEntry.isDirectory()) {
extracted.mkdirs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StreamUtils;
Expand All @@ -43,9 +42,9 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher {

private final File exploded;

IdeApplicationLauncher(Application application, BuildOutput buildOutput) {
super(application, buildOutput);
this.exploded = new File(buildOutput.getRootLocation(), "the+ide application");
IdeApplicationLauncher(Application application, File outputLocation) {
super(application, outputLocation);
this.exploded = new File(outputLocation, "the+ide application");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.util.Arrays;
import java.util.List;

import org.springframework.boot.testsupport.BuildOutput;

/**
* {@link AbstractApplicationLauncher} that launches a packaged Spring Boot application
* using {@code java -jar}.
Expand All @@ -30,8 +28,8 @@
*/
class PackagedApplicationLauncher extends AbstractApplicationLauncher {

PackagedApplicationLauncher(Application application, BuildOutput buildOutput) {
super(application, buildOutput);
PackagedApplicationLauncher(Application application, File outputLocation) {
super(application, outputLocation);
}

@Override
Expand Down

0 comments on commit 7fe6f48

Please sign in to comment.