elharo commented on a change in pull request #9: URL: https://github.com/apache/maven-verifier/pull/9#discussion_r821702522
########## File path: src/main/java/org/apache/maven/it/Verifier.java ########## @@ -1007,11 +1007,22 @@ public Properties newDefaultFilterProperties() return filterProperties; } + public void verifyFilePresent( String file ) throws VerificationException + { + verifyFilePresence( file, true ); + } + + /** + * + * @param file Review comment: document or remove the comment ########## File path: src/main/java/org/apache/maven/it/Verifier.java ########## @@ -1025,30 +1036,63 @@ public void assertFilePresent( String file ) * * @param file the file to check. * @param regex a regular expression. + * @throws VerificationException * @see Pattern */ - public void assertFileMatches( String file, String regex ) + public void verifyFileContentMatches( String file, String regex ) throws VerificationException { - assertFilePresent( file ); + verifyFilePresent( file ); try { String content = FileUtils.fileRead( file ); if ( !Pattern.matches( regex, content ) ) { - Assert.fail( "Content of " + file + " does not match " + regex ); + throw new VerificationException( "Content of " + file + " does not match " + regex ); } } catch ( IOException e ) + { + throw new VerificationException( "Could not read from " + file + ":" + e.getMessage(), e ); + } + } + + /** + * Check that given file's content matches an regular expression. Note this method also checks that the file exists + * and is readable. + * + * @param file the file to check. Review comment: nit: no period at end of doc comments that are not complete sentecnes per Oracle guidelines ########## File path: src/main/java/org/apache/maven/it/Verifier.java ########## @@ -1025,30 +1036,63 @@ public void assertFilePresent( String file ) * * @param file the file to check. * @param regex a regular expression. + * @throws VerificationException * @see Pattern */ - public void assertFileMatches( String file, String regex ) + public void verifyFileContentMatches( String file, String regex ) throws VerificationException { - assertFilePresent( file ); + verifyFilePresent( file ); try { String content = FileUtils.fileRead( file ); if ( !Pattern.matches( regex, content ) ) { - Assert.fail( "Content of " + file + " does not match " + regex ); + throw new VerificationException( "Content of " + file + " does not match " + regex ); } } catch ( IOException e ) + { + throw new VerificationException( "Could not read from " + file + ":" + e.getMessage(), e ); + } + } + + /** + * Check that given file's content matches an regular expression. Note this method also checks that the file exists + * and is readable. + * + * @param file the file to check. + * @param regex a regular expression. + * @see Pattern + * @deprecated Use {@link #verifyFileContentMatches(String, String)} instead. + */ + @Deprecated + public void assertFileMatches( String file, String regex ) + { + try + { + verifyFileContentMatches( file, regex ); + } + catch ( VerificationException e ) { Assert.fail( e.getMessage() ); } } + public void verifyFileNotPresent( String file ) throws VerificationException + { + verifyFilePresence( file, false ); + } + + /** + * + * @param file Review comment: document or remove the comment ########## File path: src/main/java/org/apache/maven/it/Verifier.java ########## @@ -1057,31 +1101,67 @@ public void assertFileNotPresent( String file ) } private void verifyArtifactPresence( boolean wanted, String org, String name, String version, String ext ) + throws VerificationException { List<String> files = getArtifactFileNameList( org, name, version, ext ); for ( String fileName : files ) { - try - { - verifyExpectedResult( fileName, wanted ); - } - catch ( VerificationException e ) - { - Assert.fail( e.getMessage() ); - } + verifyFilePresence( fileName, wanted ); } } - public void assertArtifactPresent( String org, String name, String version, String ext ) + public void verifyArtifactPresent( String org, String name, String version, String ext ) + throws VerificationException { verifyArtifactPresence( true, org, name, version, ext ); } - public void assertArtifactNotPresent( String org, String name, String version, String ext ) + public void verifyArtifactNotPresent( String org, String name, String version, String ext ) + throws VerificationException { verifyArtifactPresence( false, org, name, version, ext ); } + private void assertArtifactPresence( boolean wanted, String org, String name, String version, String ext ) + { + try + { + verifyArtifactPresence( wanted, org, name, version, ext ); + } + catch ( VerificationException e ) + { + Assert.fail( e.getMessage() ); + } + } + + /** + * + * @param org Review comment: document or remove the comment ########## File path: src/main/java/org/apache/maven/it/Verifier.java ########## @@ -1025,30 +1036,63 @@ public void assertFilePresent( String file ) * * @param file the file to check. * @param regex a regular expression. + * @throws VerificationException Review comment: document -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org