[TD-2132]<test>: add memory leak test case
This commit is contained in:
parent
19dedc226a
commit
e9c83f8251
|
@ -5,19 +5,40 @@ import org.junit.Test;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
public class AppMemoryLeakTest {
|
public class AppMemoryLeakTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected = SQLException.class)
|
||||||
public void testAppMemoryLeak() {
|
public void testCreateTooManyConnection() throws ClassNotFoundException, SQLException {
|
||||||
try {
|
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
int conCnt = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
Connection conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
||||||
}
|
System.out.println(conCnt++ + " : " + conn);
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateTooManyStatement() throws ClassNotFoundException, SQLException {
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
int stmtCnt = 0;
|
||||||
|
Connection conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
||||||
|
while (true) {
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
System.out.println(++stmtCnt + " : " + stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws ClassNotFoundException, SQLException {
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
int stmtCnt = 0;
|
||||||
|
Connection conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
||||||
|
while (true) {
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
System.out.println(++stmtCnt + " : " + stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue