@@ -61,17 +61,17 @@ public class NioTest {
6161 private static final Logger LOGGER = Logger .getLogger (NioTest .class );
6262
6363 // Test should fail in due time instead of looping forever
64- private static final int TESTTIMEOUT = 60000 ;
64+ private static final int TESTTIMEOUT = 300000 ;
6565
66- final private int totalTestCount = 4 ;
66+ final private int totalTestCount = 5 ;
6767 private int completedTestCount = 0 ;
6868
6969 private NioServer server ;
7070 private List <NioClient > clients = new ArrayList <>();
7171 private List <NioClient > maliciousClients = new ArrayList <>();
7272
7373 private ExecutorService clientExecutor = Executors .newFixedThreadPool (totalTestCount , new NamedThreadFactory ("NioClientHandler" ));;
74- private ExecutorService maliciousExecutor = Executors .newFixedThreadPool (totalTestCount , new NamedThreadFactory ("MaliciousNioClientHandler" ));;
74+ private ExecutorService maliciousExecutor = Executors .newFixedThreadPool (5 * totalTestCount , new NamedThreadFactory ("MaliciousNioClientHandler" ));;
7575
7676 private Random randomGenerator = new Random ();
7777 private byte [] testBytes ;
@@ -105,18 +105,12 @@ public void setUp() {
105105 Assert .fail (e .getMessage ());
106106 }
107107
108- /**
109- * The malicious client(s) tries to block NioServer's main IO loop
110- * thread until SSL handshake timeout value (from Link class, 15s) after
111- * which the valid NioClient(s) get the opportunity to make connection(s)
112- */
113- for (int i = 0 ; i < totalTestCount ; i ++) {
114- final NioClient maliciousClient = new NioMaliciousClient ("NioMaliciousTestClient-" + i , "127.0.0.1" , server .getPort (), 1 , new NioMaliciousTestClient ());
115- maliciousClients .add (maliciousClient );
116- maliciousExecutor .submit (new ThreadedNioClient (maliciousClient ));
117- }
118-
119108 for (int i = 0 ; i < totalTestCount ; i ++) {
109+ for (int j = 0 ; j < 4 ; j ++) {
110+ final NioClient maliciousClient = new NioMaliciousClient ("NioMaliciousTestClient-" + i , "127.0.0.1" , server .getPort (), 1 , new NioMaliciousTestClient ());
111+ maliciousClients .add (maliciousClient );
112+ maliciousExecutor .submit (new ThreadedNioClient (maliciousClient ));
113+ }
120114 final NioClient client = new NioClient ("NioTestClient-" + i , "127.0.0.1" , server .getPort (), 1 , new NioTestClient ());
121115 clients .add (client );
122116 clientExecutor .submit (new ThreadedNioClient (client ));
@@ -292,6 +286,7 @@ public void doTask(final Task task) {
292286 LOGGER .info ("Server: Received OTHER task" );
293287 }
294288 }
289+
295290 }
296291 }
297292}
0 commit comments