From 8085100e4047d8e4d133adb3f85819b096883068 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 28 Nov 2023 14:14:02 +0100 Subject: [PATCH] Try some dark magic to fix DevMojoIT.testThatNewResourcesAreServed It's perfectly stable locally, apparently also working well on Windows on CI but consistently failing with Java 17 on CI. --- .../java/io/quarkus/maven/it/DevMojoIT.java | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java index 3cbe292a417fba..31fc995b2c600f 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java @@ -649,16 +649,15 @@ public void testThatTheApplicationIsReloadedMultiModule() throws MavenInvocation // Create a new resource source = new File(testDir, "html/src/main/resources/META-INF/resources/lorem.txt"); - FileUtils.write(source, - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - "UTF-8"); + Files.writeString(source.toPath(), + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) .until(() -> devModeClient.getHttpResponse("/lorem.txt").contains("Lorem ipsum")); // Update the resource - FileUtils.write(source, uuid, "UTF-8"); + Files.writeString(source.toPath(), uuid); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) @@ -755,7 +754,7 @@ public void testThatTheApplicationIsReloadedOnNewResource() throws MavenInvocati " return \"bar\";\n" + " }\n" + "}\n"; - FileUtils.write(source, myNewResource, StandardCharsets.UTF_8); + Files.writeString(source.toPath(), myNewResource); // Wait until we get "bar" await() @@ -790,7 +789,7 @@ public void testThatClassFileAreCleanedUp() throws MavenInvocationException, IOE " return \"to be deleted\";\n" + " }\n" + "}"; - FileUtils.write(source, classDeletionResource, StandardCharsets.UTF_8); + Files.writeString(source.toPath(), classDeletionResource, StandardCharsets.UTF_8); runAndCheck(); // Wait until source file is compiled @@ -903,9 +902,8 @@ public void testThatAddingConfigFileWorksCorrectly() throws MavenInvocationExcep String uuid = UUID.randomUUID().toString(); - FileUtils.write(configurationFile, - "greeting=" + uuid, - "UTF-8"); + Files.writeString(configurationFile.toPath(), + "greeting=" + uuid); await() .pollDelay(100, TimeUnit.MILLISECONDS) .pollInterval(1, TimeUnit.SECONDS) @@ -926,9 +924,8 @@ public void testThatExternalConfigOverridesConfigInJar() throws MavenInvocationE String uuid = UUID.randomUUID().toString(); - FileUtils.write(configurationFile, - "greeting=" + uuid, - "UTF-8"); + Files.writeString(configurationFile.toPath(), + "greeting=" + uuid); await() .pollDelay(100, TimeUnit.MILLISECONDS) .pollInterval(1, TimeUnit.SECONDS) @@ -950,26 +947,25 @@ public void testThatNewResourcesAreServed() throws MavenInvocationException, IOE // Create a new resource File source = new File(testDir, "src/main/resources/META-INF/resources/lorem.txt"); - FileUtils.write(source, - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - "UTF-8"); + Files.writeString(source.toPath(), + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); await() - .pollDelay(100, TimeUnit.MILLISECONDS) + .pollDelay(200, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) .until(() -> devModeClient.getHttpResponse("/lorem.txt"), containsString("Lorem ipsum")); // Update the resource String uuid = UUID.randomUUID().toString(); - FileUtils.write(source, uuid, "UTF-8"); + Files.writeString(source.toPath(), uuid); await() - .pollDelay(100, TimeUnit.MILLISECONDS) + .pollDelay(200, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) .until(() -> devModeClient.getHttpResponse("/lorem.txt"), equalTo(uuid)); // Delete the resource source.delete(); await() - .pollDelay(100, TimeUnit.MILLISECONDS) + .pollDelay(200, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) .until(() -> devModeClient.getHttpResponse("/lorem.txt", 404)); } @@ -985,7 +981,7 @@ public void testThatConfigFileDeletionsAreDetected() throws MavenInvocationExcep .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Bonjour")); File source = new File(testDir, "src/main/resources/application.properties"); - FileUtils.delete(source); + Files.delete(source.toPath()); await() .pollDelay(100, TimeUnit.MILLISECONDS) @@ -1014,7 +1010,7 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, // Update the application.properties File source = new File(testDir, "src/main/resources-primary/application.properties"); - FileUtils.write(source, "greeting=Salut", "UTF-8"); + Files.writeString(source.toPath(), "greeting=Salut"); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) @@ -1022,16 +1018,16 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, // Add the application.yaml source = new File(testDir, "src/main/resources-secondary/application.yaml"); - FileUtils.write(source, "other:\n" + - " greeting: Buenos dias", "UTF-8"); + Files.writeString(source.toPath(), "other:\n" + + " greeting: Buenos dias"); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Salut/Buenos dias")); // Update the application.yaml - FileUtils.write(source, "other:\n" + - " greeting: Hola", "UTF-8"); + Files.writeString(source.toPath(), "other:\n" + + " greeting: Hola"); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(TestUtils.getDefaultTimeout(), TimeUnit.MINUTES) @@ -1127,7 +1123,7 @@ public void testThatNewBeanAreDiscovered() throws IOException, MavenInvocationEx " }\n" + " \n" + "}"; - FileUtils.write(source, content, "UTF-8"); + Files.writeString(source.toPath(), content); // Update the resource to use the bean File resource = new File(testDir, "src/main/java/org/acme/HelloResource.java"); @@ -1399,7 +1395,7 @@ public void testThatWatchedAbsolutePathsAreNotDeleted() throws MavenInvocationEx // Update the .env File source = new File(testDir, ".env"); - FileUtils.write(source, "GREETING=Hallo", "UTF-8"); + Files.writeString(source.toPath(), "GREETING=Hallo"); assertTrue(source.exists());