@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 testImportToolHandlesAvroSchemaMismatchExceptionProperly() throws Exception { final String writtenWithSchemaString = "writtenWithSchema"; final String actualSchemaString = "actualSchema"; final String errorMessage = "Import failed"; doReturn(true).when(importToolSpy).init(any(SqoopOptions.class)); Schema writtenWithSchema = mock(Schema.class); when(writtenWithSchema.toString()).thenReturn(writtenWithSchemaString); Schema actualSchema = mock(Schema.class); when(actualSchema.toString()).thenReturn(actualSchemaString); AvroSchemaMismatchException expectedException = new AvroSchemaMismatchException(errorMessage, writtenWithSchema, actualSchema); doThrow(expectedException).when(importToolSpy).importTable(any(SqoopOptions.class)); SqoopOptions sqoopOptions = mock(SqoopOptions.class); when(sqoopOptions.doHiveImport()).thenReturn(true); logMessage.expectError(expectedException.getMessage()); int result = importToolSpy.run(sqoopOptions); assertEquals(1, result); }
@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); }