5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-17 01:11:07 +08:00

SQOOP-2303: EmptyTypeList when returned from DatabaseProvider class results in NPE in TestNG

(Syed A. Hashmi via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2015-04-13 16:14:28 -07:00
parent 59351b1328
commit 5ea695a6d9
2 changed files with 18 additions and 12 deletions

View File

@ -19,9 +19,8 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.sqoop.common.test.db.types.DatabaseType;
import org.apache.sqoop.common.test.db.types.DatabaseTypeList;
import org.apache.sqoop.common.test.db.types.EmptyTypeList;
import org.apache.sqoop.common.test.db.types.DefaultTypeList;
import java.sql.Connection;
import java.sql.DriverManager;
@ -153,7 +152,7 @@ public String getJdbcDriver() {
* @return
*/
public DatabaseTypeList getDatabaseTypes() {
return new EmptyTypeList();
return new DefaultTypeList();
}
/**

View File

@ -17,15 +17,22 @@
*/
package org.apache.sqoop.common.test.db.types;
import java.util.LinkedList;
import java.util.List;
/**
* Default implementation that don't have any types.
* This class provides one default type to be consumed by Types Tests.
* Any DB provider which wants to have more types covered should provide
* a separate class and return that instead of this class.
*/
public class EmptyTypeList extends DatabaseTypeList {
@Override
public List<DatabaseType> getAllTypes() {
return new LinkedList<DatabaseType>();
public class DefaultTypeList extends DatabaseTypeList {
public DefaultTypeList() {
super();
// Integer type
add(DatabaseType.builder("INT")
.addExample("-32768", new Integer(-32768), "-32768")
.addExample("-1", new Integer(-1), "-1")
.addExample("0", new Integer(0), "0")
.addExample("1", new Integer(1), "1")
.addExample("32767", new Integer(32767), "32767")
.build());
}
}