How to mock a java.net.Socket using wiremock? -
i need mock java.net.socket class using wiremock technique... possible wiremock socket class?
even if bit late, in case question raised later somebody:
i in same situation. implemented separate junit @rule starts/stops serversocket , accepts socket requests test cases.
i'm not allowed share code because belongs company. i'm allowed share powerslide surely how achieve it.
in junit using client/service establish socket communication given port (in case: 9999). wiremock responses sockets written in same style http requests/responses. simplified example "any" method:
wiremock.giventhat(wiremock.anyurl()).withrequestbody(wiremock.containing("blah blah")).willreturn(wiremock.aresponse().withbody("hello world!")));
in case socket/client sending body "blah blah" wiremock return "hello world!" http entity , content of http entity forwarded socket/client socket proxy.
hope helps, chris
Comments
Post a Comment