sessionStatData = sessionStat.getStatData();
int runningCount = ((Number) sessionStatData.get("RunningCount")).intValue();
@@ -642,7 +643,6 @@ public class WebAppStat {
}
} else if (isLinux) {
osLinuxCount.incrementAndGet();
-
isAndroid = computeUserAgentAndroid(userAgent);
} else if (userAgent.indexOf("Symbian") != -1) {
osSymbianCount.incrementAndGet();
diff --git a/src/main/java/com/alibaba/druid/util/JdbcConstants.java b/src/main/java/com/alibaba/druid/util/JdbcConstants.java
index f203e65ce2..0feecaad52 100644
--- a/src/main/java/com/alibaba/druid/util/JdbcConstants.java
+++ b/src/main/java/com/alibaba/druid/util/JdbcConstants.java
@@ -59,4 +59,10 @@ public interface JdbcConstants {
* 阿里云odps
*/
public static final String ODPS = "odps";
+
+ /**
+ * Log4JDBC
+ */
+ public static final String LOG4JDBC = "log4jdbc";
+ public static final String LOG4JDBC_DRIVER = "net.sf.log4jdbc.DriverSpy";
}
diff --git a/src/main/java/com/alibaba/druid/util/JdbcUtils.java b/src/main/java/com/alibaba/druid/util/JdbcUtils.java
index 4521d3f5e0..71afa830f3 100644
--- a/src/main/java/com/alibaba/druid/util/JdbcUtils.java
+++ b/src/main/java/com/alibaba/druid/util/JdbcUtils.java
@@ -351,6 +351,8 @@ public final class JdbcUtils implements JdbcConstants {
return "org.apache.derby.jdbc.EmbeddedDriver";
} else if (rawUrl.startsWith("jdbc:mysql:")) {
return MYSQL_DRIVER;
+ } else if (rawUrl.startsWith("jdbc:log4jdbc:")) {
+ return LOG4JDBC_DRIVER;
} else if (rawUrl.startsWith("jdbc:mariadb:")) {
return MARIADB_DRIVER;
} else if (rawUrl.startsWith("jdbc:oracle:") //
@@ -421,6 +423,8 @@ public final class JdbcUtils implements JdbcConstants {
return DERBY;
} else if (rawUrl.startsWith("jdbc:mysql:")) {
return MYSQL;
+ } else if (rawUrl.startsWith("jdbc:log4jdbc:")) {
+ return LOG4JDBC;
} else if (rawUrl.startsWith("jdbc:mariadb:")) {
return MARIADB;
} else if (rawUrl.startsWith("jdbc:oracle:")) {
@@ -429,6 +433,8 @@ public final class JdbcUtils implements JdbcConstants {
return ALI_ORACLE;
} else if (rawUrl.startsWith("jdbc:microsoft:")) {
return SQL_SERVER;
+ } else if (rawUrl.startsWith("jdbc:sqlserver:")) {
+ return SQL_SERVER;
} else if (rawUrl.startsWith("jdbc:sybase:Tds:")) {
return SYBASE;
} else if (rawUrl.startsWith("jdbc:jtds:")) {
diff --git a/src/main/java/com/alibaba/druid/util/ServletPathMatcher.java b/src/main/java/com/alibaba/druid/util/ServletPathMatcher.java
index 3bd6090c3d..401c45a0ff 100644
--- a/src/main/java/com/alibaba/druid/util/ServletPathMatcher.java
+++ b/src/main/java/com/alibaba/druid/util/ServletPathMatcher.java
@@ -17,45 +17,56 @@ package com.alibaba.druid.util;
public class ServletPathMatcher implements PatternMatcher {
private final static ServletPathMatcher instance = new ServletPathMatcher();
-
+
public static ServletPathMatcher getInstance() {
return instance;
}
- /**
- *
- * three type: endsWithMatch(eg. /xxx*=/xxx/xyz), startsWithMatch(eg. *.xxx=abc.xxx), equals(eg. /xxx=/xxx).
- *
- * Notice: *xxx* will match *xxxyyyy. endsWithMatch first.
- */
- @Override
- public boolean matches(String pattern, String source) {
- if (pattern == null || source == null) {
- return false;
- }
- pattern = pattern.trim();
- source = source.trim();
- if (pattern.endsWith("*")) {
- // pattern: /druid* source:/druid/index.html
- int length = pattern.length() - 1;
- if (source.length() >= length) {
- if (pattern.substring(0, length).equals(source.substring(0, length))) {
- return true;
- }
- }
- } else if (pattern.startsWith("*")) {
- // pattern: *.html source:/xx/xx.html
- int length = pattern.length() - 1;
- if (source.length() >= length && source.endsWith(pattern.substring(1))) {
- return true;
- }
- } else {
- // pattern: /druid/index.html source:/druid/index.html
- if (pattern.equals(source)) {
- return true;
- }
- }
- return false;
- }
+ /**
+ *
+ * three type: endsWithMatch(eg. /xxx*=/xxx/xyz), startsWithMatch(eg.
+ * *.xxx=abc.xxx), equals(eg. /xxx=/xxx).
+ *
+ * Notice: *xxx* will match *xxxyyyy. endsWithMatch first.
+ */
+ @Override
+ public boolean matches(String pattern, String source) {
+ if (pattern == null || source == null) {
+ return false;
+ }
+ pattern = pattern.trim();
+ source = source.trim();
+ if (pattern.endsWith("*")) {
+ // pattern: /druid* source:/druid/index.html
+ int length = pattern.length() - 1;
+ if (source.length() >= length) {
+ if (pattern.substring(0, length).equals(
+ source.substring(0, length))) {
+ return true;
+ }
+ }
+ } else if (pattern.startsWith("*")) {
+ // pattern: *.html source:/xx/xx.html
+ int length = pattern.length() - 1;
+ if (source.length() >= length
+ && source.endsWith(pattern.substring(1))) {
+ return true;
+ }
+ } else if (pattern.contains("*")) {
+ // pattern: /druid/*/index.html source:/druid/admin/index.html
+ int start = pattern.indexOf("*");
+ int end = pattern.lastIndexOf("*");
+ if (source.startsWith(pattern.substring(0, start))
+ && source.endsWith(pattern.substring(end + 1))) {
+ return true;
+ }
+ } else {
+ // pattern: /druid/index.html source:/druid/index.html
+ if (pattern.equals(source)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/src/main/java/com/alibaba/druid/wall/WallProvider.java b/src/main/java/com/alibaba/druid/wall/WallProvider.java
index b5dc28d278..64eec2e5d4 100644
--- a/src/main/java/com/alibaba/druid/wall/WallProvider.java
+++ b/src/main/java/com/alibaba/druid/wall/WallProvider.java
@@ -641,7 +641,9 @@ public abstract class WallProvider {
violations.add(new SyntaxErrorViolation(e, sql));
}
} catch (Exception e) {
- violations.add(new SyntaxErrorViolation(e, sql));
+ if (config.isStrictSyntaxCheck()) {
+ violations.add(new SyntaxErrorViolation(e, sql));
+ }
}
if (statementList.size() > 1 && !config.isMultiStatementAllow()) {
@@ -664,15 +666,15 @@ public abstract class WallProvider {
violations.addAll(visitor.getViolations());
}
- if (visitor.getViolations().size() == 0 && context != null && context.getWarnnings() >= 2) {
- if (context.getCommentCount() > 0) {
- violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "comment not allow", sql));
- } else if (context.getLikeNumberWarnnings() > 0) {
- violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "like number", sql));
- } else {
- violations.add(new IllegalSQLObjectViolation(ErrorCode.COMPOUND, "multi-warnnings", sql));
- }
- }
+ // if (visitor.getViolations().size() == 0 && context != null && context.getWarnnings() >= 2) {
+ // if (context.getCommentCount() > 0) {
+ // violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "comment not allow", sql));
+ // } else if (context.getLikeNumberWarnnings() > 0) {
+ // violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "like number", sql));
+ // } else {
+ // violations.add(new IllegalSQLObjectViolation(ErrorCode.COMPOUND, "multi-warnnings", sql));
+ // }
+ // }
WallSqlStat sqlStat = null;
if (violations.size() > 0) {
diff --git a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java
index 5fd1d05463..942cacc63e 100644
--- a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java
+++ b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java
@@ -40,6 +40,7 @@ import com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr;
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr;
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
+import com.alibaba.druid.sql.ast.expr.SQLBooleanExpr;
import com.alibaba.druid.sql.ast.expr.SQLCaseExpr;
import com.alibaba.druid.sql.ast.expr.SQLCaseExpr.Item;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
@@ -91,7 +92,6 @@ import com.alibaba.druid.sql.ast.statement.SQLUnionQuery;
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement;
import com.alibaba.druid.sql.ast.statement.SQLUseStatement;
-import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlBooleanExpr;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
@@ -1386,8 +1386,8 @@ public class WallVisitorUtils {
return getValue(visitor, (SQLBinaryOpExpr) x);
}
- if (x instanceof MySqlBooleanExpr) {
- return ((MySqlBooleanExpr) x).getValue();
+ if (x instanceof SQLBooleanExpr) {
+ return ((SQLBooleanExpr) x).getValue();
}
if (x instanceof SQLNumericLiteralExpr) {
diff --git a/src/main/resources/META-INF/druid-driver.properties b/src/main/resources/META-INF/druid-driver.properties
index 95f94a1c44..9b1fcc926c 100644
--- a/src/main/resources/META-INF/druid-driver.properties
+++ b/src/main/resources/META-INF/druid-driver.properties
@@ -1,6 +1,7 @@
jdbc:derby:=org.apache.derby.jdbc.EmbeddedDriver
-jdbc:mysql:=com.mysql.jdbc.Driver
-jdbc:oracle:=oracle.jdbc.driver.OracleDriver
+jdbc:mysql:=com.mysql.jdbc.Driver
+jdbc:log4jdbc:=net.sf.log4jdbc.DriverSpy
+jdbc:oracle:=oracle.jdbc.driver.OracleDriver
jdbc:microsoft:=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc:jtds:=net.sourceforge.jtds.jdbc.Driver
jdbc:postgresql:=org.postgresql.Driver
diff --git a/src/main/resources/support/http/resources/js/doT.js b/src/main/resources/support/http/resources/js/doT.js
index 5019fad26f..7422b308ae 100644
--- a/src/main/resources/support/http/resources/js/doT.js
+++ b/src/main/resources/support/http/resources/js/doT.js
@@ -6,7 +6,7 @@
"use strict";
var doT = {
- version: '1.0.3',
+ version: '1.0.7',
templateSettings: {
evaluate: /\{\{([\s\S]+?\}?)\}\}/g,
interpolate: /\{\{=([\s\S]+?)\}\}/g,
diff --git a/src/test/java/com/alibaba/druid/DruidTest.java b/src/test/java/com/alibaba/druid/DruidTest.java
deleted file mode 100644
index 13ae9d095c..0000000000
--- a/src/test/java/com/alibaba/druid/DruidTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 1999-2011 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.alibaba.druid;
-
-import junit.framework.TestCase;
-
-import com.alibaba.druid.pool.DruidDataSource;
-
-public class DruidTest extends TestCase {
-
- public void test_0() throws Exception {
- DruidDataSource ds = new DruidDataSource();
- ds.setMaxWait(30);
- ds.setInitialSize(0);
- ds.setUrl("jdbc:mysql:xxx");
-
- try {
- ds.getConnection();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/test/java/com/alibaba/druid/TestRollBack.java b/src/test/java/com/alibaba/druid/TestRollBack.java
index 9a07206a86..08cae1c912 100644
--- a/src/test/java/com/alibaba/druid/TestRollBack.java
+++ b/src/test/java/com/alibaba/druid/TestRollBack.java
@@ -1,11 +1,9 @@
package com.alibaba.druid;
-import java.beans.PropertyVetoException;
-import java.sql.SQLException;
-
-import org.junit.Assert;
-
+import com.alibaba.druid.pool.DruidDataSource;
+import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -17,8 +15,8 @@ import org.nutz.dao.impl.NutDao;
import org.nutz.trans.Atom;
import org.nutz.trans.Trans;
-import com.alibaba.druid.pool.DruidDataSource;
-import com.mchange.v2.c3p0.ComboPooledDataSource;
+import java.beans.PropertyVetoException;
+import java.sql.SQLException;
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
@@ -79,7 +77,7 @@ public class TestRollBack {
}
@AfterClass
- public static void destory() {
+ public static void destroy() {
c3p0.close();
druid.close();
}
diff --git a/src/test/java/com/alibaba/druid/bvt/bug/Bug_for_JeffYin.java b/src/test/java/com/alibaba/druid/bvt/bug/Bug_for_JeffYin.java
deleted file mode 100644
index 717f95c9eb..0000000000
--- a/src/test/java/com/alibaba/druid/bvt/bug/Bug_for_JeffYin.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2011 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.alibaba.druid.bvt.bug;
-
-import java.sql.Driver;
-
-import junit.framework.TestCase;
-
-import org.junit.Assert;
-
-import com.alibaba.druid.util.JdbcUtils;
-import com.alibaba.druid.util.Utils;
-
-public class Bug_for_JeffYin extends TestCase {
-
- public void test_0() throws Exception {
- String url = "jdbc:sqlserver://localhost:1433;";
- String driverClassName = JdbcUtils.getDriverClassName(url);
- Class> driverClass = Utils.loadClass(driverClassName);
- Assert.assertNotNull(driverClass);
-
- Driver driver = (Driver) driverClass.newInstance();
-
- Assert.assertTrue(driver.acceptsURL(url));
- }
-}
diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest80.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest80.java
index ad2e23d3f6..c3fd1e2213 100644
--- a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest80.java
+++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest80.java
@@ -45,7 +45,7 @@ public class MySqlWallTest80 extends TestCase {
provider.getConfig().setCommentAllow(true);
- Assert.assertFalse(provider.checkValid(//
+ Assert.assertTrue(provider.checkValid(//
"SELECT * FROM T WHERE FID = ? OR FID LIKE 1 --"));
Assert.assertEquals(1, provider.getTableStats().size());
diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/TenantSelectTest3.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/TenantSelectTest3.java
index a01167bf0e..8f5bb27e26 100644
--- a/src/test/java/com/alibaba/druid/bvt/filter/wall/TenantSelectTest3.java
+++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/TenantSelectTest3.java
@@ -28,26 +28,27 @@ import com.alibaba.druid.wall.spi.MySqlWallProvider;
public class TenantSelectTest3 extends TestCase {
- private String sql = "SELECT ID, NAME " + //
- "FROM orders o inner join users u ON o.userid = u.id " + //
- "WHERE FID = ? OR FID = ?";
- private String expect_sql = "SELECT ID, NAME, u.tenant, o.tenant" + //
- "\nFROM orders o" + //
- "\n\tINNER JOIN users u ON o.userid = u.id" + //
- "\nWHERE FID = ?" + //
- "\n\tOR FID = ?";
-
- private WallConfig config = new WallConfig();
- private WallConfig config_callback = new WallConfig();
+ private String sql = "SELECT ID, NAME " + //
+ "FROM orders o inner join users u ON o.userid = u.id " + //
+ "WHERE FID = ? OR FID = ?";
+ private String expect_sql = "SELECT ID, NAME, u.tenant, o.tenant" + //
+ "\nFROM orders o" + //
+ "\n\tINNER JOIN users u ON o.userid = u.id" + //
+ "\nWHERE FID = ?" + //
+ "\n\tOR FID = ?";
protected void setUp() throws Exception {
+
+ }
+
+ public void testMySql() throws Exception {
+ WallConfig config = new WallConfig();
+ WallConfig config_callback = new WallConfig();
config.setTenantTablePattern("*");
config.setTenantColumn("tenant");
config_callback.setTenantCallBack(new TenantTestCallBack());
- }
-
- public void testMySql() throws Exception {
+
WallProvider.setTenantValue(123);
MySqlWallProvider provider = new MySqlWallProvider(config);
WallCheckResult checkResult = provider.check(sql);
@@ -58,6 +59,13 @@ public class TenantSelectTest3 extends TestCase {
}
public void testMySql2() throws Exception {
+ WallConfig config = new WallConfig();
+ WallConfig config_callback = new WallConfig();
+ config.setTenantTablePattern("*");
+ config.setTenantColumn("tenant");
+
+ config_callback.setTenantCallBack(new TenantTestCallBack());
+
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
WallCheckResult checkResult = provider.check(sql);
Assert.assertEquals(0, checkResult.getViolations().size());
diff --git a/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill.java b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill.java
new file mode 100644
index 0000000000..724ae1a656
--- /dev/null
+++ b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill.java
@@ -0,0 +1,56 @@
+package com.alibaba.druid.bvt.pool;
+
+import junit.framework.TestCase;
+
+import org.junit.Assert;
+
+import com.alibaba.druid.pool.DruidDataSource;
+
+public class DruidDataSourceTest_fill extends TestCase {
+
+ private DruidDataSource dataSource;
+
+ private int maxActive = 10;
+
+ protected void setUp() throws Exception {
+ dataSource = new DruidDataSource();
+ dataSource.setUrl("jdbc:mock:xxx");
+ dataSource.setMaxActive(maxActive);
+ dataSource.setTestOnBorrow(false);
+ }
+
+ protected void tearDown() throws Exception {
+ dataSource.close();
+ }
+
+ public void test_fill_0() throws Exception {
+ int fillCount = dataSource.fill(3);
+ Assert.assertEquals(3, fillCount);
+ }
+
+ public void test_fill_1() throws Exception {
+ int fillCount = dataSource.fill(1000);
+ Assert.assertEquals(maxActive, fillCount);
+ }
+
+ public void test_fill_2() throws Exception {
+ int fillCount = dataSource.fill(maxActive);
+ Assert.assertEquals(maxActive, fillCount);
+ }
+
+ public void test_fill_3() throws Exception {
+ int fillCount = dataSource.fill();
+ Assert.assertEquals(maxActive, fillCount);
+ }
+
+ public void test_fill_5() throws Exception {
+ Exception error = null;
+ try {
+ dataSource.fill(-1);
+ } catch (IllegalArgumentException e) {
+ error = e;
+ }
+ Assert.assertNotNull(error);
+ }
+
+}
diff --git a/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill2.java b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill2.java
new file mode 100644
index 0000000000..789723c6eb
--- /dev/null
+++ b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_fill2.java
@@ -0,0 +1,86 @@
+package com.alibaba.druid.bvt.pool;
+
+import java.sql.Connection;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import junit.framework.TestCase;
+
+import org.junit.Assert;
+
+import com.alibaba.druid.pool.DruidDataSource;
+
+public class DruidDataSourceTest_fill2 extends TestCase {
+
+ private DruidDataSource dataSource;
+
+ private int maxActive = 100;
+
+ protected void setUp() throws Exception {
+ dataSource = new DruidDataSource();
+ dataSource.setUrl("jdbc:mock:xxx");
+ dataSource.setMaxActive(maxActive);
+ dataSource.setTestOnBorrow(false);
+ }
+
+ protected void tearDown() throws Exception {
+ dataSource.close();
+ }
+
+ public void test_fill() throws Exception {
+ final AtomicLong errorCount = new AtomicLong();
+
+ final int THREAD_COUNT = 100;
+ final CountDownLatch startLatch = new CountDownLatch(THREAD_COUNT);
+ final CountDownLatch endLatch = new CountDownLatch(THREAD_COUNT);
+ Thread[] threads = new Thread[THREAD_COUNT];
+ for (int i = 0; i < THREAD_COUNT; ++i) {
+ threads[i] = new Thread("thread-" + i) {
+
+ public void run() {
+ startLatch.countDown();
+ try {
+ Connection conn = dataSource.getConnection();
+ Thread.sleep(2);
+ conn.close();
+ } catch (Exception e) {
+ errorCount.incrementAndGet();
+ } finally {
+ endLatch.countDown();
+ }
+ }
+ };
+ threads[i].start();
+ }
+
+ startLatch.await(1000, TimeUnit.MILLISECONDS);
+
+ final CountDownLatch fillLatch = new CountDownLatch(THREAD_COUNT);
+ final AtomicLong fillErrorCount = new AtomicLong();
+ final AtomicLong fillCount = new AtomicLong();
+ Thread fillThread = new Thread() {
+
+ public void run() {
+ try {
+ int count = dataSource.fill();
+ fillCount.getAndSet(count);
+ } catch (Exception e) {
+ fillErrorCount.incrementAndGet();
+ } finally {
+ fillLatch.countDown();
+ }
+ }
+ };
+ fillThread.start();
+
+ fillLatch.await(1000, TimeUnit.MILLISECONDS);
+
+ Assert.assertEquals(0, fillErrorCount.get());
+
+ endLatch.await(1000, TimeUnit.MILLISECONDS);
+
+ Assert.assertEquals(true, fillCount.get() > 0);
+
+ }
+}
diff --git a/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_tryGet.java b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_tryGet.java
new file mode 100644
index 0000000000..d337cec62b
--- /dev/null
+++ b/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest_tryGet.java
@@ -0,0 +1,37 @@
+package com.alibaba.druid.bvt.pool;
+
+import org.junit.Assert;
+
+import junit.framework.TestCase;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.pool.DruidPooledConnection;
+
+public class DruidDataSourceTest_tryGet extends TestCase {
+
+ private DruidDataSource dataSource;
+
+ protected void setUp() throws Exception {
+ dataSource = new DruidDataSource();
+ dataSource.setUrl("jdbc:mock:xxx");
+ dataSource.setMaxActive(1);
+ dataSource.setInitialSize(1);
+ dataSource.setTestOnBorrow(false);
+ dataSource.init();
+ }
+
+ protected void tearDown() throws Exception {
+ dataSource.close();
+ }
+
+ public void test_0() throws Exception {
+ DruidPooledConnection conn1 = this.dataSource.tryGetConnection();
+ Assert.assertNotNull(conn1);
+
+ DruidPooledConnection conn2 = this.dataSource.tryGetConnection();
+ Assert.assertNull(conn2);
+
+ conn1.close();
+ }
+
+}
diff --git a/src/test/java/com/alibaba/druid/bvt/pool/FullTest.java b/src/test/java/com/alibaba/druid/bvt/pool/FullTest.java
new file mode 100644
index 0000000000..7a66d6027c
--- /dev/null
+++ b/src/test/java/com/alibaba/druid/bvt/pool/FullTest.java
@@ -0,0 +1,37 @@
+package com.alibaba.druid.bvt.pool;
+
+import java.sql.Connection;
+
+import org.junit.Assert;
+
+import junit.framework.TestCase;
+
+import com.alibaba.druid.pool.DruidDataSource;
+
+public class FullTest extends TestCase {
+
+ private DruidDataSource dataSource;
+
+ protected void setUp() throws Exception {
+ dataSource = new DruidDataSource();
+ dataSource.setUrl("jdbc:mock:xxx");
+ dataSource.setTestOnBorrow(false);
+
+ dataSource.init();
+ }
+
+ protected void tearDown() throws Exception {
+ dataSource.close();
+ }
+
+ public void test_restart() throws Exception {
+ Assert.assertEquals(false, dataSource.isFull());
+ dataSource.fill();
+
+ Assert.assertEquals(true, dataSource.isFull());
+ Connection conn = dataSource.getConnection();
+ Assert.assertEquals(true, dataSource.isFull());
+ conn.close();
+ Assert.assertEquals(true, dataSource.isFull());
+ }
+}
diff --git a/src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGloalDataSourceStat.java b/src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGlobalDataSourceStat.java
similarity index 56%
rename from src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGloalDataSourceStat.java
rename to src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGlobalDataSourceStat.java
index 0972a1379d..e6d97441e4 100644
--- a/src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGloalDataSourceStat.java
+++ b/src/test/java/com/alibaba/druid/bvt/pool/property/PropertyTest_useGlobalDataSourceStat.java
@@ -8,23 +8,23 @@ import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.JdbcUtils;
-public class PropertyTest_useGloalDataSourceStat extends TestCase {
+public class PropertyTest_useGlobalDataSourceStat extends TestCase {
private DruidDataSource dataSource;
public void test_true() {
- System.setProperty("druid.useGloalDataSourceStat", "true");
+ System.setProperty("druid.useGlobalDataSourceStat", "true");
dataSource = new DruidDataSource();
- Assert.assertTrue(dataSource.isUseGloalDataSourceStat());
+ Assert.assertTrue(dataSource.isUseGlobalDataSourceStat());
}
public void test_false() {
- System.setProperty("druid.useGloalDataSourceStat", "false");
+ System.setProperty("druid.useGlobalDataSourceStat", "false");
dataSource = new DruidDataSource();
- Assert.assertFalse(dataSource.isUseGloalDataSourceStat());
+ Assert.assertFalse(dataSource.isUseGlobalDataSourceStat());
}
protected void tearDown() throws Exception {
- System.clearProperty("druid.useGloalDataSourceStat");
+ System.clearProperty("druid.useGlobalDataSourceStat");
JdbcUtils.close(dataSource);
}
}
diff --git a/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest0.java b/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest0.java
index d0a24ba237..5c93aaf04a 100644
--- a/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest0.java
+++ b/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest0.java
@@ -28,12 +28,12 @@ public class GlobalStatTest0 extends TestCase {
dataSourceA = new DruidDataSource();
dataSourceA.setUrl("jdbc:mock:xx_A");
dataSourceA.setFilters("stat");
- dataSourceA.setUseGloalDataSourceStat(true);
+ dataSourceA.setUseGlobalDataSourceStat(true);
dataSourceB = new DruidDataSource();
dataSourceB.setUrl("jdbc:mock:xx_A");
dataSourceB.setFilters("stat");
- dataSourceB.setUseGloalDataSourceStat(true);
+ dataSourceB.setUseGlobalDataSourceStat(true);
}
protected void tearDown() throws Exception {
diff --git a/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest1.java b/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest1.java
index 74199be9ca..5008cbbf3c 100644
--- a/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest1.java
+++ b/src/test/java/com/alibaba/druid/bvt/proxy/filter/GlobalStatTest1.java
@@ -25,12 +25,12 @@ public class GlobalStatTest1 extends TestCase {
dataSourceA = new DruidDataSource();
dataSourceA.setUrl("jdbc:mock:xx_A");
dataSourceA.setFilters("stat");
- dataSourceA.setUseGloalDataSourceStat(true);
+ dataSourceA.setUseGlobalDataSourceStat(true);
dataSourceB = new DruidDataSource();
dataSourceB.setUrl("jdbc:mock:xx_A");
dataSourceB.setFilters("stat");
- dataSourceB.setUseGloalDataSourceStat(true);
+ dataSourceB.setUseGlobalDataSourceStat(true);
}
protected void tearDown() throws Exception {
diff --git a/src/test/java/com/alibaba/druid/bvt/sql/EqualTest_boolean.java b/src/test/java/com/alibaba/druid/bvt/sql/EqualTest_boolean.java
index 9bca1c33bc..ae68890016 100644
--- a/src/test/java/com/alibaba/druid/bvt/sql/EqualTest_boolean.java
+++ b/src/test/java/com/alibaba/druid/bvt/sql/EqualTest_boolean.java
@@ -4,7 +4,7 @@ import junit.framework.TestCase;
import org.junit.Assert;
-import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlBooleanExpr;
+import com.alibaba.druid.sql.ast.expr.SQLBooleanExpr;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser;
import com.alibaba.druid.sql.parser.SQLExprParser;
@@ -13,18 +13,18 @@ public class EqualTest_boolean extends TestCase {
public void test_exits() throws Exception {
String sql = "true";
String sql_c = "false";
- MySqlBooleanExpr exprA, exprB, exprC;
+ SQLBooleanExpr exprA, exprB, exprC;
{
SQLExprParser parser = new MySqlExprParser(sql);
- exprA = (MySqlBooleanExpr) parser.expr();
+ exprA = (SQLBooleanExpr) parser.expr();
}
{
SQLExprParser parser = new MySqlExprParser(sql);
- exprB = (MySqlBooleanExpr) parser.expr();
+ exprB = (SQLBooleanExpr) parser.expr();
}
{
SQLExprParser parser = new MySqlExprParser(sql_c);
- exprC = (MySqlBooleanExpr) parser.expr();
+ exprC = (SQLBooleanExpr) parser.expr();
}
Assert.assertEquals(exprA, exprB);
Assert.assertNotEquals(exprA, exprC);
@@ -32,7 +32,7 @@ public class EqualTest_boolean extends TestCase {
Assert.assertFalse(exprA.equals(new Object()));
Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
- Assert.assertEquals(new MySqlBooleanExpr(), new MySqlBooleanExpr());
- Assert.assertEquals(new MySqlBooleanExpr().hashCode(), new MySqlBooleanExpr().hashCode());
+ Assert.assertEquals(new SQLBooleanExpr(), new SQLBooleanExpr());
+ Assert.assertEquals(new SQLBooleanExpr().hashCode(), new SQLBooleanExpr().hashCode());
}
}
diff --git a/src/test/java/com/alibaba/druid/bvt/sql/eval/SQLEvalVisitorUtilsTest.java b/src/test/java/com/alibaba/druid/bvt/sql/eval/SQLEvalVisitorUtilsTest.java
index 9c5e1c59e1..66fe661d09 100644
--- a/src/test/java/com/alibaba/druid/bvt/sql/eval/SQLEvalVisitorUtilsTest.java
+++ b/src/test/java/com/alibaba/druid/bvt/sql/eval/SQLEvalVisitorUtilsTest.java
@@ -29,6 +29,13 @@ public class SQLEvalVisitorUtilsTest extends TestCase {
Assert.assertEquals(-1, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? - ?", Arrays.