You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by bl...@apache.org on 2012/03/09 22:30:24 UTC
svn commit: r1299056 - in
/incubator/sqoop/trunk/src/test/com/cloudera/sqoop: TestColumnTypes.java
TestMultiCols.java manager/MySQLCompatTest.java
manager/OracleCompatTest.java testutil/BaseSqoopTestCase.java
testutil/ManagerCompatTestCase.java
Author: blee
Date: Fri Mar 9 21:30:23 2012
New Revision: 1299056
URL: http://svn.apache.org/viewvc?rev=1299056&view=rev
Log:
SQOOP-459 Remove redundant steps in compatibility tests: verifyReadback() method
Modified:
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestColumnTypes.java
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestMultiCols.java
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/MySQLCompatTest.java
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/OracleCompatTest.java
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/BaseSqoopTestCase.java
incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/ManagerCompatTestCase.java
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestColumnTypes.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestColumnTypes.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestColumnTypes.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestColumnTypes.java Fri Mar 9 21:30:23 2012
@@ -73,11 +73,6 @@ public class TestColumnTypes extends Man
}
@Override
- protected String getVarBinaryDbOutput(String asInserted) {
- return asInserted.toLowerCase();
- }
-
- @Override
protected String getVarBinarySeqOutput(String asInserted) {
return toLowerHexString(asInserted);
}
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestMultiCols.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestMultiCols.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestMultiCols.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/TestMultiCols.java Fri Mar 9 21:30:23 2012
@@ -47,21 +47,14 @@ public class TestMultiCols extends Impor
* @param importColumns The list of columns to import
*/
private void verifyTypes(String [] types , String [] insertVals,
- String [] validateVals, String validateLine) {
- verifyTypes(types, insertVals, validateVals, validateLine, null);
+ String validateLine) {
+ verifyTypes(types, insertVals, validateLine, null);
}
private void verifyTypes(String [] types , String [] insertVals,
- String [] validateVals, String validateLine, String [] importColumns) {
+ String validateLine, String [] importColumns) {
createTableWithColTypes(types, insertVals);
-
- int i = 0;
- for (String val : validateVals) {
- verifyReadback(++i, val);
- LOG.debug("Verified column " + i + " as value: " + val);
- }
-
verifyImport(validateLine, importColumns);
LOG.debug("Verified input line as " + validateLine + " -- ok!");
}
@@ -69,109 +62,97 @@ public class TestMultiCols extends Impor
public void testThreeStrings() {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "'foo'", "'bar'", "'baz'" };
- String [] validateVals = { "foo", "bar", "baz" };
String validateLine = "foo,bar,baz";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testStringsWithNull1() {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "'foo'", "null", "'baz'" };
- String [] validateVals = { "foo", null, "baz" };
String validateLine = "foo,null,baz";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testStringsWithNull2() {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "null", "'foo'", "'baz'" };
- String [] validateVals = { null, "foo", "baz" };
String validateLine = "null,foo,baz";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testStringsWithNull3() {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "'foo'", "'baz'", "null"};
- String [] validateVals = { "foo", "baz", null };
String validateLine = "foo,baz,null";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testThreeInts() {
String [] types = { "INTEGER", "INTEGER", "INTEGER" };
String [] insertVals = { "1", "2", "3" };
- String [] validateVals = { "1", "2", "3" };
String validateLine = "1,2,3";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testIntsWithNulls() {
String [] types = { "INTEGER", "INTEGER", "INTEGER" };
String [] insertVals = { "1", "null", "3" };
- String [] validateVals = { "1", null, "3" };
String validateLine = "1,null,3";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed1() {
String [] types = { "INTEGER", "VARCHAR(32)", "DATE" };
String [] insertVals = { "1", "'meep'", "'2009-12-31'" };
- String [] validateVals = { "1", "meep", "2009-12-31" };
String validateLine = "1,meep,2009-12-31";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed2() {
String [] types = { "INTEGER", "VARCHAR(32)", "DATE" };
String [] insertVals = { "null", "'meep'", "'2009-12-31'" };
- String [] validateVals = { null, "meep", "2009-12-31" };
String validateLine = "null,meep,2009-12-31";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed3() {
String [] types = { "INTEGER", "VARCHAR(32)", "DATE" };
String [] insertVals = { "1", "'meep'", "null" };
- String [] validateVals = { "1", "meep", null };
String validateLine = "1,meep,null";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed4() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "-42", "17", "33333333333333333333333.1714" };
- String [] validateVals = { "-42", "17", "33333333333333333333333.1714" };
String validateLine = "-42,17,33333333333333333333333.1714";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed5() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "null", "17", "33333333333333333333333.0" };
- String [] validateVals = { null, "17", "33333333333333333333333.0" };
String validateLine = "null,17,33333333333333333333333.0";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
public void testMixed6() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "33333333333333333333333", "17", "-42"};
- String [] validateVals = { "33333333333333333333333", "17", "-42" };
String validateLine = "33333333333333333333333,17,-42";
- verifyTypes(types, insertVals, validateVals, validateLine);
+ verifyTypes(types, insertVals, validateLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -182,34 +163,31 @@ public class TestMultiCols extends Impor
public void testSkipFirstCol() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "33333333333333333333333", "17", "-42"};
- String [] validateVals = { "33333333333333333333333", "17", "-42" };
String validateLine = "17,-42";
String [] loadCols = {"DATA_COL1", "DATA_COL2"};
- verifyTypes(types, insertVals, validateVals, validateLine, loadCols);
+ verifyTypes(types, insertVals, validateLine, loadCols);
}
public void testSkipSecondCol() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "33333333333333333333333", "17", "-42"};
- String [] validateVals = { "33333333333333333333333", "17", "-42" };
String validateLine = "33333333333333333333333,-42";
String [] loadCols = {"DATA_COL0", "DATA_COL2"};
- verifyTypes(types, insertVals, validateVals, validateLine, loadCols);
+ verifyTypes(types, insertVals, validateLine, loadCols);
}
public void testSkipThirdCol() {
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
String [] insertVals = { "33333333333333333333333", "17", "-42"};
- String [] validateVals = { "33333333333333333333333", "17", "-42" };
String validateLine = "33333333333333333333333,17";
String [] loadCols = {"DATA_COL0", "DATA_COL1"};
- verifyTypes(types, insertVals, validateVals, validateLine, loadCols);
+ verifyTypes(types, insertVals, validateLine, loadCols);
}
/**
@@ -223,11 +201,10 @@ public class TestMultiCols extends Impor
public void testSingleColumnsArg() throws IOException {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "'foo'", "'bar'", "'baz'" };
- String [] validateVals = { "foo", "bar", "baz" };
String validateLine = "foo,bar,baz";
String [] loadCols = {"DATA_COL0,DATA_COL1,DATA_COL2"};
- verifyTypes(types, insertVals, validateVals, validateLine, loadCols);
+ verifyTypes(types, insertVals, validateLine, loadCols);
}
/**
@@ -241,10 +218,9 @@ public class TestMultiCols extends Impor
public void testColumnsWithSpaces() throws IOException {
String [] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)" };
String [] insertVals = { "'foo'", "'bar'", "'baz'" };
- String [] validateVals = { "foo", "bar", "baz" };
String validateLine = "foo,bar,baz";
String [] loadCols = {"DATA_COL0, DATA_COL1, DATA_COL2"};
- verifyTypes(types, insertVals, validateVals, validateLine, loadCols);
+ verifyTypes(types, insertVals, validateLine, loadCols);
}
}
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/MySQLCompatTest.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/MySQLCompatTest.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/MySQLCompatTest.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/MySQLCompatTest.java Fri Mar 9 21:30:23 2012
@@ -99,47 +99,22 @@ public class MySQLCompatTest extends Man
}
@Override
- protected String getTrueBoolDbOutput() {
- return "1";
- }
-
- @Override
- protected String getFalseBoolDbOutput() {
- return "0";
- }
-
- @Override
- protected String getRealDbOutput(String realAsInserted) {
- return realAsInserted;
- }
-
- @Override
protected String getRealSeqOutput(String realAsInserted) {
return withDecimalZero(realAsInserted);
}
@Override
- protected String getFloatDbOutput(String floatAsInserted) {
- return floatAsInserted;
- }
-
- @Override
protected String getFloatSeqOutput(String floatAsInserted) {
return withDecimalZero(floatAsInserted);
}
@Override
- protected String getDoubleDbOutput(String doubleAsInserted) {
- return doubleAsInserted;
- }
-
- @Override
protected String getDoubleSeqOutput(String doubleAsInserted) {
return withDecimalZero(doubleAsInserted);
}
@Override
- protected String getTimestampDbOutput(String tsAsInserted) {
+ protected String getTimestampSeqOutput(String tsAsInserted) {
// We trim timestamps to exactly one tenth of a second.
if ("null".equals(tsAsInserted)) {
return tsAsInserted;
@@ -154,12 +129,7 @@ public class MySQLCompatTest extends Man
}
@Override
- protected String getTimestampSeqOutput(String tsAsInserted) {
- return getTimestampDbOutput(tsAsInserted);
- }
-
- @Override
- protected String getNumericDbOutput(String numAsInserted) {
+ protected String getNumericSeqOutput(String numAsInserted) {
// We always pad to exactly the number of digits in
// getNumericDecPartDigits().
@@ -188,13 +158,13 @@ public class MySQLCompatTest extends Man
}
@Override
- protected String getDecimalDbOutput(String numAsInserted) {
- return getNumericDbOutput(numAsInserted);
+ protected String getDecimalSeqOutput(String numAsInserted) {
+ return getNumericSeqOutput(numAsInserted);
}
@Test
public void testYear() {
- verifyType("YEAR", "2012", "2012-01-01", "2012");
+ verifyType("YEAR", "2012", "2012");
}
}
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/OracleCompatTest.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/OracleCompatTest.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/OracleCompatTest.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/manager/OracleCompatTest.java Fri Mar 9 21:30:23 2012
@@ -29,8 +29,6 @@ import org.apache.hadoop.conf.Configurat
import com.cloudera.sqoop.SqoopOptions;
import com.cloudera.sqoop.testutil.ManagerCompatTestCase;
-import junit.framework.AssertionFailedError;
-
/**
* Test the basic Oracle connection manager with the various column types.
*/
@@ -135,52 +133,27 @@ public class OracleCompatTest extends Ma
}
@Override
- protected String getDateDbOutput(String asInserted) {
+ protected String getDateSeqOutput(String asInserted) {
// DATE is actually a TIMESTAMP in Oracle; add a time component.
return asInserted + " 00:00:00.0";
}
@Override
- protected String getDateSeqOutput(String asInserted) {
- return getDateDbOutput(asInserted);
- }
-
- @Override
- protected String getFixedCharDbOut(int fieldWidth, String asInserted) {
- return padString(fieldWidth, asInserted);
- }
-
- @Override
protected String getFixedCharSeqOut(int fieldWidth, String asInserted) {
return padString(fieldWidth, asInserted);
}
@Override
- protected String getRealDbOutput(String realAsInserted) {
- return realAsInserted;
- }
-
- @Override
protected String getRealSeqOutput(String realAsInserted) {
return realAsInserted;
}
@Override
- protected String getFloatDbOutput(String floatAsInserted) {
- return floatAsInserted;
- }
-
- @Override
protected String getFloatSeqOutput(String floatAsInserted) {
return floatAsInserted;
}
@Override
- protected String getDoubleDbOutput(String doubleAsInserted) {
- return doubleAsInserted;
- }
-
- @Override
protected String getDoubleSeqOutput(String doubleAsInserted) {
return doubleAsInserted;
}
@@ -219,84 +192,34 @@ public class OracleCompatTest extends Ma
"Oracle treats empty strings as null (non-ANSI compliant). Skipping.");
}
- // Date and timestamp output values seem to be formatted in multiple
- // different ways depending on which Oracle JDBC driver subversion is used.
- // We override the test to control the expected output. We actually accept
- // one of multiple different output results -- if it fails one output
- // format, we check the other. Success on either is success for the whole
- // test. Because of this, we can't just use a single getTimestampDbOutput()
- // method.
-
@Override
public void testTimestamp1() {
- try {
- // Older ojdbc6_g jars succeed with this format.
- verifyType(getTimestampType(),
- getTimestampInsertStr("'2009-04-24 18:24:00'"),
- "2009-4-24 18:24:0. 0",
- "2009-04-24 18:24:00.0");
- } catch (AssertionFailedError afe) {
- // Try the test again with a different timestamp format.
- verifyType(getTimestampType(),
- getTimestampInsertStr("'2009-04-24 18:24:00'"),
- "2009-04-24 18:24:00",
- "2009-04-24 18:24:00.0");
- }
+ verifyType(getTimestampType(),
+ getTimestampInsertStr("'2009-04-24 18:24:00'"),
+ "2009-04-24 18:24:00.0");
}
@Override
public void testTimestamp2() {
- try {
- LOG.debug("Beginning testTimestamp2");
- verifyType(getTimestampType(),
- getTimestampInsertStr("'2009-04-24 18:24:00.0002'"),
- "2009-4-24 18:24:0. 200000",
- "2009-04-24 18:24:00.0002");
- } catch (AssertionFailedError afe) {
- // Try again with the newer version of the timestamp format.
- // The in-db format (third argument) looks weird to me, like it's losing
- // precision. But the final argument (the to-string version of what we
- // extract) is correct, which is what is most important.
- verifyType(getTimestampType(),
- getTimestampInsertStr("'2009-04-24 18:24:00.0002'"),
- "2009-04-24 18:24:00.2",
- "2009-04-24 18:24:00.0002");
- } finally {
- LOG.debug("End testTimestamp2");
- }
+ verifyType(getTimestampType(),
+ getTimestampInsertStr("'2009-04-24 18:24:00.0002'"),
+ "2009-04-24 18:24:00.0002");
}
@Override
public void testDate1() {
- try {
- verifyType("DATE", getDateInsertStr("'2009-01-12'"),
- "2009-01-12 00:00:00.0",
- getDateSeqOutput("2009-01-12"));
- } catch (AssertionFailedError afe) {
- // If the above format doesn't work, it might be a newer ojdbc jar,
- // which does not append the ".0" on the end.
- verifyType("DATE", getDateInsertStr("'2009-01-12'"),
- "2009-01-12 00:00:00",
- getDateSeqOutput("2009-01-12"));
- }
+ verifyType("DATE", getDateInsertStr("'2009-01-12'"),
+ getDateSeqOutput("2009-01-12"));
}
@Override
public void testDate2() {
- try {
- verifyType("DATE", getDateInsertStr("'2009-04-24'"),
- "2009-04-24 00:00:00.0",
- getDateSeqOutput("2009-04-24"));
- } catch (AssertionFailedError afe) {
- verifyType("DATE", getDateInsertStr("'2009-04-24'"),
- "2009-04-24 00:00:00",
- getDateSeqOutput("2009-04-24"));
- }
+ verifyType("DATE", getDateInsertStr("'2009-04-24'"),
+ getDateSeqOutput("2009-04-24"));
}
public void testRawVal() {
- verifyType("RAW(8)", "'12ABCD'", "12ABCD",
- getVarBinarySeqOutput("12ABCD"), true);
+ verifyType("RAW(8)", "'12ABCD'", getVarBinarySeqOutput("12ABCD"), true);
}
}
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/BaseSqoopTestCase.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/BaseSqoopTestCase.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/BaseSqoopTestCase.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/BaseSqoopTestCase.java Fri Mar 9 21:30:23 2012
@@ -417,44 +417,6 @@ public abstract class BaseSqoopTestCase
}
/**
- * Verify that the single-column single-row result can be read back from the
- * db.
- */
- protected void verifyReadback(int colNum, String expectedVal) {
- ResultSet results = null;
- try {
- results = getManager().readTable(getTableName(), getColNames());
- assertNotNull("Null results from readTable()!", results);
- assertTrue("Expected at least one row returned", results.next());
- String resultVal = results.getString(colNum);
- LOG.info("Verifying readback from " + getTableName()
- + ": got value [" + resultVal + "]");
- LOG.info("Expected value is: [" + expectedVal + "]");
- if (null != expectedVal) {
- assertNotNull("Expected non-null result value", resultVal);
- }
-
- assertEquals("Error reading inserted value back from db", expectedVal,
- resultVal);
- assertFalse("Expected at most one row returned", results.next());
- } catch (SQLException sqlE) {
- fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
- } finally {
- if (null != results) {
- try {
- results.close();
- } catch (SQLException sqlE) {
- fail("Got SQLException in resultset.close(): "
- + StringUtils.stringifyException(sqlE));
- }
- }
-
- // Free internal resources after the readTable.
- getManager().release();
- }
- }
-
- /**
* Create a new string array with 'moreEntries' appended to the 'entries'
* array.
* @param entries initial entries in the array
Modified: incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/ManagerCompatTestCase.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/ManagerCompatTestCase.java?rev=1299056&r1=1299055&r2=1299056&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/ManagerCompatTestCase.java (original)
+++ incubator/sqoop/trunk/src/test/com/cloudera/sqoop/testutil/ManagerCompatTestCase.java Fri Mar 9 21:30:23 2012
@@ -274,22 +274,12 @@ public abstract class ManagerCompatTestC
return "false";
}
- /** @return How a BOOLEAN column with value TRUE is communicated over JDBC */
- protected String getTrueBoolDbOutput() {
- return "true";
- }
-
/** @return How a BOOLEAN column with value TRUE is represented in a seq-file
* import. */
protected String getTrueBoolSeqOutput() {
return "true";
}
- /** @return How a BOOLEAN column with value FALSE is communicated over JDBC */
- protected String getFalseBoolDbOutput() {
- return "false";
- }
-
/** @return How a BOOLEAN column with value FALSE is represented in a seq-file
* import. */
protected String getFalseBoolSeqOutput() {
@@ -318,58 +308,27 @@ public abstract class ManagerCompatTestC
}
/**
- * A real value inserted as '40' may be returned as '40', '40.', or '40.0',
- * etc. Given a string that defines how a real value is inserted, determine
- * how it is returned.
- *
- * @param realAsInserted the string we used in the SQL INSERT statement
- * @return how the string version of this as returned by the database is
- * represented.
- */
- protected String getRealDbOutput(String realAsInserted) {
- return withDecimalZero(realAsInserted);
- }
-
- /**
* @return how a given real value is represented in an imported sequence
* file
*/
protected String getRealSeqOutput(String realAsInserted) {
- return getRealDbOutput(realAsInserted);
+ return withDecimalZero(realAsInserted);
}
/**
- * A float value inserted as '40' may be returned as '40', '40.', or '40.0',
- * etc. Given a string that defines how a float value is inserted, determine
- * how it is returned.
- *
- * @param floatAsInserted the string we used in the SQL INSERT statement
- * @return how the string version of this as returned by the database is
- * represented.
+ * @return how a given float value is represented in an imported sequence
+ * file
*/
- protected String getFloatDbOutput(String floatAsInserted) {
- return withDecimalZero(floatAsInserted);
- }
-
protected String getFloatSeqOutput(String floatAsInserted) {
- return getFloatDbOutput(floatAsInserted);
+ return withDecimalZero(floatAsInserted);
}
/**
- * A double value inserted as '40' may be returned as '40', '40.', or '40.0',
- * etc. Given a string that defines how a double value is inserted, determine
- * how it is returned.
- *
- * @param doubleAsInserted the string we used in the SQL INSERT statement
- * @return how the string version of this as returned by the database is
- * represented.
+ * @return how a given double value is represented in an imported sequence
+ * file
*/
- protected String getDoubleDbOutput(String doubleAsInserted) {
- return withDecimalZero(doubleAsInserted);
- }
-
protected String getDoubleSeqOutput(String doubleAsInserted) {
- return getDoubleDbOutput(doubleAsInserted);
+ return withDecimalZero(doubleAsInserted);
}
/**
@@ -402,45 +361,12 @@ public abstract class ManagerCompatTestC
return insertStr;
}
- protected String getDateDbOutput(String dateAsInserted) {
- return dateAsInserted;
- }
-
protected String getDateSeqOutput(String dateAsInserted) {
return dateAsInserted;
}
/**
* Convert an input timestamp to the string representation of the timestamp
- * returned by a database select query.
- *
- * @param tsAsInserted the input timestamp
- * @return the string version of this as returned by the database is
- * represented.
- */
- protected String getTimestampDbOutput(String tsAsInserted) {
- if ("null".equals(tsAsInserted)) {
- return tsAsInserted;
- }
-
- int dotPos = tsAsInserted.indexOf(".");
- if (-1 == dotPos) {
- // No dot in the original string; expand to 9 places.
- return tsAsInserted + ".000000000";
- } else {
- // Default with a dot is to pad the nanoseconds column to 9 places.
- int numZerosNeeded = tsAsInserted.length() - dotPos;
- String zeros = "";
- for (int i = 0; i < numZerosNeeded; i++) {
- zeros = zeros + "0";
- }
-
- return tsAsInserted + zeros;
- }
- }
-
- /**
- * Convert an input timestamp to the string representation of the timestamp
* returned by a sequencefile-based import.
*
* @param tsAsInserted the input timestamp
@@ -463,30 +389,18 @@ public abstract class ManagerCompatTestC
}
}
- protected String getNumericDbOutput(String numAsInserted) {
- return numAsInserted;
- }
-
protected String getNumericSeqOutput(String numAsInserted) {
- return getNumericDbOutput(numAsInserted);
- }
-
- protected String getDecimalDbOutput(String numAsInserted) {
return numAsInserted;
}
protected String getDecimalSeqOutput(String numAsInserted) {
- return getDecimalDbOutput(numAsInserted);
+ return numAsInserted;
}
/**
- * @return how a CHAR(fieldWidth) field is returned by the database
- * for a given input.
+ * @return how a CHAR(fieldWidth) field is represented in an imported
+ * sequence file
*/
- protected String getFixedCharDbOut(int fieldWidth, String asInserted) {
- return asInserted;
- }
-
protected String getFixedCharSeqOut(int fieldWidth, String asInserted) {
return asInserted;
}
@@ -525,14 +439,6 @@ public abstract class ManagerCompatTestC
/**
* @return A String declaring how an inserted VARBINARY will be
- * returned to us via the database.
- */
- protected String getVarBinaryDbOutput(String asInserted) {
- return asInserted;
- }
-
- /**
- * @return A String declaring how an inserted VARBINARY will be
* returned to us via the sequencefile.
*/
protected String getVarBinarySeqOutput(String asInserted) {
@@ -572,49 +478,31 @@ public abstract class ManagerCompatTestC
* Do a full verification test on the singleton value of a given type.
* @param colType The SQL type to instantiate the column.
* @param insertVal The SQL text to insert a value into the database.
- * @param returnVal The string representation of the value as extracted
- * from the db.
- */
- protected void verifyType(String colType, String insertVal,
- String returnVal) {
- verifyType(colType, insertVal, returnVal, returnVal);
- }
-
- /**
- * Do a full verification test on the singleton value of a given type.
- * @param colType The SQL type to instantiate the column.
- * @param insertVal The SQL text to insert a value into the database.
- * @param returnVal The string representation of the value as extracted from
- * the db.
* @param seqFileVal The string representation of the value as extracted
* through the DBInputFormat, serialized, and injected into a
* SequenceFile and put through toString(). This may be slightly
* different than what ResultSet.getString() returns, which is used
* by returnVal.
*/
- protected void verifyType(String colType, String insertVal, String returnVal,
+ protected void verifyType(String colType, String insertVal,
String seqFileVal) {
- verifyType(colType, insertVal, returnVal, seqFileVal, false);
+ verifyType(colType, insertVal, seqFileVal, false);
}
- protected void verifyType(String colType, String insertVal, String returnVal,
- String seqFileVal, boolean useIntPrimaryKey) {
+ protected void verifyType(String colType, String insertVal, String seqFileVal,
+ boolean useIntPrimaryKey) {
- int readBackCol;
String readbackPrepend = "";
if (useIntPrimaryKey) {
String [] types = { "INTEGER", colType };
String [] vals = { "0", insertVal };
createTableWithColTypes(types, vals);
- readBackCol = 2;
readbackPrepend = "0,"; // verifyImport will verify the entire row.
} else {
createTableForColType(colType, insertVal);
- readBackCol = 1;
}
- verifyReadback(readBackCol, returnVal);
verifyImport(readbackPrepend + seqFileVal, null);
}
@@ -629,7 +517,6 @@ public abstract class ManagerCompatTestC
@Test
public void testStringCol2() {
verifyType("CHAR(32)", STRING_VAL_IN,
- getFixedCharDbOut(32, STRING_VAL_OUT),
getFixedCharSeqOut(32, STRING_VAL_OUT));
}
@@ -661,7 +548,7 @@ public abstract class ManagerCompatTestC
return;
}
verifyType("BOOLEAN", getTrueBoolNumericSqlInput(),
- getTrueBoolDbOutput(), getTrueBoolSeqOutput());
+ getTrueBoolSeqOutput());
}
@Test
@@ -672,7 +559,7 @@ public abstract class ManagerCompatTestC
return;
}
verifyType("BOOLEAN", getFalseBoolNumericSqlInput(),
- getFalseBoolDbOutput(), getFalseBoolSeqOutput());
+ getFalseBoolSeqOutput());
}
@Test
@@ -682,7 +569,7 @@ public abstract class ManagerCompatTestC
skipped = true;
return;
}
- verifyType("BOOLEAN", getFalseBoolLiteralSqlInput(), getFalseBoolDbOutput(),
+ verifyType("BOOLEAN", getFalseBoolLiteralSqlInput(),
getFalseBoolSeqOutput());
}
@@ -729,50 +616,43 @@ public abstract class ManagerCompatTestC
@Test
public void testReal1() {
- verifyType("REAL", "256", getRealDbOutput("256"), getRealSeqOutput("256"));
+ verifyType("REAL", "256", getRealSeqOutput("256"));
}
@Test
public void testReal2() {
- verifyType("REAL", "256.45", getRealDbOutput("256.45"),
- getRealSeqOutput("256.45"));
+ verifyType("REAL", "256.45", getRealSeqOutput("256.45"));
}
@Test
public void testFloat1() {
- verifyType("FLOAT", "256", getFloatDbOutput("256"),
- getFloatSeqOutput("256"));
+ verifyType("FLOAT", "256", getFloatSeqOutput("256"));
}
@Test
public void testFloat2() {
- verifyType("FLOAT", "256.5", getFloatDbOutput("256.5"),
- getFloatSeqOutput("256.5"));
+ verifyType("FLOAT", "256.5", getFloatSeqOutput("256.5"));
}
@Test
public void testDouble1() {
- verifyType(getDoubleType(), "-256", getDoubleDbOutput("-256"),
- getDoubleSeqOutput("-256"));
+ verifyType(getDoubleType(), "-256", getDoubleSeqOutput("-256"));
}
@Test
public void testDouble2() {
- verifyType(getDoubleType(), "256.45", getDoubleDbOutput("256.45"),
- getDoubleSeqOutput("256.45"));
+ verifyType(getDoubleType(), "256.45", getDoubleSeqOutput("256.45"));
}
@Test
public void testDate1() {
verifyType("DATE", getDateInsertStr("'2009-01-12'"),
- getDateDbOutput("2009-01-12"),
getDateSeqOutput("2009-01-12"));
}
@Test
public void testDate2() {
verifyType("DATE", getDateInsertStr("'2009-04-24'"),
- getDateDbOutput("2009-04-24"),
getDateSeqOutput("2009-04-24"));
}
@@ -820,7 +700,6 @@ public abstract class ManagerCompatTestC
public void testTimestamp1() {
verifyType(getTimestampType(),
getTimestampInsertStr("'2009-04-24 18:24:00'"),
- getTimestampDbOutput("2009-04-24 18:24:00"),
getTimestampSeqOutput("2009-04-24 18:24:00"));
}
@@ -830,7 +709,6 @@ public abstract class ManagerCompatTestC
log.debug("Beginning testTimestamp2");
verifyType(getTimestampType(),
getTimestampInsertStr("'2009-04-24 18:24:00.0002'"),
- getTimestampDbOutput("2009-04-24 18:24:00.0002"),
getTimestampSeqOutput("2009-04-24 18:24:00.0002"));
} finally {
log.debug("End testTimestamp2");
@@ -850,21 +728,18 @@ public abstract class ManagerCompatTestC
@Test
public void testNumeric1() {
verifyType(getNumericType(), "1",
- getNumericDbOutput("1"),
getNumericSeqOutput("1"));
}
@Test
public void testNumeric2() {
verifyType(getNumericType(), "-10",
- getNumericDbOutput("-10"),
getNumericSeqOutput("-10"));
}
@Test
public void testNumeric3() {
verifyType(getNumericType(), "3.14159",
- getNumericDbOutput("3.14159"),
getNumericSeqOutput("3.14159"));
}
@@ -872,7 +747,6 @@ public abstract class ManagerCompatTestC
public void testNumeric4() {
verifyType(getNumericType(),
"3000000000000000000.14159",
- getNumericDbOutput("3000000000000000000.14159"),
getNumericSeqOutput("3000000000000000000.14159"));
}
@@ -880,7 +754,6 @@ public abstract class ManagerCompatTestC
public void testNumeric5() {
verifyType(getNumericType(),
"99999999999999999999.14159",
- getNumericDbOutput("99999999999999999999.14159"),
getNumericSeqOutput("99999999999999999999.14159"));
}
@@ -889,28 +762,24 @@ public abstract class ManagerCompatTestC
public void testNumeric6() {
verifyType(getNumericType(),
"-99999999999999999999.14159",
- getNumericDbOutput("-99999999999999999999.14159"),
getNumericSeqOutput("-99999999999999999999.14159"));
}
@Test
public void testDecimal1() {
verifyType(getDecimalType(), "1",
- getDecimalDbOutput("1"),
getDecimalSeqOutput("1"));
}
@Test
public void testDecimal2() {
verifyType(getDecimalType(), "-10",
- getDecimalDbOutput("-10"),
getDecimalSeqOutput("-10"));
}
@Test
public void testDecimal3() {
verifyType(getDecimalType(), "3.14159",
- getDecimalDbOutput("3.14159"),
getDecimalSeqOutput("3.14159"));
}
@@ -918,7 +787,6 @@ public abstract class ManagerCompatTestC
public void testDecimal4() {
verifyType(getDecimalType(),
"3000000000000000000.14159",
- getDecimalDbOutput("3000000000000000000.14159"),
getDecimalSeqOutput("3000000000000000000.14159"));
}
@@ -926,7 +794,6 @@ public abstract class ManagerCompatTestC
public void testDecimal5() {
verifyType(getDecimalType(),
"99999999999999999999.14159",
- getDecimalDbOutput("99999999999999999999.14159"),
getDecimalSeqOutput("99999999999999999999.14159"));
}
@@ -934,7 +801,6 @@ public abstract class ManagerCompatTestC
public void testDecimal6() {
verifyType(getDecimalType(),
"-99999999999999999999.14159",
- getDecimalDbOutput("-99999999999999999999.14159"),
getDecimalSeqOutput("-99999999999999999999.14159"));
}
@@ -958,7 +824,6 @@ public abstract class ManagerCompatTestC
String [] checkCol = { "DATA_COL0", "DATA_COL1" };
createTableWithColTypes(types, vals);
- verifyReadback(2, returnVal);
verifyImport("1," + seqFileVal, checkCol);
}
@@ -1042,7 +907,6 @@ public abstract class ManagerCompatTestC
}
verifyType(getVarBinaryType(), "'F00FABCD'",
- getVarBinaryDbOutput("F00FABCD"),
getVarBinarySeqOutput("F00FABCD"), true);
}
}