bogthe commented on a change in pull request #3101:
URL: https://github.com/apache/hadoop/pull/3101#discussion_r671298384



##########
File path: 
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ACopyFromLocalFile.java
##########
@@ -41,121 +36,33 @@
  * Some of the tests have been disabled pending a fix for HADOOP-15932 and
  * recursive directory copying; the test cases themselves may be obsolete.
  */
-public class ITestS3ACopyFromLocalFile extends AbstractS3ATestBase {
-  private static final Charset ASCII = StandardCharsets.US_ASCII;
-
-  private File file;
+public class ITestS3ACopyFromLocalFile extends
+        AbstractContractCopyFromLocalTest {
 
   @Override
-  public void teardown() throws Exception {
-    super.teardown();
-    if (file != null) {
-      file.delete();
-    }
-  }
-
-  @Test
-  public void testCopyEmptyFile() throws Throwable {
-    file = File.createTempFile("test", ".txt");
-    Path dest = upload(file, true);
-    assertPathExists("uploaded file", dest);
+  protected AbstractFSContract createContract(Configuration conf) {
+    return new S3AContract(conf);
   }
 
   @Test
-  public void testCopyFile() throws Throwable {
-    String message = "hello";
-    file = createTempFile(message);
-    Path dest = upload(file, true);
-    assertPathExists("uploaded file not found", dest);
-    S3AFileSystem fs = getFileSystem();
-    FileStatus status = fs.getFileStatus(dest);
-    assertEquals("File length of " + status,
-        message.getBytes(ASCII).length, status.getLen());
-    assertFileTextEquals(dest, message);
-  }
-
-  public void assertFileTextEquals(Path path, String expected)
-      throws IOException {
-    assertEquals("Wrong data in " + path,
-        expected, IOUtils.toString(getFileSystem().open(path), ASCII));
-  }
-
-  @Test
-  public void testCopyFileNoOverwrite() throws Throwable {
-    file = createTempFile("hello");
-    Path dest = upload(file, true);
-    // HADOOP-15932: the exception type changes here
-    intercept(PathExistsException.class,
-        () -> upload(file, false));
-  }
-
-  @Test
-  public void testCopyFileOverwrite() throws Throwable {
-    file = createTempFile("hello");
-    Path dest = upload(file, true);
-    String updated = "updated";
-    FileUtils.write(file, updated, ASCII);
-    upload(file, true);
-    assertFileTextEquals(dest, updated);
-  }
-
-  @Test
-  @Ignore("HADOOP-15932")
-  public void testCopyFileNoOverwriteDirectory() throws Throwable {
-    file = createTempFile("hello");
-    Path dest = upload(file, true);
-    S3AFileSystem fs = getFileSystem();
-    fs.delete(dest, false);
-    fs.mkdirs(dest);
-    intercept(FileAlreadyExistsException.class,
-        () -> upload(file, true));
-  }
-
-  @Test
-  public void testCopyMissingFile() throws Throwable {
-    file = File.createTempFile("test", ".txt");
-    file.delete();
-    // first upload to create
-    intercept(FileNotFoundException.class, "",
-        () -> upload(file, true));
-  }
+  public void testLocalFilesOnly() throws Throwable {
+    Path dst = fileToPath(createTempDirectory("someDir"));
 
-  @Test
-  @Ignore("HADOOP-15932")
-  public void testCopyDirectoryFile() throws Throwable {
-    file = File.createTempFile("test", ".txt");
-    // first upload to create
-    intercept(FileNotFoundException.class, "Not a file",
-        () -> upload(file.getParentFile(), true));
+    intercept(IllegalArgumentException.class,
+        () -> getFileSystem().copyFromLocalFile(false, true, dst, dst));
   }
 
-
   @Test
-  public void testLocalFilesOnly() throws Throwable {
-    Path dst = path("testLocalFilesOnly");
-    intercept(IllegalArgumentException.class,
-        () -> {
-          getFileSystem().copyFromLocalFile(false, true, dst, dst);
-          return "copy successful";
-        });
-  }
+  public void testSourceIsDirectoryAndDestinationIsFile() throws Throwable {

Review comment:
       No reason, just forgot. Moved now!




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to