I need to right test that ensures that i fixed java.net.SocketException: Broken pipe
. How to reproduce it if I have socket in java code?
Assuming that you want to reproduce it on a unit test, you should use Mockito framework to reproduce this exception.
doThrow(new SocketException()).when(mockedObject.methodReturningVoid(...))
You can find more information here