This is an automated email from the ASF dual-hosted git repository.

yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new cb9daa6c227 [MINOR] Improve TestHoodieHadoopIOFactory (#11342)
cb9daa6c227 is described below

commit cb9daa6c227dc42415aee71db0499935db4e1599
Author: Y Ethan Guo <[email protected]>
AuthorDate: Tue May 28 15:07:02 2024 -0700

    [MINOR] Improve TestHoodieHadoopIOFactory (#11342)
---
 .../hudi/io/hadoop/TestHoodieHadoopIOFactory.java  | 37 ++++++++++++----------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git 
a/hudi-hadoop-common/src/test/java/org/apache/hudi/io/hadoop/TestHoodieHadoopIOFactory.java
 
b/hudi-hadoop-common/src/test/java/org/apache/hudi/io/hadoop/TestHoodieHadoopIOFactory.java
index 86341b3c963..7aaf811e737 100644
--- 
a/hudi-hadoop-common/src/test/java/org/apache/hudi/io/hadoop/TestHoodieHadoopIOFactory.java
+++ 
b/hudi-hadoop-common/src/test/java/org/apache/hudi/io/hadoop/TestHoodieHadoopIOFactory.java
@@ -25,11 +25,14 @@ import org.apache.hudi.common.util.OrcUtils;
 import org.apache.hudi.common.util.ParquetUtils;
 import org.apache.hudi.hadoop.fs.HadoopFSUtils;
 import org.apache.hudi.io.storage.HoodieIOFactory;
+import org.apache.hudi.storage.HoodieStorage;
 import org.apache.hudi.storage.StoragePath;
 import org.apache.hudi.storage.hadoop.HoodieHadoopStorage;
 
 import org.junit.jupiter.api.Test;
 
+import java.io.IOException;
+
 import static 
org.apache.hudi.common.testutils.HoodieTestUtils.getDefaultStorageConf;
 import static org.apache.hudi.storage.HoodieStorageUtils.DEFAULT_URI;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -41,21 +44,23 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
  */
 public class TestHoodieHadoopIOFactory {
   @Test
-  public void testGetFileFormatUtils() {
-    HoodieIOFactory ioFactory = new HoodieHadoopIOFactory(
-        new HoodieHadoopStorage(HadoopFSUtils.getFs(DEFAULT_URI, 
getDefaultStorageConf())));
-    assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.parquet")) instanceof ParquetUtils);
-    assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.orc")) instanceof OrcUtils);
-    assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.hfile")) instanceof HFileUtils);
-    assertThrows(
-        UnsupportedOperationException.class,
-        () -> ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.log")));
-
-    assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.PARQUET) 
instanceof ParquetUtils);
-    assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.ORC) instanceof 
OrcUtils);
-    assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.HFILE) instanceof 
HFileUtils);
-    assertThrows(
-        UnsupportedOperationException.class,
-        () -> ioFactory.getFileFormatUtils(HoodieFileFormat.HOODIE_LOG));
+  public void testGetFileFormatUtils() throws IOException {
+    try (HoodieStorage storage =
+             new HoodieHadoopStorage(HadoopFSUtils.getFs(DEFAULT_URI, 
getDefaultStorageConf()))) {
+      HoodieIOFactory ioFactory = new HoodieHadoopIOFactory(storage);
+      assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.parquet")) instanceof ParquetUtils);
+      assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.orc")) instanceof OrcUtils);
+      assertTrue(ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.hfile")) instanceof HFileUtils);
+      assertThrows(
+          UnsupportedOperationException.class,
+          () -> ioFactory.getFileFormatUtils(new 
StoragePath("file:///a/b.log")));
+
+      assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.PARQUET) 
instanceof ParquetUtils);
+      assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.ORC) instanceof 
OrcUtils);
+      assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.HFILE) 
instanceof HFileUtils);
+      assertThrows(
+          UnsupportedOperationException.class,
+          () -> ioFactory.getFileFormatUtils(HoodieFileFormat.HOODIE_LOG));
+    }
   }
 }

Reply via email to