rdblue commented on a change in pull request #3252:
URL: https://github.com/apache/iceberg/pull/3252#discussion_r725398020
##########
File path:
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
##########
@@ -118,6 +122,37 @@ public void testCreateTableWithCaching() throws Exception {
}
}
+ @Test
+ public void testNoArgConstructor() throws Exception {
+ Catalog catalog = new HiveCatalog();
+ }
+
+ @Test
+ public void testSetConf() throws Exception {
+ HiveCatalog catalog = new HiveCatalog();
+ Configuration hadoopConfiguration = new Configuration();
+ catalog.setConf(hadoopConfiguration);
+ }
+
+ @Test
+ public void testInitialize() throws Exception {
+
+ HiveCatalog catalog = Mockito.spy(HiveCatalog.class);
+ Configuration mockHadoopConfiguration = Mockito.mock(Configuration.class);
+ CachedClientPool mockCachedClientPool =
Mockito.mock(CachedClientPool.class);
+
+ Mockito.doNothing().when(catalog).setConf(any());
+ Mockito.doReturn(mockCachedClientPool).when(catalog)
+ .makeCachedClientPool(any(), any());
+ Mockito.doReturn("test").when(mockHadoopConfiguration).get(any());
+
+ catalog.setConf(mockHadoopConfiguration);
+ catalog.initialize("test", Collections.<String, String>emptyMap());
+
+ Mockito.verify(catalog, Mockito.times(1)).makeCachedClientPool(any(),
any());
+ Assert.assertEquals(catalog.name(), "test");
Review comment:
If your aim is just to make sure that catalog initialization succeeds
when `getConf` isn't called or when `getConf` and `initialize` are called in an
unexpected order, I'd recommend doing that more directly. Adding mocks is a lot
of work (and future maintenance) just to make sure `makeCachedClientPool` is
called.
Since this suite already has a Hive Metastore set up and a test that creates
a table, I think it makes more sense to go through different initialization
sequences and verify that the catalog still works. Something like this:
1. Expected sequence: `new HiveCatalog()`, `setConf`, and then `initialize`
2. Without config: `new HiveCatalog()` and `initialize`, where `uri` and
`warehouse` are passed in the property map
3. Without config: `new HiveCatalog()` and `initialize`, where `uri` and
`warehouse` are not passed (connect error?)
4. `setConf` last: `new HiveCatalog()`, `initialize`, and then `setConf`:
should this work? I think that it should reject calls to `setConf` after
initialization.
--
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]