mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
@@ -22,11 +22,6 @@ import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* 这个场景测试访问MySql系统�
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class MySqlWallPermitTableTest extends TestCase {
|
||||
|
||||
public void test_default() throws Exception {
|
||||
|
||||
@@ -21,11 +21,6 @@ import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* 这个场景测试访问Oracle系统�
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class OracleWallPermitTableTest extends TestCase {
|
||||
|
||||
public void test_permitTable() throws Exception {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景测试访问SQLServer系统�
|
||||
* 这个场景测试访问SQLServer系统表
|
||||
*
|
||||
* @author RaymondXiu
|
||||
* @version 1.0, 2012-3-18
|
||||
@@ -36,9 +36,9 @@ public class SQLServerWallPermitTableTest extends TestCase {
|
||||
|
||||
|
||||
public void test03() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT sysobjects.name as tablename, syscolumns.name as columnname FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE sysobjects.xtype = ‘U�AND syscolumns.name LIKE �PASSWORD%�"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = ‘mytable�;"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT sysobjects.name as tablename, syscolumns.name as columnname FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE sysobjects.xtype = ‘U’ AND syscolumns.name LIKE ‘%PASSWORD%’ "));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = ‘mytable’);"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,9 @@ public class SQLServerWallTest extends TestCase {
|
||||
|
||||
public void test_stuff() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT @@version"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT 1 �comment"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT 1 — comment"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT /*comment*/1"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("WAITFOR DELAY �:0:5�"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("BULK INSERT mydata FROM ‘c:boot.ini�"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("WAITFOR DELAY ’0:0:5′ "));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("BULK INSERT mydata FROM ‘c:boot.ini’;"));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -22,11 +22,7 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
|
||||
public class WallDropTest1 extends TestCase {
|
||||
private String sql = "DROP TABLE T1";
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallInsertTest extends TestCase {
|
||||
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallInsertTest2 extends TestCase {
|
||||
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
|
||||
|
||||
|
||||
@@ -21,11 +21,7 @@ import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 测试�行注释的场�
|
||||
* @author admin
|
||||
*
|
||||
*/
|
||||
|
||||
public class WallLineCommentTest extends TestCase {
|
||||
private String sql = "select f1 from t -- ";
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallSelectIntoTest1 extends TestCase {
|
||||
private String sql = "SELECT F1, F2 INTO T2 FROM T1";
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -22,11 +22,6 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检�
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest4 extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ? OR 1 = 1";
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TestConcurrent extends TestCase {
|
||||
}
|
||||
|
||||
public void test_0() throws Exception {
|
||||
// 第一次建立连�
|
||||
// 第一次建立连接
|
||||
{
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
Assert.assertEquals(0, dataSource.getPoolingCount());
|
||||
@@ -105,7 +105,7 @@ public class TestConcurrent extends TestCase {
|
||||
Assert.assertEquals(true, dataSource.isEnable());
|
||||
}
|
||||
|
||||
// 使用�个线程模拟并�打开10个连�
|
||||
// 使用单个线程模拟并发打开10个连接
|
||||
for (int i = 0; i < 1000 * 1; ++i) {
|
||||
final int COUNT = 10;
|
||||
Connection[] connections = new Connection[COUNT];
|
||||
@@ -130,12 +130,12 @@ public class TestConcurrent extends TestCase {
|
||||
Assert.assertEquals(COUNT, dataSource.getPoolingCount());
|
||||
}
|
||||
|
||||
// 2个并�
|
||||
// 2个并发
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
concurrent(2);
|
||||
}
|
||||
|
||||
// 5个并�
|
||||
// 5个并发
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
concurrent(5);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class TestConcurrent extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 并�执行10000�
|
||||
* 并发执行10000次
|
||||
*
|
||||
* @param threadCount
|
||||
* @throws InterruptedException
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TestIdle3 extends TestCase {
|
||||
new ObjectName(
|
||||
"com.alibaba:type=DataSource,name=oracle"));
|
||||
|
||||
// 第一次创建连�
|
||||
// 第一次创建连接
|
||||
{
|
||||
Assert.assertEquals(0, dataSource.getCreateCount());
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
@@ -80,7 +80,7 @@ public class TestIdle3 extends TestCase {
|
||||
}
|
||||
|
||||
{
|
||||
// 并�创建14�
|
||||
// 并发创建14个
|
||||
int count = 14;
|
||||
Connection[] connections = new Connection[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TestIdle3_Concurrent_MaxActive extends TestCase {
|
||||
|
||||
public void test_idle2() throws Exception {
|
||||
|
||||
// 第一次创建连�
|
||||
// 第一次创建连接
|
||||
{
|
||||
Assert.assertEquals(0, dataSource.getCreateCount());
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TestRemoveAbandoned extends TestCase {
|
||||
Assert.assertEquals(1, dataSource.getActiveCount());
|
||||
Assert.assertEquals(0, dataSource.getPoolingCount());
|
||||
|
||||
// 超时之�,连接自动关�
|
||||
// 超时之后,连接自动关闭
|
||||
Thread.sleep(100);
|
||||
Assert.assertTrue(conn.isClosed());
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DruidTest {
|
||||
ds.setUsername(username);
|
||||
ds.setPassword(pswd);
|
||||
ds.setUrl(connectURI);
|
||||
ds.setInitialSize(initialSize); // �始的连接数�
|
||||
ds.setInitialSize(initialSize); // 初始的连接数;
|
||||
ds.setMaxActive(maxActive);
|
||||
ds.setMaxIdle(maxIdle);
|
||||
ds.setMinIdle(minIdle);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TestIdle3_Concurrent_MaxActive extends TestCase {
|
||||
// ManagementFactory.getPlatformMBeanServer().registerMBean(dataSource,
|
||||
// new ObjectName("com.alibaba:type=DataSource"));
|
||||
|
||||
// 第一次创建连�
|
||||
// 第一次创建连接
|
||||
{
|
||||
Assert.assertEquals(0, dataSource.getCreateCount());
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TestIdle3_Concurrent_Starvation_Longtime extends TestCase {
|
||||
|
||||
public void test_idle2() throws Exception {
|
||||
|
||||
// 第一次创建连�
|
||||
// 第一次创建连接
|
||||
{
|
||||
Assert.assertEquals(0, dataSource.getCreateCount());
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
|
||||
@@ -127,8 +127,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
public DruidDataSourceUIManager(){
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具�
|
||||
Dimension screenSize = kit.getScreenSize(); // 获��幕的尺�
|
||||
Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包
|
||||
Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸
|
||||
int screenWidth = screenSize.width / 2; // 获取屏幕的宽
|
||||
int screenHeight = screenSize.height / 2; // 获取屏幕的高
|
||||
int height = this.getHeight();
|
||||
|
||||
Reference in New Issue
Block a user