Skip to content

Commit

Permalink
ITs cleanups
Browse files Browse the repository at this point in the history
- use project.version instead of pom.version
- simple searcher logs by contains method instead of external class
  • Loading branch information
slawekjaranowski committed Aug 20, 2023
1 parent d975178 commit a9fb3b5
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 198 deletions.
35 changes: 3 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,42 +321,10 @@
<id>run-its</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>3.0.18</version>
</dependency>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.8</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<configuration>
<debug>false</debug>
<verbose>true</verbose>
<stacktrace>true</stacktrace>
<defaultScriptExtension>.groovy</defaultScriptExtension>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<addTestClassPath>true</addTestClassPath>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<projectsDirectory>src/it/projects</projectsDirectory>
<showErrors>true</showErrors>
Expand All @@ -372,6 +340,9 @@
<filterProperties>
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
</filterProperties>
<scriptVariables>
<projectVersion>${project.version}</projectVersion>
</scriptVariables>
</configuration>
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/async/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<id>async-it</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/envscript/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<id>with-env-script</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-104/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
11 changes: 2 additions & 9 deletions src/it/projects/mexec-104/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
13 changes: 3 additions & 10 deletions src/it/projects/mexec-108/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
2 changes: 1 addition & 1 deletion src/it/projects/mexec-137/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-29-non-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-29-wrong-signature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-29/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
Expand Down
10 changes: 2 additions & 8 deletions src/it/projects/mexec-29/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')

2 changes: 1 addition & 1 deletion src/it/projects/mexec-323-force-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>compile</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-323/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>compile</phase>
Expand Down
5 changes: 0 additions & 5 deletions src/it/projects/mexec-66/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-79/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-86/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
11 changes: 2 additions & 9 deletions src/it/projects/mexec-86/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion src/it/projects/mexec-88/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-92/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<configuration>
<executable>${JAVA_HOME}/bin/java</executable>
<arguments>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-98/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/mexec-gh-128/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
11 changes: 2 additions & 9 deletions src/it/projects/mexec-gh-128/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
79 changes: 6 additions & 73 deletions src/it/projects/multiple-executions/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---')
2 changes: 1 addition & 1 deletion src/it/projects/project6/project5exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@pom.version@</version>
<version>@project.version@</version>
<executions>
<execution>
<phase>process-classes</phase>
Expand Down
Loading

0 comments on commit a9fb3b5

Please sign in to comment.