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-war-plugin.git

commit b2146ba3551988c3e9163371a44b882c8425e3b6
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 25 22:20:09 2026 +0000

    Modernize Groovy IT scripts
    
    See https://github.com/apache/maven-invoker-plugin/issues/811.
---
 src/it/MWAR-131/verify.groovy |  76 ++++++++-----------------------
 src/it/MWAR-143/verify.groovy |  72 +++++++----------------------
 src/it/MWAR-326/verify.groovy |  35 ++------------
 src/it/MWAR-371/verify.groovy |  40 +++-------------
 src/it/default/verify.groovy  | 103 +++++++++++++++---------------------------
 5 files changed, 81 insertions(+), 245 deletions(-)

diff --git a/src/it/MWAR-131/verify.groovy b/src/it/MWAR-131/verify.groovy
index ca9fe0a..659f172 100644
--- a/src/it/MWAR-131/verify.groovy
+++ b/src/it/MWAR-131/verify.groovy
@@ -18,60 +18,22 @@
  * under the License.
  */
 
-import java.io.*;
-import org.codehaus.plexus.util.*;
-
-boolean result = true;
-
-try
-{
-
-  // Make sure the -classes jar from the first webapp is installed into the 
local repo
-  File localRepoClassesJar = new File( basedir,
-      
"../../../target/local-repo/com/example/mwar131-webapp/1.0-SNAPSHOT/mwar131-webapp-1.0-SNAPSHOT-classes.jar");
-
-  if ( !localRepoClassesJar.exists() || localRepoClassesJar.isDirectory() )
-  {
-      System.err.println( "The -classes jar file is missing or is a 
directory." );
-      return false;
-  }
-
-  // Make sure the -classes jar is included in WEB-INF/lib of the second webapp
-  File classesJar = new File( basedir,
-      
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/mwar131-webapp-1.0-SNAPSHOT-classes.jar");
-
-  if ( !classesJar.exists() || classesJar.isDirectory() )
-  {
-      System.err.println( "The -classes jar file is missing or is a 
directory." );
-      return false;
-  }
-
-  // Make sure dependencies of the -classes jar are included in WEB-INF/lib of 
the second webapp
-  File strutsJar = new File( basedir,
-      
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/struts-core-1.3.9.jar");
-
-  if ( !strutsJar.exists() || strutsJar.isDirectory() )
-  {
-      System.err.println( "The Struts 1.3.9 jar file is missing or is a 
directory." );
-      return false;
-  }
-
-  // Make sure transitive dependencies of the -classes jar are included in 
WEB-INF/lib of the second webapp
-  File digesterJar = new File( basedir,
-      
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/commons-digester-1.8.jar");
-
-  if ( !digesterJar.exists() || digesterJar.isDirectory() )
-  {
-      System.err.println( "The Commons Digester 1.8 jar file is missing or is 
a directory." );
-      return false;
-  }
-
-}
-catch( Throwable e )
-{
-    e.printStackTrace();
-    result = false;
-}
-
-return result;
-
+// Make sure the -classes jar from the first webapp is installed into the 
local repo
+File localRepoClassesJar = new File( basedir,
+    
"../../../target/local-repo/com/example/mwar131-webapp/1.0-SNAPSHOT/mwar131-webapp-1.0-SNAPSHOT-classes.jar");
+assert localRepoClassesJar.exists() && !localRepoClassesJar.isDirectory() : 
"The -classes jar file is missing or is a directory."
+
+// Make sure the -classes jar is included in WEB-INF/lib of the second webapp
+File classesJar = new File( basedir,
+    
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/mwar131-webapp-1.0-SNAPSHOT-classes.jar");
+assert classesJar.exists() && !classesJar.isDirectory() : "The -classes jar 
file is missing or is a directory."
+
+// Make sure dependencies of the -classes jar are included in WEB-INF/lib of 
the second webapp
+File strutsJar = new File( basedir,
+    
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/struts-core-1.3.9.jar");
+assert strutsJar.exists() && !strutsJar.isDirectory() : "The Struts 1.3.9 jar 
file is missing or is a directory."
+
+// Make sure transitive dependencies of the -classes jar are included in 
WEB-INF/lib of the second webapp
+File digesterJar = new File( basedir,
+    
"mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/commons-digester-1.8.jar");
+assert digesterJar.exists() && !digesterJar.isDirectory() : "The Commons 
Digester 1.8 jar file is missing or is a directory."
diff --git a/src/it/MWAR-143/verify.groovy b/src/it/MWAR-143/verify.groovy
index 7ba365a..0dcb44b 100644
--- a/src/it/MWAR-143/verify.groovy
+++ b/src/it/MWAR-143/verify.groovy
@@ -18,11 +18,8 @@
  * under the License.
  */
 
-import java.io.*;
 import org.codehaus.plexus.util.*;
 
-boolean result = true;
-
 boolean filesAreIdentical( File expected, File current )
     throws IOException
 {
@@ -57,68 +54,31 @@ boolean filesAreIdentical( File expected, File current )
     return true;
 }
 
-try
-{
+File originalImg = new File( basedir, 
"war-common/src/main/images/duke-beer.jpg" );
 
-    File originalImg = new File( basedir, 
"war-common/src/main/images/duke-beer.jpg" );
+File targetImg = new File( basedir, 
"war-common/target/common-overlay-1.0-SNAPSHOT/duke-beer.jpg" );
 
-    File targetImg = new File( basedir, 
"war-common/target/common-overlay-1.0-SNAPSHOT/duke-beer.jpg" );
+boolean identical = filesAreIdentical( originalImg, targetImg );
 
-    boolean identical = filesAreIdentical( originalImg, targetImg );
+assert identical : "filtered images are not identical in war-common."
 
-    if ( !identical )
-    {
-        System.err.println( "filtered images are not identical in war-common." 
);
-        return false;
-    }
+File target = new File( basedir, "war-filter-overlay/target" );
+assert target.exists() && target.isDirectory() : "target file is missing or 
not a directory."
 
-    File target = new File( basedir, "war-filter-overlay/target" );
-    if ( !target.exists() || !target.isDirectory() )
-    {
-        System.err.println( "target file is missing or not a directory." );
-        return false;
-    }
+File webappDirectory = new File( target, "custom-manifest-1.0-SNAPSHOT" );
+assert webappDirectory.exists() && webappDirectory.isDirectory() : 
"webappDirectory is missing or not a directory."
 
-    File webappDirectory = new File( target, "custom-manifest-1.0-SNAPSHOT" );
-    if ( !webappDirectory.exists() || !webappDirectory.isDirectory() )
-    {
-        System.err.println( "webappDirectory is missing or not a directory." );
-        return false;
-    }
+File param = new File( webappDirectory, "WEB-INF/classes/filter.properties" );
+assert param.exists() && !param.isDirectory() : "filter.properties file is 
missing or a directory."
 
-    File param = new File( webappDirectory, 
"WEB-INF/classes/filter.properties" );
-    if ( !param.exists() || param.isDirectory() )
-    {
-        System.err.println( "filter.properties file is missing or a 
directory." );
-        return false;
-    }
 
+String paramContent = param.getText( 'UTF-8' );
 
-    String paramContent = FileUtils.fileRead( param );
+int indexOf = paramContent.indexOf( "debug.test = hello world !" );
+assert indexOf >= 0 : "filter.properties does not contains debug.test = hello 
world !"
 
-    int indexOf = paramContent.indexOf( "debug.test = hello world !" );
-    if ( indexOf < 0 )
-    {
-        System.err.println( "filter.properties does not contains debug.test = 
hello world !" );
-        return false;
-    }
-
-    targetImg = new File( basedir, 
"war-filter-overlay/target/custom-manifest-1.0-SNAPSHOT/duke-beer.jpg" );
-
-    identical = filesAreIdentical( originalImg, targetImg );
-
-    if ( !identical )
-    {
-        System.err.println( "filtered images are not identical with overlay." 
);
-        return false;
-    }
-
-}
-catch( Throwable e )
-{
-    e.printStackTrace();
-    result = false;
-}
+targetImg = new File( basedir, 
"war-filter-overlay/target/custom-manifest-1.0-SNAPSHOT/duke-beer.jpg" );
 
-return result;
+identical = filesAreIdentical( originalImg, targetImg );
 
+assert identical : "filtered images are not identical with overlay."
diff --git a/src/it/MWAR-326/verify.groovy b/src/it/MWAR-326/verify.groovy
index c0a4425..89f9839 100644
--- a/src/it/MWAR-326/verify.groovy
+++ b/src/it/MWAR-326/verify.groovy
@@ -18,35 +18,8 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import org.codehaus.plexus.util.*;
+File target = new File( basedir, "target" );
+assert target.exists() && target.isDirectory() : "target file is missing or 
not a directory."
 
-boolean result = true;
-
-try
-{
-    File target = new File( basedir, "target" );
-    if ( !target.exists() || !target.isDirectory() )
-    {
-        System.err.println( "target file is missing or not a directory." );
-        return false;
-    }
-
-    File artifact = new File( target, 
"maven-war-plugin-test-mwar-326-1.0-SNAPSHOT.war" );
-    if ( !artifact.exists() )
-    {
-        System.err.println( "default artifact should exist." );
-        return false;
-    }
-
-    return true;
-}
-catch( Throwable e )
-{
-    e.printStackTrace();
-    return false;
-}
-
-return false;
+File artifact = new File( target, 
"maven-war-plugin-test-mwar-326-1.0-SNAPSHOT.war" );
+assert artifact.exists() : "default artifact should exist."
diff --git a/src/it/MWAR-371/verify.groovy b/src/it/MWAR-371/verify.groovy
index e66bcd5..4978d38 100644
--- a/src/it/MWAR-371/verify.groovy
+++ b/src/it/MWAR-371/verify.groovy
@@ -38,37 +38,9 @@ boolean checkFile( String fileName, String module )
     return checkFile( fileName, module, module )
 }
 
-try {
-    if ( ! checkFile( "a1.txt", "custom" ) )
-    {
-        return false
-    }
-    if ( ! checkFile( "a2.txt", "custom" ) )
-    {
-        return false
-    }
-    if ( ! checkFile( "a3.txt", "custom", "generic" ) )
-    {
-        return false
-    }
-    if ( ! checkFile( "a1.txt", "generic" ) )
-    {
-        return false
-    }
-    if ( ! checkFile( "a2.txt", "generic" ) )
-    {
-        return false
-    }
-    if ( ! checkFile( "a3.txt", "generic" ) )
-    {
-        return false
-    }
-}
-catch ( Throwable e )
-{
-    e.printStackTrace()
-    return false
-}
-
-return true
-
+assert checkFile( "a1.txt", "custom" )
+assert checkFile( "a2.txt", "custom" )
+assert checkFile( "a3.txt", "custom", "generic" )
+assert checkFile( "a1.txt", "generic" )
+assert checkFile( "a2.txt", "generic" )
+assert checkFile( "a3.txt", "generic" )
diff --git a/src/it/default/verify.groovy b/src/it/default/verify.groovy
index 22edc06..5bb254d 100644
--- a/src/it/default/verify.groovy
+++ b/src/it/default/verify.groovy
@@ -17,81 +17,50 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 
-try
-{
-    File explodedDir = new File( basedir, "target/maven-it-it0016-1.0" );
-    System.out.println( "Checking for existence of exploded directory " + 
explodedDir );
-    if ( !explodedDir.isDirectory() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-
-    String[] expectedPaths = [
-            "index.html",
-            "WEB-INF/classes/org/apache/maven/it0016/Person.class",
-            "WEB-INF/lib/commons-logging-1.0.3.jar",
-    ];
-    for ( String path : expectedPaths )
-    {
-        File file = new File( explodedDir, path );
-        System.out.println( "Checking for existence of " + file );
-        if ( !file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
-
-    String[] unexpectedPaths = [
-            "WEB-INF/lib/servlet-api-2.4.jar",
-    ];
-    for ( String path : unexpectedPaths )
-    {
-        File file = new File( explodedDir, path );
-        System.out.println( "Checking for absence of " + file );
-        if ( file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+File explodedDir = new File( basedir, "target/maven-it-it0016-1.0" );
+System.out.println( "Checking for existence of exploded directory " + 
explodedDir );
+assert explodedDir.isDirectory()
 
-    File warFile = new File( basedir, "target/maven-it-it0016-1.0.war" );
-    System.out.println( "Checking for existence of " + warFile );
-    if ( !warFile.isFile() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-
-    JarFile war = new JarFile( warFile );
-
-    String[] includedEntries = [
+String[] expectedPaths = [
+        "index.html",
         "WEB-INF/classes/org/apache/maven/it0016/Person.class",
         "WEB-INF/lib/commons-logging-1.0.3.jar",
-    ];
-    for ( String included : includedEntries )
-    {
-        System.out.println( "Checking for existence of " + included );
-        if ( war.getEntry( included ) == null )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+];
+for ( String path : expectedPaths )
+{
+    File file = new File( explodedDir, path );
+    System.out.println( "Checking for existence of " + file );
+    assert file.exists()
+}
 
-    war.close();
+String[] unexpectedPaths = [
+        "WEB-INF/lib/servlet-api-2.4.jar",
+];
+for ( String path : unexpectedPaths )
+{
+    File file = new File( explodedDir, path );
+    System.out.println( "Checking for absence of " + file );
+    assert !file.exists()
 }
-catch( Throwable t )
+
+File warFile = new File( basedir, "target/maven-it-it0016-1.0.war" );
+System.out.println( "Checking for existence of " + warFile );
+assert warFile.isFile()
+
+JarFile war = new JarFile( warFile );
+
+String[] includedEntries = [
+    "WEB-INF/classes/org/apache/maven/it0016/Person.class",
+    "WEB-INF/lib/commons-logging-1.0.3.jar",
+];
+for ( String included : includedEntries )
 {
-    t.printStackTrace();
-    return false;
+    System.out.println( "Checking for existence of " + included );
+    assert war.getEntry( included ) != null
 }
 
+war.close();
+
 return true;

Reply via email to