improved mysql exception sorter.

This commit is contained in:
wenshao
2017-07-18 16:38:20 +08:00
parent b52d70d40d
commit 1ef867781d
3 changed files with 67 additions and 3 deletions
@@ -0,0 +1,24 @@
package com.alibaba.druid.bvt.pool.vendor;
import com.alibaba.druid.pool.vendor.MySqlExceptionSorter;
import com.mysql.jdbc.CommunicationsException;
import junit.framework.TestCase;
import java.sql.SQLException;
/**
* Created by wenshao on 18/07/2017.
*/
public class MySqlExceptionSorterTest_1 extends TestCase {
public void test_0() throws Exception {
MySqlExceptionSorter sorter = new MySqlExceptionSorter();
SQLException rootException = new SQLException(
new SQLException("Could not retrieve transation read-only status server",
new CommunicationsException(null, 0, 0, null)
)
);
assertTrue(sorter.isExceptionFatal(rootException));
}
}
@@ -0,0 +1,25 @@
package com.alibaba.druid.bvt.pool.vendor;
import com.alibaba.druid.pool.vendor.MySqlExceptionSorter;
import com.mysql.jdbc.CommunicationsException;
import junit.framework.TestCase;
import java.net.SocketTimeoutException;
import java.sql.SQLException;
/**
* Created by wenshao on 18/07/2017.
*/
public class MySqlExceptionSorterTest_2 extends TestCase {
public void test_0() throws Exception {
MySqlExceptionSorter sorter = new MySqlExceptionSorter();
SQLException rootException = new SQLException(
new SQLException("Could not retrieve transation read-only status server",
new SocketTimeoutException()
)
);
assertTrue(sorter.isExceptionFatal(rootException));
}
}