steveloughran commented on a change in pull request #1388: HADOOP-16255. Add 
ChecksumFs.rename(path, path, boolean) to rename crc file as well when 
FileContext.rename(path, path, options) is called.
URL: https://github.com/apache/hadoop/pull/1388#discussion_r320397813
 
 

 ##########
 File path: 
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFs.java
 ##########
 @@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs;
+
+import java.io.IOException;
+import java.util.EnumSet;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.local.LocalFs;
+import org.apache.hadoop.fs.permission.FsPermission;
+import static org.apache.hadoop.fs.CreateFlag.*;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * This class tests the functionality of ChecksumFs.
+ */
+public class TestChecksumFs {
+  private Configuration conf;
+  private Path testRootDirPath;
+  private FileContext fc;
+
+  @Before
+  public void setUp() throws Exception {
+    conf = getTestConfiguration();
+    fc = FileContext.getFileContext(conf);
+    testRootDirPath = new Path(GenericTestUtils.getRandomizedTestDir()
+        .getAbsolutePath());
+    mkdirs(testRootDirPath);
+  }
+
+  public void tearDown() throws Exception {
+    fc.delete(testRootDirPath, true);
+  }
+
+  @Test
+  public void testRenameFileToFile() throws Exception {
+    Path srcPath = new Path(testRootDirPath, "testRenameSrc");
+    Path dstPath = new Path(testRootDirPath, "testRenameDst");
+    verifyRename(srcPath, dstPath, false);
+  }
+
+  @Test
+  public void testRenameFileToFileWithOverwrite() throws Exception {
+    Path srcPath = new Path(testRootDirPath, "testRenameSrc");
+    Path dstPath = new Path(testRootDirPath, "testRenameDst");
+    verifyRename(srcPath, dstPath, true);
+  }
+
+  @Test
+  public void testRenameFileIntoDirFile() throws Exception {
+    Path srcPath = new Path(testRootDirPath, "testRenameSrc");
+    Path dstPath = new Path(testRootDirPath, "testRenameDir/testRenameDst");
+    mkdirs(dstPath);
+    verifyRename(srcPath, dstPath, false);
+  }
+
+  @Test
+  public void testRenameFileIntoDirFileWithOverwrite() throws Exception {
+    Path srcPath = new Path(testRootDirPath, "testRenameSrc");
+    Path dstPath = new Path(testRootDirPath, "testRenameDir/testRenameDst");
+    mkdirs(dstPath);
+    verifyRename(srcPath, dstPath, true);
+  }
+
+  private void verifyRename(Path srcPath, Path dstPath,
+      boolean overwrite) throws Exception {
+    AbstractFileSystem fs = fc.getDefaultFileSystem();
+    assertTrue(fs instanceof LocalFs);
 
 Review comment:
   just cast it; you'll get a better stack trace that way

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to