@Test public void testCreateHiveClientCreatesHiveServer2ClientWhenHs2UrlIsProvided() throws Exception { when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); HiveClient hiveClient = hiveClientFactory.createHiveClient(sqoopOptions, connectionManager); assertThat(hiveClient, instanceOf(HiveServer2Client.class)); }
@Test public void testValidateOptionsSucceedsWhenHs2UrlIsUsedWithHiveImport() throws Exception { when(sqoopOptions.doHiveImport()).thenReturn(true); when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); sqoopTool.validateOptions(sqoopOptions); }
@Test public void testValidateOptionsSucceedsWhenHs2UrlIsUsedWithHiveImportAndHs2UserButWithoutHs2Keytab() throws Exception { when(sqoopOptions.doHiveImport()).thenReturn(true); when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); when(sqoopOptions.getHs2User()).thenReturn(TEST_HS2_URL); sqoopTool.validateOptions(sqoopOptions); }
@Test public void testValidateOptionsThrowsWhenHs2UrlIsUsedWithoutHiveImport() throws Exception { expectedException.expect(SqoopOptions.InvalidOptionsException.class); expectedException.expectMessage("The hs2-url option cannot be used without the hive-import option."); when(sqoopOptions.doHiveImport()).thenReturn(false); when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); sqoopTool.validateOptions(sqoopOptions); }
@Test public void testValidateOptionsThrowsWhenHs2UrlIsUsedWithHCatalogImport() throws Exception { expectedException.expect(SqoopOptions.InvalidOptionsException.class); expectedException.expectMessage("The hs2-url option cannot be used without the hive-import option."); when(sqoopOptions.getHCatTableName()).thenReturn(TEST_TABLE); when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); sqoopTool.validateOptions(sqoopOptions); }
@Test public void testCreateJdbcConnectionFactoryInitializesConnectionStringProperly() throws Exception { when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); HiveServer2ConnectionFactory connectionFactory = (HiveServer2ConnectionFactory) connectionFactoryInitializer.createJdbcConnectionFactory(sqoopOptions); assertEquals(TEST_HS2_URL, connectionFactory.getConnectionString()); }
@Test public void testCreateHiveClientInitializesHiveServer2ClientProperly() throws Exception { when(sqoopOptions.getHs2Url()).thenReturn(TEST_HS2_URL); when(connectionFactoryInitializer.createJdbcConnectionFactory(sqoopOptions)).thenReturn(jdbcConnectionFactory); HiveServer2Client hs2Client = (HiveServer2Client) hiveClientFactory.createHiveClient(sqoopOptions, connectionManager); softly.assertThat(hs2Client.getSqoopOptions()).isSameAs(sqoopOptions); softly.assertThat(hs2Client.getHs2ConnectionFactory()).isSameAs(jdbcConnectionFactory); softly.assertThat(hs2Client.getTableDefWriter().getOptions()).isSameAs(sqoopOptions); softly.assertThat(hs2Client.getTableDefWriter().getConnManager()).isSameAs(connectionManager); softly.assertThat(hs2Client.getTableDefWriter().getInputTableName()).isEqualTo(TEST_TABLE_NAME); softly.assertThat(hs2Client.getTableDefWriter().getOutputTableName()).isEqualTo(TEST_HIVE_TABLE_NAME); softly.assertThat(hs2Client.getTableDefWriter().getConfiguration()).isSameAs(configuration); softly.assertThat(hs2Client.getTableDefWriter().isCommentsEnabled()).isFalse(); softly.assertAll(); }