private void expectExceptionInCharCode(int charCode) { thrown.expect(IllegalArgumentException.class); thrown.reportMissingExceptionWithMessage("Expected IllegalArgumentException with out-of-range Hive delimiter"); TableDefWriter.getHiveOctalCharCode(charCode); }
@Test public void testUnrecognizedCodec() throws UnsupportedCodecException { thrown.expect(UnsupportedCodecException.class); thrown.reportMissingExceptionWithMessage("Expected UnsupportedCodecException with invalid codec name"); CodecMap.getCodec("bogus", new Configuration()); }
/** test invalid argument exception if several output options. */ @Test public void testSeveralOutputsIOException() throws IOException { ArrayList args = getOutputArgv(true); args.add("--warehouse-dir"); args.add(getWarehouseDir()); args.add("--target-dir"); args.add(getWarehouseDir()); String[] argv = (String[]) args.toArray(new String[0]); thrown.expect(IOException.class); thrown.reportMissingExceptionWithMessage("Expected IOException on several output options"); runImport(argv); }
@Test public void testEmptyString() throws Exception { thrown.expect(SqoopOptions.InvalidOptionsException.class); thrown.reportMissingExceptionWithMessage("Expected InvalidOptionsException on empty string"); SqoopOptions.toChar(""); }
@Test public void testUnknownEscape1() throws Exception { thrown.expect(SqoopOptions.InvalidOptionsException.class); thrown.reportMissingExceptionWithMessage("Expected InvalidOptionsException on unknown escaping"); SqoopOptions.toChar("\\Q"); }
@Override @Test public void testMultiMapTextExportWithStaging() throws IOException, SQLException { thrown.expect(IOException.class); thrown.reportMissingExceptionWithMessage("Expected IOException as staging tables are not compatible with --call"); super.testMultiMapTextExportWithStaging(); }
@Override @Test public void testMultiTransactionWithStaging() throws IOException, SQLException { thrown.expect(IOException.class); thrown.reportMissingExceptionWithMessage("Expected IOException as staging tables are not compatible with --call"); super.testMultiTransactionWithStaging(); }
@Test public void testRestoreNonExistingJob() throws IOException { // Try to restore a job that doesn't exist. Watch it fail. thrown.expect(IOException.class); thrown.reportMissingExceptionWithMessage("Expected IOException since job doesn't exist"); storage.read("DoesNotExist"); }
@Test public void testErrOctalChar() throws Exception { thrown.expect(NumberFormatException.class); thrown.reportMissingExceptionWithMessage("Expected NumberFormatException on erroneous octal char"); SqoopOptions.toChar("\\095"); }
@Test public void testBadNumMappers1() throws Exception { String [] args = { "--num-mappers", "x", }; thrown.expect(SqoopOptions.InvalidOptionsException.class); thrown.reportMissingExceptionWithMessage("Expected InvalidOptionsException on invalid --num-mappers argument"); parse(args); }
@Test public void testErrHexChar() throws Exception { thrown.expect(NumberFormatException.class); thrown.reportMissingExceptionWithMessage("Expected NumberFormatException on erroneous hex char"); SqoopOptions.toChar("\\0x9K5"); }
@Test public void testResetToOneMapperAndSplitBy() throws Exception { String extraArgs[] = { "--autoreset-to-one-mapper", "--split-by", "col0", }; thrown.expect(SqoopOptions.InvalidOptionsException.class); thrown.reportMissingExceptionWithMessage("Expected Exception on incompatibility of " + "--autoreset-to-one-mapper and --split-by"); validateImportOptions(extraArgs); }
@Test public void testGetShortName() throws UnsupportedCodecException { verifyShortName("gzip", "org.apache.hadoop.io.compress.GzipCodec"); verifyShortName("default", "org.apache.hadoop.io.compress.DefaultCodec"); thrown.expect(UnsupportedCodecException.class); thrown.reportMissingExceptionWithMessage("Expected UnsupportedCodecException with invalid codec name during getting " + "short codec name"); verifyShortName("NONE", "bogus"); }
@Test public void testHBaseBulkLoadMissingHbaseTable() throws Exception { String [] extraArgs = { longArgument(BaseSqoopTool.HBASE_BULK_LOAD_ENABLED_ARG), longArgument(BaseSqoopTool.TARGET_DIR_ARG), "./test"}; thrown.expect(SqoopOptions.InvalidOptionsException.class); thrown.reportMissingExceptionWithMessage("Expected InvalidOptionsException because of missing --hbase-table"); validateImportOptions(extraArgs); }
@Test public void testRequiredQuotes3() throws RecordParser.ParseError { RecordParser parser = new RecordParser( new DelimiterSet(',', '\n', '\"', '\\', true)); thrown.expect(RecordParser.ParseError.class); thrown.reportMissingExceptionWithMessage("Expected ParseError for required quotes"); parser.parseRecord("field1,\"field2\""); }
@Test public void testRequiredQuotes4() throws RecordParser.ParseError { RecordParser parser = new RecordParser( new DelimiterSet(',', '\n', '\"', '\\', true)); thrown.expect(RecordParser.ParseError.class); thrown.reportMissingExceptionWithMessage("Expected ParseError for required quotes"); parser.parseRecord("field1,\"field2\"\n"); }
@Test public void testCompressedFile() throws Exception { // Test all the various compression codecs. // The following values for 'codec' should pass. runCompressedTest(null); runCompressedTest(CodecMap.NONE); runCompressedTest(CodecMap.DEFLATE); thrown.expect(UnsupportedCodecException.class); thrown.reportMissingExceptionWithMessage("Expected UnsupportedCodecException for lzo"); runCompressedTest(CodecMap.LZO); }
@Test public void testNull() throws RecordParser.ParseError { RecordParser parser = new RecordParser( new DelimiterSet(',', '\n', '\"', '\\', true)); String input = null; thrown.expect(RecordParser.ParseError.class); thrown.reportMissingExceptionWithMessage("Expected ParseError for null string"); parser.parseRecord(input); }
@Test public void testAvroWithUpsert() throws IOException, SQLException { String[] argv = { "--update-key", "ID", "--update-mode", "allowinsert" }; final int TOTAL_RECORDS = 2; // ColumnGenerator gen = colGenerator("100", // Schema.create(Schema.Type.STRING), null, "VARCHAR(64)"); createAvroFile(0, TOTAL_RECORDS); createTableWithInsert(); thrown.expect(Exception.class); thrown.reportMissingExceptionWithMessage("Expected Exception during Avro export with --update-mode"); runExport(getArgv(true, 10, 10, newStrArray(argv, "-m", "" + 1))); }
@Test public void testMissingParquetFields() throws IOException, SQLException { String[] argv = {}; final int TOTAL_RECORDS = 1; // null Parquet schema means don't create an Parquet field ColumnGenerator gen = colGenerator(null, null, null, "VARCHAR(64)"); createParquetFile(TOTAL_RECORDS, gen); createTable(gen); thrown.expect(Exception.class); thrown.reportMissingExceptionWithMessage("Expected Exception on missing Parquet fields"); runExport(getArgv(true, 10, 10, newStrArray(argv, "-m", "" + 1))); } }