This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new bbf855df0 [KYUUBI #4912] [TEST] Replace Scala's assert in tests with
Scalatest's for prettified error message
bbf855df0 is described below
commit bbf855df0eca1e201c398ad14755a770ed166470
Author: liangbowen <[email protected]>
AuthorDate: Thu Jun 1 11:52:56 2023 +0800
[KYUUBI #4912] [TEST] Replace Scala's assert in tests with Scalatest's for
prettified error message
### _Why are the changes needed?_
- replacing callings to Scala's assert method by Scalatest's
`Assertions.assert`
- While Scala's assert method just throws a simple Java's Assertion Error ,
```
def assert(assertion: Boolean) {
if (!assertion)
throw new java.lang.AssertionError("assertion failed")
}
```
the Scalatest's `Assertions.assert` prettifies the error message, eg.,
`assert(a == b || c >= d) // Error message: 1 did not equal 2, and 3 was
not greater than or equal to 4`
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including
negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
locally before make a pull request
Closes #4912 from bowenliang123/scalatest-assert.
Closes #4912
e1d2ce3e0 [liangbowen] use Scalatest's assert for better error message
Authored-by: liangbowen <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../test/scala/org/apache/spark/sql/benchmark/KyuubiBenchmarkBase.scala | 1 +
.../org/apache/kyuubi/plugin/spark/authz/SparkSessionProvider.scala | 2 +-
.../scala/org/apache/spark/kyuubi/benchmark/KyuubiBenchmarkBase.scala | 1 +
.../kyuubi/service/authentication/ldap/LdapAuthenticationTestCase.scala | 2 +-
.../apache/kyuubi/credentials/HiveDelegationTokenProviderSuite.scala | 1 +
5 files changed, 5 insertions(+), 2 deletions(-)
diff --git
a/extensions/spark/kyuubi-extension-spark-common/src/test/scala/org/apache/spark/sql/benchmark/KyuubiBenchmarkBase.scala
b/extensions/spark/kyuubi-extension-spark-common/src/test/scala/org/apache/spark/sql/benchmark/KyuubiBenchmarkBase.scala
index c8c1b021d..b891a7224 100644
---
a/extensions/spark/kyuubi-extension-spark-common/src/test/scala/org/apache/spark/sql/benchmark/KyuubiBenchmarkBase.scala
+++
b/extensions/spark/kyuubi-extension-spark-common/src/test/scala/org/apache/spark/sql/benchmark/KyuubiBenchmarkBase.scala
@@ -22,6 +22,7 @@ import java.io.{File, FileOutputStream, OutputStream}
import scala.collection.JavaConverters._
import com.google.common.reflect.ClassPath
+import org.scalatest.Assertions._
trait KyuubiBenchmarkBase {
var output: Option[OutputStream] = None
diff --git
a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/SparkSessionProvider.scala
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/SparkSessionProvider.scala
index 1eccc178b..d0b30ea44 100644
---
a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/SparkSessionProvider.scala
+++
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/SparkSessionProvider.scala
@@ -23,7 +23,7 @@ import java.security.PrivilegedExceptionAction
import org.apache.hadoop.security.UserGroupInformation
import org.apache.spark.SparkConf
import org.apache.spark.sql.{DataFrame, Row, SparkSession,
SparkSessionExtensions}
-import org.scalatest.Assertions.convertToEqualizer
+import org.scalatest.Assertions._
import org.apache.kyuubi.Utils
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._
diff --git
a/extensions/spark/kyuubi-spark-connector-tpcds/src/test/scala/org/apache/spark/kyuubi/benchmark/KyuubiBenchmarkBase.scala
b/extensions/spark/kyuubi-spark-connector-tpcds/src/test/scala/org/apache/spark/kyuubi/benchmark/KyuubiBenchmarkBase.scala
index bee515592..e43998918 100644
---
a/extensions/spark/kyuubi-spark-connector-tpcds/src/test/scala/org/apache/spark/kyuubi/benchmark/KyuubiBenchmarkBase.scala
+++
b/extensions/spark/kyuubi-spark-connector-tpcds/src/test/scala/org/apache/spark/kyuubi/benchmark/KyuubiBenchmarkBase.scala
@@ -22,6 +22,7 @@ import java.io.{File, FileOutputStream, OutputStream}
import scala.collection.JavaConverters._
import com.google.common.reflect.ClassPath
+import org.scalatest.Assertions._
trait KyuubiBenchmarkBase {
var output: Option[OutputStream] = None
diff --git
a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/ldap/LdapAuthenticationTestCase.scala
b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/ldap/LdapAuthenticationTestCase.scala
index e8b92ebc0..a06eba068 100644
---
a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/ldap/LdapAuthenticationTestCase.scala
+++
b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/ldap/LdapAuthenticationTestCase.scala
@@ -21,7 +21,7 @@ import javax.security.sasl.AuthenticationException
import scala.collection.mutable
-import org.scalatest.Assertions.{fail, intercept}
+import org.scalatest.Assertions._
import org.apache.kyuubi.config.{ConfigEntry, KyuubiConf}
import org.apache.kyuubi.service.authentication.LdapAuthenticationProviderImpl
diff --git
a/kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HiveDelegationTokenProviderSuite.scala
b/kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HiveDelegationTokenProviderSuite.scala
index c3977e807..6c0370f55 100644
---
a/kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HiveDelegationTokenProviderSuite.scala
+++
b/kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HiveDelegationTokenProviderSuite.scala
@@ -37,6 +37,7 @@ import org.apache.hadoop.security.{Credentials,
UserGroupInformation}
import org.apache.hadoop.security.authorize.ProxyUsers
import org.apache.thrift.TProcessor
import org.apache.thrift.protocol.TProtocol
+import org.scalatest.Assertions._
import org.scalatest.concurrent.Eventually._
import org.scalatest.time.SpanSugar.convertIntToGrainOfTime