### Question:
HiveCatalogFactory implements CatalogFactory { @Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); }  @Override Map<String, String> requiredContext(); @Override List<String> supportedProperties(); @Override Catalog createCatalog(String name, Map<String, String> properties);  }### Answer:
@Test public void test() { final String catalogName = "mycatalog"; final HiveCatalog expectedCatalog = HiveTestUtils.createHiveCatalog(catalogName, null); final CatalogDescriptor catalogDescriptor = new HiveCatalogDescriptor(); final Map<String, String> properties = catalogDescriptor.toProperties(); final Catalog actualCatalog = TableFactoryService.find(CatalogFactory.class, properties) .createCatalog(catalogName, properties); checkEquals(expectedCatalog, (HiveCatalog) actualCatalog); }
@Test public void testLoadHDFSConfigFromEnv() throws IOException { final String k1 = "what is connector?"; final String v1 = "Hive"; final String catalogName = "HiveCatalog"; final File hadoopConfDir = tempFolder.newFolder(); final File hdfsSiteFile = new File(hadoopConfDir, "hdfs-site.xml"); writeProperty(hdfsSiteFile, k1, v1); final Map<String, String> originalEnv = System.getenv(); final Map<String, String> newEnv = new HashMap<>(originalEnv); newEnv.put("HADOOP_CONF_DIR", hadoopConfDir.getAbsolutePath()); CommonTestUtils.setEnv(newEnv); final CatalogDescriptor catalogDescriptor = new HiveCatalogDescriptor(); final Map<String, String> properties = catalogDescriptor.toProperties(); final HiveConf hiveConf; try { final HiveCatalog hiveCatalog = (HiveCatalog) TableFactoryService.find(CatalogFactory.class, properties) .createCatalog(catalogName, properties); hiveConf = hiveCatalog.getHiveConf(); } finally { CommonTestUtils.setEnv(originalEnv); } assertEquals(v1, hiveConf.get(k1, null)); }