samredai commented on a change in pull request #3252:
URL: https://github.com/apache/iceberg/pull/3252#discussion_r725281115
##########
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:
This particular test was just to add some coverage generally to the
initialize method but you're right, I am missing coverage for the actual case
from that thread which was really the `toString()` method so I'll add a test
for that as well. Playing around with the 0.12.x branch and the master branch
(which has the NPE fix in), the root problem seems that `toString()` hits a NPE
before `setConf()` is called. In that thread the user was in a scala repl so
`toString()` was getting called and the following fails in `0.12.x` but works
after the NPE fix.
```java
HiveCatalog catalog = new HiveCatalog();
catalog.toString() // called by the scala repl, runs into NPE in 0.12.x
```
I thought maybe the user could do a one-liner to get the conf set before the
repl tries to print but `setConf()` doesn't return `this`. (Should it return
`this`?)
--
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]