Generating an IOException When Closing a Socket/ServerSocket

Hi Everyone!

Can somebody tell me how to generate an IOException when closing a socket because I'm currently making a junit test case and i want to test my exception handling. Kindly check the code below.

try

{

serverSocket.close();// <<-- this should throw an IOException.

}

catch(IOException e)

{

// This is the part that I want to test.

}

Thanks!

[656 byte] By [GideonRaya] at [2007-10-2 22:06:30]
# 1
Not the best, but the simplest solution: add a throw new IOException("whatever"); after the close() statement... That should work for testing...
falke2203a at 2007-7-14 1:23:11 > top of Java-index,Core,Core APIs...