This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 68252b777c improve exception assertions in PinotDriverTest (#13813)
68252b777c is described below
commit 68252b777c48a36328cec895f2038a04d86e76c4
Author: sullis <[email protected]>
AuthorDate: Tue Aug 13 21:43:32 2024 -0700
improve exception assertions in PinotDriverTest (#13813)
---
.../org/apache/pinot/client/PinotDriverTest.java | 24 ++++++++--------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git
a/pinot-clients/pinot-jdbc-client/src/test/java/org/apache/pinot/client/PinotDriverTest.java
b/pinot-clients/pinot-jdbc-client/src/test/java/org/apache/pinot/client/PinotDriverTest.java
index 05691534c0..14ecbc8b2f 100644
---
a/pinot-clients/pinot-jdbc-client/src/test/java/org/apache/pinot/client/PinotDriverTest.java
+++
b/pinot-clients/pinot-jdbc-client/src/test/java/org/apache/pinot/client/PinotDriverTest.java
@@ -21,13 +21,13 @@ package org.apache.pinot.client;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashSet;
import java.util.Set;
import org.testng.Assert;
import org.testng.annotations.Test;
-
public class PinotDriverTest {
static final String DB_URL =
"jdbc:pinot://localhost:8000?controller=localhost:9000";
static final String BAD_URL =
"jdbc:someOtherDB://localhost:8000?controller=localhost:9000";
@@ -62,21 +62,15 @@ public class PinotDriverTest {
conn.close();
}
- @Test
- public void testDriverBadURL() {
- try {
- DriverManager.getConnection(BAD_URL);
- } catch (Exception e) {
- Assert.assertTrue(e.getMessage().contains("No suitable driver found"));
- }
+ @Test(expectedExceptions = SQLException.class,
+ expectedExceptionsMessageRegExp = "No suitable driver found for
jdbc:someOtherDB:.*")
+ public void testDriverBadURL() throws Exception {
+ DriverManager.getConnection(BAD_URL);
}
- @Test
- public void testDriverGoodURLNoConnection() {
- try {
- DriverManager.getConnection(GOOD_URL_NO_CONNECTION);
- } catch (Exception e) {
- Assert.assertTrue(e.getMessage().contains("Failed to connect to url"));
- }
+ @Test(expectedExceptions = SQLException.class,
+ expectedExceptionsMessageRegExp = "Failed to connect to url :
jdbc:pinot:.*")
+ public void testDriverGoodURLNoConnection() throws Exception {
+ DriverManager.getConnection(GOOD_URL_NO_CONNECTION);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]