1
- package com .twitter .finagle .mysql
1
+ package com .twitter .finagle .mysql . unit
2
2
3
3
import com .twitter .finagle .Stack
4
+ import com .twitter .finagle .mysql .Capability
5
+ import com .twitter .finagle .mysql .HandshakeSettings
6
+ import com .twitter .finagle .mysql .MysqlCharset
4
7
import com .twitter .finagle .mysql .param .Charset
5
8
import com .twitter .finagle .mysql .param .Credentials
6
9
import com .twitter .finagle .mysql .param .Database
@@ -14,40 +17,31 @@ class HandshakeSettingsTest extends AnyFunSuite {
14
17
Capability .Transactions ,
15
18
Capability .MultiResults
16
19
)
17
- private val withFoundRows = initial + Capability .FoundRows
18
- private val withInteractive = initial + Capability .Interactive
19
20
20
21
test(" HandshakeSettings adds FoundRows by default" ) {
21
22
val settings = HandshakeSettings (clientCapabilities = initial)
22
- assert(settings.calculatedClientCapabilities == withFoundRows )
23
+ assert(settings.calculatedClientCapabilities.has( Capability . FoundRows ) )
23
24
}
24
25
25
- test(" HandshakeSettings returns initial when found rows is disabled" ) {
26
+ test(" HandshakeSettings does not add FoundRows when found rows is disabled" ) {
26
27
val settings = HandshakeSettings (clientCapabilities = initial, enableFoundRows = false )
27
- assert(settings.calculatedClientCapabilities == initial )
28
+ assert(! settings.calculatedClientCapabilities.has( Capability . FoundRows ) )
28
29
}
29
30
30
31
test(" HandshakeSettings adds Interactive by default" ) {
31
32
val settings = HandshakeSettings (clientCapabilities = initial)
32
- assert(settings.calculatedClientCapabilities == withInteractive )
33
+ assert(settings.calculatedClientCapabilities.has( Capability . Interactive ) )
33
34
}
34
35
35
- test(" HandshakeSettings returns initial when interactive is disabled" ) {
36
+ test(" HandshakeSettings does not add Interactive when interactive is disabled" ) {
36
37
val settings = HandshakeSettings (clientCapabilities = initial, interactive = false )
37
- assert(settings.calculatedClientCapabilities == initial )
38
+ assert(! settings.calculatedClientCapabilities.has( Capability . Interactive ) )
38
39
}
39
40
40
- test(" HandshakeSettings adds ConnectWithDB if database is defined" ) {
41
+ test(" HandshakeSettings adds ConnectWithDB and SSL settings if database is defined" ) {
41
42
val settings = HandshakeSettings (clientCapabilities = initial, database = Some (" test" ))
42
- val withDB = withFoundRows + Capability .ConnectWithDB
43
- assert(settings.calculatedClientCapabilities == withDB)
44
- }
45
-
46
- test(" HandshakeSettings can calculate settings for SSL/TLS" ) {
47
- val settings = HandshakeSettings (clientCapabilities = initial, database = Some (" test" ))
48
- val withDB = withFoundRows + Capability .ConnectWithDB
49
- val withSSL = withDB + Capability .SSL
50
- assert(settings.sslCalculatedClientCapabilities == withSSL)
43
+ assert(settings.calculatedClientCapabilities.has(Capability .ConnectWithDB ))
44
+ assert(settings.sslCalculatedClientCapabilities.has(Capability .SSL ))
51
45
}
52
46
53
47
test(" HandshakeSettings can read values from Stack params" ) {
@@ -65,5 +59,4 @@ class HandshakeSettingsTest extends AnyFunSuite {
65
59
assert(! settings.enableFoundRows)
66
60
assert(! settings.interactive)
67
61
}
68
-
69
62
}
0 commit comments