diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java index 8f236cbdc7406..b3234607f6644 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java @@ -18,8 +18,10 @@ public class AeshConsole extends QuarkusConsole { private String promptMessage; private int totalStatusLines = 0; private int lastWriteCursorX; + private final boolean inputSupport; - public AeshConsole(Connection connection) { + public AeshConsole(Connection connection, boolean inputSupport) { + this.inputSupport = inputSupport; INSTANCE = this; this.connection = connection; connection.openNonBlocking(); @@ -62,6 +64,9 @@ public AeshInputHolder createHolder(InputHandler inputHandler) { } private synchronized AeshConsole setPromptMessage(String promptMessage) { + if (!inputSupport) { + return this; + } StringBuilder buffer = new StringBuilder(); clearStatusMessages(buffer); int newLines = countLines(statusMessage) + countLines(promptMessage); @@ -95,29 +100,31 @@ private synchronized void end(Connection conn) { private void setup(Connection conn) { size = conn.size(); - // Ctrl-C ends the game - conn.setSignalHandler(event -> { - switch (event) { - case INT: - //todo: why does async exit not work here - //Quarkus.asyncExit(); - //end(conn); - new Thread(new Runnable() { - @Override - public void run() { - System.exit(0); - } - }).start(); - break; - } - }); // Keyboard handling - conn.setStdinHandler(keys -> { - InputHolder handler = inputHandlers.peek(); - if (handler != null) { - handler.handler.handleInput(keys); - } - }); + if (inputSupport) { + conn.setSignalHandler(event -> { + switch (event) { + // Ctrl-C shutdown + case INT: + //todo: why does async exit not work here + //Quarkus.asyncExit(); + //end(conn); + new Thread(new Runnable() { + @Override + public void run() { + System.exit(0); + } + }).start(); + break; + } + }); + conn.setStdinHandler(keys -> { + InputHolder handler = inputHandlers.peek(); + if (handler != null) { + handler.handler.handleInput(keys); + } + }); + } conn.setCloseHandler(close -> end(conn)); conn.setSizeHandler(size -> setup(conn)); @@ -126,7 +133,11 @@ public void run() { //conn.write(ANSI.ALTERNATE_BUFFER); //conn.write(ANSI.CURSOR_HIDE); - attributes = conn.enterRawMode(); + if (inputSupport) { + attributes = conn.enterRawMode(); + } else { + attributes = conn.getAttributes(); + } StringBuilder sb = new StringBuilder(); printStatusAndPrompt(sb); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/ConsoleHelper.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/ConsoleHelper.java index 6f57065e1ef88..54f3d81770a7d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/ConsoleHelper.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/ConsoleHelper.java @@ -6,7 +6,7 @@ import org.aesh.readline.tty.terminal.TerminalConnection; import org.aesh.terminal.Connection; -import io.quarkus.deployment.TestConfig; +import io.quarkus.deployment.dev.testing.TestConfig; import io.quarkus.dev.console.BasicConsole; import io.quarkus.dev.console.QuarkusConsole; @@ -18,22 +18,23 @@ public static synchronized void installConsole(TestConfig config) { } QuarkusConsole.installed = true; if (config.basicConsole) { - QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, true, System.out); + QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, !config.disableConsoleInput, System.out); } else { try { new TerminalConnection(new Consumer() { @Override public void accept(Connection connection) { if (connection.supportsAnsi()) { - QuarkusConsole.INSTANCE = new AeshConsole(connection); + QuarkusConsole.INSTANCE = new AeshConsole(connection, !config.disableConsoleInput); } else { connection.close(); - QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, true, System.out); + QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, !config.disableConsoleInput, + System.out); } } }); } catch (IOException e) { - QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, true, System.out); + QuarkusConsole.INSTANCE = new BasicConsole(config.disableColor, !config.disableConsoleInput, System.out); } } RedirectPrintStream ps = new RedirectPrintStream(); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java index cea13c6d135f4..0a3b2a911ea27 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java @@ -107,6 +107,7 @@ public class JunitTestRunner { private final Pattern exclude; private final boolean displayInConsole; private final boolean failingTestsOnly; + private final TestType testType; private volatile boolean testsRunning = false; private volatile boolean aborted; @@ -127,6 +128,7 @@ public JunitTestRunner(Builder builder) { this.exclude = builder.exclude; this.displayInConsole = builder.displayInConsole; this.failingTestsOnly = builder.failingTestsOnly; + this.testType = builder.testType; } public void runTests() { @@ -201,6 +203,9 @@ public void quarkusStarting() { @Override public void executionStarted(TestIdentifier testIdentifier) { + if (aborted) { + return; + } String className = ""; Class clazz = null; if (testIdentifier.getSource().isPresent()) { @@ -476,15 +481,16 @@ private DiscoveryResult discoverTestClasses(DevModeContext devModeContext) { unitTestClasses.add(name); } - List> qtClasses = new ArrayList<>(); + List> itClasses = new ArrayList<>(); + List> utClasses = new ArrayList<>(); for (String i : quarkusTestClasses) { try { - qtClasses.add(Thread.currentThread().getContextClassLoader().loadClass(i)); + itClasses.add(Thread.currentThread().getContextClassLoader().loadClass(i)); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } - qtClasses.sort(Comparator.comparing(new Function, String>() { + itClasses.sort(Comparator.comparing(new Function, String>() { @Override public String apply(Class aClass) { ClassInfo def = index.getClassByName(DotName.createSimple(aClass.getName())); @@ -521,14 +527,26 @@ public String apply(Class aClass) { transformedClasses); for (String i : unitTestClasses) { try { - qtClasses.add(cl.loadClass(i)); + utClasses.add(cl.loadClass(i)); } catch (ClassNotFoundException exception) { throw new RuntimeException(exception); } } } - return new DiscoveryResult(cl, qtClasses); + if (testType == TestType.ALL) { + //run unit style tests first + //before the quarkus tests have started + //which stops quarkus interfering with WireMock + List> ret = new ArrayList<>(utClasses.size() + itClasses.size()); + ret.addAll(utClasses); + ret.addAll(itClasses); + return new DiscoveryResult(cl, ret); + } else if (testType == TestType.UNIT) { + return new DiscoveryResult(cl, utClasses); + } else { + return new DiscoveryResult(cl, itClasses); + } } private static Set collectTestAnnotations(Index index) { @@ -607,6 +625,7 @@ public boolean test(String logRecord) { } static class Builder { + private TestType testType = TestType.ALL; private TestState testState; private long runId = -1; private DevModeContext devModeContext; @@ -627,6 +646,11 @@ public Builder setRunId(long runId) { return this; } + public Builder setTestType(TestType testType) { + this.testType = testType; + return this; + } + public Builder setDevModeContext(DevModeContext devModeContext) { this.devModeContext = devModeContext; return this; diff --git a/core/deployment/src/main/java/io/quarkus/deployment/TestConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java similarity index 90% rename from core/deployment/src/main/java/io/quarkus/deployment/TestConfig.java rename to core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java index 97e581e8ea62d..81ae2dfaaf43a 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/TestConfig.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConfig.java @@ -1,4 +1,4 @@ -package io.quarkus.deployment; +package io.quarkus.deployment.dev.testing; import java.time.Duration; import java.util.List; @@ -94,6 +94,13 @@ public class TestConfig { @ConfigItem(defaultValue = "true") public boolean console; + /** + * Disables the ability to enter input on the console. + * + */ + @ConfigItem(defaultValue = "false") + public boolean disableConsoleInput; + /** * Changes tests to use the 'flat' ClassPath used in Quarkus 1.x versions. * @@ -134,6 +141,17 @@ public class TestConfig { @ConfigItem(defaultValue = "10m") Duration hangDetectionTimeout; + /** + * The type of test to run, this can be either: + * + * quarkus-test: Only runs {@code @QuarkusTest} annotated test classes + * unit: Only runs classes that are not annotated with {@code @QuarkusTest} + * all: Runs both, running the unit tests first + * + */ + @ConfigItem(defaultValue = "all") + TestType type; + @ConfigGroup public static class Profile { @@ -157,6 +175,5 @@ public enum Mode { PAUSED, ENABLED, DISABLED - } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java index 71f83ed551706..799f2d0d9e906 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java @@ -25,6 +25,7 @@ import io.quarkus.bootstrap.app.CuratedApplication; import io.quarkus.deployment.dev.ClassScanResult; import io.quarkus.deployment.dev.DevModeContext; +import io.quarkus.runtime.configuration.HyphenateEnumConverter; public class TestRunner { @@ -55,6 +56,7 @@ public class TestRunner { String appPropertiesExcludeTags; String appPropertiesIncludePattern; String appPropertiesExcludePattern; + String appPropertiesTestType; public TestRunner(TestSupport testSupport, DevModeContext devModeContext, CuratedApplication testApplication) { this.testSupport = testSupport; @@ -85,9 +87,6 @@ private void runTests(ClassScanResult classScanResult, boolean reRunFailures) { if (compileProblem != null) { return; } - if (testApplication == null) { - return; - } if (disabled) { return; } @@ -137,7 +136,7 @@ public void run() { current = queuedChanges; queuedChanges = null; } - testsRunning = run; + testsRunning = false; } if (run) { runTests(current); @@ -208,6 +207,7 @@ private void runInternal(ClassScanResult classScanResult, boolean reRunFailures) .setExcludeTags(testSupport.excludeTags) .setInclude(testSupport.include) .setExclude(testSupport.exclude) + .setTestType(testSupport.testType) .setFailingTestsOnly(testSupport.failingTestsOnly); if (reRunFailures) { Set ids = new HashSet<>(); @@ -278,6 +278,7 @@ private void handleApplicationPropertiesChange() { String excludeTags = p.getProperty("quarkus.test.exclude-tags"); String includePattern = p.getProperty("quarkus.test.include-pattern"); String excludePattern = p.getProperty("quarkus.test.exclude-pattern"); + String testType = p.getProperty("quarkus.test.type"); if (!firstRun) { if (!Objects.equals(includeTags, appPropertiesIncludeTags)) { if (includeTags == null) { @@ -309,11 +310,19 @@ private void handleApplicationPropertiesChange() { testSupport.exclude = Pattern.compile(excludePattern); } } + if (!Objects.equals(testType, appPropertiesTestType)) { + if (testType == null) { + testSupport.testType = TestType.ALL; + } else { + testSupport.testType = new HyphenateEnumConverter<>(TestType.class).convert(testType); + } + } } appPropertiesIncludeTags = includeTags; appPropertiesExcludeTags = excludeTags; appPropertiesIncludePattern = includePattern; appPropertiesExcludePattern = excludePattern; + appPropertiesTestType = testType; break; } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java index 1a789d49bccdf..548285e4ba998 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java @@ -39,6 +39,7 @@ public class TestSupport implements TestController { volatile boolean displayTestOutput; volatile Boolean explicitDisplayTestOutput; volatile boolean failingTestsOnly; + volatile TestType testType = TestType.ALL; public TestSupport(CuratedApplication curatedApplication, List compilationProviders, DevModeContext context) { @@ -143,7 +144,6 @@ public synchronized void stop() { } } if (testRunner != null) { - testRunner.disable(); } } @@ -217,6 +217,11 @@ public TestSupport setConfiguredDisplayTestOutput(boolean displayTestOutput) { return this; } + public TestSupport setTestType(TestType testType) { + this.testType = testType; + return this; + } + @Override public TestState currentState() { return testState; diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java index c169b21f40b4f..9755006be371f 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java @@ -14,7 +14,6 @@ import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.IsNormal; import io.quarkus.deployment.IsTest; -import io.quarkus.deployment.TestConfig; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.Produce; @@ -37,7 +36,6 @@ */ public class TestTracingProcessor { - private static TestConfig.Mode lastEnabledValue; private static boolean consoleInstalled = false; @BuildStep(onlyIfNot = IsNormal.class) @@ -83,14 +81,22 @@ ServiceStartBuildItem startTesting(TestConfig config, LiveReloadBuildItem liveRe testSupport.setPatterns(config.includePattern.orElse(null), config.excludePattern.orElse(null)); testSupport.setConfiguredDisplayTestOutput(config.displayTestOutput); + testSupport.setTestType(config.type); if (!liveReloadBuildItem.isLiveReload()) { if (config.continuousTesting == TestConfig.Mode.ENABLED) { testSupport.start(); } else if (config.continuousTesting == TestConfig.Mode.PAUSED) { - testSupport.init(); testSupport.stop(); } } + + QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread().getContextClassLoader(); + ((QuarkusClassLoader) cl.parent()).addCloseTask(new Runnable() { + @Override + public void run() { + testSupport.stop(); + } + }); return null; } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestType.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestType.java new file mode 100644 index 0000000000000..174e1e6b0a822 --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestType.java @@ -0,0 +1,7 @@ +package io.quarkus.deployment.dev.testing; + +public enum TestType { + UNIT, + QUARKUS_TEST, + ALL +} diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java b/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java index 9f6167e0b533d..b52386150fda7 100644 --- a/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java +++ b/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java @@ -12,10 +12,12 @@ public class BasicConsole extends QuarkusConsole { private static final Logger statusLogger = Logger.getLogger("quarkus"); final PrintStream printStream; + final boolean inputSupport; final boolean noColor; public BasicConsole(boolean noColor, boolean inputSupport, PrintStream printStream) { this.noColor = noColor; + this.inputSupport = inputSupport; this.printStream = printStream; if (inputSupport) { Thread t = new Thread(new Runnable() { @@ -49,6 +51,9 @@ public InputHolder createHolder(InputHandler inputHandler) { return new InputHolder(inputHandler) { @Override protected void setPromptMessage(String prompt) { + if (!inputSupport) { + return; + } if (prompt == null) { return; } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java new file mode 100644 index 0000000000000..62b495db3f426 --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java @@ -0,0 +1,43 @@ +package io.quarkus.vertx.http.testrunner; + +import java.util.function.Supplier; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusDevModeTest; +import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; + +public class QuarkusTestTypeTestCase { + + @RegisterExtension + static QuarkusDevModeTest test = new QuarkusDevModeTest() + .setArchiveProducer(new Supplier() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) + .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.type=quarkus-test")), + "application.properties"); + } + }) + .setTestArchiveProducer(new Supplier() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class).addClasses(SimpleET.class, UnitET.class); + } + }); + + @Test + public void testQuarkusTestMode() throws InterruptedException { + TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + Assertions.assertEquals(1L, ts.getLastRun()); + Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(1L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + } +} diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerTestUtils.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerTestUtils.java index 4a7a5774ba665..111d547bc82e1 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerTestUtils.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerTestUtils.java @@ -40,7 +40,7 @@ public Boolean call() throws Exception { } public static String appProperties(String... props) { - return "quarkus.test.continuous-testing=enabled\nquarkus.test.console=false\nquarkus.test.display-test-output=true\n" + return "quarkus.test.continuous-testing=enabled\nquarkus.test.display-test-output=true\nquarkus.test.basic-console=true\nquarkus.disable-console-input=true\n" + String.join("\n", Arrays.asList(props)); } } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java new file mode 100644 index 0000000000000..36f389e542079 --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java @@ -0,0 +1,44 @@ +package io.quarkus.vertx.http.testrunner; + +import java.util.function.Supplier; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusDevModeTest; +import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; + +public class UnitTestTypeTestCase { + + @RegisterExtension + static QuarkusDevModeTest test = new QuarkusDevModeTest() + .setArchiveProducer(new Supplier() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) + .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.type=unit")), + "application.properties"); + } + }) + .setTestArchiveProducer(new Supplier() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class).addClasses(SimpleET.class, UnitET.class); + } + }); + + @Test + public void testUnitMode() throws InterruptedException { + TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + Assertions.assertEquals(1L, ts.getLastRun()); + Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(0L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + + } +} diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusDevModeTest.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusDevModeTest.java index 8e682b77b544d..16768ef55c160 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusDevModeTest.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusDevModeTest.java @@ -9,8 +9,10 @@ import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Files; +import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.nio.file.attribute.FileTime; import java.util.ArrayList; import java.util.Arrays; @@ -75,6 +77,8 @@ public class QuarkusDevModeTest implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, TestInstanceFactory { private static final Logger rootLogger; + public static final OpenOption[] OPEN_OPTIONS = { StandardOpenOption.SYNC, StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE }; private Handler[] originalRootLoggerHandlers; static { @@ -292,7 +296,7 @@ private DevModeContext exportArchive(Path deploymentDir, Path testSourceDir, Pat byte[] data = FileUtil.readFileContents(in); Path resolved = deploymentResourcePath.resolve(relative); Files.createDirectories(resolved.getParent()); - Files.write(resolved, data); + Files.write(resolved, data, OPEN_OPTIONS); } } catch (IOException e) { throw new UncheckedIOException(e); @@ -351,7 +355,7 @@ private DevModeContext exportArchive(Path deploymentDir, Path testSourceDir, Pat byte[] data = FileUtil.readFileContents(in); Path resolved = deploymentTestResourcePath.resolve(relative); Files.createDirectories(resolved.getParent()); - Files.write(resolved, data); + Files.write(resolved, data, OPEN_OPTIONS); } } catch (IOException e) { throw new UncheckedIOException(e); @@ -590,7 +594,7 @@ private void modifyPath(Function mutator, Path sourceDirectory, throw new RuntimeException("File was not modified, mutator function had no effect"); } - Files.write(input, content.getBytes(StandardCharsets.UTF_8)); + Files.write(input, content.getBytes(StandardCharsets.UTF_8), OPEN_OPTIONS); sleepForFileChanges(sourceDirectory, oldSrc); sleepForFileChanges(input, old); } catch (IOException e) { @@ -648,7 +652,7 @@ public void modifyResourceFile(String path, Function mutator) { String content = new String(data, StandardCharsets.UTF_8); content = mutator.apply(content); - Files.write(resourcePath, content.getBytes(StandardCharsets.UTF_8)); + Files.write(resourcePath, content.getBytes(StandardCharsets.UTF_8), OPEN_OPTIONS); sleepForFileChanges(resourcePath, old); } catch (IOException e) { throw new UncheckedIOException(e); @@ -663,7 +667,7 @@ public void addResourceFile(String path, byte[] data) { final Path resourceFilePath = deploymentResourcePath.resolve(path); long oldParent = modTime(resourceFilePath.getParent()); try { - Files.write(resourceFilePath, data); + Files.write(resourceFilePath, data, OPEN_OPTIONS); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -736,7 +740,7 @@ private Path copySourceFilesForClass(Path projectSourcesDir, Path deploymentSour byte[] data = FileUtil.readFileContents(in); Path resolved = deploymentSourcesDir.resolve(relative); Files.createDirectories(resolved.getParent()); - Files.write(resolved, data); + Files.write(resolved, data, OPEN_OPTIONS); return resolved; } catch (IOException e) { throw new UncheckedIOException(e);