SQOOP-3198: Fix DirectMySQLExportTest and OracleExportTest
(Szabolcs Vasas via Anna Szonyi)
diff --git a/src/test/com/cloudera/sqoop/TestExport.java b/src/test/com/cloudera/sqoop/TestExport.java
index 8b468c8..7948dae 100644
--- a/src/test/com/cloudera/sqoop/TestExport.java
+++ b/src/test/com/cloudera/sqoop/TestExport.java
@@ -124,6 +124,20 @@
String getType();
}
+ protected static class IntColumnGenerator implements ColumnGenerator {
+ public String getExportText(int rowNum) {
+ int day = rowNum + 1;
+ return String.valueOf(day);
+ }
+ public String getVerifyText(int rowNum) {
+ int day = rowNum + 1;
+ return String.valueOf(day);
+ }
+ public String getType() {
+ return "INT";
+ }
+ }
+
/**
* Create a data file that gets exported to the db.
* @param fileNum the number of the file (for multi-file export)
@@ -906,14 +920,14 @@
public void testLessColumnsInFileThanInTable() throws IOException, SQLException {
final int TOTAL_RECORDS = 10;
- ColumnGenerator genDate = getDateColumnGenerator();
+ ColumnGenerator genInteger = new IntColumnGenerator();
ColumnGenerator genTime = getTimeColumnGenerator();
- createTextFile(0, TOTAL_RECORDS, false, genDate);
- createTable(genDate, genTime);
+ createTextFile(0, TOTAL_RECORDS, false, genInteger);
+ createTable(genInteger, genTime);
runExport(getArgv(true, 10, 10));
verifyExport(TOTAL_RECORDS);
- assertColMinAndMax(forIdx(0), genDate);
+ assertColMinAndMax(forIdx(0), genInteger);
// test that the Time column is with NULL values
class NullColumnGenerator implements ColumnGenerator {
@@ -1045,21 +1059,6 @@
}
}
- // a normal string column
- class IntColumnGenerator implements ColumnGenerator {
- public String getExportText(int rowNum) {
- int day = rowNum + 1;
- return String.valueOf(day);
- }
- public String getVerifyText(int rowNum) {
- int day = rowNum + 1;
- return String.valueOf(day);
- }
- public String getType() {
- return "INT";
- }
- }
-
// test that the second column is with NULL values after import
class NullColumnGenerator implements ColumnGenerator {
public String getExportText(int rowNum) {
diff --git a/src/test/com/cloudera/sqoop/manager/DirectMySQLExportTest.java b/src/test/com/cloudera/sqoop/manager/DirectMySQLExportTest.java
index ec7b84a..9fa8816 100644
--- a/src/test/com/cloudera/sqoop/manager/DirectMySQLExportTest.java
+++ b/src/test/com/cloudera/sqoop/manager/DirectMySQLExportTest.java
@@ -38,6 +38,7 @@
import com.cloudera.sqoop.SqoopOptions;
import com.cloudera.sqoop.TestExport;
import com.cloudera.sqoop.mapreduce.MySQLExportMapper;
+import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -302,18 +303,30 @@
}
}
+ @Ignore("Ignoring this test as staging is not supported in direct mode.")
@Override
@Test
public void testMultiMapTextExportWithStaging()
throws IOException, SQLException {
- // disable this test as staging is not supported in direct mode
}
+ @Ignore("Ignoring this test as staging is not supported in direct mode.")
@Override
@Test
public void testMultiTransactionWithStaging()
throws IOException, SQLException {
- // disable this test as staging is not supported in direct mode
+ }
+
+ @Ignore("Ignoring this test as --input-null-non-string is not supported in direct mode.")
+ @Override
+ @Test
+ public void testLessColumnsInFileThanInTableInputNullIntPassed() throws IOException, SQLException {
+ }
+
+ @Ignore("Ignoring this test as --input-null-string is not supported in direct mode.")
+ @Override
+ @Test
+ public void testLessColumnsInFileThanInTableInputNullStringPassed() throws IOException, SQLException {
}
private void verifyTableColumnContents(Connection connection,
diff --git a/src/test/org/apache/sqoop/TestExportUsingProcedure.java b/src/test/org/apache/sqoop/TestExportUsingProcedure.java
index 68e79f1..1783676 100644
--- a/src/test/org/apache/sqoop/TestExportUsingProcedure.java
+++ b/src/test/org/apache/sqoop/TestExportUsingProcedure.java
@@ -343,11 +343,11 @@
* columns in the table.
*/
public static void insertFunctiontestLessColumnsInFileThanInTable(int id, String msg,
- final Date date1, final Timestamp t2) throws SQLException {
+ final int number, final Timestamp t2) throws SQLException {
insertFunction(id, msg, new SetExtraArgs() {
@Override
public void set(PreparedStatement on) throws SQLException {
- on.setDate(3, date1);
+ on.setInt(3, number);
on.setNull(4, Types.TIMESTAMP);
}
});