add ServiceUtilsSuite

This commit is contained in:
Kent Yao 2020-10-23 10:34:44 +08:00
parent c485df6b24
commit 76a7d55685

View File

@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -15,13 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
package yaooqinn.kyuubi.service package org.apache.kyuubi.service
import org.apache.spark.SparkFunSuite import org.apache.kyuubi.KyuubiFunSuite
import org.apache.kyuubi.service.ServiceUtils class ServiceUtilsSuite extends KyuubiFunSuite {
class ServiceUtilsSuite extends SparkFunSuite {
test("test index or domain match") { test("test index or domain match") {
assert(ServiceUtils.indexOfDomainMatch(null) === -1) assert(ServiceUtils.indexOfDomainMatch(null) === -1)
@ -42,4 +40,13 @@ class ServiceUtilsSuite extends SparkFunSuite {
val user8 = "Kent*xxx/xxx" val user8 = "Kent*xxx/xxx"
assert(ServiceUtils.indexOfDomainMatch(user8) === 8) assert(ServiceUtils.indexOfDomainMatch(user8) === 8)
} }
test("get short name") {
assert(ServiceUtils.getShortName(null) === null)
assert(ServiceUtils.getShortName("") === "")
assert(ServiceUtils.getShortName("kent") === "kent")
assert(ServiceUtils.getShortName("kent/x") == "kent")
assert(ServiceUtils.getShortName("kent@abc/c") === "kent")
assert(ServiceUtils.getShortName("kent/abc@c") === "kent")
}
} }