InstrumentHsqldbManagerFactory.class.getName()); clearDir(TABLE_NAME); createIdTable(TABLE_NAME, 0); List<String> args = new ArrayList<String>(); args.add("--connect");
@Test public void testTableNameWithSpecialCharacters() throws Exception { // Table name with special characters to verify proper table name escaping final String TABLE_NAME = "my-table.ext"; createIdTable(TABLE_NAME, 0); // Now add some rows. insertIdRows(TABLE_NAME, 0, 10); List<String> args = getArgListForTable(TABLE_NAME, false, true); createJob("emptyJob", args); runJob("emptyJob"); assertDirOfNumbers(TABLE_NAME, 10); }
@Test public void testFullAppendImport() throws Exception { final String TABLE_NAME = "fullAppend1"; createIdTable(TABLE_NAME, 10); List<String> args = getArgListForTable(TABLE_NAME, true, true); Configuration conf = newConf(); SqoopOptions options = new SqoopOptions(); options.setConf(conf); runImport(options, args); assertDirOfNumbers(TABLE_NAME, 10); }
@Test public void testEmptyAppendImport() throws Exception { final String TABLE_NAME = "emptyAppend1"; createIdTable(TABLE_NAME, 0); List<String> args = getArgListForTable(TABLE_NAME, true, true); Configuration conf = newConf(); SqoopOptions options = new SqoopOptions(); options.setConf(conf); runImport(options, args); assertDirOfNumbers(TABLE_NAME, 0); }
@Test public void testEmptyJobAppend() throws Exception { // Create a job and run an import on an empty table. // Nothing should happen. final String TABLE_NAME = "emptyJob"; createIdTable(TABLE_NAME, 0); List<String> args = getArgListForTable(TABLE_NAME, false, true); createJob("emptyJob", args); runJob("emptyJob"); assertDirOfNumbers(TABLE_NAME, 0); // Running the job a second time should result in // nothing happening, it's still empty. runJob("emptyJob"); assertDirOfNumbers(TABLE_NAME, 0); }
@Test public void testAppend() throws Exception { // Create a table with data in it; import it. // Then add more data, verify that only the incremental data is pulled. final String TABLE_NAME = "append"; createIdTable(TABLE_NAME, 10); List<String> args = getArgListForTable(TABLE_NAME, false, true); createJob(TABLE_NAME, args); runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 10); // Add some more rows. insertIdRows(TABLE_NAME, 10, 20); // Import only those rows. runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 20); }
@Test public void testEmptyThenFullJobAppend() throws Exception { // Create an empty table. Import it; nothing happens. // Add some rows. Verify they are appended. final String TABLE_NAME = "emptyThenFull"; createIdTable(TABLE_NAME, 0); List<String> args = getArgListForTable(TABLE_NAME, false, true); createJob(TABLE_NAME, args); runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 0); // Now add some rows. insertIdRows(TABLE_NAME, 0, 10); // Running the job a second time should import 10 rows. runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 10); // Add some more rows. insertIdRows(TABLE_NAME, 10, 20); // Import only those rows. runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 20); }
@Test public void testEmptyThenFullJobAppendWithQuery() throws Exception { // Create an empty table. Import it; nothing happens. // Add some rows. Verify they are appended. final String TABLE_NAME = "withQuery"; createIdTable(TABLE_NAME, 0); clearDir(TABLE_NAME); final String QUERY = "SELECT id FROM \"withQuery\" WHERE $CONDITIONS"; List<String> args = getArgListForQuery(QUERY, TABLE_NAME, false, true, false); createJob(TABLE_NAME, args); runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 0); // Now add some rows. insertIdRows(TABLE_NAME, 0, 10); // Running the job a second time should import 10 rows. runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 10); // Add some more rows. insertIdRows(TABLE_NAME, 10, 20); // Import only those rows. runJob(TABLE_NAME); assertDirOfNumbers(TABLE_NAME, 20); }