mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
remove fastjson dependency
This commit is contained in:
@@ -2,14 +2,14 @@ package com.alibaba.druid;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
|
||||
public class Bug_for_alibank extends TestCase {
|
||||
public void test_bug() throws Exception {
|
||||
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
|
||||
String jsonStrz = "{\"addContact\":[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
|
||||
System.out.println(jsonStrz);
|
||||
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
|
||||
System.out.println(JSON.toJSONString(o));
|
||||
Object o = JSONUtils.parse(jsonStrz.replaceAll("\\\\", ""));
|
||||
System.out.println(JSONUtils.toJSONString(o));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -15,19 +17,18 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.ha.cobar.CobarConfigLoader;
|
||||
import com.alibaba.druid.pool.ha.cobar.CobarDataSource;
|
||||
import com.alibaba.druid.pool.ha.cobar.CobarFailureDetecter;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class CobarDataSourceTest extends TestCase {
|
||||
|
||||
public void test_cobarDataSource() throws Exception {
|
||||
String url = "jdbc:cobar://127.0.0.1:8080/druid";
|
||||
|
||||
final JSONObject config = new JSONObject();
|
||||
final HashMap<String, Object> config = new HashMap<String, Object>();
|
||||
|
||||
JSONArray cobarList = new JSONArray();
|
||||
ArrayList<Object> cobarList = new ArrayList<Object>();
|
||||
|
||||
JSONObject cobarA = new JSONObject();
|
||||
HashMap<String, Object> cobarA = new HashMap<String, Object>();
|
||||
cobarA.put("ip", "mock");
|
||||
cobarA.put("port", 80);
|
||||
cobarA.put("schema", "cobarA");
|
||||
@@ -35,7 +36,7 @@ public class CobarDataSourceTest extends TestCase {
|
||||
|
||||
cobarList.add(cobarA);
|
||||
|
||||
JSONObject cobarB = new JSONObject();
|
||||
HashMap<String, Object> cobarB = new HashMap<String, Object>();
|
||||
cobarB.put("ip", "mock");
|
||||
cobarB.put("port", 81);
|
||||
cobarB.put("schema", "cobarB");
|
||||
@@ -62,7 +63,7 @@ public class CobarDataSourceTest extends TestCase {
|
||||
CobarConfigLoader configLoader = new CobarConfigLoader(dataSource) {
|
||||
|
||||
public void load() throws SQLException {
|
||||
responseMessage = config.toJSONString();
|
||||
responseMessage = JSONUtils.toJSONString(config);
|
||||
|
||||
handleResponseMessage();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class StatFilterTest extends TestCase {
|
||||
|
||||
@@ -52,6 +52,6 @@ public class StatFilterTest extends TestCase {
|
||||
}
|
||||
Assert.assertEquals(true, count > 0);
|
||||
|
||||
System.out.println(JSON.toJSONString(sqlList));
|
||||
System.out.println(JSONUtils.toJSONString(sqlList));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.vendor.OracleExceptionSorter;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class TestOracle_DruidDataSource extends TestCase {
|
||||
|
||||
@@ -69,13 +68,13 @@ public class TestOracle_DruidDataSource extends TestCase {
|
||||
endLatch.await();
|
||||
|
||||
for (Object item : JdbcStatManager.getInstance().getDataSourceList().values()) {
|
||||
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
|
||||
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
|
||||
String text = JSONUtils.toJSONString(item);
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
for (Object item : JdbcStatManager.getInstance().getSqlList().values()) {
|
||||
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
|
||||
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
|
||||
String text = JSONUtils.toJSONString(item);
|
||||
System.out.println(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,13 @@ import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class TestOracle extends TestCase {
|
||||
|
||||
@@ -38,8 +36,8 @@ public class TestOracle extends TestCase {
|
||||
|
||||
TabularData dataSourcesList = JdbcStatManager.getInstance().getDataSourceList();
|
||||
for (Object item : dataSourcesList.values()) {
|
||||
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
|
||||
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
|
||||
String text = JSONUtils.toJSONString(item);
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import oracle.jdbc.OracleStatement;
|
||||
@@ -17,7 +15,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class TestMigrate extends OracleTest {
|
||||
|
||||
@@ -340,7 +338,7 @@ public class TestMigrate extends OracleTest {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return JSON.toJSONString(this);
|
||||
return JSONUtils.toJSONString(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
|
||||
public class TestTransform extends OracleTest {
|
||||
|
||||
@@ -440,7 +440,7 @@ public class TestTransform extends OracleTest {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return JSON.toJSONString(this);
|
||||
return JSONUtils.toJSONString(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user