Skip to content

Commit d26a718

Browse files
committed
Add assertions to unit tests
1 parent 94fc43c commit d26a718

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ More background at https://lists.apache.org/thread/63lr45kyh78s64spwsjxjy8zdyzpr
4646

4747
The current project has not yet carried out any release work.
4848

49-
## contribute
49+
## Contributing
5050

5151
Refer to [CONTRIBUTING](./doc/CONTRIBUTING.md) .

doc/CONTRIBUTING.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ gnome-text-editor ~/.m2/setting.xml
4343
```
4444

4545
```xml
46+
4647
<settings>
47-
<servers>
48-
<server>
49-
<id>central</id>
50-
<username><!-- your token username --></username>
51-
<password><!-- your token password --></password>
52-
</server>
53-
</servers>
48+
<servers>
49+
<server>
50+
<id>central</id>
51+
<username><!-- Aloha, your token username --></username>
52+
<password><!-- Aloha, your token password --></password>
53+
</server>
54+
</servers>
5455
</settings>
5556
```
5657

@@ -65,5 +66,5 @@ mvn clean install -DskipTests
6566
cd ../
6667
git clone [email protected]:linghengqian/hive-server2-jdbc-driver.git
6768
cd ./hive-server2-jdbc-driver/
68-
./mvnw -Ppublishing-via-the-central-portal -DskipTests clean deploy
69+
./mvnw -Ppublishing-via-the-central-portal -Dgpg.keyname=${Aloha, your keyname} -DskipTests clean deploy
6970
```

hive-server2-jdbc-driver-thin/src/test/java/com/github/linghengqian/hive/server2/jdbc/driver/thin/HiveServer2Test.java hive-server2-jdbc-driver-thin/src/test/java/com/github/linghengqian/hive/server2/jdbc/driver/thin/HiveServer2ThinTest.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
import org.testcontainers.utility.DockerImageName;
1010

1111
import java.sql.Connection;
12+
import java.sql.ResultSet;
1213
import java.sql.SQLException;
1314
import java.sql.Statement;
1415
import java.time.Duration;
1516
import java.time.temporal.ChronoUnit;
1617

1718
import static org.awaitility.Awaitility.await;
19+
import static org.hamcrest.MatcherAssert.assertThat;
20+
import static org.hamcrest.Matchers.is;
1821

1922
@SuppressWarnings({"SqlNoDataSourceInspection", "resource"})
2023
@Testcontainers
21-
public class HiveServer2Test {
24+
public class HiveServer2ThinTest {
2225

2326
@Container
2427
public static final GenericContainer<?> CONTAINER = new GenericContainer<>(DockerImageName.parse("apache/hive:4.1.0-SNAPSHOT"))
@@ -41,11 +44,17 @@ void test() throws SQLException {
4144
Connection connection = hikariDataSource.getConnection();
4245
Statement statement = connection.createStatement()) {
4346
statement.execute("CREATE DATABASE demo_ds_0");
44-
statement.executeQuery("show tables");
47+
ResultSet firstResultSet = statement.executeQuery("show tables");
48+
assertThat(firstResultSet.next(), is(false));
4549
statement.execute("create table hive_example(a string, b int) partitioned by(c int)");
50+
statement.execute("alter table hive_example add partition(c=1)");
4651
statement.execute("insert into hive_example partition(c=1) values('a', 1), ('a', 2),('b',3)");
47-
statement.executeQuery("select count(distinct a) from hive_example");
48-
statement.executeQuery("select sum(b) from hive_example");
52+
ResultSet secondResultSet = statement.executeQuery("select count(distinct a) from hive_example");
53+
assertThat(secondResultSet.next(), is(true));
54+
assertThat(secondResultSet.getInt("_c0"), is(2));
55+
ResultSet thirdResultSet = statement.executeQuery("select sum(b) from hive_example");
56+
assertThat(thirdResultSet.next(), is(true));
57+
assertThat(thirdResultSet.getInt("_c0"), is(6));
4958
}
5059
}
5160
}

hive-server2-jdbc-driver-uber/src/test/java/com/github/linghengqian/hive/server2/jdbc/driver/uber/HiveServer2Test.java hive-server2-jdbc-driver-uber/src/test/java/com/github/linghengqian/hive/server2/jdbc/driver/uber/HiveServer2UberTest.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
import org.testcontainers.utility.DockerImageName;
1010

1111
import java.sql.Connection;
12+
import java.sql.ResultSet;
1213
import java.sql.SQLException;
1314
import java.sql.Statement;
1415
import java.time.Duration;
1516
import java.time.temporal.ChronoUnit;
1617

1718
import static org.awaitility.Awaitility.await;
19+
import static org.hamcrest.MatcherAssert.assertThat;
20+
import static org.hamcrest.Matchers.is;
1821

1922
@SuppressWarnings({"SqlNoDataSourceInspection", "resource"})
2023
@Testcontainers
21-
public class HiveServer2Test {
24+
public class HiveServer2UberTest {
2225

2326
@Container
2427
public static final GenericContainer<?> CONTAINER = new GenericContainer<>(DockerImageName.parse("apache/hive:4.1.0-SNAPSHOT"))
@@ -41,11 +44,17 @@ void test() throws SQLException {
4144
Connection connection = hikariDataSource.getConnection();
4245
Statement statement = connection.createStatement()) {
4346
statement.execute("CREATE DATABASE demo_ds_0");
44-
statement.executeQuery("show tables");
47+
ResultSet firstResultSet = statement.executeQuery("show tables");
48+
assertThat(firstResultSet.next(), is(false));
4549
statement.execute("create table hive_example(a string, b int) partitioned by(c int)");
50+
statement.execute("alter table hive_example add partition(c=1)");
4651
statement.execute("insert into hive_example partition(c=1) values('a', 1), ('a', 2),('b',3)");
47-
statement.executeQuery("select count(distinct a) from hive_example");
48-
statement.executeQuery("select sum(b) from hive_example");
52+
ResultSet secondResultSet = statement.executeQuery("select count(distinct a) from hive_example");
53+
assertThat(secondResultSet.next(), is(true));
54+
assertThat(secondResultSet.getInt("_c0"), is(2));
55+
ResultSet thirdResultSet = statement.executeQuery("select sum(b) from hive_example");
56+
assertThat(thirdResultSet.next(), is(true));
57+
assertThat(thirdResultSet.getInt("_c0"), is(6));
4958
}
5059
}
5160
}

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@
138138
<goals>
139139
<goal>sign</goal>
140140
</goals>
141+
<configuration>
142+
<!--suppress MavenModelInspection -->
143+
<keyname>${gpg.keyname}</keyname>
144+
<!--suppress MavenModelInspection -->
145+
<passphraseServerId>${gpg.keyname}</passphraseServerId>
146+
</configuration>
141147
</execution>
142148
</executions>
143149
</plugin>

0 commit comments

Comments
 (0)