Relative Content

Tag Archive for javamockitojunit4

getInputStream() of a mock Socket returns a null object

I’m writing a junitTest that should test a serverHandler object that handle the reciving and sending of message to a server.
I’m doing that by mocking the socket of the server and putting my own ObjectInputStream and ObjectOutputStream so that I will be able to controll what message the server is sending.
I cant wrap my head why the “output” object in the serverHandler is created and is set as ObjectOutputStream created in the test, while the “input” object remains null and blocks the code flow until the timer in executor runs up and stop the thread.