4

I am quite new to akka-http and especially to websockets. I have a service which runs on localhost:8080 and has a path /greeter. When a request comes on this path then it forwards the request to /greeter on localhost:9000 where the handler is of return type Flow[Message,Message,Any]. I need to unit test the method which is on localhost:8080 where originally the request came. So in unit test we will need to use mocking for the response of localhost:9000 method that handles the request. So can anyone suggest how that mocking can be achieved as I am unable to figure out the way.

val http: HttpExt = Http()   
def webSocketResponse: Flow[Message,Message,Future[WebSocketUpgradeResponse]] = http.webSocketClientFlow(WebSocketRequest("ws://localhost:9000/greeter"))       
 val sampleRoutes =  path(GREETER) {
          val webSocketFlow: Flow[Message, Message, Future[WebSocketUpgradeResponse]] = webSocketResponse
          logDuration(handleWebSocketMessages(webSocketFlow))
        }

0 Answers0