提交 6543814f 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Merge pull request #544 from OpenSkywalking/fix/sjdbcbug

Plugin test must compile with jdk 1.6, so not allow to use lambda.
......@@ -26,7 +26,7 @@ import com.dangdang.ddframe.rdb.sharding.executor.threadlocal.ExecutorDataMap;
import com.dangdang.ddframe.rdb.sharding.util.EventBusInstance;
import com.google.common.base.Optional;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -96,7 +96,7 @@ public class InterceptorTest {
public void setUp() throws SQLException {
executeInterceptor = new ExecuteInterceptor();
asyncExecuteInterceptor = new AsyncExecuteInterceptor();
allArguments = new Object[]{SQLType.DQL, null};
allArguments = new Object[] {SQLType.DQL, null};
}
@Test
......@@ -118,9 +118,11 @@ public class InterceptorTest {
executeInterceptor.beforeMethod(null, null, allArguments, null, null);
asyncExecuteInterceptor.beforeMethod(null, null, null, null, null);
final Map<String, Object> dataMap = ExecutorDataMap.getDataMap();
ES.submit(() -> {
ES.submit(new Runnable() {
@Override public void run() {
ExecutorDataMap.setDataMap(dataMap);
sendEvent("ds_1", "select * from t_order_1");
}
}).get();
asyncExecuteInterceptor.afterMethod(null, null, null, null, null);
sendEvent("ds_0", "select * from t_order_0");
......@@ -146,9 +148,11 @@ public class InterceptorTest {
executeInterceptor.beforeMethod(null, null, allArguments, null, null);
asyncExecuteInterceptor.beforeMethod(null, null, null, null, null);
final Map<String, Object> dataMap = ExecutorDataMap.getDataMap();
ES.submit(() -> {
ES.submit(new Runnable() {
@Override public void run() {
ExecutorDataMap.setDataMap(dataMap);
sendError();
}
}).get();
asyncExecuteInterceptor.handleMethodException(null, null, null, null, new SQLException("test"));
asyncExecuteInterceptor.afterMethod(null, null, null, null, null);
......@@ -184,7 +188,11 @@ public class InterceptorTest {
}
private void sendEvent(String datasource, String sql) {
DQLExecutionEvent event = new DQLExecutionEvent(datasource, sql, Arrays.asList("1", 100));
List<Object> parameters = new ArrayList<Object>();
parameters.add("1");
parameters.add(100);
DQLExecutionEvent event = new DQLExecutionEvent(datasource, sql, parameters);
EventBusInstance.getInstance().post(event);
event.setEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
EventBusInstance.getInstance().post(event);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册