maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MENFORCER-317) RequireFileChecksum ignores configured message
Date Sat, 06 Oct 2018 10:23:00 GMT

    [ https://issues.apache.org/jira/browse/MENFORCER-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16640670#comment-16640670
] 

ASF GitHub Bot commented on MENFORCER-317:
------------------------------------------

khmarbaise closed pull request #40: MENFORCER-317 - Fix RequireFileChecksum ignores configured
message
URL: https://github.com/apache/maven-enforcer/pull/40
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java
b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java
index 1ab2aba..4ec1c54 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java
@@ -100,8 +100,13 @@ else if ( "sha512".equals( this.type ) )
             }
             if ( !checksum.equalsIgnoreCase( this.checksum ) )
             {
-                throw new EnforcerRuleException( this.type + " hash of " + this.file + "
was " + checksum
-                    + " but expected " + this.checksum );
+                String exceptionMessage = getMessage();
+                if ( exceptionMessage == null )
+                {
+                    exceptionMessage = this.type + " hash of " + this.file + " was " + checksum
+                        + " but expected " + this.checksum;
+                }
+                throw new EnforcerRuleException( exceptionMessage );
             }
         }
         catch ( IOException e )
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFileChecksum.java
b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFileChecksum.java
index 4333cb3..3f8ed9b 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFileChecksum.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFileChecksum.java
@@ -175,6 +175,25 @@ public void testFileChecksumMd5ChecksumMismatchFailure()
         rule.execute( EnforcerTestUtils.getHelper() );
     }
 
+    @Test
+    public void testFileChecksumMd5ChecksumMismatchFailureWithMessage()
+        throws IOException, EnforcerRuleException
+    {
+        File f = temporaryFolder.newFile();
+        FileUtils.fileWrite( f, "message" );
+        String configuredMessage = "testMessage";
+
+        expectedException.expect( EnforcerRuleException.class );
+        expectedException.expectMessage( configuredMessage );
+
+        rule.setFile( f );
+        rule.setChecksum( "ffeeddccbbaa99887766554433221100" );
+        rule.setType( "md5" );
+        rule.setMessage( configuredMessage );
+
+        rule.execute( EnforcerTestUtils.getHelper() );
+    }
+
     @Test
     public void testFileChecksumSha1()
         throws IOException, EnforcerRuleException


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> RequireFileChecksum ignores configured message
> ----------------------------------------------
>
>                 Key: MENFORCER-317
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-317
>             Project: Maven Enforcer Plugin
>          Issue Type: Bug
>          Components: Standard Rules
>    Affects Versions: 3.0.0-M2
>            Reporter: Falko Modler
>            Assignee: Karl Heinz Marbaise
>            Priority: Major
>              Labels: up-for-grabs
>             Fix For: 3.0.0
>
>
> The [documentation for RequireFileChecksum |https://maven.apache.org/enforcer/enforcer-rules/requireFileChecksum.html]
says, that you can set a {{message}} that is used for a violation message.
> However, this configuable attribute coming from {{AbstractStandardEnforcerRule}} is simply
ignored/not evaluated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message