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

Add better exception logging to BaseSqoopTestCase

From: Aaron Kimball <aaron@cloudera.com>

git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1149889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Bayer 2011-07-22 20:03:44 +00:00
parent c05f1c3710
commit 13e32e71cf

View File

@ -30,6 +30,7 @@
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.util.StringUtils;
import org.apache.log4j.BasicConfigurator; import org.apache.log4j.BasicConfigurator;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -170,11 +171,13 @@ public void setUp() {
try { try {
testServer.resetServer(); testServer.resetServer();
} catch (SQLException sqlE) { } catch (SQLException sqlE) {
LOG.error("Got SQLException: " + sqlE.toString()); LOG.error("Got SQLException: " + StringUtils.stringifyException(sqlE));
fail("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
LOG.error("Could not find class for db driver: " + cnfe.toString()); LOG.error("Could not find class for db driver: "
fail("Could not find class for db driver: " + cnfe.toString()); + StringUtils.stringifyException(cnfe));
fail("Could not find class for db driver: "
+ StringUtils.stringifyException(cnfe));
} }
manager = testServer.getManager(); manager = testServer.getManager();
@ -187,7 +190,8 @@ public void setUp() {
try { try {
this.manager = f.getManager(opts); this.manager = f.getManager(opts);
} catch (IOException ioe) { } catch (IOException ioe) {
fail("IOException instantiating manager: " + ioe); fail("IOException instantiating manager: " +
StringUtils.stringifyException(ioe));
} }
} }
} }
@ -202,8 +206,8 @@ public void tearDown() {
manager = null; manager = null;
} }
} catch (SQLException sqlE) { } catch (SQLException sqlE) {
LOG.error("Got SQLException: " + sqlE.toString()); LOG.error("Got SQLException: " + StringUtils.stringifyException(sqlE));
fail("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
} }
} }
@ -268,7 +272,8 @@ protected void createTableWithColTypes(String [] colTypes, String [] vals) {
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
statement.executeUpdate(); statement.executeUpdate();
} catch (SQLException sqlException) { } catch (SQLException sqlException) {
fail("Could not create table: " + sqlException.toString()); fail("Could not create table: "
+ StringUtils.stringifyException(sqlException));
} finally { } finally {
if (null != statement) { if (null != statement) {
try { try {
@ -291,7 +296,8 @@ protected void createTableWithColTypes(String [] colTypes, String [] vals) {
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException sqlException) { } catch (SQLException sqlException) {
fail("Could not create table: " + sqlException.toString()); fail("Could not create table: "
+ StringUtils.stringifyException(sqlException));
} finally { } finally {
if (null != statement) { if (null != statement) {
try { try {
@ -312,7 +318,7 @@ protected void createTableWithColTypes(String [] colTypes, String [] vals) {
} catch (SQLException connSE) { } catch (SQLException connSE) {
} }
} }
fail("Could not create table: " + se.toString()); fail("Could not create table: " + StringUtils.stringifyException(se));
} }
} }
@ -369,13 +375,14 @@ protected void verifyReadback(int colNum, String expectedVal) {
assertEquals("Error reading inserted value back from db", expectedVal, resultVal); assertEquals("Error reading inserted value back from db", expectedVal, resultVal);
assertFalse("Expected at most one row returned", results.next()); assertFalse("Expected at most one row returned", results.next());
} catch (SQLException sqlE) { } catch (SQLException sqlE) {
fail("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
} finally { } finally {
if (null != results) { if (null != results) {
try { try {
results.close(); results.close();
} catch (SQLException sqlE) { } catch (SQLException sqlE) {
fail("Got SQLException in resultset.close(): " + sqlE.toString()); fail("Got SQLException in resultset.close(): "
+ StringUtils.stringifyException(sqlE));
} }
} }