improve Config Filter support https

This commit is contained in:
wenshao
2012-08-18 22:28:42 +08:00
parent 970bf5d427
commit cc6956c7df
2 changed files with 40 additions and 1 deletions
@@ -169,7 +169,7 @@ public class ConfigFilter extends FilterAdapter {
InputStream inStream = null;
try {
boolean xml = false;
if (filePath.startsWith("http://")) {
if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
URL url = new URL(filePath);
inStream = url.openStream();
@@ -0,0 +1,39 @@
package com.alibaba.druid.bvt.filter.config;
import java.sql.Connection;
import com.alibaba.druid.mock.MockDriver;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.JdbcUtils;
import junit.framework.Assert;
import junit.framework.TestCase;
public class ConfigLoadFilterTest6 extends TestCase {
private DruidDataSource dataSource;
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("druid-configFile=https://raw.github.com/AlibabaTech/druid/master/src/test/resources/bvt/config/config-0.properties");
}
protected void tearDown() throws Exception {
JdbcUtils.close(dataSource);
}
public void test_http_config() throws Exception {
Assert.assertEquals(true, dataSource.isTestOnBorrow()); // default
Assert.assertEquals(8, dataSource.getMaxActive());
dataSource.init();
Assert.assertEquals(false, dataSource.isTestOnBorrow());
Assert.assertEquals(10, dataSource.getMaxActive());
Assert.assertEquals("jdbc:mock:config-0", dataSource.getUrl());
Assert.assertEquals(MockDriver.instance, dataSource.getDriver());
Connection conn = dataSource.getConnection();
conn.close();
}
}