Hadoop Common
  1. Hadoop Common
  2. HADOOP-6479

TestUTF8 assertions could fail with better text

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.22.0
    • Fix Version/s: 0.21.0
    • Component/s: test
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      My HADOOP-6220 patch failed on Hudson with an error TestUTF8, but not one that is in any way useful:

      Error Message: null
      
      Stacktrace:
      
      junit.framework.AssertionFailedError: null
      	at org.apache.hadoop.io.TestUTF8.testIO(TestUTF8.java:80)
      

      The tests should use better assertions for easier diagnostics

        Activity

        Hide
        steve_l added a comment -

        This patch uses assertEquals() over assertTrue(before.equals(afterX)); should be more meaningful

        Show
        steve_l added a comment - This patch uses assertEquals() over assertTrue(before.equals(afterX)) ; should be more meaningful
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12429528/HADOOP-6479.patch
        against trunk revision 896259.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/testReport/
        Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/artifact/trunk/build/test/checkstyle-errors.html
        Console output: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12429528/HADOOP-6479.patch against trunk revision 896259. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/testReport/ Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/artifact/trunk/build/test/checkstyle-errors.html Console output: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-h4.grid.sp2.yahoo.net/257/console This message is automatically generated.
        Hide
        Tom White added a comment -

        I've just committed this. Thanks Steve!

        Show
        Tom White added a comment - I've just committed this. Thanks Steve!
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Common-trunk-Commit #136 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Common-trunk-Commit/136/)
        . TestUTF8 assertions could fail with better text. Contributed by Steve Loughran.

        Show
        Hudson added a comment - Integrated in Hadoop-Common-trunk-Commit #136 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Common-trunk-Commit/136/ ) . TestUTF8 assertions could fail with better text. Contributed by Steve Loughran.
        Hide
        Konstantin Boudnik added a comment -

        I think it could've been using some descriptive message to indicate the cause of the failure.

        Show
        Konstantin Boudnik added a comment - I think it could've been using some descriptive message to indicate the cause of the failure.
        Hide
        steve_l added a comment -

        @Konstantin, assertEquals() automatically generates a descriptive message in the cause of failure, even if you don't include a message

        	public static String format(String message, Object expected, Object actual) {
        		String formatted= "";
        		if (message != null)
        			formatted= message+" ";
        		return formatted+"expected:<"+expected+"> but was:<"+actual+">";
        	}
        

        That's why it's nice, it gives you the expected and actual. You just need to remember to put the expected first in the assertion or it gets confusing

        Show
        steve_l added a comment - @Konstantin, assertEquals() automatically generates a descriptive message in the cause of failure, even if you don't include a message public static String format( String message, Object expected, Object actual) { String formatted= ""; if (message != null ) formatted= message+ " " ; return formatted+ "expected:<" +expected+ "> but was:<" +actual+ ">" ; } That's why it's nice, it gives you the expected and actual. You just need to remember to put the expected first in the assertion or it gets confusing
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Common-trunk #211 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Common-trunk/211/)
        . TestUTF8 assertions could fail with better text. Contributed by Steve Loughran.

        Show
        Hudson added a comment - Integrated in Hadoop-Common-trunk #211 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Common-trunk/211/ ) . TestUTF8 assertions could fail with better text. Contributed by Steve Loughran.

          People

          • Assignee:
            Steve Loughran
            Reporter:
            Steve Loughran
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development