ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [2/5] git commit: AMBARI-6827. UpgradeCatalog170Test, Unit test fixed.
Date Mon, 18 Aug 2014 13:47:57 GMT
AMBARI-6827. UpgradeCatalog170Test, Unit test fixed.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fad3d3ed
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fad3d3ed
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fad3d3ed

Branch: refs/heads/branch-alerts-dev
Commit: fad3d3ed173b7dc0c4265f0b0fb8ddbab6839358
Parents: ace4a3e
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Fri Aug 15 14:48:15 2014 -0700
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Mon Aug 18 09:47:45 2014 -0400

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog170Test.java      | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fad3d3ed/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index ac1bd25..5a91f56 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -36,6 +36,8 @@ import static org.easymock.EasyMock.verify;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -110,9 +112,20 @@ public class UpgradeCatalog170Test {
   public void testExecuteDDLUpdates() throws Exception {
 
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
+    Connection connection = createNiceMock(Connection.class);
+    PreparedStatement stmt = createNiceMock(PreparedStatement.class);
     Configuration configuration = createNiceMock(Configuration.class);
     ResultSet resultSet = createNiceMock(ResultSet.class);
     expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
+    expect(dbAccessor.getNewConnection()).andReturn(connection);
+    expect(connection.prepareStatement("SELECT config_id FROM clusterconfig " +
+      "WHERE type_name = ? ORDER BY create_timestamp")).andReturn(stmt);
+    expect(connection.prepareStatement("UPDATE clusterconfig SET version = ? " +
+      "WHERE config_id = ?")).andReturn(stmt);
+    stmt.close();
+    expectLastCall().times(2);
+    connection.close();
+    expectLastCall();
 
     Capture<DBAccessor.DBColumnInfo> clusterConfigAttributesColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> maskColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
@@ -170,7 +183,7 @@ public class UpgradeCatalog170Test {
     resultSet.close();
     expectLastCall().anyTimes();
 
-    replay(dbAccessor, configuration, resultSet);
+    replay(dbAccessor, configuration, resultSet, connection, stmt);
     AbstractUpgradeCatalog upgradeCatalog = getUpgradeCatalog(dbAccessor);
     Class<?> c = AbstractUpgradeCatalog.class;
     Field f = c.getDeclaredField("configuration");
@@ -178,7 +191,7 @@ public class UpgradeCatalog170Test {
     f.set(upgradeCatalog, configuration);
 
     upgradeCatalog.executeDDLUpdates();
-    verify(dbAccessor, configuration, resultSet);
+    verify(dbAccessor, configuration, resultSet, connection, stmt);
 
     assertClusterConfigColumns(clusterConfigAttributesColumnCapture);
     assertViewColumns(maskColumnCapture);


Mime
View raw message