@@ -13,15 +13,13 @@ trait BaseSqlTests {
13
13
14
14
private val timeout : Int = 15000
15
15
16
- protected def isMysql : Boolean = false
17
-
18
16
protected def failedTest : PartialFunction [Throwable , Unit ] = {
19
17
case ex : Throwable =>
20
18
logger.warn(" failed in test" , ex)
21
19
fail(" test failed. see warning above" )
22
20
}
23
21
24
- private def sendWithTimeout (json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] = {
22
+ protected def sendWithTimeout (json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] = {
25
23
val p = Promise [(Message [JsonObject ], JsonObject )]()
26
24
vertx.eventBus.sendWithTimeout(address, json, timeout, {
27
25
case Success (reply) => p.success(reply, reply.body())
@@ -30,7 +28,7 @@ trait BaseSqlTests {
30
28
p.future
31
29
}
32
30
33
- private def replyWithTimeout (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] = {
31
+ protected def replyWithTimeout (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] = {
34
32
val p = Promise [(Message [JsonObject ], JsonObject )]()
35
33
msg.replyWithTimeout(json, timeout, {
36
34
case Success (reply) => p.success(reply, reply.body())
@@ -39,13 +37,13 @@ trait BaseSqlTests {
39
37
p.future
40
38
}
41
39
42
- private def checkOkay (json : JsonObject )(msg : (Message [JsonObject ], JsonObject )): (Message [JsonObject ], JsonObject ) = {
40
+ protected def checkOkay (json : JsonObject )(msg : (Message [JsonObject ], JsonObject )): (Message [JsonObject ], JsonObject ) = {
43
41
assertEquals(s " should get 'ok' back when sending ${json.encode()}, but got ${msg._2.encode()}" ,
44
42
" ok" , msg._2.getString(" status" ))
45
43
(msg._1, msg._2)
46
44
}
47
45
48
- private def checkError (json : JsonObject )(msg : (Message [JsonObject ], JsonObject )): (Message [JsonObject ], JsonObject ) = {
46
+ protected def checkError (json : JsonObject )(msg : (Message [JsonObject ], JsonObject )): (Message [JsonObject ], JsonObject ) = {
49
47
assertEquals(s " should get an 'error' back when sending ${json.encode()}, but got ${msg._2.encode()}" ,
50
48
" error" , msg._2.getString(" status" ))
51
49
(msg._1, msg._2)
@@ -57,19 +55,19 @@ trait BaseSqlTests {
57
55
protected def sendFail (json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] =
58
56
sendWithTimeout(json) map checkError(json)
59
57
60
- private def replyOk (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] =
58
+ protected def replyOk (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] =
61
59
replyWithTimeout(msg, json) map checkOkay(json)
62
60
63
- private def replyFail (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] =
61
+ protected def replyFail (msg : Message [JsonObject ], json : JsonObject ): Future [(Message [JsonObject ], JsonObject )] =
64
62
replyWithTimeout(msg, json) map checkError(json)
65
63
66
- private def setupTableTest (): Future [_] = for {
64
+ protected def setupTableTest (): Future [_] = for {
67
65
(msg, reply) <- sendOk(raw(createTableStatement(" some_test" )))
68
66
} yield {
69
67
assertEquals(0 , reply.getInteger(" rows" ))
70
68
}
71
69
72
- private def setupTypeTest (): Future [_] = for {
70
+ protected def setupTypeTest (): Future [_] = for {
73
71
_ <- setupTableTest()
74
72
(msg, reply) <- sendOk(insert(" some_test" ,
75
73
Json .fromArrayString( """ ["name","email","is_male","age","money","wedding_date"]""" ),
@@ -389,13 +387,7 @@ trait BaseSqlTests {
389
387
| name VARCHAR(255),
390
388
| PRIMARY KEY (id)
391
389
|);""" .stripMargin))
392
- (msg, _) <- replyOk(msg, raw(
393
- s """ CREATE TABLE test_two (
394
- | id SERIAL,
395
- | name VARCHAR(255),
396
- | one_id BIGINT ${if (isMysql) " UNSIGNED" else " " } NOT NULL,
397
- | PRIMARY KEY (id)
398
- |); """ .stripMargin))
390
+ (msg, _) <- replyOk(msg, raw(createTableTestTwo))
399
391
(msg, _) <- replyOk(msg, raw(
400
392
""" ALTER TABLE test_two ADD CONSTRAINT test_two_one_id_fk
401
393
|FOREIGN KEY (one_id)
0 commit comments