From 8f27ad9726ddecbd7f1fbe2f535866baf4bd01bc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 7 Aug 2020 09:49:10 +0100 Subject: [PATCH] Remove version from name of Ant-built jar Previously, the project version was included in the name of the Ant-built jar and the integration test assumed that there would be a single jar in the output directory. This assumption did not hold true if the project's version had changed and the project had been built again without a clean. This resulted in two jars, one for the previous version and one for the current version, in the output directory. This caused a test failure. This commit updates the build.xml to remove the version from the name of the Ant-built jar and updates the integration test to find it. Closes gh-22782 --- .../spring-boot-smoke-test-ant/build.xml | 4 ++-- .../smoketest/ant/SampleAntApplicationIT.java | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.xml index de41e746f83..97409a5ee75 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.xml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.xml @@ -11,7 +11,7 @@ actual jars). Run with '$ java -jar target/*.jar'. - + @@ -37,7 +37,7 @@ - + diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant/SampleAntApplicationIT.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant/SampleAntApplicationIT.java index 0aff1e43dd2..e13efd01e27 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant/SampleAntApplicationIT.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant/SampleAntApplicationIT.java @@ -17,7 +17,6 @@ package smoketest.ant; import java.io.File; -import java.io.FileFilter; import java.io.InputStreamReader; import java.util.concurrent.TimeUnit; @@ -38,17 +37,9 @@ public class SampleAntApplicationIT { @Test void runJar() throws Exception { - File target = new File("build/ant/libs"); - File[] jarFiles = target.listFiles(new FileFilter() { - - @Override - public boolean accept(File file) { - return file.getName().endsWith(".jar"); - } - - }); - assertThat(jarFiles).hasSize(1); - Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start(); + File libs = new File("build/ant/libs"); + Process process = new JavaExecutable().processBuilder("-jar", "spring-boot-smoke-test-ant.jar").directory(libs) + .start(); process.waitFor(5, TimeUnit.MINUTES); assertThat(process.exitValue()).isEqualTo(0); String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));