@@ -39,9 +39,9 @@ class RequestResponseSpec extends WordSpec with ShouldMatchers {
39
39
40
40
// def worker(implicit system: ActorSystem) = system.actorOf(Props(new SentinelClientWorker(new InetSocketAddress("localhost", 9999), PingPong.stages, "Worker")(1, 1, 10)).withDispatcher("nl.gideondk.sentinel.sentinel-dispatcher"))
41
41
42
- def client (implicit system : ActorSystem ) = Client (" localhost" , 9999 , RandomRouter (16 ), " Worker" , 5 seconds, SimpleMessage .stages)(system)
42
+ def client (portNumber : Int )( implicit system : ActorSystem ) = Client (" localhost" , portNumber , RandomRouter (16 ), " Worker" , 5 seconds, SimpleMessage .stages)(system)
43
43
44
- def server (implicit system : ActorSystem ) = SentinelServer (9999 , SimpleServerHandler )(SimpleMessage .stages)(system)
44
+ def server (portNumber : Int )( implicit system : ActorSystem ) = SentinelServer (portNumber , SimpleServerHandler )(SimpleMessage .stages)(system)
45
45
46
46
" A client" should {
47
47
// "return a exception when a request is done when no connection is available" in new TestKitSpec {
@@ -52,17 +52,19 @@ class RequestResponseSpec extends WordSpec with ShouldMatchers {
52
52
// evaluating { result.get } should produce[SentinelClientWorker.NoConnectionAvailable]
53
53
// }
54
54
55
- // "be able to request a response from a server" in new TestKitSpec {
56
- // val s = server
57
- // val c = client
55
+ " be able to request a response from a server" in new TestKitSpec {
56
+ val portNumber = TestHelpers .portNumber.getAndIncrement()
57
+ val s = server(portNumber)
58
+ val c = client(portNumber)
58
59
59
- // val action = c <~< SimpleCommand(PING_PONG_COMMAND, "")
60
- // action.run.isSuccess
61
- // }
60
+ val action = c <~< SimpleCommand (PING_PONG_COMMAND , " " )
61
+ action.run.isSuccess
62
+ }
62
63
63
64
" be able to stream requests to a server" in new TestKitSpec {
64
- val s = server
65
- val c = client
65
+ val portNumber = TestHelpers .portNumber.getAndIncrement()
66
+ val s = server(portNumber)
67
+ val c = client(portNumber)
66
68
67
69
val chunks = List .fill(5 )(SimpleStreamChunk (" ABCDE" ))
68
70
val action = c <<?~~< (SimpleCommand (TOTAL_CHUNK_SIZE , " " ), Process .emitRange(0 , 500 ) |> process1.lift(x ⇒ SimpleStreamChunk (" ABCDE" )) onComplete (Process .emit(SimpleStreamChunk (" " ))))
0 commit comments