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-resources-plugin.git
commit bb98287068b1eb31b2f86b6e9e097f980a0a54e2 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 22:30:46 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/MRESOURCES-106/verify.groovy | 60 +++++++---------------------------- src/it/profile-override/verify.groovy | 43 ++++--------------------- 2 files changed, 18 insertions(+), 85 deletions(-) diff --git a/src/it/MRESOURCES-106/verify.groovy b/src/it/MRESOURCES-106/verify.groovy index 5f9e6b5..f02012f 100644 --- a/src/it/MRESOURCES-106/verify.groovy +++ b/src/it/MRESOURCES-106/verify.groovy @@ -18,56 +18,20 @@ * under the License. */ -import java.io.*; -import java.util.*; +File target = new File( basedir, "target" ); +assert target.isDirectory() : "target file is missing or a directory." -boolean result = true; +File someResource = new File( target, "/classes/filter.properties" ); +assert someResource.isFile() : "file.txt is missing or not a file." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } +Properties p = new Properties(); +someResource.withInputStream { p.load( it ) } - File someResource = new File( target, "/classes/filter.properties" ); - if ( !someResource.exists() || !someResource.isFile() ) - { - System.err.println( "file.txt is missing or not a file." ); - return false; - } +File f = new File( p.getProperty( "location" ) ); +assert f.exists() : "Property was not correctly filtered: " + f + "\n" + f.getAbsolutePath() - FileInputStream fis = new FileInputStream( someResource ); - Properties p = new Properties(); - p.load( fis ); +File filteredBasedir = new File( p.getProperty( "basedir" ) ); +assert filteredBasedir.exists() : "Property was not correctly filtered: " + filteredBasedir + "\n" + filteredBasedir.getAbsolutePath() - File f = new File( p.getProperty( "location" ) ); - if ( !f.exists() ) - { - System.err.println( "Property was not correctly filtered: " + f + "\n" + f.getAbsolutePath() ); - result = false; - } - - File basedir = new File( p.getProperty( "basedir" ) ); - if ( !basedir.exists() ) - { - System.err.println( "Property was not correctly filtered: " + basedir + "\n" + basedir.getAbsolutePath() ); - result = false; - } - - File expectedLocation = new File( basedir, "src/main/resources/file.txt" ); - if ( !expectedLocation.equals( f ) ) - { - System.err.println( "Files doesn't match:\n" + basedir + "\n" + expectedLocation ); - result = false; - } -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File expectedLocation = new File( filteredBasedir, "src/main/resources/file.txt" ); +assert expectedLocation.equals( f ) : "Files doesn't match:\n" + filteredBasedir + "\n" + expectedLocation diff --git a/src/it/profile-override/verify.groovy b/src/it/profile-override/verify.groovy index 79545d2..ebc9a58 100644 --- a/src/it/profile-override/verify.groovy +++ b/src/it/profile-override/verify.groovy @@ -18,43 +18,12 @@ * under the License. */ -import java.io.*; +File target = new File( basedir, "target" ); +assert target.isDirectory() : "target file is missing or a directory." -import org.codehaus.plexus.util.*; +File someResource = new File( target, "/classes/config.properties" ); +assert someResource.isFile() : "config.properties is missing or not a file." -boolean result = true; +String paramContent = someResource.getText( 'UTF-8' ); -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } - - File someResource = new File( target, "/classes/config.properties" ); - if ( !someResource.exists() || someResource.isDirectory() ) - { - System.err.println( "config.properties is missing or not a file." ); - return false; - } - - String paramContent = FileUtils.fileRead( someResource ); - - int indexOf = paramContent.indexOf( "env=production" ); - if ( indexOf < 0 ) - { - System.err.println( "config.properties not contains env=production" ); - return false; - } - - -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +assert paramContent.contains( "env=production" ) : "config.properties not contains env=production"
