summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-10-13 21:25:12 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2019-10-13 21:25:12 +0800
commit7b8f403a0d3f95a825a09a709bc17a694952683d (patch)
tree053aa1f8e1f7d75df69597c6fb81fddd4acd1411 /example
parent114b385269c6f5049615e67c8c42dc25be337626 (diff)
downloadcask-7b8f403a0d3f95a825a09a709bc17a694952683d.tar.gz
cask-7b8f403a0d3f95a825a09a709bc17a694952683d.tar.bz2
cask-7b8f403a0d3f95a825a09a709bc17a694952683d.zip
fix tests
Diffstat (limited to 'example')
-rw-r--r--example/websockets/app/test/src/ExampleTests.scala11
-rw-r--r--example/websockets2/app/test/src/ExampleTests.scala14
-rw-r--r--example/websockets3/app/test/src/ExampleTests.scala14
-rw-r--r--example/websockets4/app/test/src/ExampleTests.scala14
4 files changed, 23 insertions, 30 deletions
diff --git a/example/websockets/app/test/src/ExampleTests.scala b/example/websockets/app/test/src/ExampleTests.scala
index e8889b0..413937d 100644
--- a/example/websockets/app/test/src/ExampleTests.scala
+++ b/example/websockets/app/test/src/ExampleTests.scala
@@ -39,14 +39,13 @@ object ExampleTests extends TestSuite{
Thread.sleep(100)
out ==> List("haoyi world", "haoyi hello")
- var error: String = ""
- val ws2 = cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
- case cask.Ws.Text(s) => out = s :: out
- case cask.Ws.Error(t) => error += t.toString
- case cask.Ws.Close(code, reason) => error += reason
+ val ex = intercept[Exception] {
+ cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
+ case _ => /*do nothing*/
+ }
}
+ assert(ex.getMessage.contains("403"))
- assert(error.contains("403"))
}finally ws.close()
}
diff --git a/example/websockets2/app/test/src/ExampleTests.scala b/example/websockets2/app/test/src/ExampleTests.scala
index 11796ed..61038c5 100644
--- a/example/websockets2/app/test/src/ExampleTests.scala
+++ b/example/websockets2/app/test/src/ExampleTests.scala
@@ -36,14 +36,12 @@ object ExampleTests extends TestSuite{
Thread.sleep(100)
out ==> List("haoyi world", "haoyi hello")
- var error: String = ""
- val ws2 = cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
- case cask.Ws.Text(s) => out = s :: out
- case cask.Ws.Error(t) => error += t.toString
- case cask.Ws.Close(code, reason) => error += reason
- }
-
- assert(error.contains("403"))
+ val ex = intercept[Exception](
+ cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
+ case _ => /*do nothing*/
+ }
+ )
+ assert(ex.getMessage.contains("403"))
}finally ws.close()
}
diff --git a/example/websockets3/app/test/src/ExampleTests.scala b/example/websockets3/app/test/src/ExampleTests.scala
index 868194e..ed1242d 100644
--- a/example/websockets3/app/test/src/ExampleTests.scala
+++ b/example/websockets3/app/test/src/ExampleTests.scala
@@ -37,14 +37,12 @@ object ExampleTests extends TestSuite{
Thread.sleep(100)
out ==> List("haoyi world", "haoyi hello")
- var error: String = ""
- val ws2 = cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
- case cask.Ws.Text(s) => out = s :: out
- case cask.Ws.Error(t) => error += t.toString
- case cask.Ws.Close(code, reason) => error += reason
- }
-
- assert(error.contains("403"))
+ val ex = intercept[Exception](
+ cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
+ case _ => /*do nothing*/
+ }
+ )
+ assert(ex.getMessage.contains("403"))
}finally ws.close()
}
}
diff --git a/example/websockets4/app/test/src/ExampleTests.scala b/example/websockets4/app/test/src/ExampleTests.scala
index cd33bb4..f122228 100644
--- a/example/websockets4/app/test/src/ExampleTests.scala
+++ b/example/websockets4/app/test/src/ExampleTests.scala
@@ -37,14 +37,12 @@ object ExampleTests extends TestSuite{
Thread.sleep(100)
out ==> List("haoyi world", "haoyi hello")
- var error: String = ""
- val ws2 = cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
- case cask.Ws.Text(s) => out = s :: out
- case cask.Ws.Error(t) => error += t.toString
- case cask.Ws.Close(code, reason) => error += reason
- }
-
- assert(error.contains("403"))
+ val ex = intercept[Exception](
+ cask.WsClient.connect("ws://localhost:8080/connect/nobody") {
+ case _ => /*do nothing*/
+ }
+ )
+ assert(ex.getMessage.contains("403"))
}finally ws.close()
}
}