diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 0e7aa4527a875..f503180c5b658 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1464,6 +1464,13 @@ quarkus-vertx-http-deployment ${project.version} + + io.quarkus + quarkus-vertx-http-deployment + ${project.version} + test-jar + test + io.quarkus quarkus-vertx-web diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java index 203333a07f9b3..9e5fa01ad8238 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java @@ -6,20 +6,27 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem; +import io.quarkus.deployment.builditem.LaunchModeBuildItem; import io.quarkus.deployment.builditem.ServiceStartBuildItem; +import io.quarkus.dev.testing.TestWatchedFiles; public class HotDeploymentConfigFileBuildStep { @BuildStep - ServiceStartBuildItem setupConfigFileHotDeployment(List files) { + ServiceStartBuildItem setupConfigFileHotDeployment(List files, + LaunchModeBuildItem launchModeBuildItem) { // TODO: this should really be an output of the RuntimeRunner RuntimeUpdatesProcessor processor = RuntimeUpdatesProcessor.INSTANCE; - if (processor != null) { + if (processor != null || launchModeBuildItem.isAuxiliaryApplication()) { Map watchedFilePaths = files.stream() .collect(Collectors.toMap(HotDeploymentWatchedFileBuildItem::getLocation, HotDeploymentWatchedFileBuildItem::isRestartNeeded, (isRestartNeeded1, isRestartNeeded2) -> isRestartNeeded1 || isRestartNeeded2)); - processor.setWatchedFilePaths(watchedFilePaths); + if (launchModeBuildItem.isAuxiliaryApplication()) { + TestWatchedFiles.setWatchedFilePaths(watchedFilePaths); + } else { + processor.setWatchedFilePaths(watchedFilePaths, false); + } } return null; } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java index 214b957d38dbf..953fcb669f058 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java @@ -20,6 +20,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -81,9 +82,6 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable private final DevModeType devModeType; volatile Throwable compileProblem; - // file path -> isRestartNeeded - private volatile Map watchedFilePaths = Collections.emptyMap(); - private volatile Predicate disableInstrumentationForClassPredicate = new AlwaysFalsePredicate<>(); private volatile Predicate disableInstrumentationForIndexPredicate = new AlwaysFalsePredicate<>(); @@ -95,12 +93,6 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable private final TimestampSet test = new TimestampSet(); final Map sourceFileTimestamps = new ConcurrentHashMap<>(); - /** - * Resources that appear in both src and target, these will be removed if the src resource subsequently disappears. - * This map contains the paths in the target dir, one for each module, otherwise on a second module we will delete files - * from the first one - */ - private final Map> correspondingResources = new ConcurrentHashMap<>(); private final List preScanSteps = new CopyOnWriteArrayList<>(); private final List>> noRestartChangesConsumers = new CopyOnWriteArrayList<>(); private final List hotReplacementSetup = new ArrayList<>(); @@ -115,6 +107,13 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable */ private static volatile IndexView lastStartIndex; + /** + * Resources that appear in both src and target, these will be removed if the src resource subsequently disappears. + * This map contains the paths in the target dir, one for each module, otherwise on a second module we will delete files + * from the first one + */ + private final Map> correspondingResources = new ConcurrentHashMap<>(); + private final TestSupport testSupport; private volatile boolean firstTestScanComplete; private volatile Boolean instrumentationEnabled; @@ -248,9 +247,11 @@ private void periodicTestCompile() { try { ClassScanResult changedTestClassResult = compileTestClasses(); ClassScanResult changedApp = checkForChangedClasses(compiler, DevModeContext.ModuleInfo::getMain, false, test); - Set filesChanged = checkForFileChange(DevModeContext.ModuleInfo::getMain, test); - boolean configFileRestartNeeded = filesChanged.stream().map(watchedFilePaths::get) + Set filesChanges = new HashSet<>(checkForFileChange(s -> s.getTest().get(), test)); + filesChanges.addAll(checkForFileChange(DevModeContext.ModuleInfo::getMain, test)); + boolean configFileRestartNeeded = filesChanges.stream().map(test.watchedFilePaths::get) .anyMatch(Boolean.TRUE::equals); + ClassScanResult merged = ClassScanResult.merge(changedTestClassResult, changedApp); if (configFileRestartNeeded) { if (compileProblem != null) { @@ -369,7 +370,8 @@ public boolean doScan(boolean userInitiated, boolean force) throws IOException { main); Set filesChanged = checkForFileChange(DevModeContext.ModuleInfo::getMain, main); - boolean configFileRestartNeeded = filesChanged.stream().map(watchedFilePaths::get).anyMatch(Boolean.TRUE::equals); + boolean configFileRestartNeeded = filesChanged.stream().map(main.watchedFilePaths::get) + .anyMatch(Boolean.TRUE::equals); boolean instrumentationChange = false; if (ClassChangeAgent.getInstrumentation() != null && lastStartIndex != null && !configFileRestartNeeded && devModeType != DevModeType.REMOTE_LOCAL_SIDE) { @@ -561,7 +563,7 @@ ClassScanResult checkForChangedClasses(QuarkusCompiler compiler, changedSourceFiles = sourcesStream .parallel() .filter(p -> matchingHandledExtension(p).isPresent() - && sourceFileWasRecentModified(p, ignoreFirstScanChanges, timestampSet)) + && sourceFileWasRecentModified(p, ignoreFirstScanChanges)) .map(Path::toFile) //Needing a concurrent Set, not many standard options: .collect(Collectors.toCollection(ConcurrentSkipListSet::new)); @@ -695,7 +697,7 @@ Set checkForFileChange(Function ret = new HashSet<>(); for (DevModeContext.ModuleInfo module : context.getAllModules()) { - final Set moduleResources = correspondingResources.computeIfAbsent(module.getName(), + final Set moduleResources = correspondingResources.computeIfAbsent(cuf.apply(module), m -> Collections.newSetFromMap(new ConcurrentHashMap<>())); boolean doCopy = true; String rootPath = cuf.apply(module).getResourcePath(); @@ -759,13 +761,15 @@ Set checkForFileChange(Function existing) { + //existing can be null when running tests + //as there is both normal and test resources, but only one set of watched timestampts + if (existing != null && value > existing) { ret.add(path); log.infof("File change detected: %s", file); if (doCopy && !Files.isDirectory(file)) { @@ -795,8 +799,7 @@ Set checkForFileChange(Function watchedFilePaths) { - boolean includeTest = test.watchedFileTimestamps.isEmpty(); - this.watchedFilePaths = watchedFilePaths; - main.watchedFileTimestamps.clear(); + public RuntimeUpdatesProcessor setWatchedFilePaths(Map watchedFilePaths, boolean isTest) { + if (isTest) { + setWatchedFilePathsInternal(watchedFilePaths, test, s -> Arrays.asList(s.getTest().get(), s.getMain())); + } else { + main.watchedFileTimestamps.clear(); + setWatchedFilePathsInternal(watchedFilePaths, main, s -> Collections.singletonList(s.getMain())); + } + return this; + } + + private RuntimeUpdatesProcessor setWatchedFilePathsInternal(Map watchedFilePaths, + TimestampSet timestamps, Function> cuf) { + timestamps.watchedFilePaths = watchedFilePaths; Map extraWatchedFilePaths = new HashMap<>(); for (DevModeContext.ModuleInfo module : context.getAllModules()) { - String rootPath = module.getMain().getResourcePath(); + List compilationUnits = cuf.apply(module); + for (DevModeContext.CompilationUnit unit : compilationUnits) { + String rootPath = unit.getResourcePath(); - if (rootPath == null) { - rootPath = module.getMain().getClassesPath(); - } - if (rootPath == null) { - continue; - } - Path root = Paths.get(rootPath); - for (String path : watchedFilePaths.keySet()) { - Path config = root.resolve(path); - if (config.toFile().exists()) { - try { - FileTime lastModifiedTime = Files.getLastModifiedTime(config); - main.watchedFileTimestamps.put(config, lastModifiedTime.toMillis()); - if (includeTest) { - test.watchedFileTimestamps.put(config, lastModifiedTime.toMillis()); + if (rootPath == null) { + rootPath = unit.getClassesPath(); + } + if (rootPath == null) { + continue; + } + Path root = Paths.get(rootPath); + for (String path : watchedFilePaths.keySet()) { + Path config = root.resolve(path); + if (config.toFile().exists()) { + try { + FileTime lastModifiedTime = Files.getLastModifiedTime(config); + timestamps.watchedFileTimestamps.put(config, lastModifiedTime.toMillis()); + } catch (IOException e) { + throw new UncheckedIOException(e); } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } else { - main.watchedFileTimestamps.put(config, 0L); - Map extraWatchedFileTimestamps = expandGlobPattern(root, config); - main.watchedFileTimestamps.putAll(extraWatchedFileTimestamps); - for (Path extraPath : extraWatchedFileTimestamps.keySet()) { - extraWatchedFilePaths.put(root.relativize(extraPath).toString(), this.watchedFilePaths.get(path)); - } - if (includeTest) { - test.watchedFileTimestamps.put(config, 0L); + } else { + timestamps.watchedFileTimestamps.put(config, 0L); + Map extraWatchedFileTimestamps = expandGlobPattern(root, config); + timestamps.watchedFileTimestamps.putAll(extraWatchedFileTimestamps); + for (Path extraPath : extraWatchedFileTimestamps.keySet()) { + extraWatchedFilePaths.put(root.relativize(extraPath).toString(), + timestamps.watchedFilePaths.get(path)); + } + timestamps.watchedFileTimestamps.putAll(extraWatchedFileTimestamps); } - main.watchedFileTimestamps.putAll(extraWatchedFileTimestamps); } } } - this.watchedFilePaths.putAll(extraWatchedFilePaths); + timestamps.watchedFilePaths.putAll(extraWatchedFilePaths); return this; } @@ -974,11 +984,17 @@ static class TimestampSet { final Map watchedFileTimestamps = new ConcurrentHashMap<>(); final Map classFileChangeTimeStamps = new ConcurrentHashMap<>(); final Map classFilePathToSourceFilePath = new ConcurrentHashMap<>(); + // file path -> isRestartNeeded + private volatile Map watchedFilePaths = Collections.emptyMap(); public void merge(TimestampSet other) { watchedFileTimestamps.putAll(other.watchedFileTimestamps); classFileChangeTimeStamps.putAll(other.classFileChangeTimeStamps); classFilePathToSourceFilePath.putAll(other.classFilePathToSourceFilePath); + Map newVal = new HashMap<>(watchedFilePaths); + newVal.putAll(other.watchedFilePaths); + watchedFilePaths = newVal; + } } 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 799f2d0d9e906..e9a29b16821fb 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,8 @@ import io.quarkus.bootstrap.app.CuratedApplication; import io.quarkus.deployment.dev.ClassScanResult; import io.quarkus.deployment.dev.DevModeContext; +import io.quarkus.deployment.dev.RuntimeUpdatesProcessor; +import io.quarkus.dev.testing.TestWatchedFiles; import io.quarkus.runtime.configuration.HyphenateEnumConverter; public class TestRunner { @@ -243,6 +245,10 @@ public void runComplete(TestRunResults results) { synchronized (this) { runner = null; } + Map watched = TestWatchedFiles.retrieveWatchedFilePaths(); + if (watched != null) { + RuntimeUpdatesProcessor.INSTANCE.setWatchedFilePaths(watched, true); + } if (disabled) { return; } diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/testing/TestWatchedFiles.java b/core/devmode-spi/src/main/java/io/quarkus/dev/testing/TestWatchedFiles.java new file mode 100644 index 0000000000000..8f67ac3b14c0d --- /dev/null +++ b/core/devmode-spi/src/main/java/io/quarkus/dev/testing/TestWatchedFiles.java @@ -0,0 +1,23 @@ +package io.quarkus.dev.testing; + +import java.util.Map; + +/** + * provides a way for a test run to tell the external application about watched paths. + * + * This could be a test specific application.properties or import.sql for example + */ +public class TestWatchedFiles { + + private static volatile Map watchedFilePaths; + + public static Map retrieveWatchedFilePaths() { + Map watchedFilePaths = TestWatchedFiles.watchedFilePaths; + TestWatchedFiles.watchedFilePaths = null; + return watchedFilePaths; + } + + public static void setWatchedFilePaths(Map watchedFilePaths) { + TestWatchedFiles.watchedFilePaths = watchedFilePaths; + } +} diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index 5bebabca2fe6d..12eec63882f5a 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -653,6 +653,7 @@ private void addProject(MavenDevModeLauncher.Builder builder, LocalProject local .setTestSourcePaths(testSourcePaths) .setTestClassesPath(testClassesPath) .setTestResourcePath(testResourcePath) + .setTestResourcesOutputPath(testClassesPath) .build(); if (root) { diff --git a/extensions/hibernate-orm/deployment/pom.xml b/extensions/hibernate-orm/deployment/pom.xml index 8e60cdce048ba..75cea02da2efe 100644 --- a/extensions/hibernate-orm/deployment/pom.xml +++ b/extensions/hibernate-orm/deployment/pom.xml @@ -67,6 +67,11 @@ quarkus-jdbc-h2-deployment test + + io.quarkus + quarkus-junit5 + test + io.rest-assured rest-assured @@ -82,6 +87,17 @@ quarkus-smallrye-metrics-deployment test + + io.quarkus + quarkus-vertx-http-deployment + test + test-jar + + + org.awaitility + awaitility + test + diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java index 36d68d2cc2b1c..07143d2dd5c24 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java @@ -867,11 +867,9 @@ private static void producePersistenceUnitDescriptorFromConfig( "Unable to find file referenced in '" + HIBERNATE_ORM_CONFIG_PREFIX + "sql-load-script=" + persistenceUnitConfig.sqlLoadScript.get() + "'. Remove property or add file to your path."); } - if (launchMode == LaunchMode.DEVELOPMENT) { - // in dev mode we want to make sure that we watch for changes to file even if it doesn't currently exist - // as a user could still add it after performing the initial configuration - hotDeploymentWatchedFiles.produce(new HotDeploymentWatchedFileBuildItem(importFile.get())); - } + // in dev mode we want to make sure that we watch for changes to file even if it doesn't currently exist + // as a user could still add it after performing the initial configuration + hotDeploymentWatchedFiles.produce(new HotDeploymentWatchedFileBuildItem(importFile.get())); } else { //Disable implicit loading of the default import script (import.sql) descriptor.getProperties().setProperty(AvailableSettings.HBM2DDL_IMPORT_FILES, ""); diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateET.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateET.java new file mode 100644 index 0000000000000..a8d612e2e79e1 --- /dev/null +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateET.java @@ -0,0 +1,21 @@ +package io.quarkus.hibernate.orm; + +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +/** + * Test for continuous testing with hibernate + */ +@QuarkusTest +public class HibernateET { + + @Test + public void testImport() { + RestAssured.when().get("/my-entity/1").then().body(is("MyEntity:TEST ENTITY")); + } + +} diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java index dfeb4982c4487..cb5b033cdafe8 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java @@ -5,11 +5,15 @@ import java.util.function.Function; 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; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; public class HibernateHotReloadTestCase { @@ -17,8 +21,18 @@ public class HibernateHotReloadTestCase { final static QuarkusDevModeTest TEST = new QuarkusDevModeTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) .addClasses(MyEntity.class, MyEntityTestResource.class) - .addAsResource("application.properties") - .addAsResource("import.sql")); + .add(new StringAsset( + //TODO: we can't use devservices here because of issues with the class loading + //sometimes the external application.properties is picked up and sometimes it isn't + ContinuousTestingTestUtils.appProperties( + "quarkus.hibernate-orm.database.generation=drop-and-create", + "quarkus.datasource.jdbc.url=jdbc:h2:mem:test", + "%test.quarkus.datasource.jdbc.url=jdbc:h2:mem:testrunner")), + "application.properties") + .addAsResource("import.sql")) + .setTestArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) + .addClass(HibernateET.class) + .addAsResource(new StringAsset("INSERT INTO MyEntity(id, name) VALUES(1, 'TEST ENTITY');"), "import.sql")); @Test public void testAddNewFieldToEntity() { @@ -65,6 +79,43 @@ public String apply(String s) { RestAssured.when().get("/other-entity/2").then().body(is("OtherEntity:import.sql load script entity")); } + @Test + public void testImportSqlWithContinuousTesting() { + + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); + Assertions.assertEquals(1L, ts.getLastRun()); + Assertions.assertEquals(0L, ts.getTestsFailed()); + Assertions.assertEquals(1L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + + TEST.modifyTestResourceFile("import.sql", new Function() { + @Override + public String apply(String s) { + return s.replace("TEST ENTITY", "new entity"); + } + }); + ts = ContinuousTestingTestUtils.waitForRun(2); + Assertions.assertEquals(2L, ts.getLastRun()); + Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(0L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + + TEST.modifyTestSourceFile(HibernateET.class, new Function() { + @Override + public String apply(String s) { + return s.replace("TEST ENTITY", "new entity"); + } + }); + ts = ContinuousTestingTestUtils.waitForRun(3); + Assertions.assertEquals(3L, ts.getLastRun()); + Assertions.assertEquals(0L, ts.getTestsFailed()); + Assertions.assertEquals(1L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + } + private void assertBodyIs(String expectedBody) { RestAssured.when().get("/my-entity/2").then().body(is(expectedBody)); } diff --git a/extensions/vertx-http/deployment/pom.xml b/extensions/vertx-http/deployment/pom.xml index 801fabbd1de0f..4a999a77eb4ad 100644 --- a/extensions/vertx-http/deployment/pom.xml +++ b/extensions/vertx-http/deployment/pom.xml @@ -103,6 +103,17 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + maven-compiler-plugin 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/ContinuousTestingTestUtils.java similarity index 97% rename from extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerTestUtils.java rename to extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/ContinuousTestingTestUtils.java index 2770080114718..66972d2aa7e7e 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/ContinuousTestingTestUtils.java @@ -13,7 +13,7 @@ /** * Utilities for testing the test runner itself */ -public class TestRunnerTestUtils { +public class ContinuousTestingTestUtils { public static TestStatus waitForFirstRunToComplete() { return waitForRun(1); 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 index 62b495db3f426..e4b84dfecf957 100644 --- 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 @@ -20,7 +20,7 @@ public class QuarkusTestTypeTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.type=quarkus-test")), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.type=quarkus-test")), "application.properties"); } }) @@ -33,7 +33,7 @@ public JavaArchive get() { @Test public void testQuarkusTestMode() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java index 21714ab6c7424..2cf7be5815213 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java @@ -21,7 +21,7 @@ public class TestChangeTrackingWhenStartFailsTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClasses(HelloResource.class, StartupFailer.class).add( - new StringAsset(TestRunnerTestUtils.appProperties()), + new StringAsset(ContinuousTestingTestUtils.appProperties()), "application.properties"); } }) @@ -34,7 +34,7 @@ public JavaArchive get() { @Test public void testChangeTrackingOnStartupFailure() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(2L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); @@ -48,7 +48,7 @@ public String apply(String s) { return s.replace("//fail();", "fail();"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); @@ -61,7 +61,7 @@ public String apply(String s) { return s.replace("fail();", "fail();fail();"); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); @@ -74,7 +74,7 @@ public String apply(String s) { return s.replace("fail();fail();", "//fail();"); } }); - ts = TestRunnerTestUtils.waitForRun(4); + ts = ContinuousTestingTestUtils.waitForRun(4); Assertions.assertEquals(4L, ts.getLastRun()); Assertions.assertEquals(2L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java index 8bd46b08f533c..627fe449b514d 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java @@ -24,7 +24,7 @@ public class TestRunnerSmokeTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties()), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties()), "application.properties"); } }) @@ -37,7 +37,7 @@ public JavaArchive get() { @Test public void checkTestsAreRun() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(2L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -66,7 +66,7 @@ public String apply(String s) { return s.replace("//setup(router);", "setup(router);"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); @@ -81,7 +81,7 @@ public String apply(String s) { return s.replace("Hi", "hello"); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); 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 index 36f389e542079..b607a6c6067a9 100644 --- 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 @@ -20,7 +20,7 @@ public class UnitTestTypeTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.type=unit")), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.type=unit")), "application.properties"); } }) @@ -33,7 +33,7 @@ public JavaArchive get() { @Test public void testUnitMode() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java index 91f26a8b37a43..d5814be494580 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java @@ -12,7 +12,7 @@ import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.TestRunnerTestUtils; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; public class TestBrokenOnlyTestCase { @@ -23,7 +23,7 @@ public class TestBrokenOnlyTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(BrokenOnlyResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties()), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties()), "application.properties"); } }) @@ -36,7 +36,7 @@ public JavaArchive get() { @Test public void testBrokenOnlyMode() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -52,7 +52,7 @@ public String apply(String s) { return s.replace("@QuarkusTest", "@QuarkusTest //noop change"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); //passing test should not have been run @@ -65,7 +65,7 @@ public String apply(String s) { return s.replace("//setup(router);", "setup(router);"); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -79,7 +79,7 @@ public String apply(String s) { return s.replace("//failannotation", "@Test"); } }); - ts = TestRunnerTestUtils.waitForRun(4); + ts = ContinuousTestingTestUtils.waitForRun(4); Assertions.assertEquals(4L, ts.getLastRun()); Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); @@ -93,7 +93,7 @@ public String apply(String s) { return s.replace("Assertions.fail();", "//noop"); } }); - ts = TestRunnerTestUtils.waitForRun(5); + ts = ContinuousTestingTestUtils.waitForRun(5); Assertions.assertEquals(5L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java index 599f4717635ed..bb734ba7bf7ab 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java @@ -12,8 +12,8 @@ import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; -import io.quarkus.vertx.http.testrunner.TestRunnerTestUtils; public class ExcludePatternTestCase { @@ -24,7 +24,7 @@ public class ExcludePatternTestCase { public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) .add(new StringAsset( - TestRunnerTestUtils.appProperties("quarkus.test.exclude-pattern=.*BarET")), + ContinuousTestingTestUtils.appProperties("quarkus.test.exclude-pattern=.*BarET")), "application.properties"); } }) @@ -37,7 +37,7 @@ public JavaArchive get() { @Test public void checkTestsAreRun() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -47,10 +47,10 @@ public void checkTestsAreRun() throws InterruptedException { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties("quarkus.test.exclude-pattern=missing"); + return ContinuousTestingTestUtils.appProperties("quarkus.test.exclude-pattern=missing"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); @@ -60,10 +60,10 @@ public String apply(String s) { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties(); + return ContinuousTestingTestUtils.appProperties(); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java index 6074522262b6f..36c3093f320b8 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java @@ -12,8 +12,8 @@ import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; -import io.quarkus.vertx.http.testrunner.TestRunnerTestUtils; public class IncludePatternTestCase { @@ -24,7 +24,7 @@ public class IncludePatternTestCase { public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) .add(new StringAsset( - TestRunnerTestUtils.appProperties("quarkus.test.include-pattern=.*BarET")), + ContinuousTestingTestUtils.appProperties("quarkus.test.include-pattern=.*BarET")), "application.properties"); } }) @@ -37,7 +37,7 @@ public JavaArchive get() { @Test public void checkTestsAreRun() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -47,10 +47,10 @@ public void checkTestsAreRun() throws InterruptedException { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties("quarkus.test.include-pattern=io\\.quarkus.*"); + return ContinuousTestingTestUtils.appProperties("quarkus.test.include-pattern=io\\.quarkus.*"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); @@ -60,10 +60,10 @@ public String apply(String s) { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties(); + return ContinuousTestingTestUtils.appProperties(); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java index 1407d0c91fc1f..b99135a7c1e33 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java @@ -12,8 +12,8 @@ import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; -import io.quarkus.vertx.http.testrunner.TestRunnerTestUtils; public class ExcludeTagsTestCase { @@ -23,7 +23,7 @@ public class ExcludeTagsTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.exclude-tags=a")), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.exclude-tags=a")), "application.properties"); } }) @@ -36,7 +36,7 @@ public JavaArchive get() { @Test public void checkTestsAreRun() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(3L, ts.getTestsPassed()); @@ -46,13 +46,13 @@ public void checkTestsAreRun() throws InterruptedException { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties("quarkus.test.exclude-tags=c"); + return ContinuousTestingTestUtils.appProperties("quarkus.test.exclude-tags=c"); } }); //we sleep here to make sure it is not the dev mode restart that is //causing the config to be updated Thread.sleep(1000); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(4L, ts.getTestsPassed()); @@ -62,10 +62,10 @@ public String apply(String s) { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties(); + return ContinuousTestingTestUtils.appProperties(); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(5L, ts.getTestsPassed()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java index f9b78753dc102..a192f696e1b29 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java @@ -12,8 +12,8 @@ import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; +import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; -import io.quarkus.vertx.http.testrunner.TestRunnerTestUtils; public class IncludeTagsTestCase { @@ -23,7 +23,7 @@ public class IncludeTagsTestCase { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) - .add(new StringAsset(TestRunnerTestUtils.appProperties("quarkus.test.include-tags=a")), + .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.include-tags=a")), "application.properties"); } }) @@ -36,7 +36,7 @@ public JavaArchive get() { @Test public void checkTestsAreRun() throws InterruptedException { - TestStatus ts = TestRunnerTestUtils.waitForFirstRunToComplete(); + TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); @@ -46,10 +46,10 @@ public void checkTestsAreRun() throws InterruptedException { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties("quarkus.test.include-tags=c"); + return ContinuousTestingTestUtils.appProperties("quarkus.test.include-tags=c"); } }); - ts = TestRunnerTestUtils.waitForRun(2); + ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); @@ -59,10 +59,10 @@ public String apply(String s) { test.modifyResourceFile("application.properties", new Function() { @Override public String apply(String s) { - return TestRunnerTestUtils.appProperties(); + return ContinuousTestingTestUtils.appProperties(); } }); - ts = TestRunnerTestUtils.waitForRun(3); + ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(5L, ts.getTestsPassed()); 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 343349e0daf06..cf1237660f5e3 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 @@ -386,7 +386,8 @@ private DevModeContext exportArchive(Path deploymentDir, Path testSourceDir, Pat moduleBuilder .setTestSourcePaths(Collections.singleton(deploymentTestSourcePath.toAbsolutePath().toString())) .setTestClassesPath(testClasses.toAbsolutePath().toString()) - .setTestResourcePath(deploymentTestResourcePath.toAbsolutePath().toString()); + .setTestResourcePath(deploymentTestResourcePath.toAbsolutePath().toString()) + .setTestResourcesOutputPath(testClasses.toAbsolutePath().toString()); } context.setApplicationRoot( @@ -670,8 +671,12 @@ private long modTime(Path path) { * the deployment resources directory */ public void modifyResourceFile(String path, Function mutator) { + Path resourcePath = deploymentResourcePath.resolve(path); + internalModifyResource(mutator, resourcePath); + } + + private void internalModifyResource(Function mutator, Path resourcePath) { try { - Path resourcePath = deploymentResourcePath.resolve(path); long old = modTime(resourcePath); byte[] data; try (InputStream in = Files.newInputStream(resourcePath)) { @@ -688,6 +693,15 @@ public void modifyResourceFile(String path, Function mutator) { } } + /** + * Adds or overwrites a resource file with the given data. The path is an absolute path into to + * the deployment resources directory + */ + public void modifyTestResourceFile(String path, Function mutator) { + Path resourcePath = deploymentTestResourcePath.resolve(path); + internalModifyResource(mutator, resourcePath); + } + /** * Adds or overwrites a resource file with the given data. The path is an absolute path into to * the deployment resources directory