diff --git a/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java index 1e620a5a584..5d0edddb02e 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java +++ b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java @@ -39,7 +39,7 @@ public class DatabaseAccessObject { pstmt.executeUpdate(); s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName); } catch (SQLException e) { - s_logger.warn("Ignored SQL Exception when trying to drop " + (isForeignKey ? "foreign " : "") + "key " + key + " on table " + tableName, e); + s_logger.debug("Ignored SQL Exception when trying to drop " + (isForeignKey ? "foreign " : "") + "key " + key + " on table " + tableName + " exception: " + e.getMessage()); } } @@ -49,7 +49,7 @@ public class DatabaseAccessObject { pstmt.executeUpdate(); s_logger.debug("Primary key is dropped successfully from the table " + tableName); } catch (SQLException e) { - s_logger.warn("Ignored SQL Exception when trying to drop primary key on table " + tableName, e); + s_logger.debug("Ignored SQL Exception when trying to drop primary key on table " + tableName + " exception: " + e.getMessage()); } } @@ -68,7 +68,7 @@ public class DatabaseAccessObject { pstmt.executeQuery(); columnExists = true; } catch (SQLException e) { - s_logger.warn("Field " + columnName + " doesn't exist in " + tableName, e); + s_logger.debug("Field " + columnName + " doesn't exist in " + tableName + " ignoring exception: " + e.getMessage()); } return columnExists; } diff --git a/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java index 5d37fbf326a..9a2115e9629 100644 --- a/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java +++ b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java @@ -70,8 +70,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(1)).debug(anyString()); - verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + verify(loggerMock, times(1)).debug(contains("successfully")); } @Test(expected = NullPointerException.class) @@ -100,8 +99,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -120,8 +118,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -138,8 +135,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(1)).debug(anyString()); - verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + verify(loggerMock, times(1)).debug(contains("successfully")); } @Test @@ -157,8 +153,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(0)).executeUpdate(); verify(preparedStatementMock, times(0)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -177,8 +172,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @SuppressWarnings("static-access") @@ -231,8 +225,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(1)).debug(anyString()); - verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + verify(loggerMock, times(1)).debug(contains("successfully")); } @Test(expected = NullPointerException.class) @@ -257,8 +250,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -274,8 +266,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(0)).executeUpdate(); verify(preparedStatementMock, times(0)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -292,8 +283,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeUpdate(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).debug(anyString()); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(contains("Exception")); } @Test @@ -309,7 +299,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeQuery(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + verify(loggerMock, times(0)).debug(anyString(), any(Throwable.class)); } @Test(expected = NullPointerException.class) @@ -336,7 +326,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeQuery(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(anyString()); } @Test @@ -354,7 +344,7 @@ public class DatabaseAccessObjectTest { verify(connectionMock, times(1)).prepareStatement(anyString()); verify(preparedStatementMock, times(1)).executeQuery(); verify(preparedStatementMock, times(1)).close(); - verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + verify(loggerMock, times(1)).debug(anyString()); } @Test