jackye1995 commented on a change in pull request #2565:
URL: https://github.com/apache/iceberg/pull/2565#discussion_r629535089



##########
File path: mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java
##########
@@ -191,91 +191,103 @@ public void testCreateDropTableToCatalog() throws 
IOException {
   }
 
   @Test
-  public void testLoadCatalog() throws IOException {
-    conf.set(InputFormatConfig.CATALOG, Catalogs.LOCATION);
-    Assert.assertFalse(Catalogs.loadCatalog(conf, null).isPresent());
+  public void testLoadCatalog_legacy_default() {
+    Optional<Catalog> defaultCatalog = Catalogs.loadCatalog(conf, null);
+    Assert.assertTrue(defaultCatalog.isPresent());
+    Assert.assertTrue(defaultCatalog.get() instanceof HiveCatalog);
+  }
 
-    String nonExistentCatalogType = "fooType";
+  @Test
+  public void testLoadCatalog_legacy_hive() {
+    conf.set(InputFormatConfig.CATALOG, CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE);
+    Optional<Catalog> hiveCatalog = Catalogs.loadCatalog(conf, null);
+    Assert.assertTrue(hiveCatalog.isPresent());
+    Assert.assertTrue(hiveCatalog.get() instanceof HiveCatalog);
+  }
 
-    conf.set(InputFormatConfig.CATALOG, nonExistentCatalogType);
-    AssertHelpers.assertThrows(
-            "should complain about catalog not supported", 
UnsupportedOperationException.class,
-            "Unknown catalog type", () -> Catalogs.loadCatalog(conf, null));
+  @Test
+  public void testLoadCatalog_legacy_location() {
+    conf.set(InputFormatConfig.CATALOG, Catalogs.LOCATION);
+    Assert.assertFalse(Catalogs.loadCatalog(conf, null).isPresent());
+  }
 
+  @Test
+  public void testLoadCatalog_legacy_hadoop() {
     conf.set(InputFormatConfig.CATALOG, 
CatalogUtil.ICEBERG_CATALOG_TYPE_HADOOP);
     conf.set(InputFormatConfig.HADOOP_CATALOG_WAREHOUSE_LOCATION, 
"/tmp/mylocation");
     Optional<Catalog> hadoopCatalog = Catalogs.loadCatalog(conf, null);
-
     Assert.assertTrue(hadoopCatalog.isPresent());
     Assert.assertTrue(hadoopCatalog.get() instanceof HadoopCatalog);
+  }
 
-    conf.set(InputFormatConfig.CATALOG, CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE);
-    Optional<Catalog> hiveCatalog = Catalogs.loadCatalog(conf, null);
-
-    Assert.assertTrue(hiveCatalog.isPresent());
-    Assert.assertTrue(hiveCatalog.get() instanceof HiveCatalog);
-
-    conf.set(InputFormatConfig.CATALOG, Catalogs.LOCATION);
-    Assert.assertFalse(Catalogs.loadCatalog(conf, null).isPresent());
+  @Test
+  public void testLoadCatalog_legacy_unknown() {
+    conf.set(InputFormatConfig.CATALOG, "fooType");
+    AssertHelpers.assertThrows(
+            "should complain about catalog not supported", 
UnsupportedOperationException.class,
+            "Unknown catalog type", () -> Catalogs.loadCatalog(conf, null));
+  }
 
-    // arbitrary catalog name with non existent catalog type
+  @Test
+  public void testLoadCatalog_unknown() {
     String catalogName = "barCatalog";
-    conf.unset(InputFormatConfig.CATALOG);
-    conf.set(String.format(InputFormatConfig.CATALOG_TYPE_TEMPLATE, 
catalogName), nonExistentCatalogType);
+    conf.set(InputFormatConfig.catalogTypeConfigKey(catalogName), "fooType");
     AssertHelpers.assertThrows(
             "should complain about catalog not supported", 
UnsupportedOperationException.class,
             "Unknown catalog type:", () -> Catalogs.loadCatalog(conf, 
catalogName));
+  }
 
-    // arbitrary catalog name with hadoop catalog type and default warehouse 
location
-    conf.set(String.format(InputFormatConfig.CATALOG_TYPE_TEMPLATE, 
catalogName),
-            CatalogUtil.ICEBERG_CATALOG_TYPE_HADOOP);
-    hadoopCatalog = Catalogs.loadCatalog(conf, catalogName);
-
+  @Test
+  public void testLoadCatalog_hadoop_warehouseLocation() {

Review comment:
       will do




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



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

Reply via email to