String newVal = propsFromConf.getProperty(key); if (key.equals(ConfVars.CONNECT_URL_KEY.getVarname())) { oldVal = MetaStoreServerUtils.anonymizeConnectionURL(oldVal); newVal = MetaStoreServerUtils.anonymizeConnectionURL(newVal);
@Test public void testAnonymizeConnectionURL() { String connectionURL = null; String expectedConnectionURL = null; String result = MetaStoreServerUtils.anonymizeConnectionURL(connectionURL); assertEquals(expectedConnectionURL, result); connectionURL = "jdbc:mysql://localhost:1111/db?user=user&password=password"; expectedConnectionURL = "jdbc:mysql://localhost:1111/db?user=****&password=****"; result = MetaStoreServerUtils.anonymizeConnectionURL(connectionURL); assertEquals(expectedConnectionURL, result); connectionURL = "jdbc:derby:sample;user=jill;password=toFetchAPail"; expectedConnectionURL = "jdbc:derby:sample;user=****;password=****"; result = MetaStoreServerUtils.anonymizeConnectionURL(connectionURL); assertEquals(expectedConnectionURL, result); connectionURL = "jdbc:mysql://[(host=myhost1,port=1111,user=sandy,password=secret)," + "(host=myhost2,port=2222,user=finn,password=secret)]/db"; expectedConnectionURL = "jdbc:mysql://[(host=myhost1,port=1111,user=****,password=****)," + "(host=myhost2,port=2222,user=****,password=****)]/db"; result = MetaStoreServerUtils.anonymizeConnectionURL(connectionURL); assertEquals(expectedConnectionURL, result); connectionURL = "jdbc:derby:memory:${test.tmp.dir}/junit_metastore_db;create=true"; result = MetaStoreServerUtils.anonymizeConnectionURL(connectionURL); assertEquals(connectionURL, result); }