mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve Config Filter support https
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user