### Question:
MySQLDataSource extends BaseDataSource { @Override public String getPassword() { password = super.getPassword(); if(password.contains(sensitiveParam)){ logger.warn("sensitive param : {} in password field is filtered", sensitiveParam); password = password.replace(sensitiveParam, ""); } return password; }  @Override String driverClassSelector(); @Override DbType dbTypeSelector(); @Override String getUser(); @Override String getPassword();  }### Answer:
@Test public void testGetPassword(){ MySQLDataSource dataSource = new MySQLDataSource(); String safePwd= "test_pwd"; dataSource.setPassword(safePwd); Assert.assertEquals("test_pwd", dataSource.getPassword()); String sensitivePwd= "test_pwd?autoDeserialize=true"; dataSource.setPassword(sensitivePwd); Assert.assertEquals("test_pwd?", dataSource.getPassword()); }
@Test public void testGetPasswordWithDecodePassword(){ MySQLDataSource dataSource = new MySQLDataSource(); String password= ""; dataSource.setPassword(password); Assert.assertEquals("", dataSource.getPassword()); password= "IUAjJCVeJipNVEl6TkRVMg=="; dataSource.setPassword(password); Assert.assertNotNull(dataSource.getPassword()); Assert.assertNotNull(dataSource.getPassword()); dataSource.setPassword(password); PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE,"true"); Assert.assertEquals("123456", dataSource.getPassword()); dataSource.setPassword(password); Assert.assertEquals("123456", dataSource.getPassword()); Assert.assertEquals("123456", dataSource.getPassword()); Assert.assertEquals("123456", dataSource.getPassword()); dataSource.setPassword(password); PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE,"false"); Assert.assertEquals("IUAjJCVeJipNVEl6TkRVMg==", dataSource.getPassword()); dataSource.setPassword(password); Assert.assertEquals("IUAjJCVeJipNVEl6TkRVMg==", dataSource.getPassword()); Assert.assertEquals("IUAjJCVeJipNVEl6TkRVMg==", dataSource.getPassword()); Assert.assertEquals("IUAjJCVeJipNVEl6TkRVMg==", dataSource.getPassword()); }