improve test cov
This commit is contained in:
parent
5d1ea8547a
commit
0b07dfd6dd
@ -20,5 +20,4 @@ package org.apache.kyuubi
|
||||
class KyuubiException(message: String, cause: Throwable) extends Exception(message, cause) {
|
||||
|
||||
def this(message: String) = this(message, null)
|
||||
def this(cause: Throwable) = this(cause.getMessage, cause)
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ trait Service {
|
||||
/**
|
||||
* Initialize the service.
|
||||
*
|
||||
* The transition must be from [[LATENT]]to [[INITIALIZED]] unless the
|
||||
* The transition must be from [[LATENT]] to [[INITIALIZED]] unless the
|
||||
* operation failed and an exception was raised.
|
||||
*
|
||||
* @param conf the configuration of the service
|
||||
|
||||
@ -26,7 +26,7 @@ class KyuubiSQLExceptionSuite extends KyuubiFunSuite {
|
||||
val msg1 = "this is just a dummy msg 1"
|
||||
val msg2 = "this is just a dummy msg 2"
|
||||
|
||||
val e0 = new RuntimeException(msg0)
|
||||
val e0 = new KyuubiException(msg0)
|
||||
val e1 = new KyuubiException(msg1, e0)
|
||||
val e2 = new KyuubiSQLException(msg2, e1)
|
||||
assert(e2.toTStatus === KyuubiSQLException.toTStatus(e2))
|
||||
|
||||
@ -37,5 +37,8 @@ class HandleIdentifierSuite extends KyuubiFunSuite {
|
||||
val id4 = HandleIdentifier()
|
||||
assert(id4 !== id1)
|
||||
assert(id4 !== new Integer(1))
|
||||
|
||||
val id5 = HandleIdentifier(id1.publicId, id1.publicId)
|
||||
assert(id1 !== id5, "no matched secret id")
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class ServiceDiscovery private (
|
||||
.forPath(s"/$namespace")
|
||||
} catch {
|
||||
case _: NodeExistsException => // do nothing
|
||||
case e: KeeperException => throw new KyuubiException(e)
|
||||
case e: KeeperException => throw new KyuubiException(s"Failed to create namespace '/$namespace'", e)
|
||||
}
|
||||
super.initialize(conf)
|
||||
}
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.cli
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.UUID
|
||||
|
||||
import org.apache.hive.service.cli.thrift.THandleIdentifier
|
||||
import org.apache.spark.SparkFunSuite
|
||||
|
||||
class HandleIdentifierSuite extends SparkFunSuite {
|
||||
|
||||
test("handle identifier instantiating and equality") {
|
||||
// default constructor
|
||||
val pid = UUID.randomUUID()
|
||||
val sid = UUID.randomUUID()
|
||||
val handleId1 = new HandleIdentifier(pid, sid)
|
||||
assert(pid === handleId1.getPublicId)
|
||||
assert(sid === handleId1.getSecretId)
|
||||
assert(handleId1.toTHandleIdentifier.bufferForGuid() !== null)
|
||||
assert(handleId1.toTHandleIdentifier.bufferForSecret() !== null)
|
||||
assert(handleId1.toString === pid.toString)
|
||||
|
||||
// constructor without any parameter
|
||||
val handleId2 = new HandleIdentifier()
|
||||
assert(pid !== handleId2.getPublicId)
|
||||
assert(sid !== handleId2.getSecretId)
|
||||
assert(handleId1 !== handleId2)
|
||||
assert(handleId1.toTHandleIdentifier !== handleId2.toTHandleIdentifier)
|
||||
|
||||
// constructor with THandleIdentifier
|
||||
val handleId3 = new HandleIdentifier(handleId1.toTHandleIdentifier)
|
||||
assert(handleId1 === handleId3)
|
||||
|
||||
val tHandleId = new THandleIdentifier(ByteBuffer.allocate(16), ByteBuffer.allocate(16))
|
||||
val handleId4 = new HandleIdentifier(tHandleId)
|
||||
assert(handleId1 !== handleId4)
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user