提交 2bb969a9 编写于 作者: S Shuaiqiang Chang

tests:add import

上级 db6f4514
......@@ -51,13 +51,17 @@ public class TSDBStatement implements Statement {
if (isClosed) {
throw new SQLException("Invalid method call on a closed statement.");
}
this.connecter.executeQuery(sql);
System.out.println(sql);
long res = this.connecter.executeQuery(sql);
long resultSetPointer = this.connecter.getResultSet();
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
this.connecter.freeResultSet(res);
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
} else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
// create/insert/update/del/alter
this.connecter.freeResultSet(res);
return null;
} else {
return new TSDBResultSet(this.connecter, resultSetPointer);
......
......@@ -21,7 +21,7 @@ public class TSDBAsyncSubscribeTest {
String topic = "test";
long subscribId = 0;
// @Before
@Before
public void createDatabase() throws SQLException {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
......@@ -43,7 +43,7 @@ public class TSDBAsyncSubscribeTest {
}
}
// @Test
@Test
public void subscribe() throws Exception {
TSDBSubscribe subscribe = null;
try {
......@@ -70,7 +70,6 @@ public class TSDBAsyncSubscribeTest {
@Override
public void invoke(TSDBResultSet resultSet) {
System.out.println("resultSet");
try {
while (null != resultSet && resultSet.next()) {
System.out.print("callback_" + name + ": ");
......@@ -87,7 +86,7 @@ public class TSDBAsyncSubscribeTest {
}
}
// @After
@After
public void close() throws Exception {
statement.executeQuery("drop database test");
statement.close();
......
......@@ -4,10 +4,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
......@@ -40,20 +37,33 @@ public class TSDBImportTest {
@Test
public void insertInto() throws Exception {
long ts = System.currentTimeMillis();
long ts = 1496732686000l;
for (int i = 0; i < 50; i++) {
ts += i;
ts ++;
int row = statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")");
System.out.println("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")" + "\t" + row);
System.out.println("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")\t" + row);
assertEquals(1, row);
}
}
@Test
public void selectData() throws Exception {
String sql = "select * from test.t0";
ResultSet resSet = statement.executeQuery(sql);
while (resSet.next()) {
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
System.out.printf(i + ": " + resSet.getString(i) + "\t");
}
}
resSet.close();
}
@Test
public void importInto() throws Exception {
// 避免时间重复
long ts = System.currentTimeMillis() + 1000;
long ts = 1496732686000l;
StringBuilder sqlBuilder = new StringBuilder("insert into ").append(dbName).append(".").append(tName).append(" values ");
......@@ -68,9 +78,9 @@ public class TSDBImportTest {
assertEquals(10, rows);
}
@After
// @After
public void close() throws Exception {
statement.executeQuery("drop database " + dbName);
statement.executeUpdate("drop database " + dbName);
statement.close();
connection.close();
}
......
......@@ -20,7 +20,7 @@ public class TSDBSubscribeTest {
String host = "localhost";
String topic = "test";
// @Before
@Before
public void createDatabase() throws SQLException {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
......@@ -42,7 +42,7 @@ public class TSDBSubscribeTest {
}
}
// @Test
@Test
public void subscribe() throws Exception {
TSDBSubscribe subscribe = null;
long subscribId = 0;
......@@ -81,7 +81,7 @@ public class TSDBSubscribeTest {
}
}
// @After
@After
public void close() throws Exception {
statement.executeQuery("drop database " + dbName);
statement.close();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册