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

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

    Modernize Groovy IT scripts
    
    See https://github.com/apache/maven-invoker-plugin/issues/811.
---
 src/it/MEJB-72/verify.groovy              | 35 +++---------------
 src/it/default/verify.groovy              | 45 +++++++----------------
 src/it/exclude-ejb-jar-xml/verify.groovy  | 15 ++------
 src/it/manifest-content/verify.groovy     | 18 ++--------
 src/it/mejb-34-filtered/verify.groovy     | 60 ++++++++-----------------------
 src/it/mejb-34-not-filtered/verify.groovy | 60 ++++++++-----------------------
 src/it/mejb-93/verify.groovy              | 27 +++-----------
 src/it/reactor/verify.groovy              |  8 +----
 8 files changed, 58 insertions(+), 210 deletions(-)

diff --git a/src/it/MEJB-72/verify.groovy b/src/it/MEJB-72/verify.groovy
index 570f1c6..3dbeb72 100644
--- a/src/it/MEJB-72/verify.groovy
+++ b/src/it/MEJB-72/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-it-mejb72-1.0-SNAPSHOT.jar" );
-    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-it-mejb72-1.0-SNAPSHOT.jar" );
+assert artifact.exists() : "default artifact should exist.";
diff --git a/src/it/default/verify.groovy b/src/it/default/verify.groovy
index 2dc56ab..14cf850 100644
--- a/src/it/default/verify.groovy
+++ b/src/it/default/verify.groovy
@@ -17,43 +17,24 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 
-try
-{
-    File jarFile = new File( basedir, "target/maven-it-it0017-1.0.jar" );
-    System.out.println( "Checking for existence of " + jarFile );
-    if ( !jarFile.isFile() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-
-    JarFile jar = new JarFile( jarFile );
+File jarFile = new File( basedir, "target/maven-it-it0017-1.0.jar" );
+System.out.println( "Checking for existence of " + jarFile );
+assert jarFile.isFile();
 
-    String[] includedEntries = [
-        "META-INF/ejb-jar.xml",
-        "org/apache/maven/it0017/Person.class",
-    ];
-    for ( String included : includedEntries )
-    {
-        System.out.println( "Checking for existence of " + included );
-        if ( jar.getEntry( included ) == null )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+JarFile jar = new JarFile( jarFile );
 
-    jar.close();
-}
-catch( Throwable t )
+String[] includedEntries = [
+    "META-INF/ejb-jar.xml",
+    "org/apache/maven/it0017/Person.class",
+];
+for ( String included : includedEntries )
 {
-    t.printStackTrace();
-    return false;
+    System.out.println( "Checking for existence of " + included );
+    assert jar.getEntry( included ) != null : "Missing " + included;
 }
 
+jar.close();
+
 return true;
diff --git a/src/it/exclude-ejb-jar-xml/verify.groovy 
b/src/it/exclude-ejb-jar-xml/verify.groovy
index c47fbc4..95d1f21 100644
--- a/src/it/exclude-ejb-jar-xml/verify.groovy
+++ b/src/it/exclude-ejb-jar-xml/verify.groovy
@@ -17,17 +17,11 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.zip.*;
-import java.util.regex.*;
 
 File jarFile = new File( basedir, "target/test-1.0.jar" );
 System.out.println( "Checking for existence of " + jarFile );
-if ( !jarFile.isFile() )
-{
-    throw new FileNotFoundException( "Missing " + jarFile );
-}
+assert jarFile.isFile() : "Missing " + jarFile;
 
 ZipInputStream zis = new ZipInputStream( new FileInputStream( jarFile ) );
 
@@ -48,9 +42,4 @@ while (true)
 
 zis.close();
 
-if ( count != 1 )
-{
-    throw new IllegalStateException( "Wrong number of ejb-jar.xml's in 
archive: " + count );
-}
-
-return true;
+assert count == 1 : "Wrong number of ejb-jar.xml's in archive: " + count;
diff --git a/src/it/manifest-content/verify.groovy 
b/src/it/manifest-content/verify.groovy
index 190d22c..1bbce3e 100644
--- a/src/it/manifest-content/verify.groovy
+++ b/src/it/manifest-content/verify.groovy
@@ -17,31 +17,19 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 
 File jarFile = new File( basedir, "target/test-1.0.jar" );
 System.out.println( "Checking for existence of " + jarFile );
-if ( !jarFile.isFile() )
-{
-    throw new FileNotFoundException( "Missing " + jarFile );
-}
+assert jarFile.isFile() : "Missing " + jarFile;
 
 JarFile jar = new JarFile( jarFile );
 
 Attributes manifest = jar.getManifest().getMainAttributes();
 
-if ( !manifest.getValue( new Attributes.Name( "Created-By" ) ).startsWith( 
"Maven EJB Plugin" ) )
-{
-    throw new IllegalStateException( "Created-By not equals Maven EJB Plugin" 
);
-}
+assert manifest.getValue( new Attributes.Name( "Created-By" ) ).startsWith( 
"Maven EJB Plugin" ) : "Created-By not equals Maven EJB Plugin";
 
 String classpath = manifest.getValue( Attributes.Name.CLASS_PATH );
-if ( classpath == null || classpath.indexOf( "junit-3.8.2.jar" ) < 0 )
-{
-    throw new IllegalStateException( "Bad Class-Path " + classpath );
-}
+assert classpath != null && classpath.indexOf( "junit-3.8.2.jar" ) >= 0 : "Bad 
Class-Path " + classpath;
 
 jar.close();
diff --git a/src/it/mejb-34-filtered/verify.groovy 
b/src/it/mejb-34-filtered/verify.groovy
index 81a085b..6d2bc20 100644
--- a/src/it/mejb-34-filtered/verify.groovy
+++ b/src/it/mejb-34-filtered/verify.groovy
@@ -17,56 +17,26 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 import java.util.zip.ZipEntry;
-import org.codehaus.plexus.util.IOUtil;
 
-try
-{
-    File file = new File( basedir, "target/mejb-34-filtered-1.0.jar" );
-    System.out.println( "Checking for existence of " + file );
-    if ( !file.isFile() )
-    {
-        System.out.println( "FAILURE! Missing JAR file" );
-        return false;
-    }
+File file = new File( basedir, "target/mejb-34-filtered-1.0.jar" );
+System.out.println( "Checking for existence of " + file );
+assert file.isFile() : "FAILURE! Missing JAR file";
 
-    JarFile jarFile = new JarFile( file );
+JarFile jarFile = new JarFile( file );
 
-    ZipEntry zipEntry = jarFile.getEntry( "META-INF/ejb-jar.xml" );
-    if ( zipEntry == null )
-    {
-        System.out.println( "FAILURE! Missing META-INF/ejb-jar.xml in the JAR 
file" );
-        return false;
-    }
-    else
-    {
-        InputStream is = jarFile.getInputStream( zipEntry );
-        String contents = IOUtil.toString ( is, "UTF-8" );
-        int index = contents.indexOf( "myKey" );
-        if ( index >= 0 )
-        {
-            System.out.println( "FAILURE! The key 'myKey' has not been 
replaced during filtering" );
-            return false;
-        }
-        index = contents.indexOf( "myValue" );
-        if ( index < 0 )
-        {
-            System.out.println( "FAILURE! The value 'myValue' has not been 
injected during filtering" );
-            return false;
-        }
-        is.close();
-    }
+ZipEntry zipEntry = jarFile.getEntry( "META-INF/ejb-jar.xml" );
+assert zipEntry != null : "FAILURE! Missing META-INF/ejb-jar.xml in the JAR 
file";
 
-    jarFile.close();
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
+InputStream is = jarFile.getInputStream( zipEntry );
+String contents = is.getText( 'UTF-8' );
+int index = contents.indexOf( "myKey" );
+assert index < 0 : "FAILURE! The key 'myKey' has not been replaced during 
filtering";
+index = contents.indexOf( "myValue" );
+assert index >= 0 : "FAILURE! The value 'myValue' has not been injected during 
filtering";
+is.close();
+
+jarFile.close();
 
 return true;
diff --git a/src/it/mejb-34-not-filtered/verify.groovy 
b/src/it/mejb-34-not-filtered/verify.groovy
index c7ab21d..5d7de7c 100644
--- a/src/it/mejb-34-not-filtered/verify.groovy
+++ b/src/it/mejb-34-not-filtered/verify.groovy
@@ -17,56 +17,26 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 import java.util.zip.ZipEntry;
-import org.codehaus.plexus.util.IOUtil;
 
-try
-{
-    File file = new File( basedir, "target/mejb-34-not-filtered-1.0.jar" );
-    System.out.println( "Checking for existence of " + file );
-    if ( !file.isFile() )
-    {
-        System.out.println( "FAILURE! Missing JAR file" );
-        return false;
-    }
+File file = new File( basedir, "target/mejb-34-not-filtered-1.0.jar" );
+System.out.println( "Checking for existence of " + file );
+assert file.isFile() : "FAILURE! Missing JAR file";
 
-    JarFile jarFile = new JarFile( file );
+JarFile jarFile = new JarFile( file );
 
-    ZipEntry zipEntry = jarFile.getEntry( "META-INF/ejb-jar.xml" );
-    if ( zipEntry == null )
-    {
-        System.out.println( "FAILURE! Missing META-INF/ejb-jar.xml in the JAR 
file" );
-        return false;
-    }
-    else
-    {
-        InputStream is = jarFile.getInputStream( zipEntry );
-        String contents = IOUtil.toString ( is, "UTF-8" );
-        int index = contents.indexOf( "myKey" );
-        if ( index < 0 )
-        {
-            System.out.println( "FAILURE! The key 'myKey' has been replaced, 
but filtering is turned off" );
-            return false;
-        }
-        index = contents.indexOf( "myValue" );
-        if ( index >= 0 )
-        {
-            System.out.println( "FAILURE! The value 'myValue' has been 
injected, but filtering is turned off" );
-            return false;
-        }
-        is.close();
-    }
+ZipEntry zipEntry = jarFile.getEntry( "META-INF/ejb-jar.xml" );
+assert zipEntry != null : "FAILURE! Missing META-INF/ejb-jar.xml in the JAR 
file";
 
-    jarFile.close();
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
+InputStream is = jarFile.getInputStream( zipEntry );
+String contents = is.getText( 'UTF-8' );
+int index = contents.indexOf( "myKey" );
+assert index >= 0 : "FAILURE! The key 'myKey' has been replaced, but filtering 
is turned off";
+index = contents.indexOf( "myValue" );
+assert index < 0 : "FAILURE! The value 'myValue' has been injected, but 
filtering is turned off";
+is.close();
+
+jarFile.close();
 
 return true;
diff --git a/src/it/mejb-93/verify.groovy b/src/it/mejb-93/verify.groovy
index 25cb297..3f93cab 100644
--- a/src/it/mejb-93/verify.groovy
+++ b/src/it/mejb-93/verify.groovy
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-import java.io.*
-import java.util.*
 import groovy.xml.XmlSlurper
 
 /**
@@ -45,28 +43,13 @@ println "ProjectVersion:" + projectVersion
 
 
 def jarFile = new File( basedir, "target/maven-it-mejb93-1.0.jar" )
-if ( !jarFile.isFile() )
-{
-    println ( "FAILURE!" )
-    return false
-}
+assert jarFile.isFile()
 
 def buildLog = new File( basedir, "build.log" ).getText('UTF-8')
 
-if (!buildLog.contains ('' + projectVersion + ':ejb (default-ejb) @ 
maven-it-mejb93 ---')) {
-  println ( "default executions did not happen.")
-  return false
-}
-if (!buildLog.contains ('' + projectVersion + ':ejb (second-execution) @ 
maven-it-mejb93 ---')) {
-  println ( "second executions did not happen.")
-  return false
-}
-if (!buildLog.contains ('[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-ejb-plugin:' + projectVersion
+assert buildLog.contains ('' + projectVersion + ':ejb (default-ejb) @ 
maven-it-mejb93 ---') : "default executions did not happen."
+assert buildLog.contains ('' + projectVersion + ':ejb (second-execution) @ 
maven-it-mejb93 ---') : "second executions did not happen."
+assert buildLog.contains ('[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-ejb-plugin:' + projectVersion
     + ':ejb (second-execution) on project maven-it-mejb93: '
     + 'You have to use a classifier to attach supplemental artifacts to the '
-    + 'project instead of replacing them. -> [Help 1]')) {
-  println ( "exception message does not exists or the expected content does 
not exist.")
-  return false
-}
-
-return true;
+    + 'project instead of replacing them. -> [Help 1]') : "exception message 
does not exists or the expected content does not exist."
diff --git a/src/it/reactor/verify.groovy b/src/it/reactor/verify.groovy
index d9bcae4..fe55e95 100644
--- a/src/it/reactor/verify.groovy
+++ b/src/it/reactor/verify.groovy
@@ -17,17 +17,11 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
 import java.util.jar.*;
-import java.util.regex.*;
 
 File jarFile = new File( basedir, "sub/target/sub-1.0.jar" );
 System.out.println( "Checking for existence of " + jarFile );
-if ( !jarFile.isFile() )
-{
-    throw new Exception( "Missing " + jarFile );
-}
+assert jarFile.isFile() : "Missing " + jarFile;
 
 JarFile jar = new JarFile( jarFile );
 

Reply via email to