Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simulate a socket disconnection?

Tags:

java

tcp

sockets

My application uploads files to server of my client, but he want special "pause upload" function. I cant simply close connection, not even kill process - he need to lost connection otherwise his server application delete unfinished file - so i have to simulate in code "cable unplug" - do you have any suggestion? thanks for your help and sorry for my english :) jirka

like image 922
jirka Avatar asked Feb 23 '26 00:02

jirka


1 Answers

You can use Mockito to create a Socket mock for your unit tests, as suggested on this question: Testing Java Sockets

like image 149
PaoloVictor Avatar answered Feb 24 '26 15:02

PaoloVictor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!