mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleOrderByItem;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@@ -52,7 +51,7 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
if (i != 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
((OracleOrderByItem) this.items.get(i)).output(buf);
|
||||
this.items.get(i).output(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>druid 监控</title>
|
||||
<title>druid monitor</title>
|
||||
<link href='css/bootstrap.min.css' rel="stylesheet" >
|
||||
<script type="text/javascript" src="js/jquery.min.js"></script>
|
||||
<style type="text/css">
|
||||
@@ -52,7 +52,7 @@
|
||||
<form id="loginForm" method="post" autocomplete="off" >
|
||||
<fieldset>
|
||||
<div id="alertInfo" class="alert alert-error clearfix" style="margin-bottom: 5px;width: 195px; padding: 2px 15px 2px 10px;display: none;">
|
||||
用户名或密码不正确
|
||||
The username or password you entered is incorrect.
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<input type="text" placeholder="用户名" name="loginUsername" >
|
||||
@@ -60,8 +60,8 @@
|
||||
<div class="clearfix">
|
||||
<input type="password" placeholder="密码" name="loginPassword">
|
||||
</div>
|
||||
<button id="loginBtn" class="btn btn-primary" type="button">登 录</button>
|
||||
<button class="btn" type="reset">重 置</button>
|
||||
<button id="loginBtn" class="btn btn-primary" type="button">Sign in</button>
|
||||
<button class="btn" type="reset">Reset</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -47,23 +47,56 @@ public class DruidStatServiceTest extends TestCase {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
|
||||
public void test_statService() throws Exception {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test_statService_getSqlList() throws Exception {
|
||||
String sql = "select 1";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
conn.close();
|
||||
|
||||
|
||||
String result = DruidStatService.getInstance().service("/sql.json");
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSONUtils.parse(result);
|
||||
|
||||
|
||||
List<Map<String, Object>> sqlList = (List<Map<String, Object>>) resultMap.get("Content");
|
||||
|
||||
|
||||
Assert.assertEquals(1, sqlList.size());
|
||||
|
||||
Map<String, Object> sqlStat = sqlList.get(0);
|
||||
|
||||
Assert.assertEquals(0, sqlStat.get("RunningCount"));
|
||||
Assert.assertEquals(1, sqlStat.get("ExecuteCount"));
|
||||
Assert.assertEquals(1, sqlStat.get("FetchRowCount"));
|
||||
Assert.assertEquals(0, sqlStat.get("EffectedRowCount"));
|
||||
}
|
||||
|
||||
public void test_statService_getDataSourceList() throws Exception {
|
||||
String sql = "select 1";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
|
||||
String result = DruidStatService.getInstance().service("/datasource.json");
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSONUtils.parse(result);
|
||||
|
||||
List<Map<String, Object>> dataSourceList = (List<Map<String, Object>>) resultMap.get("Content");
|
||||
|
||||
Assert.assertEquals(1, dataSourceList.size());
|
||||
|
||||
Map<String, Object> dataSourceStat = dataSourceList.get(0);
|
||||
|
||||
Assert.assertEquals(1, dataSourceStat.get("PoolingCount"));
|
||||
Assert.assertEquals(0, dataSourceStat.get("ActiveCount"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user