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.

enter image description here

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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -