tests: add test
This commit is contained in:
parent
2bb969a9fb
commit
f732250271
|
@ -1,16 +1,13 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>JDBCDriver</name>
|
<name>JDBCDriver</name>
|
||||||
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
||||||
<description>TDengine JDBC Driver</description>
|
<description>TDengine JDBC Driver</description>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
|
<name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
|
||||||
|
@ -18,14 +15,12 @@
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
|
<connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
|
||||||
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
||||||
<tag>HEAD</tag>
|
<tag>HEAD</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<name>taosdata</name>
|
<name>taosdata</name>
|
||||||
|
@ -34,17 +29,13 @@
|
||||||
<organizationUrl>https://www.taosdata.com/</organizationUrl>
|
<organizationUrl>https://www.taosdata.com/</organizationUrl>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
|
|
||||||
<commons-logging.version>1.1.2</commons-logging.version>
|
<commons-logging.version>1.1.2</commons-logging.version>
|
||||||
<commons-lang3.version>3.5</commons-lang3.version>
|
<commons-lang3.version>3.5</commons-lang3.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
|
@ -68,8 +59,12 @@
|
||||||
<version>4.8.2</version>
|
<version>4.8.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.8.3</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -78,7 +73,6 @@
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptors>
|
<descriptors>
|
||||||
<!--<descriptor>src/main/assembly/assembly.xml</descriptor>-->
|
|
||||||
<descriptor>src/main/assembly/assembly-jar.xml</descriptor>
|
<descriptor>src/main/assembly/assembly-jar.xml</descriptor>
|
||||||
</descriptors>
|
</descriptors>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -112,8 +106,31 @@
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.8.3</version>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>com/**/*</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>pre-test</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>post-test</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class TestPreparedStatement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resSet.close();
|
resSet.close();
|
||||||
|
pstmt.close();
|
||||||
connection.close();
|
connection.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class TSDBAsyncSubscribeTest {
|
public class AsyncSubscribeTest {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
String dbName = "test";
|
String dbName = "test";
|
|
@ -9,7 +9,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class TSDBImportTest {
|
public class ImportTest {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
String dbName = "test";
|
String dbName = "test";
|
||||||
|
@ -36,7 +36,7 @@ public class TSDBImportTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void insertInto() throws Exception {
|
public void insertData() throws Exception {
|
||||||
long ts = 1496732686000l;
|
long ts = 1496732686000l;
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
|
@ -49,6 +49,7 @@ public class TSDBImportTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectData() throws Exception {
|
public void selectData() throws Exception {
|
||||||
|
insertData();
|
||||||
String sql = "select * from test.t0";
|
String sql = "select * from test.t0";
|
||||||
ResultSet resSet = statement.executeQuery(sql);
|
ResultSet resSet = statement.executeQuery(sql);
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ public class TSDBImportTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void importInto() throws Exception {
|
public void importData() throws Exception {
|
||||||
// 避免时间重复
|
// 避免时间重复
|
||||||
long ts = 1496732686000l;
|
long ts = 1496732686000l;
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ public class TSDBImportTest {
|
||||||
assertEquals(10, rows);
|
assertEquals(10, rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @After
|
@After
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
statement.executeUpdate("drop database " + dbName);
|
statement.executeUpdate("drop database " + dbName);
|
||||||
statement.close();
|
statement.close();
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class SelectTest {
|
||||||
|
Connection connection = null;
|
||||||
|
Statement statement = null;
|
||||||
|
String dbName = "test";
|
||||||
|
String tName = "t0";
|
||||||
|
String host = "localhost";
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void createDatabaseAndTable() throws SQLException {
|
||||||
|
try {
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
|
||||||
|
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata"
|
||||||
|
, properties);
|
||||||
|
|
||||||
|
statement = connection.createStatement();
|
||||||
|
statement.executeUpdate("drop database if exists " + dbName);
|
||||||
|
statement.executeUpdate("create database if not exists " + dbName);
|
||||||
|
statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void selectData() throws SQLException {
|
||||||
|
long ts = 1496732686000l;
|
||||||
|
|
||||||
|
for (int i = 0; i < 50; 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);
|
||||||
|
assertEquals(1, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql = "select * from " + dbName + "." + tName;
|
||||||
|
ResultSet resSet = statement.executeQuery(sql);
|
||||||
|
|
||||||
|
int num = 0;
|
||||||
|
while (resSet.next()) {
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
resSet.close();
|
||||||
|
|
||||||
|
assertEquals(num, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws SQLException {
|
||||||
|
statement.executeUpdate("drop database " + dbName);
|
||||||
|
statement.close();
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
|
public class StableTest {
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class TSDBSubscribeTest {
|
public class SubscribeTest {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
String dbName = "test";
|
String dbName = "test";
|
Loading…
Reference in New Issue