From 747df3d414fe82f6d10951079321d1e194c42249 Mon Sep 17 00:00:00 2001 From: Kent Yao Date: Fri, 22 Jun 2018 16:02:48 +0800 Subject: [PATCH] ServiceUtils test added --- .../kyuubi/service/ServiceUtilsSuite.scala | 44 +++++++++++++++++++ .../kyuubi/utils/ReflectUtilsSuite.scala | 28 ++++++------ pom.xml | 4 +- 3 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 kyuubi-server/src/test/scala/yaooqinn/kyuubi/service/ServiceUtilsSuite.scala diff --git a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/service/ServiceUtilsSuite.scala b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/service/ServiceUtilsSuite.scala new file mode 100644 index 000000000..0c94fa81d --- /dev/null +++ b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/service/ServiceUtilsSuite.scala @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package yaooqinn.kyuubi.service + +import org.apache.spark.SparkFunSuite + +class ServiceUtilsSuite extends SparkFunSuite { + + test("test index or domain match") { + assert(ServiceUtils.indexOfDomainMatch(null) === -1) + val user1 = "Kent" + assert(ServiceUtils.indexOfDomainMatch(user1) === -1) + val user2 = "Kent/xxx" + assert(ServiceUtils.indexOfDomainMatch(user2) === 4) + val user3 = "Kent/////xxx" + assert(ServiceUtils.indexOfDomainMatch(user3) === 4) + val user4 = "Kent/@/@//xxx" + assert(ServiceUtils.indexOfDomainMatch(user4) === 4) + val user5 = "Kent/xxx@xxx" + assert(ServiceUtils.indexOfDomainMatch(user5) === 4) + val user6 = "Kent@xxx@xxx" + assert(ServiceUtils.indexOfDomainMatch(user6) === 4) + val user7 = "Kent/xxx/xxx" + assert(ServiceUtils.indexOfDomainMatch(user7) === 4) + val user8 = "Kent*xxx/xxx" + assert(ServiceUtils.indexOfDomainMatch(user8) === 8) + } + +} diff --git a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/utils/ReflectUtilsSuite.scala b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/utils/ReflectUtilsSuite.scala index c8d91fc3e..74176b406 100644 --- a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/utils/ReflectUtilsSuite.scala +++ b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/utils/ReflectUtilsSuite.scala @@ -1,20 +1,18 @@ /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * * Licensed to the Apache Software Foundation (ASF) under one or more - * * contributor license agreements. See the NOTICE file distributed with - * * this work for additional information regarding copyright ownership. - * * The ASF licenses this file to You under the Apache License, Version 2.0 - * * (the "License"); you may not use this file except in compliance with - * * the License. You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package yaooqinn.kyuubi.utils @@ -124,7 +122,7 @@ class ReflectUtilsSuite extends SparkFunSuite { test("test reflect module") { val rule1 = ReflectUtils.reflectModule(className = "yaooqinn.kyuubi.TestRule", silent = true) - assert(rule1.get.isInstanceOf[Rule[LogicalPlan]]) + assert(rule1.get.isInstanceOf[Rule[_]]) val rule2 = ReflectUtils.reflectModule(className = "yaooqinn.kyuubi.TestRule2", silent = true) assert(rule2.isEmpty) diff --git a/pom.xml b/pom.xml index ac0b3d7e4..d1fb051a1 100644 --- a/pom.xml +++ b/pom.xml @@ -41,8 +41,8 @@ yaooqinn Kent Yao - hzyaoqin@corp.netease.com - yaooqinn + yaooqinn@hotmail.com + NetEase https://github.com/yaooqinn