Encrypt tool and Decrypt

This commit is contained in:
xiaoyu830411
2012-08-31 13:57:44 +08:00
parent 6290be2561
commit e19def644d
5 changed files with 41 additions and 33 deletions
@@ -30,6 +30,21 @@ public class ConfigFilterTest extends ConfigFileGenerator {
}
}
@Test
public void testInitRemoteConfigFileBySystemProperty() throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setFilters("config");
System.setProperty(ConfigFilter.SYS_PROP_CONFIG_FILE, FileConfigLoader.PROTOCOL_PREFIX + this.filePath);
try {
dataSource.init();
Assert.assertEquals("The username is " + dataSource.getUsername(), "test1", dataSource.getUsername());
} finally {
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_FILE);
JdbcUtils.close(dataSource);
}
}
@Test
public void testInitInvalidRemoteConfigFile() throws SQLException {
@@ -16,10 +16,6 @@ public class FileConfigLoaderTest {
isSupported = configLoader.isSupported("jdbc:/opt/mytest");
Assert.assertFalse("The value is " + isSupported + ", not false", isSupported);
System.setProperty(FileConfigLoader.SYS_PROP_CONFIG_FILE, "/opt/mytest");
isSupported = configLoader.isSupported(null);
Assert.assertTrue("The value is " + isSupported + ", not true", isSupported);
}
@Test
@@ -27,9 +23,5 @@ public class FileConfigLoaderTest {
FileConfigLoader configLoader = new FileConfigLoader();
String filePath = configLoader.getFilePath(FileConfigLoader.PROTOCOL_PREFIX + "/opt/test/test.properties");
Assert.assertEquals("The path is " + filePath, filePath, "/opt/test/test.properties");
System.setProperty(FileConfigLoader.SYS_PROP_CONFIG_FILE, "/opt/mytest");
filePath = configLoader.getFilePath(null);
Assert.assertEquals("The path is " + filePath, filePath, "/opt/mytest");
}
}
@@ -20,17 +20,6 @@ public class FileConfigLoaderTest1 extends ConfigFileGenerator {
Assert.assertEquals("The value is " + p.getProperty("username") + ", not test1", "test1", p.getProperty("username"));
}
@Test
public void testLoadConfigBySystemProperty() {
System.setProperty(FileConfigLoader.SYS_PROP_CONFIG_FILE, this.filePath);
FileConfigLoader configLoader = new FileConfigLoader();
Properties p = configLoader.loadConfig(null);
Assert.assertNotNull("The properties is null", p);
Assert.assertEquals("The value is " + p.getProperty("username") + ", not test1", "test1", p.getProperty("username"));
}
@Test
public void testLoadConfigByNotExistFile() {
FileConfigLoader configLoader = new FileConfigLoader();