This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-acr-plugin.git
commit d4c75a44f09c776c193f4ddb4632648e7eae7547 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 22:30:52 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/it-01/verify.groovy | 53 +++++++++++++----------------------- src/it/it-02/verify.groovy | 67 +++++++++++++++++----------------------------- src/it/it-03/verify.groovy | 11 ++------ src/it/it-04/verify.groovy | 52 ++++++++++------------------------- src/it/it-05/verify.groovy | 4 +-- src/it/it-06/verify.groovy | 4 +-- 6 files changed, 60 insertions(+), 131 deletions(-) diff --git a/src/it/it-01/verify.groovy b/src/it/it-01/verify.groovy index 2adf593..3f5119d 100644 --- a/src/it/it-01/verify.groovy +++ b/src/it/it-01/verify.groovy @@ -19,42 +19,25 @@ import java.util.jar.JarFile -try { - var jarFile = new File(basedir, "target/maven-acr-plugin-it01-1.0.jar") - println "Checking for existence of $jarFile" - if (!jarFile.isFile()) { - println "FAILURE!" - return false; - } +var jarFile = new File(basedir, "target/maven-acr-plugin-it01-1.0.jar") +println "Checking for existence of $jarFile" +assert jarFile.isFile() : "FAILURE!" - var jar = new JarFile(jarFile) +var jar = new JarFile(jarFile) - var includedEntries = [ - "META-INF/application-client.xml", - "org/apache/maven/plugin/acr/it/it01/SampleApp.class" - ] - for (String included : includedEntries) { - println "Checking for existence of $included" - if (jar.getEntry(included) == null) { - println "FAILURE!" - return false - } - } - - jar.close() - - // Make sure that the jar has been added with a .jar extension - var localRepo = new File(basedir.getParentFile().getParentFile(), "local-repo") - var repoFile = new File(localRepo, - "/org/apache/maven/plugin/maven-acr-plugin-it01/1.0/maven-acr-plugin-it01-1.0.jar"); - if (!repoFile.exists()) { - println "Jar file for application client not found in repo [" + repoFile.getAbsolutePath() + "]" - return false - } -} -catch (Throwable t) { - t.printStackTrace() - return false +var includedEntries = [ + "META-INF/application-client.xml", + "org/apache/maven/plugin/acr/it/it01/SampleApp.class" +] +for (String included : includedEntries) { + println "Checking for existence of $included" + assert jar.getEntry(included) != null : "FAILURE!" } -return true +jar.close() + +// Make sure that the jar has been added with a .jar extension +var localRepo = new File(basedir.getParentFile().getParentFile(), "local-repo") +var repoFile = new File(localRepo, + "/org/apache/maven/plugin/maven-acr-plugin-it01/1.0/maven-acr-plugin-it01-1.0.jar"); +assert repoFile.exists() : "Jar file for application client not found in repo [" + repoFile.getAbsolutePath() + "]" diff --git a/src/it/it-02/verify.groovy b/src/it/it-02/verify.groovy index 462749d..c40b502 100644 --- a/src/it/it-02/verify.groovy +++ b/src/it/it-02/verify.groovy @@ -19,52 +19,33 @@ import java.util.jar.JarFile -try { - var jarFile = new File(basedir, "app-client/target/maven-acr-plugin-it02-app-client-1.0.jar") - println "Checking for existence of $jarFile" - if (!jarFile.isFile()) { - println "FAILURE!" - return false - } - - var jar = new JarFile(jarFile) - - var includedEntries = [ - "META-INF/application-client.xml", - "org/apache/maven/plugin/acr/it/it02/SampleApp.class" - ] - for (String included : includedEntries) { - println "Checking for existence of $included" - if (jar.getEntry(included) == null) { - println "FAILURE!" - return false - } - } - - jar.close() - - var bundleJarFile = new File(basedir, "bundle/target/maven-acr-plugin-it02-bundle-1.0.jar") - var bundle = new JarFile(bundleJarFile); - +var jarFile = new File(basedir, "app-client/target/maven-acr-plugin-it02-app-client-1.0.jar") +println "Checking for existence of $jarFile" +assert jarFile.isFile() : "FAILURE!" + +var jar = new JarFile(jarFile) + +var includedEntries = [ + "META-INF/application-client.xml", + "org/apache/maven/plugin/acr/it/it02/SampleApp.class" +] +for (String included : includedEntries) { + println "Checking for existence of $included" + assert jar.getEntry(included) != null : "FAILURE!" +} - var includedBundleEntries = [ - "org/apache/maven/plugin/acr/it/it02/DependencyTest.class" - ] - for (String included : includedBundleEntries) { - println "Checking for existence of $included" - if (bundle.getEntry(included) == null) { - println "FAILURE!" - return false - } - } +jar.close() - bundle.close() +var bundleJarFile = new File(basedir, "bundle/target/maven-acr-plugin-it02-bundle-1.0.jar") +var bundle = new JarFile(bundleJarFile); -} -catch (Throwable t) { - t.printStackTrace() - return false +var includedBundleEntries = [ + "org/apache/maven/plugin/acr/it/it02/DependencyTest.class" +] +for (String included : includedBundleEntries) { + println "Checking for existence of $included" + assert bundle.getEntry(included) != null : "FAILURE!" } -return true +bundle.close() diff --git a/src/it/it-03/verify.groovy b/src/it/it-03/verify.groovy index eee4260..2072c58 100644 --- a/src/it/it-03/verify.groovy +++ b/src/it/it-03/verify.groovy @@ -17,14 +17,11 @@ * under the License. */ -import java.util.zip.ZipEntry import java.util.zip.ZipInputStream var jarFile = new File(basedir, "target/maven-acr-plugin-it03-1.0.jar") println "Checking for existence of $jarFile" -if (!jarFile.isFile()) { - throw new FileNotFoundException("Missing " + jarFile) -} +assert jarFile.isFile() : "Missing " + jarFile var zis = new ZipInputStream(new FileInputStream(jarFile)) @@ -42,8 +39,4 @@ while (true) { zis.close() -if (count != 1) { - throw new IllegalStateException("Wrong number of application-client.xml's in archive: " + count) -} - -return true +assert count == 1 : "Wrong number of application-client.xml's in archive: " + count diff --git a/src/it/it-04/verify.groovy b/src/it/it-04/verify.groovy index 0e9e745..a885525 100644 --- a/src/it/it-04/verify.groovy +++ b/src/it/it-04/verify.groovy @@ -17,46 +17,22 @@ * under the License. */ - -import org.codehaus.plexus.util.IOUtil - import java.util.jar.JarFile -try { - var file = new File(basedir, "target/maven-acr-plugin-it04-1.0.jar") - println "Checking for existence of $file" - if (!file.isFile()) { - println "FAILURE! Missing JAR file" - return false - } - - var jarFile = new JarFile(file) +var file = new File(basedir, "target/maven-acr-plugin-it04-1.0.jar") +println "Checking for existence of $file" +assert file.isFile() : "FAILURE! Missing JAR file" - var zipEntry = jarFile.getEntry("META-INF/application-client.xml") - if (zipEntry == null) { - println "FAILURE! Missing META-INF/application-client.xml in the JAR file" - return false - } else { - var is = jarFile.getInputStream(zipEntry) - var contents = IOUtil.toString(is, "UTF-8") - var index = contents.indexOf("it04.key.value"); - if (index >= 0) { - println "FAILURE! The key 'it04.key.value' has not been replaced during filtering" - return false - } - index = contents.indexOf("it04-success") - if (index < 0) { - println "FAILURE! The value 'it04-success' has not been injected during filtering" - return false - } - is.close() - } +var jarFile = new JarFile(file) - jarFile.close() -} -catch (Throwable t) { - t.printStackTrace() - return false -} +var zipEntry = jarFile.getEntry("META-INF/application-client.xml") +assert zipEntry != null : "FAILURE! Missing META-INF/application-client.xml in the JAR file" +var is = jarFile.getInputStream(zipEntry) +var contents = is.getText('UTF-8') +var index = contents.indexOf("it04.key.value"); +assert index < 0 : "FAILURE! The key 'it04.key.value' has not been replaced during filtering" +index = contents.indexOf("it04-success") +assert index >= 0 : "FAILURE! The value 'it04-success' has not been injected during filtering" +is.close() -return true +jarFile.close() diff --git a/src/it/it-05/verify.groovy b/src/it/it-05/verify.groovy index 4cf017b..02afaed 100644 --- a/src/it/it-05/verify.groovy +++ b/src/it/it-05/verify.groovy @@ -22,7 +22,5 @@ def log = new File(basedir, "build.log").text // The lifecycle mapping must bind the acr goal to the loaded extension's version, // not to whatever version repository metadata resolves for a version-less binding. -if (!log.contains(":" + version + ":acr (default-acr)")) { - throw new AssertionError("acr goal did not run at extension version " + version) -} +assert log.contains(":" + version + ":acr (default-acr)") : "acr goal did not run at extension version " + version assert new File(basedir, "target/maven-acr-plugin-it05-1.0.jar").isFile() diff --git a/src/it/it-06/verify.groovy b/src/it/it-06/verify.groovy index 243cb96..5fc59d3 100644 --- a/src/it/it-06/verify.groovy +++ b/src/it/it-06/verify.groovy @@ -28,6 +28,4 @@ def expected = [ "maven-install-plugin:3.1.4:install" ] def missing = expected.findAll { !log.contains("org.apache.maven.plugins:" + it + " ") } -if (!missing.isEmpty()) { - throw new AssertionError("Default bindings not used: " + missing) -} +assert missing.isEmpty() : "Default bindings not used: " + missing
