incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject [1/2] git commit: AMBARI-2688. Error messages printed to log. (Artem Baranchuk via smohanty)
Date Thu, 25 Jul 2013 02:38:59 GMT
Updated Branches:
  refs/heads/trunk 66ad274e7 -> c7f0212d4


AMBARI-2688. Error messages printed to log. (Artem Baranchuk via smohanty)


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

Branch: refs/heads/trunk
Commit: 188a6c4158a439720c59bd8c2f3b9f095e8c7bd4
Parents: 66ad274
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Wed Jul 24 19:37:24 2013 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Wed Jul 24 19:37:24 2013 -0700

----------------------------------------------------------------------
 .../server/configuration/Configuration.java      | 11 ++++++-----
 .../server/configuration/ConfigurationTest.java  | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/188a6c41/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index a6d03b5..f3e2b25 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -599,11 +599,12 @@ public class Configuration {
 
   public String getRcaDatabasePassword() {
     String passwdProp = properties.getProperty(SERVER_JDBC_RCA_USER_PASSWD_KEY);
-    String dbpasswd = readPasswordFromStore(passwdProp);
-    if (dbpasswd != null)
-      return dbpasswd;
-    else
-      return readPasswordFromFile(passwdProp, SERVER_JDBC_RCA_USER_PASSWD_DEFAULT);
+    if (passwdProp != null) {
+      String dbpasswd = readPasswordFromStore(passwdProp);
+      if (dbpasswd != null)
+        return dbpasswd;
+    }
+    return readPasswordFromFile(passwdProp, SERVER_JDBC_RCA_USER_PASSWD_DEFAULT);
   }
 
   private String readPasswordFromFile(String filePath, String defaultPassword) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/188a6c41/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 48674e4..e5d5bfb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -165,4 +165,23 @@ public class ConfigurationTest {
     Assert.assertEquals(System.getProperty(conf.JAVAX_SSL_TRUSTSTORE_PASSWORD, "unknown"),
encrypted);
   }
 
+  @Test
+  public void testGetRcaDatabasePassword_fromStore() {
+    String serverJdbcRcaUserPasswdKey = "key";
+    String encrypted = "password";
+
+    Properties properties = new Properties();
+    properties.setProperty(Configuration.SERVER_JDBC_RCA_USER_PASSWD_KEY, serverJdbcRcaUserPasswdKey);
+    Configuration conf = spy(new Configuration(properties));
+    doReturn(encrypted).when(conf).readPasswordFromStore(serverJdbcRcaUserPasswdKey);
+
+    Assert.assertEquals(encrypted, conf.getRcaDatabasePassword());
+  }
+
+  @Test
+  public void testGetRcaDatabasePassword_fromFile() {
+    Configuration conf = spy(new Configuration(new Properties()));
+    Assert.assertEquals("mapred", conf.getRcaDatabasePassword());
+  }
+
 }


Mime
View raw message