From a9fb3b5ffb047f88f240a8d485f99495418000f2 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 20 Aug 2023 11:51:18 +0200 Subject: [PATCH] ITs cleanups - use project.version instead of pom.version - simple searcher logs by contains method instead of external class --- pom.xml | 35 +------- src/it/projects/async/pom.xml | 2 +- src/it/projects/envscript/pom.xml | 2 +- src/it/projects/mexec-104/pom.xml | 2 +- src/it/projects/mexec-104/verify.groovy | 11 +-- src/it/projects/mexec-108/verify.groovy | 13 +-- src/it/projects/mexec-137/pom.xml | 2 +- src/it/projects/mexec-29-non-static/pom.xml | 2 +- .../projects/mexec-29-wrong-signature/pom.xml | 2 +- src/it/projects/mexec-29/pom.xml | 2 +- src/it/projects/mexec-29/verify.groovy | 10 +-- src/it/projects/mexec-323-force-java/pom.xml | 2 +- src/it/projects/mexec-323/pom.xml | 2 +- src/it/projects/mexec-66/verify.groovy | 5 -- src/it/projects/mexec-79/pom.xml | 2 +- src/it/projects/mexec-86/pom.xml | 2 +- src/it/projects/mexec-86/verify.groovy | 11 +-- src/it/projects/mexec-88/pom.xml | 2 +- src/it/projects/mexec-92/pom.xml | 2 +- src/it/projects/mexec-98/pom.xml | 2 +- src/it/projects/mexec-gh-128/pom.xml | 2 +- src/it/projects/mexec-gh-128/verify.groovy | 11 +-- .../multiple-executions/verify.groovy | 79 ++----------------- src/it/projects/project6/project5exec/pom.xml | 2 +- src/test/groovy/IntegrationBase.groovy | 27 ------- 25 files changed, 36 insertions(+), 198 deletions(-) delete mode 100644 src/test/groovy/IntegrationBase.groovy diff --git a/pom.xml b/pom.xml index b6fff975..69e4a4ca 100644 --- a/pom.xml +++ b/pom.xml @@ -321,42 +321,10 @@ run-its - - org.codehaus.gmaven - gmaven-plugin - 1.5 - - - org.codehaus.groovy - groovy - 3.0.18 - - - org.codehaus.gmaven.runtime - gmaven-runtime-1.8 - 1.5 - - - - false - true - true - .groovy - - - - - testCompile - - - - - org.apache.maven.plugins maven-invoker-plugin - true ${project.build.directory}/local-repo src/it/projects true @@ -372,6 +340,9 @@ ${mrm.repository.url} + + ${project.version} + diff --git a/src/it/projects/async/pom.xml b/src/it/projects/async/pom.xml index 8d17e89a..471327e1 100644 --- a/src/it/projects/async/pom.xml +++ b/src/it/projects/async/pom.xml @@ -22,7 +22,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ async-it diff --git a/src/it/projects/envscript/pom.xml b/src/it/projects/envscript/pom.xml index 2cb3e5d2..5a748bc9 100644 --- a/src/it/projects/envscript/pom.xml +++ b/src/it/projects/envscript/pom.xml @@ -22,7 +22,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ with-env-script diff --git a/src/it/projects/mexec-104/pom.xml b/src/it/projects/mexec-104/pom.xml index 67f3a36e..7184bcba 100644 --- a/src/it/projects/mexec-104/pom.xml +++ b/src/it/projects/mexec-104/pom.xml @@ -20,7 +20,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-104/verify.groovy b/src/it/projects/mexec-104/verify.groovy index cd5103c6..9cf4e6ba 100644 --- a/src/it/projects/mexec-104/verify.groovy +++ b/src/it/projects/mexec-104/verify.groovy @@ -17,13 +17,6 @@ * under the License. */ -import java.io.* -import java.util.* +def buildLog = new File(basedir, "build.log").text -t = new IntegrationBase() - -def buildLog = new File( basedir, "build.log" ) - -t.checkExistenceAndContentOfAFile(buildLog, [ - "[DEBUG] (f) arguments = [-cp, target/classes, Main, null]", -]) +assert buildLog.contains("[DEBUG] (f) arguments = [-cp, target/classes, Main, null]") diff --git a/src/it/projects/mexec-108/verify.groovy b/src/it/projects/mexec-108/verify.groovy index e97e9374..07a8c454 100644 --- a/src/it/projects/mexec-108/verify.groovy +++ b/src/it/projects/mexec-108/verify.groovy @@ -17,14 +17,7 @@ * under the License. */ -import java.io.* -import java.util.* +def buildLog = new File(basedir, "build.log").text -t = new IntegrationBase() - -def buildLog = new File( basedir, "build.log" ) - -t.checkExistenceAndContentOfAFile(buildLog, [ - "[DEBUG] (f) environmentVariables = {key=null}", - "[DEBUG] (f) arguments = [-cp, target/classes, Main]", -]) +assert buildLog.contains("[DEBUG] (f) environmentVariables = {key=null}") +assert buildLog.contains("[DEBUG] (f) arguments = [-cp, target/classes, Main]") diff --git a/src/it/projects/mexec-137/pom.xml b/src/it/projects/mexec-137/pom.xml index db596e7e..ebc963f6 100644 --- a/src/it/projects/mexec-137/pom.xml +++ b/src/it/projects/mexec-137/pom.xml @@ -18,7 +18,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ test diff --git a/src/it/projects/mexec-29-non-static/pom.xml b/src/it/projects/mexec-29-non-static/pom.xml index e7c1f9da..26881044 100644 --- a/src/it/projects/mexec-29-non-static/pom.xml +++ b/src/it/projects/mexec-29-non-static/pom.xml @@ -40,7 +40,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ test diff --git a/src/it/projects/mexec-29-wrong-signature/pom.xml b/src/it/projects/mexec-29-wrong-signature/pom.xml index e7c1f9da..26881044 100644 --- a/src/it/projects/mexec-29-wrong-signature/pom.xml +++ b/src/it/projects/mexec-29-wrong-signature/pom.xml @@ -40,7 +40,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ test diff --git a/src/it/projects/mexec-29/pom.xml b/src/it/projects/mexec-29/pom.xml index ac96cfd2..12637544 100644 --- a/src/it/projects/mexec-29/pom.xml +++ b/src/it/projects/mexec-29/pom.xml @@ -40,7 +40,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ test diff --git a/src/it/projects/mexec-29/verify.groovy b/src/it/projects/mexec-29/verify.groovy index e7d11ac7..11b5cee5 100644 --- a/src/it/projects/mexec-29/verify.groovy +++ b/src/it/projects/mexec-29/verify.groovy @@ -17,14 +17,8 @@ * under the License. */ -import java.io.* -import java.util.* -t = new IntegrationBase() +def buildLog = new File( basedir, "build.log" ).text -def buildLog = new File( basedir, "build.log" ) - -t.checkExistenceAndContentOfAFile(buildLog, [ - "java.lang.ClassNotFoundException: org.codehaus.mojo.exec.NoMain", -]) +assert buildLog.contains('java.lang.ClassNotFoundException: org.codehaus.mojo.exec.NoMain') diff --git a/src/it/projects/mexec-323-force-java/pom.xml b/src/it/projects/mexec-323-force-java/pom.xml index 31436bc3..135f140b 100644 --- a/src/it/projects/mexec-323-force-java/pom.xml +++ b/src/it/projects/mexec-323-force-java/pom.xml @@ -18,7 +18,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ compile diff --git a/src/it/projects/mexec-323/pom.xml b/src/it/projects/mexec-323/pom.xml index b14d2ed1..07300abf 100644 --- a/src/it/projects/mexec-323/pom.xml +++ b/src/it/projects/mexec-323/pom.xml @@ -18,7 +18,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ compile diff --git a/src/it/projects/mexec-66/verify.groovy b/src/it/projects/mexec-66/verify.groovy index fec16549..7c787fe4 100644 --- a/src/it/projects/mexec-66/verify.groovy +++ b/src/it/projects/mexec-66/verify.groovy @@ -16,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import java.io.* -import java.util.* - -t = new IntegrationBase() - def buildLog = new File(basedir, 'build.log') def expectedClasspath = new File(basedir, 'target/classes').getAbsolutePath() diff --git a/src/it/projects/mexec-79/pom.xml b/src/it/projects/mexec-79/pom.xml index 1286023b..ab1f1bf1 100644 --- a/src/it/projects/mexec-79/pom.xml +++ b/src/it/projects/mexec-79/pom.xml @@ -21,7 +21,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-86/pom.xml b/src/it/projects/mexec-86/pom.xml index d6b5b1ca..81c30cd8 100644 --- a/src/it/projects/mexec-86/pom.xml +++ b/src/it/projects/mexec-86/pom.xml @@ -17,7 +17,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-86/verify.groovy b/src/it/projects/mexec-86/verify.groovy index 1e54c16f..51542e52 100644 --- a/src/it/projects/mexec-86/verify.groovy +++ b/src/it/projects/mexec-86/verify.groovy @@ -38,13 +38,6 @@ // Otherwise this test will fail. import org.codehaus.plexus.util.FileUtils -import org.codehaus.plexus.util.IOUtil - -import java.io.* -import java.util.* - -import static junit.framework.Assert.assertEquals -import static junit.framework.Assert.assertTrue private int countTheNumberOfLines(String expectedHexString, String line) { int numberOfLine = 0; @@ -99,11 +92,11 @@ def expectedLines = [ for (int i = 0; i < expectedLines.size(); i++) { def expectedLine = convertStringToHex(expectedLines[i]); - assertTrue(expectedHexString.contains((expectedLine))); + assert expectedHexString.contains(expectedLine); } def LINE = System.getProperty("line.separator"); def LineInHex = convertStringToHex(LINE); def numberOfLine = countTheNumberOfLines(expectedHexString, LineInHex); -assertEquals(5, numberOfLine); +assert 5 == numberOfLine; diff --git a/src/it/projects/mexec-88/pom.xml b/src/it/projects/mexec-88/pom.xml index 4f50b50c..e1fcaca4 100644 --- a/src/it/projects/mexec-88/pom.xml +++ b/src/it/projects/mexec-88/pom.xml @@ -17,7 +17,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-92/pom.xml b/src/it/projects/mexec-92/pom.xml index a0a6b897..670e4235 100644 --- a/src/it/projects/mexec-92/pom.xml +++ b/src/it/projects/mexec-92/pom.xml @@ -17,7 +17,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ ${JAVA_HOME}/bin/java diff --git a/src/it/projects/mexec-98/pom.xml b/src/it/projects/mexec-98/pom.xml index ea0368c2..f090e3b5 100644 --- a/src/it/projects/mexec-98/pom.xml +++ b/src/it/projects/mexec-98/pom.xml @@ -17,7 +17,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-gh-128/pom.xml b/src/it/projects/mexec-gh-128/pom.xml index fab36cc5..5384d3ec 100644 --- a/src/it/projects/mexec-gh-128/pom.xml +++ b/src/it/projects/mexec-gh-128/pom.xml @@ -17,7 +17,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/it/projects/mexec-gh-128/verify.groovy b/src/it/projects/mexec-gh-128/verify.groovy index d61cee01..33df2f3c 100644 --- a/src/it/projects/mexec-gh-128/verify.groovy +++ b/src/it/projects/mexec-gh-128/verify.groovy @@ -17,13 +17,6 @@ * under the License. */ -import java.io.* -import java.util.* +def buildLog = new File( basedir, "build.log" ).text -t = new IntegrationBase() - -def buildLog = new File( basedir, "build.log" ) - -t.checkExistenceAndContentOfAFile(buildLog, [ - "[ERROR] Timeout. Process runs longer than 1000 ms." -]) +assert buildLog.contains("[ERROR] Timeout. Process runs longer than 1000 ms.") diff --git a/src/it/projects/multiple-executions/verify.groovy b/src/it/projects/multiple-executions/verify.groovy index 0c16113d..45b56928 100644 --- a/src/it/projects/multiple-executions/verify.groovy +++ b/src/it/projects/multiple-executions/verify.groovy @@ -17,78 +17,11 @@ * under the License. */ -import java.io.* -import java.util.* -t = new IntegrationBase() - -def buildLog = new File( basedir, "build.log" ) - -def getPluginVersion() { - def pom = new XmlSlurper().parse(new File(basedir, 'pom.xml')) - - def allPlugins = pom.build.plugins.plugin; - - def configurationMavenPlugin = allPlugins.find { - item -> item.groupId.equals("org.codehaus.mojo") && item.artifactId.equals("exec-maven-plugin"); - } - - return configurationMavenPlugin.version; -} +def buildLog = new File( basedir, "build.log" ).text -def getProjectVersion() { - def pom = new XmlSlurper().parse(new File(basedir, 'pom.xml')) - - def allPlugins = pom.version; - - return pom.version; -} -def getMavenVersion(buildLog) { - def maven = null; - buildLog.eachLine { line -> - if (line.startsWith("Apache Maven 2.0.11")) { - maven = "2.0.11"; - } else if (line.startsWith("Apache Maven 2.2.1")) { - maven = "2.2.1"; - } else if (line.startsWith("Apache Maven 3.0.3")) { - maven = "3.0.3"; - } else if (line.startsWith("Apache Maven 3.0.4")) { - maven = "3.0.4"; - } else if (line.startsWith("Apache Maven 3.0.5")) { - maven = "3.0.5"; - } else if (line.startsWith("Apache Maven 3.1.0")) { - maven = "3.1.0"; - } else if (line.startsWith("Apache Maven 3.1.1")) { - maven = "3.1.1"; - } else if (line.startsWith("Apache Maven 3.2.1")) { - maven = "3.2.1"; - } - } - - return maven -} - -def mavenVersion = getMavenVersion(buildLog) - - -def projectVersion = getProjectVersion(); -def pluginVersion = getPluginVersion(); - -println "Project version: ${projectVersion}" -println "Plugin version ${pluginVersion}" - -if (mavenVersion.equals("2.0.11") || mavenVersion.equals("2.2.1")) { - t.checkExistenceAndContentOfAFile(buildLog, [ - "[DEBUG] (f) arguments = [-cp, target/classes, Main]", - "[INFO] [exec:exec {execution: first-execution}]", - "[INFO] [exec:exec {execution: second-execution}]", - "[INFO] [exec:exec {execution: third-execution}]", - ]) -} else { - t.checkExistenceAndContentOfAFile(buildLog, [ - "[DEBUG] (f) arguments = [-cp, target/classes, Main]", - "[INFO] --- exec-maven-plugin:" + pluginVersion + ":exec (first-execution) @ multiple-execution ---", - "[INFO] --- exec-maven-plugin:" + pluginVersion + ":exec (second-execution) @ multiple-execution ---", - "[INFO] --- exec-maven-plugin:" + pluginVersion + ":exec (third-execution) @ multiple-execution ---", - ]) -} +// Newer versions of Maven can contains short name of plugin +assert buildLog.contains('[DEBUG] (f) arguments = [-cp, target/classes, Main]') +assert buildLog.contains(':' + projectVersion + ':exec (first-execution) @ multiple-execution ---') +assert buildLog.contains(':' + projectVersion + ':exec (second-execution) @ multiple-execution ---') +assert buildLog.contains(':' + projectVersion + ':exec (third-execution) @ multiple-execution ---') \ No newline at end of file diff --git a/src/it/projects/project6/project5exec/pom.xml b/src/it/projects/project6/project5exec/pom.xml index c63f702b..ed7c30fc 100644 --- a/src/it/projects/project6/project5exec/pom.xml +++ b/src/it/projects/project6/project5exec/pom.xml @@ -14,7 +14,7 @@ org.codehaus.mojo exec-maven-plugin - @pom.version@ + @project.version@ process-classes diff --git a/src/test/groovy/IntegrationBase.groovy b/src/test/groovy/IntegrationBase.groovy deleted file mode 100644 index 2309d1d8..00000000 --- a/src/test/groovy/IntegrationBase.groovy +++ /dev/null @@ -1,27 +0,0 @@ -class IntegrationBase { - - void checkExistenceAndContentOfAFile(file, contents) { - if (!file.canRead()) { - throw new FileNotFoundException( "Could not find the " + file); - } - - def lines_to_check_in_unix_script_marker = [:]; - (0..contents.size()).each { index -> - lines_to_check_in_unix_script_marker[index] = false - } - - file.eachLine { file_content, file_line -> - contents.eachWithIndex { contents_expected, index -> - if (file_content.equals(contents_expected)) { - lines_to_check_in_unix_script_marker[index] = true; - } - } - } - - contents.eachWithIndex { value, index -> - if ( lines_to_check_in_unix_script_marker[index] == false ) { - throw new Exception("The expected content in " + file + " couldn't be found." + contents[index]); - } - } - } -}