hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject svn commit: r1587759 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java
Date Wed, 16 Apr 2014 00:05:45 GMT
Author: cnauroth
Date: Wed Apr 16 00:05:45 2014
New Revision: 1587759

URL: http://svn.apache.org/r1587759
Log:
HDFS-5409. TestOfflineEditsViewer#testStored fails on Windows due to CRLF line endings in
editsStored.xml from git checkout. Contributed by Chris Nauroth.

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1587759&r1=1587758&r2=1587759&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Wed Apr 16 00:05:45 2014
@@ -349,6 +349,9 @@ Release 2.5.0 - UNRELEASED
     HDFS-6243. HA NameNode transition to active or shutdown may leave lingering
     image transfer thread. (cnauroth)
 
+    HDFS-5409. TestOfflineEditsViewer#testStored fails on Windows due to CRLF
+    line endings in editsStored.xml from git checkout. (cnauroth)
+
 Release 2.4.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java?rev=1587759&r1=1587758&r2=1587759&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TestOfflineEditsViewer.java
Wed Apr 16 00:05:45 2014
@@ -21,11 +21,13 @@ package org.apache.hadoop.hdfs.tools.off
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hdfs.DFSTestUtil;
@@ -166,7 +168,8 @@ public class TestOfflineEditsViewer {
     assertTrue("Edits " + editsStored + " should have all op codes",
         hasAllOpCodes(editsStored));
     assertTrue("Reference XML edits and parsed to XML should be same",
-        filesEqual(editsStoredXml, editsStoredParsedXml));
+        FileUtils.contentEqualsIgnoreEOL(new File(editsStoredXml),
+          new File(editsStoredParsedXml), "UTF-8"));
     assertTrue(
         "Reference edits and reparsed (bin to XML to bin) should be same",
         filesEqualIgnoreTrailingZeros(editsStored, editsStoredReparsed));
@@ -270,26 +273,4 @@ public class TestOfflineEditsViewer {
 
     return true;
   }
-
-  /**
-   * Compare two files, throw exception is they are not same
-   *
-   * @param filename1 first file to compare
-   * @param filename2 second file to compare
-   */
-  private boolean filesEqual(String filename1,
-    String filename2) throws IOException {
-
-    // make file 1 the small one
-    ByteBuffer bb1 = ByteBuffer.wrap(DFSTestUtil.loadFile(filename1));
-    ByteBuffer bb2 = ByteBuffer.wrap(DFSTestUtil.loadFile(filename2));
-
-    // compare from 0 to capacity
-    bb1.position(0);
-    bb1.limit(bb1.capacity());
-    bb2.position(0);
-    bb2.limit(bb2.capacity());
-
-    return bb1.equals(bb2);
-  }
 }



Mime
View raw message