mirror of https://github.com/alibaba/druid.git
Compare commits
12 Commits
dc0b31b5e5
...
2dab163614
Author | SHA1 | Date |
---|---|---|
|
2dab163614 | |
|
8917bb77ed | |
|
6b822813ab | |
|
fb832684d3 | |
|
646cff1498 | |
|
6e579d4257 | |
|
83ede27185 | |
|
ceab45fbcc | |
|
bb77736eff | |
|
7f4bf8c99f | |
|
43b68cd81e | |
|
f2e998f284 |
|
@ -24,3 +24,4 @@ replay_pid*.log
|
|||
|
||||
.vscode
|
||||
druid-spring-boot-3-starter/demo-db.mv.db
|
||||
/worktrees/
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
# Qwen Code Context for Druid Project
|
||||
|
||||
This document provides essential context for Qwen Code to understand and assist with the Druid project.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a **Java** project. Druid is a high-performance, scalable JDBC connection pool implementation for Java applications. It's designed to provide efficient database connection management and includes features for monitoring and statistics.
|
||||
|
||||
Key aspects:
|
||||
- **Main Technology:** Java, built with Maven.
|
||||
- **Core Functionality:** JDBC Connection Pooling (`DruidDataSource`).
|
||||
- **Additional Features:** SQL monitoring, statistics, and security features like SQL firewall (`WallFilter`).
|
||||
- **Integration:** Provides Spring Boot starters for easy integration (`druid-spring-boot-starter`, `druid-spring-boot-3-starter`).
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `pom.xml`: Root Maven project file. Defines parent POM, manages modules, dependencies, and build profiles.
|
||||
- `core/`: Contains the main Druid library source code.
|
||||
- `core/pom.xml`: Maven configuration for the core library.
|
||||
- `core/src/main/java/com/alibaba/druid/`: Main source code for the Druid library.
|
||||
- `pool/`: Core connection pooling logic (e.g., `DruidDataSource`).
|
||||
- `sql/`: SQL parsing and analysis.
|
||||
- `stat/`: Statistics collection and management.
|
||||
- `wall/`: SQL firewall/filtering logic.
|
||||
- `filter/`: Extensible filter mechanism for connections/statements.
|
||||
- `druid-spring-boot-starter/`: Spring Boot Starter for integrating Druid into Spring Boot 2.x applications.
|
||||
- `druid-spring-boot-3-starter/`: Spring Boot Starter for integrating Druid into Spring Boot 3.x applications.
|
||||
- `druid-demo-petclinic/`: A demo application, likely based on Spring PetClinic, showcasing Druid usage.
|
||||
- `doc/`: Documentation files.
|
||||
- `README.md`: General project introduction and quick start guide.
|
||||
|
||||
## Building and Running
|
||||
|
||||
- **Prerequisites:** Java 8+ JDK, Apache Maven.
|
||||
- **Build Command:** `mvn clean install` (from the project root). This compiles the code, runs tests, and packages the artifacts (JARs).
|
||||
- **Run Demo:** Navigate to `druid-demo-petclinic` and follow its specific instructions (likely `mvn spring-boot:run`).
|
||||
|
||||
## Development Conventions
|
||||
|
||||
- **Build Tool:** Apache Maven is used for dependency management and building.
|
||||
- **Language:** Java.
|
||||
- **Testing:** Unit and integration tests are likely located within `src/test` directories of respective modules (e.g., `core/src/test`). The `pom.xml` configures the `maven-surefire-plugin` to run tests.
|
||||
- **Code Style:** Checkstyle is configured (see `pom.xml` and `src/checkstyle/druid-checks.xml`) to enforce coding standards.
|
||||
- **Modularization:** The project is a multi-module Maven project, separating the core library from Spring Boot integration modules.
|
||||
- **Versioning:** Version information is managed in the root `pom.xml` and reflected in `core/src/main/java/com/alibaba/druid/VERSION.java`.
|
|
@ -3149,6 +3149,9 @@ public class DruidDataSource extends DruidAbstractDataSource
|
|||
|
||||
// shrink connections by HotSpot intrinsic function _arraycopy for performance optimization.
|
||||
int removeCount = evictCount + keepAliveCount;
|
||||
if (removeCount > poolingCount) {
|
||||
removeCount = poolingCount;
|
||||
}
|
||||
if (removeCount > 0) {
|
||||
int breakedCount = poolingCount - i;
|
||||
if (breakedCount > 0) {
|
||||
|
@ -3253,7 +3256,9 @@ public class DruidDataSource extends DruidAbstractDataSource
|
|||
lock.lock();
|
||||
try {
|
||||
int fillCount = minIdle - (activeCount + poolingCount + createTaskCount);
|
||||
emptySignal(fillCount);
|
||||
if (fillCount > 0) {
|
||||
emptySignal(fillCount);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package com.alibaba.druid.sql.dialect.doris.parser;
|
||||
|
||||
import com.alibaba.druid.DbType;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionBy;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionByList;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionByRange;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionByValue;
|
||||
import com.alibaba.druid.sql.dialect.starrocks.parser.StarRocksCreateTableParser;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
public class DorisCreateTableParser
|
||||
extends StarRocksCreateTableParser {
|
||||
|
@ -10,4 +16,54 @@ public class DorisCreateTableParser
|
|||
super(exprParser);
|
||||
dbType = DbType.doris;
|
||||
}
|
||||
|
||||
public SQLPartitionBy parsePartitionBy() {
|
||||
if (lexer.nextIf(Token.PARTITION)) {
|
||||
accept(Token.BY);
|
||||
SQLPartitionBy partitionClause;
|
||||
boolean hasLparen = false;
|
||||
if (lexer.nextIfIdentifier(FnvHash.Constants.RANGE)) {
|
||||
partitionClause = new SQLPartitionByRange();
|
||||
accept(Token.LPAREN);
|
||||
hasLparen = true;
|
||||
} else if (lexer.nextIfIdentifier(FnvHash.Constants.LIST)) {
|
||||
partitionClause = new SQLPartitionByList();
|
||||
((SQLPartitionByList) partitionClause).setType(SQLPartitionByList.PartitionByListType.LIST_EXPRESSION);
|
||||
accept(Token.LPAREN);
|
||||
hasLparen = true;
|
||||
} else {
|
||||
partitionClause = new SQLPartitionByValue();
|
||||
}
|
||||
|
||||
for (; ;) {
|
||||
partitionClause.addColumn(this.exprParser.expr());
|
||||
if (lexer.nextIf(Token.COMMA)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (hasLparen && !lexer.nextIf(Token.RPAREN)) {
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
accept(Token.LPAREN);
|
||||
for (; ; ) {
|
||||
if (lexer.token() == Token.RPAREN) {
|
||||
break;
|
||||
}
|
||||
partitionClause.addPartition(this.getExprParser().parsePartition());
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
return partitionClause;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,6 +444,9 @@ public class HiveOutputVisitor extends SQLASTOutputVisitor implements HiveASTVis
|
|||
}
|
||||
|
||||
public boolean visit(SQLCharExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
String text = x.getText();
|
||||
if (text == null) {
|
||||
print0(ucase ? "NULL" : "null");
|
||||
|
@ -489,7 +492,9 @@ public class HiveOutputVisitor extends SQLASTOutputVisitor implements HiveASTVis
|
|||
|
||||
print0(buf.toString());
|
||||
}
|
||||
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.alibaba.druid.sql.dialect.impala.ast;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionValue;
|
||||
|
||||
public class ImpalaSQLPartitionValue extends SQLPartitionValue {
|
||||
|
@ -8,6 +9,9 @@ public class ImpalaSQLPartitionValue extends SQLPartitionValue {
|
|||
private Operator leftOperator;
|
||||
private Operator rightOperator;
|
||||
|
||||
public ImpalaSQLPartitionValue() {
|
||||
super();
|
||||
}
|
||||
public void setOperator(Operator operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
@ -50,4 +54,20 @@ public class ImpalaSQLPartitionValue extends SQLPartitionValue {
|
|||
public void setRightOperator(Operator rightOperator) {
|
||||
this.rightOperator = rightOperator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImpalaSQLPartitionValue clone() {
|
||||
ImpalaSQLPartitionValue x = new ImpalaSQLPartitionValue();
|
||||
x.setOperator(operator);
|
||||
x.setLeftBound(leftBound);
|
||||
x.setRightBound(rightBound);
|
||||
x.setLeftOperator(leftOperator);
|
||||
x.setRightOperator(rightOperator);
|
||||
for (SQLExpr item : items) {
|
||||
SQLExpr item2 = item.clone();
|
||||
item2.setParent(x);
|
||||
x.items.add(item2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -718,6 +718,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
|||
}
|
||||
|
||||
public boolean visit(SQLCharExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
if (this.appender == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -781,6 +784,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
|||
}
|
||||
|
||||
appender.append('\'');
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -818,4 +818,21 @@ public class OdpsExprParser extends HiveExprParser {
|
|||
}
|
||||
return super.methodRest(expr, acceptLPAREN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLName name() {
|
||||
SQLObject locationHolder = null;
|
||||
if (lexer.isKeepSourceLocation()) {
|
||||
locationHolder = new SQLIdentifierExpr("temp");
|
||||
lexer.computeRowAndColumn(locationHolder);
|
||||
}
|
||||
|
||||
SQLName name = super.name();
|
||||
|
||||
if (locationHolder != null) {
|
||||
name.setSource(locationHolder.getSourceLine(), locationHolder.getSourceColumn());
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -742,6 +742,9 @@ public class OdpsOutputVisitor extends HiveOutputVisitor implements OdpsASTVisit
|
|||
}
|
||||
|
||||
public boolean visit(SQLCharExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
String text = x.getText();
|
||||
if (text == null) {
|
||||
print0(ucase ? "NULL" : "null");
|
||||
|
@ -772,7 +775,9 @@ public class OdpsOutputVisitor extends HiveOutputVisitor implements OdpsASTVisit
|
|||
|
||||
print0(buf.toString());
|
||||
}
|
||||
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2791,6 +2791,9 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
|||
}
|
||||
|
||||
public boolean visit(SQLCharExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
if (parameterized) {
|
||||
print('?');
|
||||
incrementReplaceCunt();
|
||||
|
@ -2823,7 +2826,9 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
|||
} else {
|
||||
printChars(x.getText());
|
||||
}
|
||||
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1265,8 +1265,7 @@ public class SQLExprParser extends SQLParser {
|
|||
expr.addBeforeComment(beforeComments);
|
||||
}
|
||||
if (lexer.hasComment() && lexer.isKeepComments()) {
|
||||
// @todo 是否保留注释,暂时待定,因为保留的话,有20来个测试用例会失败 by lizongbo
|
||||
// expr.addAfterComment(lexer.readAndResetComments());
|
||||
expr.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
@ -3223,6 +3222,7 @@ public class SQLExprParser extends SQLParser {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
item.addAfterComment(lexer.comments);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1129,7 +1129,9 @@ public class SQLSelectParser extends SQLParser {
|
|||
final List<SQLSelectItem> selectList = queryBlock.getSelectList();
|
||||
boolean hasComma = true;
|
||||
for (; ; ) {
|
||||
List<String> previousComments = lexer.comments;
|
||||
final SQLSelectItem selectItem = this.exprParser.parseSelectItem();
|
||||
selectItem.addBeforeComment(previousComments);
|
||||
selectList.add(selectItem);
|
||||
selectItem.setParent(queryBlock);
|
||||
if (!hasComma && selectItem.getExpr() instanceof SQLVariantRefExpr) {
|
||||
|
|
|
@ -556,6 +556,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
this.indentCount++;
|
||||
for (int i = 0, lineItemCount = 0, size = selectList.size(); i < size; ++i, ++lineItemCount) {
|
||||
SQLSelectItem selectItem = selectList.get(i);
|
||||
if (selectItem.hasBeforeComment()) {
|
||||
printlnComments(selectItem.getBeforeCommentsDirect());
|
||||
}
|
||||
SQLExpr selectItemExpr = selectItem.getExpr();
|
||||
|
||||
int paramCount = paramCount(selectItemExpr);
|
||||
|
@ -987,11 +990,17 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
printOperator(operator);
|
||||
print(' ');
|
||||
Number number = ((SQLIntegerExpr) right).getNumber();
|
||||
if (right.hasBeforeComment()) {
|
||||
printlnComments(right.getBeforeCommentsDirect());
|
||||
}
|
||||
if (number instanceof BigInteger) {
|
||||
print0(((BigInteger) number).toString());
|
||||
} else {
|
||||
print(number.longValue());
|
||||
}
|
||||
if (right.hasAfterComment()) {
|
||||
printAfterComments(right.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1016,10 +1025,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
}
|
||||
|
||||
if (isPrettyFormat() && item.hasBeforeComment() && !parameterized) {
|
||||
printlnComments(item.getBeforeCommentsDirect());
|
||||
}
|
||||
|
||||
visitBinaryLeft(item, operator);
|
||||
|
||||
// if (isPrettyFormat() && item.hasAfterComment()) {
|
||||
|
@ -1076,9 +1081,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
private void visitorBinaryRight(SQLBinaryOpExpr x) {
|
||||
SQLExpr right = x.getRight();
|
||||
SQLBinaryOperator op = x.getOperator();
|
||||
if (isPrettyFormat() && right.hasBeforeComment()) {
|
||||
printlnComments(right.getBeforeCommentsDirect());
|
||||
}
|
||||
if (right instanceof SQLBinaryOpExpr) {
|
||||
SQLBinaryOpExpr binaryRight = (SQLBinaryOpExpr) right;
|
||||
SQLBinaryOperator rightOp = binaryRight.getOperator();
|
||||
|
@ -1126,11 +1128,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
printExpr(right, parameterized);
|
||||
}
|
||||
|
||||
if (right.hasAfterComment() && isPrettyFormat()) {
|
||||
print(' ');
|
||||
printlnComment(right.getAfterCommentsDirect());
|
||||
}
|
||||
|
||||
if (x.getHint() != null) {
|
||||
x.getHint().accept(this);
|
||||
}
|
||||
|
@ -1453,6 +1450,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLCharExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
if (x.isParenthesized()) {
|
||||
print('(');
|
||||
}
|
||||
|
@ -1469,6 +1469,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
if (x.isParenthesized()) {
|
||||
print(')');
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1569,6 +1572,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLIdentifierExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
if (x.isParenthesized()) {
|
||||
print('(');
|
||||
}
|
||||
|
@ -1592,6 +1598,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
if (x.isParenthesized()) {
|
||||
print(')');
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1949,6 +1958,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLIntegerExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
boolean parameterized = this.parameterized;
|
||||
if (x.isParenthesized() && !parameterized) {
|
||||
print('(');
|
||||
|
@ -1957,12 +1969,18 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
if (x.isParenthesized() && !parameterized) {
|
||||
print(')');
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Integer ONE = Integer.valueOf(1);
|
||||
|
||||
protected void printInteger(SQLIntegerExpr x, boolean parameterized) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
Number number = x.getNumber();
|
||||
if (number.equals(ONE)) {
|
||||
if (DbType.oracle.equals(dbType)) {
|
||||
|
@ -1976,6 +1994,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
String name = ((SQLIdentifierExpr) left).getName();
|
||||
if ("rownum".equals(name)) {
|
||||
print(1);
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2003,6 +2024,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
if (this.parameters != null) {
|
||||
ExportParameterVisitorUtils.exportParameter(this.parameters, x);
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2011,9 +2035,15 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
} else {
|
||||
print(number.longValue());
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean visit(SQLMethodInvokeExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
if (x.isParenthesized()) {
|
||||
print('(');
|
||||
}
|
||||
|
@ -2035,6 +2065,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
replaceCount++;
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2047,6 +2080,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
if (x.isParenthesized()) {
|
||||
print(')');
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2369,6 +2405,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLNullExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
SQLObject parent = x.getParent();
|
||||
if (this.parameterized
|
||||
&& (parent instanceof ValuesClause || parent instanceof SQLInListExpr ||
|
||||
|
@ -2383,10 +2422,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
this.getParameters().add(null);
|
||||
}
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
print0(ucase ? "NULL" : "null");
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2406,6 +2451,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLPropertyExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
SQLExpr owner = x.getOwner();
|
||||
|
||||
String mapTableName = null, ownerName = null;
|
||||
|
@ -2461,6 +2509,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
} else {
|
||||
printName0(name);
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3174,6 +3225,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
final String name = identifierExpr.getName();
|
||||
if (!this.parameterized) {
|
||||
printName0(name, false);
|
||||
if (identifierExpr.hasAfterComment()) {
|
||||
printAfterComments(identifierExpr.getAfterCommentsDirect());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3191,6 +3245,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
} else {
|
||||
printName0(name);
|
||||
}
|
||||
if (identifierExpr.hasAfterComment()) {
|
||||
printAfterComments(identifierExpr.getAfterCommentsDirect());
|
||||
}
|
||||
} else if (expr instanceof SQLPropertyExpr) {
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) expr;
|
||||
SQLExpr owner = propertyExpr.getOwner();
|
||||
|
@ -3333,10 +3390,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
}
|
||||
|
||||
public boolean visit(SQLVariantRefExpr x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
int index = x.getIndex();
|
||||
|
||||
if (index < 0 || inputParameters == null || index >= inputParameters.size()) {
|
||||
print0(x.getName());
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3370,6 +3433,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
} else {
|
||||
printParameter(param);
|
||||
}
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4596,6 +4662,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
protected void printJoinHint(SQLJoinTableSource x){}
|
||||
@Override
|
||||
public boolean visit(SQLJoinTableSource x) {
|
||||
if (x.hasBeforeComment()) {
|
||||
printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
SQLCommentHint hint = x.getHint();
|
||||
if (hint != null) {
|
||||
hint.accept(this);
|
||||
|
@ -4704,6 +4773,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
|||
|
||||
printPivot(x.getPivot());
|
||||
printUnpivot(x.getUnpivot());
|
||||
if (x.hasAfterComment()) {
|
||||
printAfterComments(x.getAfterCommentsDirect());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -550,6 +550,8 @@ public final class JdbcUtils implements JdbcConstants {
|
|||
return JdbcConstants.GBASE8S_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:sundb:")) {
|
||||
return JdbcConstants.SUNDB_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:gaussdb:")) {
|
||||
return "com.huawei.gaussdb.jdbc.Driver";
|
||||
} else {
|
||||
throw new SQLException("unknown jdbc driver : " + rawUrl);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
|||
case trino:
|
||||
case supersql:
|
||||
case polardbx:
|
||||
case goldendb:
|
||||
if (config == null) {
|
||||
config = new WallConfig(MySqlWallProvider.DEFAULT_CONFIG_DIR);
|
||||
}
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockDriver;
|
||||
|
@ -48,7 +49,7 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
@ -60,8 +61,8 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
MockStatement mockStmt = stmt.unwrap(MockStatement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -76,9 +77,9 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
MockStatement mockStmt = stmt.unwrap(MockStatement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -93,8 +94,8 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
MockPreparedStatement mockStmt = stmt.unwrap(MockPreparedStatement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -110,9 +111,9 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
MockPreparedStatement mockStmt = stmt.unwrap(MockPreparedStatement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -127,8 +128,8 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
Statement mockStmt = stmt.unwrap(Statement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -144,9 +145,9 @@ public class Bug_for_happyday517 extends PoolTestCase {
|
|||
|
||||
Statement mockStmt = stmt.unwrap(Statement.class);
|
||||
|
||||
Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
|
||||
assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
|
||||
assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
|
|
@ -15,13 +15,15 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DataTruncation;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
|
@ -66,7 +68,7 @@ public class Bug_for_happyday517_2 extends TestCase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
}
|
||||
|
||||
public void test_bug() throws Exception {
|
||||
|
@ -81,7 +83,7 @@ public class Bug_for_happyday517_2 extends TestCase {
|
|||
error = ex;
|
||||
}
|
||||
|
||||
Assert.assertTrue(exception == error);
|
||||
assertTrue(exception == error);
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockDriver;
|
||||
|
@ -43,12 +44,12 @@ public class Bug_for_happyday517_3 extends TestCase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
assertEquals(originalDataSourceCount, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
}
|
||||
|
||||
public void test_bug() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Assert.assertEquals(false, conn.getAutoCommit());
|
||||
assertEquals(false, conn.getAutoCommit());
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,15 +15,16 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class Bug_for_order extends TestCase {
|
||||
public void test_bug_for_xuershan() throws Exception {
|
||||
String sql = "select * from order";
|
||||
String format = SQLUtils.formatMySql(sql);
|
||||
String expected = "SELECT *\nFROM order";
|
||||
Assert.assertEquals(expected, format);
|
||||
assertEquals(expected, format);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser;
|
||||
|
@ -32,6 +33,6 @@ public class Bug_for_qianbi extends TestCase {
|
|||
|
||||
// System.out.println(out.toString());
|
||||
|
||||
Assert.assertEquals(expected, out.toString());
|
||||
assertEquals(expected, out.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
|
@ -47,6 +48,6 @@ public class Bug_for_ruiyi extends TestCase {
|
|||
|
||||
//System.out.println(out.toString());
|
||||
|
||||
Assert.assertEquals(expected, out.toString());
|
||||
assertEquals(expected, out.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
|
@ -32,6 +33,6 @@ public class Bug_for_weizhi extends TestCase {
|
|||
|
||||
String expected = "INSERT INTO aaa\nVALUES (1, 2, '这是个反斜杠\\\\');";
|
||||
|
||||
Assert.assertEquals(expected, SQLUtils.formatMySql(sql));
|
||||
assertEquals(expected, SQLUtils.formatMySql(sql));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockDriver;
|
||||
|
@ -52,7 +53,7 @@ public class Bug_for_xuershan extends TestCase {
|
|||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
stmt.execute();
|
||||
Assert.assertNull(stmt.getResultSet());
|
||||
assertNull(stmt.getResultSet());
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.alibaba.druid.wall.WallConfig;
|
|||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* https://github.com/alibaba/druid/issues/4094
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
|
@ -25,6 +26,6 @@ public class Issue_697 extends TestCase {
|
|||
"VALUES (1010103, now(), now(), 10101, 0\n" +
|
||||
"\t, 'flow=''Ctr''', 'be:login,dev:pc, env:web, type:ctr, from:$loginfrom, result:true');";
|
||||
|
||||
Assert.assertEquals(expected, SQLUtils.formatMySql(sql));
|
||||
assertEquals(expected, SQLUtils.formatMySql(sql));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.bug;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -29,7 +30,7 @@ public class Issue_728 extends TestCase {
|
|||
WallConfig config = new WallConfig();
|
||||
config.setConstArithmeticAllow(false);
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void test2() throws Exception {
|
||||
|
@ -38,7 +39,7 @@ public class Issue_728 extends TestCase {
|
|||
WallConfig config = new WallConfig();
|
||||
config.setCaseConditionConstAllow(false);
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void test3() throws Exception {
|
||||
|
@ -47,6 +48,6 @@ public class Issue_728 extends TestCase {
|
|||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpBitwiseAllow(false);
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.encoding.EncodingConvertFilter;
|
||||
import com.alibaba.druid.filter.stat.StatFilter;
|
||||
|
@ -13,25 +16,25 @@ import com.alibaba.druid.pool.DruidDataSource;
|
|||
public class ClearFilterTest extends PoolTestCase {
|
||||
public void test_filters() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
Assert.assertEquals(0, dataSource.getProxyFilters().size());
|
||||
assertEquals(0, dataSource.getProxyFilters().size());
|
||||
dataSource.setFilters("encoding");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
dataSource.setFilters("!stat");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
Assert.assertEquals(StatFilter.class.getName(), dataSource.getFilterClassNames().get(0));
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(StatFilter.class.getName(), dataSource.getFilterClassNames().get(0));
|
||||
dataSource.setClearFiltersEnable(false);
|
||||
dataSource.setFilters("!encoding");
|
||||
Assert.assertEquals(StatFilter.class.getName(), dataSource.getFilterClassNames().get(0));
|
||||
Assert.assertEquals(EncodingConvertFilter.class.getName(), dataSource.getFilterClassNames().get(1));
|
||||
assertEquals(StatFilter.class.getName(), dataSource.getFilterClassNames().get(0));
|
||||
assertEquals(EncodingConvertFilter.class.getName(), dataSource.getFilterClassNames().get(1));
|
||||
|
||||
dataSource.setConnectionProperties("druid.clearFiltersEnable=false");
|
||||
Assert.assertFalse(dataSource.isClearFiltersEnable());
|
||||
assertFalse(dataSource.isClearFiltersEnable());
|
||||
|
||||
dataSource.setConnectionProperties("druid.clearFiltersEnable=true");
|
||||
Assert.assertTrue(dataSource.isClearFiltersEnable());
|
||||
assertTrue(dataSource.isClearFiltersEnable());
|
||||
|
||||
dataSource.setConnectionProperties("druid.clearFiltersEnable=xx"); // no change
|
||||
Assert.assertTrue(dataSource.isClearFiltersEnable());
|
||||
assertTrue(dataSource.isClearFiltersEnable());
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
|
|
|
@ -15,12 +15,15 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.encoding.EncodingConvertFilter;
|
||||
|
@ -68,7 +71,7 @@ public class EncodingConvertFilterTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test_stat() throws Exception {
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
|
||||
EncodingConvertFilter filter = (EncodingConvertFilter) dataSource.getProxyFilters().get(0);
|
||||
|
||||
|
@ -82,8 +85,8 @@ public class EncodingConvertFilterTest extends TestCase {
|
|||
|
||||
String param1 = (String) raw.getParameters().get(0);
|
||||
|
||||
Assert.assertEquals(PARAM_VALUE, new String(param1.getBytes(SERVER_ENCODING), CLIENT_ENCODING));
|
||||
Assert.assertFalse(param1.equals(PARAM_VALUE));
|
||||
assertEquals(PARAM_VALUE, new String(param1.getBytes(SERVER_ENCODING), CLIENT_ENCODING));
|
||||
assertFalse(param1.equals(PARAM_VALUE));
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
|
@ -92,7 +95,7 @@ public class EncodingConvertFilterTest extends TestCase {
|
|||
|
||||
rs.next();
|
||||
|
||||
Assert.assertEquals(text, rs.getString(1));
|
||||
assertEquals(text, rs.getString(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.sql.CallableStatement;
|
||||
|
@ -27,7 +31,6 @@ import java.util.Collections;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.encoding.EncodingConvertFilter;
|
||||
import com.alibaba.druid.mock.MockCallableStatement;
|
||||
|
@ -78,7 +81,7 @@ public class EncodingConvertFilterTest2 extends TestCase {
|
|||
}
|
||||
|
||||
public void test_stat() throws Exception {
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
|
||||
EncodingConvertFilter filter = (EncodingConvertFilter) dataSource.getProxyFilters().get(0);
|
||||
|
||||
|
@ -94,8 +97,8 @@ public class EncodingConvertFilterTest2 extends TestCase {
|
|||
String param1 = (String) raw.getParameters().get(0);
|
||||
|
||||
String C_TEXT = new String(param1.getBytes(SERVER_ENCODING), CLIENT_ENCODING);
|
||||
Assert.assertEquals(PARAM_VALUE, C_TEXT);
|
||||
Assert.assertFalse(param1.equals(PARAM_VALUE));
|
||||
assertEquals(PARAM_VALUE, C_TEXT);
|
||||
assertFalse(param1.equals(PARAM_VALUE));
|
||||
|
||||
MyResultSet rawRs = new MyResultSet(raw);
|
||||
|
||||
|
@ -107,33 +110,33 @@ public class EncodingConvertFilterTest2 extends TestCase {
|
|||
|
||||
rs.next();
|
||||
|
||||
Assert.assertEquals(text, rs.getString(1));
|
||||
Assert.assertEquals(text, rs.getString("1"));
|
||||
Assert.assertEquals(text, rs.getObject(1));
|
||||
Assert.assertEquals(text, rs.getObject("1"));
|
||||
Assert.assertEquals(text, rs.getObject(1, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(text, rs.getObject("1", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getString(1));
|
||||
assertEquals(text, rs.getString("1"));
|
||||
assertEquals(text, rs.getObject(1));
|
||||
assertEquals(text, rs.getObject("1"));
|
||||
assertEquals(text, rs.getObject(1, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getObject("1", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
Assert.assertEquals(text, rs.getString(2));
|
||||
Assert.assertEquals(text, rs.getString("2"));
|
||||
Assert.assertEquals(text, rs.getObject(2));
|
||||
Assert.assertEquals(text, rs.getObject("2"));
|
||||
Assert.assertEquals(text, rs.getObject(2, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(text, rs.getObject("2", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getString(2));
|
||||
assertEquals(text, rs.getString("2"));
|
||||
assertEquals(text, rs.getObject(2));
|
||||
assertEquals(text, rs.getObject("2"));
|
||||
assertEquals(text, rs.getObject(2, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getObject("2", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
Assert.assertEquals(text, rs.getString(3));
|
||||
Assert.assertEquals(text, rs.getString("3"));
|
||||
Assert.assertEquals(text, rs.getObject(3));
|
||||
Assert.assertEquals(text, rs.getObject("3"));
|
||||
Assert.assertEquals(text, rs.getObject(3, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(text, rs.getObject("3", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getString(3));
|
||||
assertEquals(text, rs.getString("3"));
|
||||
assertEquals(text, rs.getObject(3));
|
||||
assertEquals(text, rs.getObject("3"));
|
||||
assertEquals(text, rs.getObject(3, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getObject("3", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
Assert.assertEquals(text, rs.getString(4));
|
||||
Assert.assertEquals(text, rs.getString("4"));
|
||||
Assert.assertEquals(text, rs.getObject(4));
|
||||
Assert.assertEquals(text, rs.getObject("4"));
|
||||
Assert.assertEquals(text, rs.getObject(4, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(text, rs.getObject("4", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getString(4));
|
||||
assertEquals(text, rs.getString("4"));
|
||||
assertEquals(text, rs.getObject(4));
|
||||
assertEquals(text, rs.getObject("4"));
|
||||
assertEquals(text, rs.getObject(4, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(text, rs.getObject("4", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
stmt.registerOutParameter(2, Types.VARCHAR);
|
||||
stmt.registerOutParameter(3, Types.CLOB);
|
||||
|
@ -141,96 +144,96 @@ public class EncodingConvertFilterTest2 extends TestCase {
|
|||
raw.getOutParameters().add(param1);
|
||||
|
||||
|
||||
Assert.assertEquals(C_TEXT, stmt.getString(4));
|
||||
Assert.assertEquals(C_TEXT, stmt.getString("4"));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject(4));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject("4"));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject(4, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject("4", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(C_TEXT, stmt.getString(4));
|
||||
assertEquals(C_TEXT, stmt.getString("4"));
|
||||
assertEquals(C_TEXT, stmt.getObject(4));
|
||||
assertEquals(C_TEXT, stmt.getObject("4"));
|
||||
assertEquals(C_TEXT, stmt.getObject(4, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(C_TEXT, stmt.getObject("4", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
Assert.assertEquals(C_TEXT, stmt.getString(5));
|
||||
Assert.assertEquals(C_TEXT, stmt.getString("5"));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject(5));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject("5"));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject(5, Collections.<String, Class<?>>emptyMap()));
|
||||
Assert.assertEquals(C_TEXT, stmt.getObject("5", Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(C_TEXT, stmt.getString(5));
|
||||
assertEquals(C_TEXT, stmt.getString("5"));
|
||||
assertEquals(C_TEXT, stmt.getObject(5));
|
||||
assertEquals(C_TEXT, stmt.getObject("5"));
|
||||
assertEquals(C_TEXT, stmt.getObject(5, Collections.<String, Class<?>>emptyMap()));
|
||||
assertEquals(C_TEXT, stmt.getObject("5", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
stmt.setObject(1, C_TEXT);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(0));
|
||||
assertEquals(param1, raw.getParameters().get(0));
|
||||
|
||||
stmt.setObject(2, new StringReader(C_TEXT));
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(1)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(1)));
|
||||
|
||||
stmt.setCharacterStream(3, new StringReader(C_TEXT));
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(2)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(2)));
|
||||
|
||||
stmt.setCharacterStream(4, new StringReader(C_TEXT), C_TEXT.length());
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(3)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(3)));
|
||||
|
||||
stmt.setCharacterStream(5, new StringReader(C_TEXT), (long) C_TEXT.length());
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(4)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(4)));
|
||||
|
||||
stmt.setObject(6, C_TEXT, Types.VARCHAR);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(5));
|
||||
assertEquals(param1, raw.getParameters().get(5));
|
||||
stmt.setObject(7, new StringReader(C_TEXT), Types.VARCHAR);
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(6)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(6)));
|
||||
|
||||
stmt.setObject(8, C_TEXT, Types.VARCHAR, 0);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(7));
|
||||
assertEquals(param1, raw.getParameters().get(7));
|
||||
stmt.setObject(9, new StringReader(C_TEXT), Types.VARCHAR, 0);
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(8)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(8)));
|
||||
|
||||
stmt.setObject(10, 1, Types.INTEGER);
|
||||
Assert.assertEquals(1, raw.getParameters().get(9));
|
||||
assertEquals(1, raw.getParameters().get(9));
|
||||
|
||||
stmt.setObject(11, 2, Types.INTEGER, 0);
|
||||
Assert.assertEquals(2, raw.getParameters().get(10));
|
||||
assertEquals(2, raw.getParameters().get(10));
|
||||
|
||||
stmt.setObject(12, 3);
|
||||
Assert.assertEquals(3, raw.getParameters().get(11));
|
||||
assertEquals(3, raw.getParameters().get(11));
|
||||
|
||||
stmt.setObject("13", C_TEXT, Types.VARCHAR);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(12));
|
||||
assertEquals(param1, raw.getParameters().get(12));
|
||||
stmt.setObject("14", new StringReader(C_TEXT), Types.VARCHAR);
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(13)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(13)));
|
||||
|
||||
stmt.setObject("15", C_TEXT, Types.VARCHAR, 0);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(14));
|
||||
assertEquals(param1, raw.getParameters().get(14));
|
||||
stmt.setObject("16", new StringReader(C_TEXT), Types.VARCHAR, 0);
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(15)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(15)));
|
||||
|
||||
stmt.setObject("17", 1, Types.INTEGER);
|
||||
Assert.assertEquals(1, raw.getParameters().get(16));
|
||||
assertEquals(1, raw.getParameters().get(16));
|
||||
|
||||
stmt.setObject("18", 2, Types.INTEGER, 0);
|
||||
Assert.assertEquals(2, raw.getParameters().get(17));
|
||||
assertEquals(2, raw.getParameters().get(17));
|
||||
|
||||
stmt.setObject("19", 3);
|
||||
Assert.assertEquals(3, raw.getParameters().get(18));
|
||||
assertEquals(3, raw.getParameters().get(18));
|
||||
|
||||
stmt.setCharacterStream("20", new StringReader(C_TEXT));
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(19)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(19)));
|
||||
|
||||
stmt.setCharacterStream("21", new StringReader(C_TEXT), C_TEXT.length());
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(20)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(20)));
|
||||
|
||||
stmt.setCharacterStream("22", new StringReader(C_TEXT), (long) C_TEXT.length());
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(21)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(21)));
|
||||
|
||||
stmt.setObject("23", C_TEXT);
|
||||
Assert.assertEquals(param1, raw.getParameters().get(22));
|
||||
assertEquals(param1, raw.getParameters().get(22));
|
||||
|
||||
stmt.setObject("24", new StringReader(C_TEXT));
|
||||
Assert.assertEquals(param1, Utils.read((Reader) raw.getParameters().get(23)));
|
||||
assertEquals(param1, Utils.read((Reader) raw.getParameters().get(23)));
|
||||
|
||||
stmt.setObject("25", 1, Types.INTEGER);
|
||||
Assert.assertEquals(1, raw.getParameters().get(24));
|
||||
assertEquals(1, raw.getParameters().get(24));
|
||||
|
||||
stmt.setObject("26", 2, Types.INTEGER, 0);
|
||||
Assert.assertEquals(2, raw.getParameters().get(25));
|
||||
assertEquals(2, raw.getParameters().get(25));
|
||||
|
||||
stmt.setObject("27", 3);
|
||||
Assert.assertEquals(3, raw.getParameters().get(26));
|
||||
assertEquals(3, raw.getParameters().get(26));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Connection;
|
||||
|
@ -10,7 +14,6 @@ import java.sql.Statement;
|
|||
import java.sql.Types;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -41,39 +44,39 @@ public class FilterChainImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test_size() {
|
||||
Assert.assertEquals(dataSource.getProxyFilters().size(), new FilterChainImpl(dataSource).getFilterSize());
|
||||
assertEquals(dataSource.getProxyFilters().size(), new FilterChainImpl(dataSource).getFilterSize());
|
||||
}
|
||||
|
||||
public void test_unwrap() throws Exception {
|
||||
Assert.assertNull(new FilterChainImpl(dataSource).unwrap(null, null));
|
||||
assertNull(new FilterChainImpl(dataSource).unwrap(null, null));
|
||||
}
|
||||
|
||||
public void test_unwrap_5() throws Exception {
|
||||
Assert.assertNull(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
assertNull(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
(Clob) null));
|
||||
}
|
||||
|
||||
public void test_unwrap_6() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Assert.assertTrue(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
assertTrue(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
new MockNClob()) instanceof NClob);
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_unwrap_8() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Assert.assertTrue(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
assertTrue(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
(Clob) new MockNClob()) instanceof NClob);
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_unwrap_7() throws Exception {
|
||||
Assert.assertNull(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
assertNull(new FilterChainImpl(dataSource).wrap((ConnectionProxy) dataSource.getConnection().getConnection(),
|
||||
(NClob) null));
|
||||
}
|
||||
|
||||
public void test_unwrap_9() throws Exception {
|
||||
Assert.assertNull(new FilterChainImpl(dataSource).wrap((StatementProxy) null, (NClob) null));
|
||||
assertNull(new FilterChainImpl(dataSource).wrap((StatementProxy) null, (NClob) null));
|
||||
}
|
||||
|
||||
public void test_getUnicodeStream() throws Exception {
|
||||
|
@ -83,7 +86,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getUnicodeStream(1));
|
||||
assertNull(rs.getUnicodeStream(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -98,7 +101,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getUnicodeStream("1"));
|
||||
assertNull(rs.getUnicodeStream("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -113,7 +116,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getRef(1));
|
||||
assertNull(rs.getRef(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -128,7 +131,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getRef("1"));
|
||||
assertNull(rs.getRef("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -143,7 +146,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getArray(1));
|
||||
assertNull(rs.getArray(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -158,7 +161,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getArray("1"));
|
||||
assertNull(rs.getArray("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -173,7 +176,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getURL(1));
|
||||
assertNull(rs.getURL(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -188,7 +191,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getURL("1"));
|
||||
assertNull(rs.getURL("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -203,7 +206,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getRowId(1));
|
||||
assertNull(rs.getRowId(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -218,7 +221,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getRowId("1"));
|
||||
assertNull(rs.getRowId("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -233,7 +236,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNClob(1));
|
||||
assertNull(rs.getNClob(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -248,7 +251,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNClob("1"));
|
||||
assertNull(rs.getNClob("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -263,7 +266,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getSQLXML(1));
|
||||
assertNull(rs.getSQLXML(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -278,7 +281,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getSQLXML("1"));
|
||||
assertNull(rs.getSQLXML("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -293,7 +296,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNString(1));
|
||||
assertNull(rs.getNString(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -308,7 +311,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNString("1"));
|
||||
assertNull(rs.getNString("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -323,7 +326,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNCharacterStream(1));
|
||||
assertNull(rs.getNCharacterStream(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -338,7 +341,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getNCharacterStream("1"));
|
||||
assertNull(rs.getNCharacterStream("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -353,7 +356,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getObject(1));
|
||||
assertNull(rs.getObject(1));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
@ -368,7 +371,7 @@ public class FilterChainImplTest extends TestCase {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
Assert.assertNull(rs.getObject("1"));
|
||||
assertNull(rs.getObject("1"));
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -36,7 +40,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getURL(1));
|
||||
assertNull(stmt.getURL(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -47,7 +51,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getURL("1"));
|
||||
assertNull(stmt.getURL("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -58,7 +62,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getString(1));
|
||||
assertNull(stmt.getString(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -69,7 +73,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getString("1"));
|
||||
assertNull(stmt.getString("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -80,7 +84,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertFalse(stmt.getBoolean(1));
|
||||
assertFalse(stmt.getBoolean(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -91,7 +95,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertFalse(stmt.getBoolean("1"));
|
||||
assertFalse(stmt.getBoolean("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -103,7 +107,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getByte(1));
|
||||
assertEquals(0, stmt.getByte(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -114,7 +118,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getByte("1"));
|
||||
assertEquals(0, stmt.getByte("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -125,7 +129,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getShort(1));
|
||||
assertEquals(0, stmt.getShort(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -136,7 +140,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getShort("1"));
|
||||
assertEquals(0, stmt.getShort("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -147,7 +151,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getInt(1));
|
||||
assertEquals(0, stmt.getInt(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -158,7 +162,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getInt("1"));
|
||||
assertEquals(0, stmt.getInt("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -169,7 +173,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getLong(1));
|
||||
assertEquals(0, stmt.getLong(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -180,7 +184,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertEquals(0, stmt.getLong("1"));
|
||||
assertEquals(0, stmt.getLong("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -191,7 +195,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertTrue(0F == stmt.getFloat(1));
|
||||
assertTrue(0F == stmt.getFloat(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -202,7 +206,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertTrue(0F == stmt.getFloat("1"));
|
||||
assertTrue(0F == stmt.getFloat("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -213,7 +217,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertTrue(0D == stmt.getDouble(1));
|
||||
assertTrue(0D == stmt.getDouble(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -224,7 +228,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertTrue(0D == stmt.getDouble("1"));
|
||||
assertTrue(0D == stmt.getDouble("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -236,7 +240,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBytes(1));
|
||||
assertNull(stmt.getBytes(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -247,7 +251,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBytes("1"));
|
||||
assertNull(stmt.getBytes("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -259,7 +263,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getDate(1));
|
||||
assertNull(stmt.getDate(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -270,7 +274,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getDate("1"));
|
||||
assertNull(stmt.getDate("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -281,7 +285,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTime(1));
|
||||
assertNull(stmt.getTime(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -292,7 +296,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTime("1"));
|
||||
assertNull(stmt.getTime("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -303,7 +307,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTimestamp(1));
|
||||
assertNull(stmt.getTimestamp(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -314,7 +318,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTimestamp("1"));
|
||||
assertNull(stmt.getTimestamp("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -325,7 +329,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBigDecimal(1));
|
||||
assertNull(stmt.getBigDecimal(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -336,7 +340,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBigDecimal("1"));
|
||||
assertNull(stmt.getBigDecimal("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -347,7 +351,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getRef(1));
|
||||
assertNull(stmt.getRef(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -358,7 +362,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getRef("1"));
|
||||
assertNull(stmt.getRef("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -369,7 +373,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBlob(1));
|
||||
assertNull(stmt.getBlob(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -380,7 +384,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getBlob("1"));
|
||||
assertNull(stmt.getBlob("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -391,7 +395,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getArray(1));
|
||||
assertNull(stmt.getArray(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -402,7 +406,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getArray("1"));
|
||||
assertNull(stmt.getArray("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -413,7 +417,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getDate(1, null));
|
||||
assertNull(stmt.getDate(1, null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -424,7 +428,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getDate("1", null));
|
||||
assertNull(stmt.getDate("1", null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -435,7 +439,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTime(1, null));
|
||||
assertNull(stmt.getTime(1, null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -446,7 +450,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTime("1", null));
|
||||
assertNull(stmt.getTime("1", null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -457,7 +461,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTimestamp(1, null));
|
||||
assertNull(stmt.getTimestamp(1, null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -468,7 +472,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getTimestamp("1", null));
|
||||
assertNull(stmt.getTimestamp("1", null));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -479,7 +483,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getRowId(1));
|
||||
assertNull(stmt.getRowId(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -490,7 +494,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getRowId("1"));
|
||||
assertNull(stmt.getRowId("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -501,7 +505,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNClob(1));
|
||||
assertNull(stmt.getNClob(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -512,7 +516,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNClob("1"));
|
||||
assertNull(stmt.getNClob("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -523,7 +527,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getSQLXML(1));
|
||||
assertNull(stmt.getSQLXML(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -534,7 +538,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getSQLXML("1"));
|
||||
assertNull(stmt.getSQLXML("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -545,7 +549,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNString(1));
|
||||
assertNull(stmt.getNString(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -556,7 +560,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNString("1"));
|
||||
assertNull(stmt.getNString("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -567,7 +571,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNCharacterStream(1));
|
||||
assertNull(stmt.getNCharacterStream(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -578,7 +582,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getNCharacterStream("1"));
|
||||
assertNull(stmt.getNCharacterStream("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -589,7 +593,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getCharacterStream(1));
|
||||
assertNull(stmt.getCharacterStream(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -600,7 +604,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getCharacterStream("1"));
|
||||
assertNull(stmt.getCharacterStream("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -611,7 +615,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getObject(1));
|
||||
assertNull(stmt.getObject(1));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -622,7 +626,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getObject("1"));
|
||||
assertNull(stmt.getObject("1"));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -633,7 +637,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getObject(1, Collections.<String, Class<?>>emptyMap()));
|
||||
assertNull(stmt.getObject(1, Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
@ -644,7 +648,7 @@ public class FilterChainImplTest2 extends TestCase {
|
|||
CallableStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.registerOutParameter(1, Types.VARCHAR);
|
||||
|
||||
Assert.assertNull(stmt.getObject("1", Collections.<String, Class<?>>emptyMap()));
|
||||
assertNull(stmt.getObject("1", Collections.<String, Class<?>>emptyMap()));
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -7,7 +9,6 @@ import java.sql.SQLException;
|
|||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -55,7 +56,7 @@ public class FilterChainImplTest3 extends TestCase {
|
|||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("select ?");
|
||||
stmt.setNull(1, Types.VARCHAR);
|
||||
Assert.assertNull(stmt.executeQuery());
|
||||
assertNull(stmt.executeQuery());
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
@ -64,7 +65,7 @@ public class FilterChainImplTest3 extends TestCase {
|
|||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareCall("select ?");
|
||||
stmt.setNull(1, Types.VARCHAR);
|
||||
Assert.assertNull(stmt.executeQuery());
|
||||
assertNull(stmt.executeQuery());
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ public class FilterChainImplTest3 extends TestCase {
|
|||
public void test_executeQuery_3() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
Assert.assertNull(stmt.executeQuery("select 1"));
|
||||
assertNull(stmt.executeQuery("select 1"));
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ public class FilterChainImplTest3 extends TestCase {
|
|||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute("select 1");
|
||||
Assert.assertNull(stmt.getResultSet());
|
||||
assertNull(stmt.getResultSet());
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockClob;
|
||||
import com.alibaba.druid.mock.MockResultSet;
|
||||
|
@ -26,7 +29,6 @@ import com.alibaba.druid.proxy.jdbc.StatementProxy;
|
|||
import com.alibaba.druid.proxy.jdbc.StatementProxyImpl;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
|
@ -65,8 +67,8 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = chain.resultSet_getClob(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getClob_1() throws Exception {
|
||||
|
@ -74,8 +76,8 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = chain.resultSet_getClob(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject() throws Exception {
|
||||
|
@ -83,8 +85,8 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_1() throws Exception {
|
||||
|
@ -92,8 +94,8 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_2() throws Exception {
|
||||
|
@ -101,8 +103,8 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_3() throws Exception {
|
||||
|
@ -110,7 +112,7 @@ public class FilterChainTest_Clob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,15 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockCallableStatement;
|
||||
|
@ -65,8 +67,8 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = chain.callableStatement_getClob(statement, 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getClob_1() throws Exception {
|
||||
|
@ -74,8 +76,8 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = chain.callableStatement_getClob(statement, "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject() throws Exception {
|
||||
|
@ -83,8 +85,8 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_1() throws Exception {
|
||||
|
@ -92,8 +94,8 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_2() throws Exception {
|
||||
|
@ -101,8 +103,8 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_3() throws Exception {
|
||||
|
@ -110,7 +112,7 @@ public class FilterChainTest_Clob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
@ -22,7 +25,6 @@ import java.util.Properties;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockNClob;
|
||||
|
@ -66,8 +68,8 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = chain.resultSet_getClob(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getClob_1() throws Exception {
|
||||
|
@ -75,8 +77,8 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = chain.resultSet_getClob(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject() throws Exception {
|
||||
|
@ -84,8 +86,8 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_1() throws Exception {
|
||||
|
@ -93,8 +95,8 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_2() throws Exception {
|
||||
|
@ -102,8 +104,8 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_3() throws Exception {
|
||||
|
@ -111,7 +113,7 @@ public class FilterChainTest_NClob extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,15 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockCallableStatement;
|
||||
|
@ -65,8 +67,8 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = chain.callableStatement_getClob(statement, 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getClob_1() throws Exception {
|
||||
|
@ -74,8 +76,8 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = chain.callableStatement_getClob(statement, "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,8 +86,8 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_1() throws Exception {
|
||||
|
@ -93,8 +95,8 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_2() throws Exception {
|
||||
|
@ -102,8 +104,8 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_3() throws Exception {
|
||||
|
@ -111,7 +113,7 @@ public class FilterChainTest_NClob_2 extends TestCase {
|
|||
|
||||
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof NClobProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof NClobProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,15 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockResultSet;
|
||||
|
@ -62,8 +64,8 @@ public class FilterChainTest_ResultSet extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_1() throws Exception {
|
||||
|
@ -71,8 +73,8 @@ public class FilterChainTest_ResultSet extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_2() throws Exception {
|
||||
|
@ -80,8 +82,8 @@ public class FilterChainTest_ResultSet extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_resultSet_getObject_3() throws Exception {
|
||||
|
@ -89,7 +91,7 @@ public class FilterChainTest_ResultSet extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
@ -22,7 +25,6 @@ import java.util.Properties;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChainImpl;
|
||||
import com.alibaba.druid.mock.MockCallableStatement;
|
||||
|
@ -66,8 +68,8 @@ public class FilterChainTest_ResultSet_2 extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, 1);
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_1() throws Exception {
|
||||
|
@ -75,8 +77,8 @@ public class FilterChainTest_ResultSet_2 extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, "1");
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_2() throws Exception {
|
||||
|
@ -84,8 +86,8 @@ public class FilterChainTest_ResultSet_2 extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, 1, Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
|
||||
public void test_getObject_3() throws Exception {
|
||||
|
@ -93,7 +95,7 @@ public class FilterChainTest_ResultSet_2 extends TestCase {
|
|||
|
||||
ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, "1", Collections.<String, Class<?>>emptyMap());
|
||||
|
||||
Assert.assertTrue(clob instanceof ResultSetProxy);
|
||||
Assert.assertEquals(1, invokeCount);
|
||||
assertTrue(clob instanceof ResultSetProxy);
|
||||
assertEquals(1, invokeCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.Filter;
|
||||
|
@ -46,14 +47,14 @@ public class FilterDatasourceConnectAndRecycleFilterTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Assert.assertEquals(0, filter.getDataSourceConnectCount());
|
||||
Assert.assertEquals(0, filter.getDataSourceRecycleCount());
|
||||
assertEquals(0, filter.getDataSourceConnectCount());
|
||||
assertEquals(0, filter.getDataSourceRecycleCount());
|
||||
Connection conn = dataSource.getConnection();
|
||||
Assert.assertEquals(1, filter.getDataSourceConnectCount());
|
||||
Assert.assertEquals(0, filter.getDataSourceRecycleCount());
|
||||
assertEquals(1, filter.getDataSourceConnectCount());
|
||||
assertEquals(0, filter.getDataSourceRecycleCount());
|
||||
conn.close();
|
||||
Assert.assertEquals(1, filter.getDataSourceConnectCount());
|
||||
Assert.assertEquals(1, filter.getDataSourceRecycleCount());
|
||||
assertEquals(1, filter.getDataSourceConnectCount());
|
||||
assertEquals(1, filter.getDataSourceRecycleCount());
|
||||
}
|
||||
|
||||
public static class TestFilter extends FilterAdapter {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.Filter;
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -17,7 +18,7 @@ public class FilterManagerTest extends TestCase {
|
|||
try {
|
||||
Thread.currentThread().setContextClassLoader(null);
|
||||
|
||||
Assert.assertNotNull(FilterManager.getFilter("stat"));
|
||||
assertNotNull(FilterManager.getFilter("stat"));
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(current);
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ public class FilterManagerTest extends TestCase {
|
|||
} catch (SQLException e) {
|
||||
error = e;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
assertNotNull(error);
|
||||
}
|
||||
|
||||
public void test_loadFilter_2() throws Exception {
|
||||
|
@ -46,7 +47,7 @@ public class FilterManagerTest extends TestCase {
|
|||
} catch (SQLException e) {
|
||||
error = e;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
assertNotNull(error);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -32,7 +35,6 @@ import com.alibaba.druid.util.JdbcUtils;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
import java.sql.Timestamp;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* lizongbo
|
||||
|
@ -65,7 +67,7 @@ public class MySQL8DateTimeSqlTypeFilterTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test_mysql8datetime() throws Exception {
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
|
||||
MySQL8DateTimeSqlTypeFilter filter = (MySQL8DateTimeSqlTypeFilter) dataSource.getProxyFilters().get(0);
|
||||
|
||||
|
@ -81,10 +83,10 @@ public class MySQL8DateTimeSqlTypeFilterTest extends TestCase {
|
|||
rs.next();
|
||||
Object obj1 = rs.getObject(1);
|
||||
System.out.println(obj1.getClass() + "|" + obj1);
|
||||
Assert.assertEquals(Timestamp.class, obj1.getClass());
|
||||
assertEquals(Timestamp.class, obj1.getClass());
|
||||
Object obj2 = rs.getObject("cc");
|
||||
System.out.println(obj2.getClass() + "|" + obj2);
|
||||
Assert.assertEquals(Timestamp.class, obj2.getClass());
|
||||
assertEquals(Timestamp.class, obj2.getClass());
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -29,7 +30,7 @@ public class Slf4jFilterTest extends TestCase {
|
|||
dataSource.init();
|
||||
|
||||
Slf4jLogFilter filter = dataSource.unwrap(Slf4jLogFilter.class);
|
||||
Assert.assertNotNull(filter);
|
||||
assertNotNull(filter);
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
|
|
|
@ -15,11 +15,17 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
@ -45,11 +51,11 @@ public class StatFilterAfterResetTest extends TestCase {
|
|||
|
||||
public void test_stat() throws Exception {
|
||||
final String sql = "SELECT 1";
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertNull(sqlStat);
|
||||
assertNull(sqlStat);
|
||||
|
||||
{
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
@ -59,27 +65,27 @@ public class StatFilterAfterResetTest extends TestCase {
|
|||
rs.close();
|
||||
|
||||
sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
Assert.assertEquals("first failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals("first failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
|
||||
rs.close();
|
||||
|
||||
Assert.assertEquals("second failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals("second failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
|
||||
JdbcStatManager.getInstance().reset();
|
||||
|
||||
Assert.assertFalse(sqlStat.isRemoved());
|
||||
assertFalse(sqlStat.isRemoved());
|
||||
|
||||
JdbcStatManager.getInstance().reset();
|
||||
Assert.assertTrue(sqlStat.isRemoved());
|
||||
assertTrue(sqlStat.isRemoved());
|
||||
|
||||
{
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
@ -90,14 +96,14 @@ public class StatFilterAfterResetTest extends TestCase {
|
|||
conn.close();
|
||||
}
|
||||
|
||||
Assert.assertNotSame(sqlStat, dataSource.getDataSourceStat().getSqlStat(sql));
|
||||
assertNotSame(sqlStat, dataSource.getDataSourceStat().getSqlStat(sql));
|
||||
|
||||
{
|
||||
Assert.assertEquals(0, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(0, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
|
||||
sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -28,7 +31,6 @@ import java.util.List;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.nutz.lang.util.ByteInputStream;
|
||||
|
||||
import com.alibaba.druid.mock.MockBlob;
|
||||
|
@ -102,19 +104,19 @@ public class StatFilterBuildSlowParameterTest extends TestCase {
|
|||
// //////
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
String slowParameters = sqlStat.getLastSlowParameters();
|
||||
Assert.assertNotNull(slowParameters);
|
||||
assertNotNull(slowParameters);
|
||||
|
||||
List<Object> parameters = (List<Object>) JSONUtils.parse(slowParameters);
|
||||
Assert.assertEquals(5, parameters.size());
|
||||
assertEquals(5, parameters.size());
|
||||
|
||||
Assert.assertEquals(true, parameters.get(0));
|
||||
Assert.assertEquals(123, parameters.get(1));
|
||||
Assert.assertEquals(10001, parameters.get(2));
|
||||
Assert.assertEquals(dateText, parameters.get(3));
|
||||
Assert.assertEquals(dateText, parameters.get(4));
|
||||
assertEquals(true, parameters.get(0));
|
||||
assertEquals(123, parameters.get(1));
|
||||
assertEquals(10001, parameters.get(2));
|
||||
assertEquals(dateText, parameters.get(3));
|
||||
assertEquals(dateText, parameters.get(4));
|
||||
}
|
||||
|
||||
currentMillis = System.currentTimeMillis();
|
||||
|
@ -141,19 +143,19 @@ public class StatFilterBuildSlowParameterTest extends TestCase {
|
|||
// //////
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
String slowParameters = sqlStat.getLastSlowParameters();
|
||||
Assert.assertNotNull(slowParameters);
|
||||
assertNotNull(slowParameters);
|
||||
|
||||
List<Object> parameters = (List<Object>) JSONUtils.parse(slowParameters);
|
||||
Assert.assertEquals(5, parameters.size());
|
||||
assertEquals(5, parameters.size());
|
||||
|
||||
Assert.assertEquals(false, parameters.get(0));
|
||||
Assert.assertEquals(234, parameters.get(1));
|
||||
Assert.assertEquals(10002, parameters.get(2));
|
||||
Assert.assertEquals(dateText, parameters.get(3));
|
||||
Assert.assertEquals(dateText, parameters.get(4));
|
||||
assertEquals(false, parameters.get(0));
|
||||
assertEquals(234, parameters.get(1));
|
||||
assertEquals(10002, parameters.get(2));
|
||||
assertEquals(dateText, parameters.get(3));
|
||||
assertEquals(dateText, parameters.get(4));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -182,19 +184,19 @@ public class StatFilterBuildSlowParameterTest extends TestCase {
|
|||
// //////
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
String slowParameters = sqlStat.getLastSlowParameters();
|
||||
Assert.assertNotNull(slowParameters);
|
||||
assertNotNull(slowParameters);
|
||||
|
||||
List<Object> parameters = (List<Object>) JSONUtils.parse(slowParameters);
|
||||
Assert.assertEquals(5, parameters.size());
|
||||
assertEquals(5, parameters.size());
|
||||
|
||||
Assert.assertEquals(null, parameters.get(0));
|
||||
Assert.assertEquals(buf.substring(0, 97) + "...", parameters.get(1));
|
||||
Assert.assertEquals("<Clob>", parameters.get(2));
|
||||
Assert.assertEquals("<NClob>", parameters.get(3));
|
||||
Assert.assertEquals("<Blob>", parameters.get(4));
|
||||
assertEquals(null, parameters.get(0));
|
||||
assertEquals(buf.substring(0, 97) + "...", parameters.get(1));
|
||||
assertEquals("<Clob>", parameters.get(2));
|
||||
assertEquals("<NClob>", parameters.get(3));
|
||||
assertEquals("<Blob>", parameters.get(4));
|
||||
}
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
@ -222,19 +224,19 @@ public class StatFilterBuildSlowParameterTest extends TestCase {
|
|||
// //////
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
String slowParameters = sqlStat.getLastSlowParameters();
|
||||
Assert.assertNotNull(slowParameters);
|
||||
assertNotNull(slowParameters);
|
||||
|
||||
List<Object> parameters = (List<Object>) JSONUtils.parse(slowParameters);
|
||||
Assert.assertEquals(5, parameters.size());
|
||||
assertEquals(5, parameters.size());
|
||||
|
||||
Assert.assertEquals("<InputStream>", parameters.get(0));
|
||||
Assert.assertEquals(buf.substring(0, 97) + "...", parameters.get(1));
|
||||
Assert.assertEquals(dateText, parameters.get(2));
|
||||
Assert.assertEquals(56789.123, parameters.get(3));
|
||||
Assert.assertEquals("<com.alibaba.druid.mock.MockRowId>", parameters.get(4));
|
||||
assertEquals("<InputStream>", parameters.get(0));
|
||||
assertEquals(buf.substring(0, 97) + "...", parameters.get(1));
|
||||
assertEquals(dateText, parameters.get(2));
|
||||
assertEquals(56789.123, parameters.get(3));
|
||||
assertEquals("<com.alibaba.druid.mock.MockRowId>", parameters.get(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockClob;
|
||||
|
@ -57,7 +60,7 @@ public class StatFilterClobTest extends TestCase {
|
|||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
Assert.assertTrue(rs.getObject(1) instanceof ClobProxy);
|
||||
assertTrue(rs.getObject(1) instanceof ClobProxy);
|
||||
rs.close();
|
||||
|
||||
stmt.close();
|
||||
|
@ -65,11 +68,11 @@ public class StatFilterClobTest extends TestCase {
|
|||
conn.close();
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getClobOpenCount());
|
||||
assertEquals(1, sqlStat.getClobOpenCount());
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
import com.alibaba.druid.filter.FilterChain;
|
||||
|
@ -55,7 +56,7 @@ public class StatFilterExecErrorTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
|
||||
try {
|
||||
stmt.executeQuery();
|
||||
|
@ -65,8 +66,8 @@ public class StatFilterExecErrorTest extends TestCase {
|
|||
JdbcUtils.close(conn);
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getErrorCount());
|
||||
Assert.assertEquals(0, sqlStat.getRunningCount());
|
||||
assertEquals(1, sqlStat.getErrorCount());
|
||||
assertEquals(0, sqlStat.getRunningCount());
|
||||
|
||||
sqlStat.reset();
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
|
@ -56,14 +58,14 @@ public class StatFilterExecuteFirstResultSetTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test_stat() throws Exception {
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
final String sql = "select 1";
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
boolean firstResult = stmt.execute();
|
||||
Assert.assertTrue(firstResult);
|
||||
assertTrue(firstResult);
|
||||
|
||||
ResultSet rs = stmt.getResultSet();
|
||||
rs.next();
|
||||
|
@ -75,10 +77,10 @@ public class StatFilterExecuteFirstResultSetTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getHistogramSum());
|
||||
assertEquals(1, sqlStat.getHistogramSum());
|
||||
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
|
||||
static class MyMockPreparedStatement extends MockPreparedStatement {
|
||||
|
|
|
@ -15,11 +15,14 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
|
@ -55,17 +58,17 @@ public class StatFilterExecuteTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test_stat() throws Exception {
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
final String sql = "update x";
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
|
||||
Assert.assertEquals(0, dataSource.getDataSourceStat().getSqlStat(sql).getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(0, dataSource.getDataSourceStat().getSqlStat(sql).getExecuteAndResultHoldTimeHistogramSum());
|
||||
|
||||
boolean firstResult = stmt.execute();
|
||||
Assert.assertFalse(firstResult);
|
||||
assertFalse(firstResult);
|
||||
|
||||
stmt.close();
|
||||
|
||||
|
@ -73,9 +76,9 @@ public class StatFilterExecuteTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getHistogramSum());
|
||||
assertEquals(1, sqlStat.getHistogramSum());
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
|
||||
static class MyMockPreparedStatement extends MockPreparedStatement {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -54,7 +55,7 @@ public class StatFilterOpenBlobCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -65,10 +66,10 @@ public class StatFilterOpenBlobCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getBlobOpenCount());
|
||||
assertEquals(2, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -79,7 +80,7 @@ public class StatFilterOpenBlobCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -91,9 +92,9 @@ public class StatFilterOpenBlobCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getBlobOpenCount());
|
||||
assertEquals(3, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -66,7 +67,7 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -77,10 +78,10 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getBlobOpenCount());
|
||||
assertEquals(2, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -91,7 +92,7 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -103,10 +104,10 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getBlobOpenCount());
|
||||
assertEquals(3, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_2() throws Exception {
|
||||
|
@ -117,7 +118,7 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -130,10 +131,10 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(4, sqlStat.getBlobOpenCount());
|
||||
assertEquals(4, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_4() throws Exception {
|
||||
|
@ -144,7 +145,7 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -158,9 +159,9 @@ public class StatFilterOpenBlobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(5, sqlStat.getBlobOpenCount());
|
||||
assertEquals(5, sqlStat.getBlobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
assertEquals(0, sqlStat.getBlobOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -57,7 +58,7 @@ public class StatFilterOpenClobCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -68,10 +69,10 @@ public class StatFilterOpenClobCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getClobOpenCount());
|
||||
assertEquals(2, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -82,7 +83,7 @@ public class StatFilterOpenClobCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -94,9 +95,9 @@ public class StatFilterOpenClobCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getClobOpenCount());
|
||||
assertEquals(3, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -71,7 +72,7 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -82,10 +83,10 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getClobOpenCount());
|
||||
assertEquals(2, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -96,7 +97,7 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -108,10 +109,10 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getClobOpenCount());
|
||||
assertEquals(3, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_2() throws Exception {
|
||||
|
@ -122,7 +123,7 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -135,10 +136,10 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(4, sqlStat.getClobOpenCount());
|
||||
assertEquals(4, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_4() throws Exception {
|
||||
|
@ -149,7 +150,7 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -163,9 +164,9 @@ public class StatFilterOpenClobCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(5, sqlStat.getClobOpenCount());
|
||||
assertEquals(5, sqlStat.getClobOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getClobOpenCount());
|
||||
assertEquals(0, sqlStat.getClobOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -53,7 +54,7 @@ public class StatFilterOpenInputStreamCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -64,10 +65,10 @@ public class StatFilterOpenInputStreamCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(2, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -78,7 +79,7 @@ public class StatFilterOpenInputStreamCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -90,9 +91,9 @@ public class StatFilterOpenInputStreamCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(3, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -54,7 +55,7 @@ public class StatFilterOpenInputStreamCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -65,10 +66,10 @@ public class StatFilterOpenInputStreamCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(2, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -79,7 +80,7 @@ public class StatFilterOpenInputStreamCountTest2 extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -91,9 +92,9 @@ public class StatFilterOpenInputStreamCountTest2 extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(3, sqlStat.getInputStreamOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
assertEquals(0, sqlStat.getInputStreamOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.nutz.lang.stream.StringReader;
|
||||
|
@ -54,7 +55,7 @@ public class StatFilterOpenReaderCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -65,10 +66,10 @@ public class StatFilterOpenReaderCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(2, sqlStat.getReaderOpenCount());
|
||||
assertEquals(2, sqlStat.getReaderOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -79,7 +80,7 @@ public class StatFilterOpenReaderCountTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -91,9 +92,9 @@ public class StatFilterOpenReaderCountTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(3, sqlStat.getReaderOpenCount());
|
||||
assertEquals(3, sqlStat.getReaderOpenCount());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
assertEquals(0, sqlStat.getReaderOpenCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -53,8 +54,8 @@ public class StatFilterReadBytesLengthTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(0, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadBytesLength());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -64,12 +65,12 @@ public class StatFilterReadBytesLengthTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(6, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(6, sqlStat.getReadBytesLength());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(0, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadBytesLength());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -80,8 +81,8 @@ public class StatFilterReadBytesLengthTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(0, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadBytesLength());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -91,11 +92,11 @@ public class StatFilterReadBytesLengthTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(7, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(7, sqlStat.getReadBytesLength());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
Assert.assertEquals(0, sqlStat.getReadBytesLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadBytesLength());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.FilterAdapter;
|
||||
|
@ -53,7 +54,7 @@ public class StatFilterReadStringLengthTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -63,10 +64,10 @@ public class StatFilterReadStringLengthTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(6, sqlStat.getReadStringLength());
|
||||
assertEquals(6, sqlStat.getReadStringLength());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
}
|
||||
|
||||
public void test_stat_1() throws Exception {
|
||||
|
@ -77,7 +78,7 @@ public class StatFilterReadStringLengthTest extends TestCase {
|
|||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
@ -87,9 +88,9 @@ public class StatFilterReadStringLengthTest extends TestCase {
|
|||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(7, sqlStat.getReadStringLength());
|
||||
assertEquals(7, sqlStat.getReadStringLength());
|
||||
|
||||
sqlStat.reset();
|
||||
Assert.assertEquals(0, sqlStat.getReadStringLength());
|
||||
assertEquals(0, sqlStat.getReadStringLength());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,16 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
@ -47,11 +51,11 @@ public class StatFilterResultSetMultiCloseTest extends PoolTestCase {
|
|||
|
||||
public void test_stat() throws Exception {
|
||||
final String sql = "SELECT 1";
|
||||
Assert.assertTrue(dataSource.isInited());
|
||||
assertTrue(dataSource.isInited());
|
||||
|
||||
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
|
||||
Assert.assertNull(sqlStat);
|
||||
assertNull(sqlStat);
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
|
@ -61,18 +65,18 @@ public class StatFilterResultSetMultiCloseTest extends PoolTestCase {
|
|||
rs.close();
|
||||
|
||||
sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
|
||||
Assert.assertNotNull(sqlStat);
|
||||
assertNotNull(sqlStat);
|
||||
|
||||
Assert.assertEquals("first failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals("first failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
|
||||
rs.close();
|
||||
|
||||
Assert.assertEquals("second failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals("second failed", 1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFileGenerator;
|
||||
|
@ -25,7 +27,7 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
try {
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("The username is " + dataSource.getUsername(), "test1", dataSource.getUsername());
|
||||
assertEquals("The username is " + dataSource.getUsername(), "test1", dataSource.getUsername());
|
||||
} finally {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
|
@ -40,7 +42,7 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
try {
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("The username is " + dataSource.getUsername(), "test1", dataSource.getUsername());
|
||||
assertEquals("The username is " + dataSource.getUsername(), "test1", dataSource.getUsername());
|
||||
} finally {
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_FILE);
|
||||
JdbcUtils.close(dataSource);
|
||||
|
@ -61,7 +63,7 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
} finally {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
assertNotNull(error);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,7 +78,7 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
|
||||
try {
|
||||
dataSource.init();
|
||||
Assert.assertEquals("The password is " + dataSource.getPassword() + ", is not xiaoyu", "xiaoyu",
|
||||
assertEquals("The password is " + dataSource.getPassword() + ", is not xiaoyu", "xiaoyu",
|
||||
dataSource.getPassword());
|
||||
} finally {
|
||||
JdbcUtils.close(dataSource);
|
||||
|
@ -91,7 +93,7 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
try {
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("The password is " + dataSource.getPassword(), "xiaoyu", dataSource.getPassword());
|
||||
assertEquals("The password is " + dataSource.getPassword(), "xiaoyu", dataSource.getPassword());
|
||||
} finally {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
|
@ -124,6 +126,6 @@ public class ConfigFilterTest extends ConfigFileGenerator {
|
|||
} finally {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
|
@ -26,13 +28,13 @@ public class ConfigFilterTest1 extends TestCase {
|
|||
|
||||
dataSource.setPassword(ConfigTools.encrypt(plainPassword));
|
||||
|
||||
Assert.assertFalse(plainPassword.equals(dataSource.getPassword()));
|
||||
assertFalse(plainPassword.equals(dataSource.getPassword()));
|
||||
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_DECRYPT, "true");
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals(plainPassword, dataSource.getPassword());
|
||||
assertEquals(plainPassword, dataSource.getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
|
@ -21,67 +22,67 @@ public class ConfigFilterTest2 extends TestCase {
|
|||
|
||||
public void test_decrypt() throws Exception {
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_FILE, "bvt/config/config-0.properties");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-0", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(10, dataSource.getMaxActive());
|
||||
assertEquals("jdbc:mock:config-0", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(10, dataSource.getMaxActive());
|
||||
}
|
||||
|
||||
public void test_decrypt1() throws Exception {
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_FILE, "bvt/config/config-1.properties");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-1", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(11, dataSource.getMaxActive());
|
||||
Assert.assertEquals(3, dataSource.getProxyFilters().size());
|
||||
assertEquals("jdbc:mock:config-1", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(11, dataSource.getMaxActive());
|
||||
assertEquals(3, dataSource.getProxyFilters().size());
|
||||
}
|
||||
|
||||
public void test_decrypt2() throws Exception {
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_FILE, "bvt/config/config-2.properties");
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_DECRYPT, "true");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-2", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(12, dataSource.getMaxActive());
|
||||
Assert.assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:config-2", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(12, dataSource.getMaxActive());
|
||||
assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
}
|
||||
|
||||
public void test_decrypt3() throws Exception {
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_FILE, "bvt/config/config-3.properties");
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-3", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(13, dataSource.getMaxActive());
|
||||
Assert.assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:config-3", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(13, dataSource.getMaxActive());
|
||||
assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
}
|
||||
|
||||
public void test_decrypt4() throws Exception {
|
||||
String file = Thread.currentThread().getContextClassLoader().getResource("bvt/config/config-3.properties").getFile();
|
||||
dataSource.addConnectionProperty(ConfigFilter.CONFIG_FILE, "file://" + file);
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-3", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(13, dataSource.getMaxActive());
|
||||
Assert.assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:config-3", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(13, dataSource.getMaxActive());
|
||||
assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
}
|
||||
|
||||
public void test_decrypt5() throws Exception {
|
||||
Assert.assertEquals(1, dataSource.getProxyFilters().size());
|
||||
assertEquals(1, dataSource.getProxyFilters().size());
|
||||
|
||||
try {
|
||||
String file = Thread.currentThread().getContextClassLoader().getResource("bvt/config/config-2.properties").getFile();
|
||||
|
@ -90,10 +91,10 @@ public class ConfigFilterTest2 extends TestCase {
|
|||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:config-2", dataSource.getUrl());
|
||||
Assert.assertEquals(false, dataSource.isTestOnBorrow());
|
||||
Assert.assertEquals(12, dataSource.getMaxActive());
|
||||
Assert.assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:config-2", dataSource.getUrl());
|
||||
assertEquals(false, dataSource.isTestOnBorrow());
|
||||
assertEquals(12, dataSource.getMaxActive());
|
||||
assertEquals("abcdefg1234567890", dataSource.getPassword());
|
||||
} finally {
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_FILE);
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_DECRYPT);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
|
@ -42,9 +43,9 @@ public class ConfigFilterTest3 extends TestCase {
|
|||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
Assert.assertEquals("sa", dataSource.getUsername());
|
||||
Assert.assertEquals(password, dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
assertEquals("sa", dataSource.getUsername());
|
||||
assertEquals(password, dataSource.getPassword());
|
||||
}
|
||||
|
||||
public void test_sys_property() throws Exception {
|
||||
|
@ -65,9 +66,9 @@ public class ConfigFilterTest3 extends TestCase {
|
|||
try {
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
Assert.assertEquals("sa", dataSource.getUsername());
|
||||
Assert.assertEquals(password, dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
assertEquals("sa", dataSource.getUsername());
|
||||
assertEquals(password, dataSource.getPassword());
|
||||
} finally {
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_KEY);
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_FILE);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
|
@ -42,9 +43,9 @@ public class ConfigFilterTest4 extends TestCase {
|
|||
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
Assert.assertEquals("sa", dataSource.getUsername());
|
||||
Assert.assertEquals(password, dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
assertEquals("sa", dataSource.getUsername());
|
||||
assertEquals(password, dataSource.getPassword());
|
||||
}
|
||||
|
||||
public void test_sys_property() throws Exception {
|
||||
|
@ -65,9 +66,9 @@ public class ConfigFilterTest4 extends TestCase {
|
|||
try {
|
||||
dataSource.init();
|
||||
|
||||
Assert.assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
Assert.assertEquals("sa", dataSource.getUsername());
|
||||
Assert.assertEquals(password, dataSource.getPassword());
|
||||
assertEquals("jdbc:mock:xx0", dataSource.getUrl());
|
||||
assertEquals("sa", dataSource.getUsername());
|
||||
assertEquals(password, dataSource.getPassword());
|
||||
} finally {
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_KEY);
|
||||
System.clearProperty(ConfigFilter.SYS_PROP_CONFIG_FILE);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
|
@ -9,6 +10,6 @@ import com.alibaba.druid.filter.config.ConfigFilter;
|
|||
public class ConfigFilterTest5 extends TestCase {
|
||||
public void test_loadClassPath() throws Exception {
|
||||
ConfigFilter filter = new ConfigFilter();
|
||||
Assert.assertNotNull(filter.loadConfig("classpath:bvt/config/config-0.properties"));
|
||||
assertNotNull(filter.loadConfig("classpath:bvt/config/config-0.properties"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.alibaba.druid.filter.Filter;
|
||||
import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
|
||||
import com.alibaba.druid.stat.JdbcDataSourceStat;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.sql.Driver;
|
||||
import java.util.List;
|
||||
|
@ -16,8 +18,8 @@ public class ConfigFilterTest6 extends TestCase {
|
|||
public void testInitFastFail() {
|
||||
ConfigFilter filter = new ConfigFilter();
|
||||
IllegalArgumentException exception =
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> filter.init(new DataSourceProxyImpl()));
|
||||
Assert.assertEquals("ConfigLoader only support DruidDataSource", exception.getMessage());
|
||||
assertThrows(IllegalArgumentException.class, () -> filter.init(new DataSourceProxyImpl()));
|
||||
assertEquals("ConfigLoader only support DruidDataSource", exception.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
|
@ -13,7 +14,7 @@ public class ConfigToolsTest extends TestCase {
|
|||
String cipherText = ConfigTools.encrypt(plainText);
|
||||
String decipherText = ConfigTools.decrypt(cipherText);
|
||||
|
||||
Assert.assertEquals(plainText, decipherText);
|
||||
assertEquals(plainText, decipherText);
|
||||
}
|
||||
|
||||
public void test_genKeys() throws Exception {
|
||||
|
@ -21,7 +22,7 @@ public class ConfigToolsTest extends TestCase {
|
|||
String[] keys = ConfigTools.genKeyPair(512);
|
||||
|
||||
String cipherText = ConfigTools.encrypt(keys[0], plainText);
|
||||
Assert.assertEquals(plainText, ConfigTools.decrypt(keys[1], cipherText));
|
||||
assertEquals(plainText, ConfigTools.decrypt(keys[1], cipherText));
|
||||
}
|
||||
|
||||
public void test_genKeys1024() throws Exception {
|
||||
|
@ -29,6 +30,6 @@ public class ConfigToolsTest extends TestCase {
|
|||
String[] keys = ConfigTools.genKeyPair(1024);
|
||||
|
||||
String cipherText = ConfigTools.encrypt(keys[0], plainText);
|
||||
Assert.assertEquals(plainText, ConfigTools.decrypt(keys[1], cipherText));
|
||||
assertEquals(plainText, ConfigTools.decrypt(keys[1], cipherText));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.alibaba.druid.bvt.filter.log;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.logging.Log4jFilter;
|
||||
import com.alibaba.druid.filter.logging.LogFilter;
|
||||
|
@ -13,10 +14,10 @@ public class LogFilterTest4 extends TestCase {
|
|||
public void test_properties() throws Exception {
|
||||
LogFilter filter = new Log4jFilter();
|
||||
|
||||
Assert.assertEquals(true, filter.isConnectionLogEnabled());
|
||||
Assert.assertEquals(true, filter.isStatementLogEnabled());
|
||||
Assert.assertEquals(false, filter.isStatementExecutableSqlLogEnable());
|
||||
Assert.assertEquals(true, filter.isResultSetLogEnabled());
|
||||
assertEquals(true, filter.isConnectionLogEnabled());
|
||||
assertEquals(true, filter.isStatementLogEnabled());
|
||||
assertEquals(false, filter.isStatementExecutableSqlLogEnable());
|
||||
assertEquals(true, filter.isResultSetLogEnabled());
|
||||
}
|
||||
|
||||
public void test_properties_1() throws Exception {
|
||||
|
@ -28,10 +29,10 @@ public class LogFilterTest4 extends TestCase {
|
|||
try {
|
||||
LogFilter filter = new Log4jFilter();
|
||||
|
||||
Assert.assertEquals(false, filter.isConnectionLogEnabled());
|
||||
Assert.assertEquals(false, filter.isStatementLogEnabled());
|
||||
Assert.assertEquals(true, filter.isStatementExecutableSqlLogEnable());
|
||||
Assert.assertEquals(false, filter.isResultSetLogEnabled());
|
||||
assertEquals(false, filter.isConnectionLogEnabled());
|
||||
assertEquals(false, filter.isStatementLogEnabled());
|
||||
assertEquals(true, filter.isStatementExecutableSqlLogEnable());
|
||||
assertEquals(false, filter.isResultSetLogEnabled());
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("druid.log.conn", "true");
|
||||
|
@ -41,10 +42,10 @@ public class LogFilterTest4 extends TestCase {
|
|||
|
||||
filter.configFromProperties(properties);
|
||||
|
||||
Assert.assertEquals(true, filter.isConnectionLogEnabled());
|
||||
Assert.assertEquals(true, filter.isStatementLogEnabled());
|
||||
Assert.assertEquals(false, filter.isStatementExecutableSqlLogEnable());
|
||||
Assert.assertEquals(true, filter.isResultSetLogEnabled());
|
||||
assertEquals(true, filter.isConnectionLogEnabled());
|
||||
assertEquals(true, filter.isStatementLogEnabled());
|
||||
assertEquals(false, filter.isStatementExecutableSqlLogEnable());
|
||||
assertEquals(true, filter.isResultSetLogEnabled());
|
||||
} finally {
|
||||
System.clearProperty("druid.log.conn");
|
||||
System.clearProperty("druid.log.stmt");
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.alibaba.druid.bvt.filter.log;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.alibaba.druid.filter.logging.Slf4jLogFilter;
|
||||
|
@ -11,30 +12,30 @@ import com.alibaba.druid.filter.logging.Slf4jLogFilter;
|
|||
public class Slf4jLogFilterTest extends TestCase {
|
||||
public void test_slf4j() throws Exception {
|
||||
Slf4jLogFilter filter = new Slf4jLogFilter();
|
||||
Assert.assertEquals("druid.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
Assert.assertEquals("druid.sql.Connection", filter.getConnectionLoggerName());
|
||||
Assert.assertEquals("druid.sql.Statement", filter.getStatementLoggerName());
|
||||
Assert.assertEquals("druid.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
assertEquals("druid.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
assertEquals("druid.sql.Connection", filter.getConnectionLoggerName());
|
||||
assertEquals("druid.sql.Statement", filter.getStatementLoggerName());
|
||||
assertEquals("druid.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
|
||||
filter.setDataSourceLoggerName("x.sql.DataSource");
|
||||
filter.setConnectionLoggerName("x.sql.Connection");
|
||||
filter.setStatementLoggerName("x.sql.Statement");
|
||||
filter.setResultSetLoggerName("x.sql.ResultSet");
|
||||
|
||||
Assert.assertEquals("x.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
Assert.assertEquals("x.sql.Connection", filter.getConnectionLoggerName());
|
||||
Assert.assertEquals("x.sql.Statement", filter.getStatementLoggerName());
|
||||
Assert.assertEquals("x.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
assertEquals("x.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
assertEquals("x.sql.Connection", filter.getConnectionLoggerName());
|
||||
assertEquals("x.sql.Statement", filter.getStatementLoggerName());
|
||||
assertEquals("x.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
|
||||
filter.setDataSourceLogger(LoggerFactory.getLogger("y.sql.DataSource"));
|
||||
filter.setConnectionLogger(LoggerFactory.getLogger("y.sql.Connection"));
|
||||
filter.setStatementLogger(LoggerFactory.getLogger("y.sql.Statement"));
|
||||
filter.setResultSetLogger(LoggerFactory.getLogger("y.sql.ResultSet"));
|
||||
|
||||
Assert.assertEquals("y.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
Assert.assertEquals("y.sql.Connection", filter.getConnectionLoggerName());
|
||||
Assert.assertEquals("y.sql.Statement", filter.getStatementLoggerName());
|
||||
Assert.assertEquals("y.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
assertEquals("y.sql.DataSource", filter.getDataSourceLoggerName());
|
||||
assertEquals("y.sql.Connection", filter.getConnectionLoggerName());
|
||||
assertEquals("y.sql.Statement", filter.getStatementLoggerName());
|
||||
assertEquals("y.sql.ResultSet", filter.getResultSetLoggerName());
|
||||
|
||||
filter.isDataSourceLogEnabled();
|
||||
filter.isConnectionLogEnabled();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -15,7 +16,7 @@ public class BigSqlTest extends TestCase {
|
|||
sql += " or id=0";
|
||||
}
|
||||
WallConfig config = new WallConfig();
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void test_true2() throws Exception {
|
||||
|
@ -25,6 +26,6 @@ public class BigSqlTest extends TestCase {
|
|||
sql += " and id=0";
|
||||
}
|
||||
WallConfig config = new WallConfig();
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class BitwiseAndTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) & 2")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpBitwiseAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) & 2", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class BitwiseInvertTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where ~2")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpBitwiseAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where ~2", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class BitwiseOrTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) | 2")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpBitwiseAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) | 2", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class BitwiseXorTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) ^ (1=1)")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpBitwiseAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where (id = 1) ^ (1=1)", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class BooleanXorTest extends TestCase {
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where id = 1 XOR id = 2")); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConditionOpXorAllow(true);
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where id = 1 XOR id = 2", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class ConstantArithmeticCheckTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where 3 - 1")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConstArithmeticAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where 3 - 1", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,21 +15,22 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils;
|
||||
|
||||
public class CountTest extends TestCase {
|
||||
public void test_isTrue() throws Exception {
|
||||
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) > 0")));
|
||||
Assert.assertEquals(Boolean.TRUE,
|
||||
assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) > 0")));
|
||||
assertEquals(Boolean.TRUE,
|
||||
WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) >= 0")));
|
||||
Assert.assertEquals(Boolean.FALSE,
|
||||
assertEquals(Boolean.FALSE,
|
||||
WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) < 0")));
|
||||
Assert.assertEquals(Boolean.TRUE,
|
||||
assertEquals(Boolean.TRUE,
|
||||
WallVisitorUtils.getValue(SQLUtils.toSQLExpr("NOT (select count(*) from t) < 0")));
|
||||
|
||||
//
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
|
@ -27,11 +29,11 @@ import com.alibaba.druid.wall.WallUtils;
|
|||
|
||||
public class DoPrivilegedTest extends TestCase {
|
||||
public void test_0() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select @@version_compile_os FROM X"));
|
||||
assertTrue(WallUtils.isValidateMySql("select @@version_compile_os FROM X"));
|
||||
}
|
||||
|
||||
public void test_0_0() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select * FROM X where version=@@version_compile_os"));
|
||||
assertFalse(WallUtils.isValidateMySql("select * FROM X where version=@@version_compile_os"));
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
|
@ -41,7 +43,7 @@ public class DoPrivilegedTest extends TestCase {
|
|||
WallProvider.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select @@version_compile_os FROM X", config));
|
||||
assertTrue(WallUtils.isValidateMySql("select @@version_compile_os FROM X", config));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -31,10 +32,10 @@ public class IdentEqualsTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -31,10 +32,10 @@ public class IdentEqualsTest1 extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -11,12 +13,12 @@ public class IntersectTest extends TestCase {
|
|||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setMinusAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(//
|
||||
assertFalse(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B", config)); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(//
|
||||
assertTrue(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B")); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,19 +15,20 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils;
|
||||
|
||||
public class LikeTest extends TestCase {
|
||||
public void test_isTrue() throws Exception {
|
||||
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("f1 like '%'")));
|
||||
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("f1 like '%%'")));
|
||||
Assert.assertEquals(null, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("a1 = b1 AND f1 like '%%'")));
|
||||
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("a1 = b1 OR f1 like '%%'")));
|
||||
assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("f1 like '%'")));
|
||||
assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("f1 like '%%'")));
|
||||
assertEquals(null, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("a1 = b1 AND f1 like '%%'")));
|
||||
assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("a1 = b1 OR f1 like '%%'")));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -11,12 +13,12 @@ public class MinusTest extends TestCase {
|
|||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setIntersectAllow(false);
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(//
|
||||
assertFalse(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A Intersect SELECT * FROM B", config)); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(//
|
||||
assertTrue(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A Intersect SELECT * FROM B")); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -32,10 +33,10 @@ public class MustParameterizedTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -32,10 +33,10 @@ public class MustParameterizedTest1 extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -32,10 +33,10 @@ public class MustParameterizedTest2 extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -30,17 +32,17 @@ public class MustParameterizedTest3 extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select * from t where id = (3 + 5 - 2 - 1)", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select * from t where id != id + 3", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("delete from t where id != id + 3", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("delete from t where id = 'aa' + 'bbb'", config));
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select * from t where id = ? ORDER BY 1", config));
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ?", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = 7", config));
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select 1, 2, 3 --", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t fid = fid", config));
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t fid > 5", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select * from t where id = (3 + 5 - 2 - 1)", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select * from t where id != id + 3", config));
|
||||
assertFalse(WallUtils.isValidateMySql("delete from t where id != id + 3", config));
|
||||
assertFalse(WallUtils.isValidateMySql("delete from t where id = 'aa' + 'bbb'", config));
|
||||
assertTrue(WallUtils.isValidateMySql("select * from t where id = ? ORDER BY 1", config));
|
||||
assertTrue(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ?", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = 7", config));
|
||||
assertTrue(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select 1, 2, 3 --", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t fid = fid", config));
|
||||
assertFalse(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ? union select * from t fid > 5", config));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -32,10 +33,10 @@ public class MustParameterizedTest4 extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class PGDenyFunctionTest extends TestCase {
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidatePostgres(//
|
||||
assertFalse(WallUtils.isValidatePostgres(//
|
||||
"select * from t where fid = 1 union SELECT current_catalog() from t where id = ?")); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setFunctionCheck(false);
|
||||
Assert.assertTrue(WallUtils.isValidatePostgres(//
|
||||
assertTrue(WallUtils.isValidatePostgres(//
|
||||
"SELECT current_catalog() from t where id = ?", config)); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class PGWallTest extends TestCase {
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidatePostgres(//
|
||||
assertTrue(WallUtils.isValidatePostgres(//
|
||||
"select wm_concat(article_id) over() from t_nds_web_article")); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class StrictSyntaxCheckTest extends TestCase {
|
||||
public void test_syntax() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT SELECT")); // 部分永真
|
||||
}
|
||||
|
||||
public void test_syntax_1() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setStrictSyntaxCheck(false);
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"SELECT SELECT", config)); // 部分永真
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
|
@ -30,12 +32,12 @@ import com.alibaba.druid.wall.WallUtils;
|
|||
*/
|
||||
public class TAEWallTest extends TestCase {
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
assertTrue(WallUtils.isValidateMySql(//
|
||||
"select * from t where 1=1 AND status = 1")); //
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
assertFalse(WallUtils.isValidateMySql(//
|
||||
"select * from t where status = 1 OR 1=1")); //
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -42,10 +43,10 @@ public class TenantDeleteTest extends TestCase {
|
|||
|
||||
WallProvider.setTenantValue("test");
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("DELETE FROM orders" + //
|
||||
assertEquals("DELETE FROM orders" + //
|
||||
"\nWHERE FID = ?", resultSql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -50,20 +51,20 @@ public class TenantInsertTest extends TestCase {
|
|||
{
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
{
|
||||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,20 +78,20 @@ public class TenantInsertTest extends TestCase {
|
|||
{
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
{
|
||||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -105,20 +106,20 @@ public class TenantInsertTest extends TestCase {
|
|||
{
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
{
|
||||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,20 +139,20 @@ public class TenantInsertTest extends TestCase {
|
|||
{
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
{
|
||||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(insert_sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -46,18 +47,18 @@ public class TenantSelectTest extends TestCase {
|
|||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
public void testMySql2() throws Exception {
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -47,18 +48,18 @@ public class TenantSelectTest2 extends TestCase {
|
|||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
public void testMySql2() throws Exception {
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -50,10 +51,10 @@ public class TenantSelectTest3 extends TestCase {
|
|||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
public void testMySql2() throws Exception {
|
||||
|
@ -66,9 +67,9 @@ public class TenantSelectTest3 extends TestCase {
|
|||
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -51,28 +52,28 @@ public class TenantSelectTest4 extends TestCase {
|
|||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
config.setSelectWhereAlwayTrueCheck(false);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
|
||||
provider.reset();
|
||||
config.setSelectWhereAlwayTrueCheck(true);
|
||||
checkResult = provider.check(sql);
|
||||
Assert.assertEquals(1, checkResult.getViolations().size());
|
||||
assertEquals(1, checkResult.getViolations().size());
|
||||
}
|
||||
|
||||
public void testMySql2() throws Exception {
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
provider.getConfig().setSelectWhereAlwayTrueCheck(false);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
|
||||
provider.reset();
|
||||
provider.getConfig().setSelectWhereAlwayTrueCheck(true);
|
||||
checkResult = provider.check(sql);
|
||||
Assert.assertEquals(1, checkResult.getViolations().size());
|
||||
assertEquals(1, checkResult.getViolations().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
@ -46,19 +47,19 @@ public class TenantUpdateTest extends TestCase {
|
|||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
|
||||
public void testMySql2() throws Exception {
|
||||
WallProvider.setTenantValue(123);
|
||||
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
|
||||
WallCheckResult checkResult = provider.check(sql);
|
||||
Assert.assertEquals(0, checkResult.getViolations().size());
|
||||
assertEquals(0, checkResult.getViolations().size());
|
||||
|
||||
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
|
||||
Assert.assertEquals(expect_sql, resultSql);
|
||||
assertEquals(expect_sql, resultSql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -36,14 +37,14 @@ public class WallAllowSelectAllColumnDefaultTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateSqlServer(sql, config));
|
||||
assertTrue(WallUtils.isValidateSqlServer(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
@ -37,14 +38,14 @@ public class WallAllowSelectAllColumnTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer(sql, config));
|
||||
assertFalse(WallUtils.isValidateSqlServer(sql, config));
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue