- private List<SimpleClient> createAndStartClient(int amountOfCLients)
- throws InterruptedException, ExecutionException {
- List<SimpleClient> clientsHorde = new ArrayList<>();
- for (int i = 0; i < amountOfCLients; i++) {
- SimpleClient sc = new SimpleClient(address, port, getClass().getResourceAsStream(
- OF_BINARY_MESSAGE_INPUT_TXT));
- sc.setSecuredClient(true);
- clientsHorde.add(sc);
- sc.start();
+ @Test
+ public void testRunWithEncryptionOnEpoll() throws InterruptedException, IOException, ExecutionException {
+ int serverPort = 28001;
+ tcpHandler = new TcpHandler(serverAddress, serverPort);
+ tcpHandler.setChannelInitializer(mockChannelInitializer);
+
+ //Use Epoll native transport
+ assertEquals( "failed to start server", true, startupServer(true));
+ assertEquals( "wrong connection count", 0, tcpHandler.getNumberOfConnections());
+ assertEquals( "wrong port", serverPort, tcpHandler.getPort());
+ assertEquals( "wrong address", serverAddress.getHostAddress(), tcpHandler.getAddress());
+
+ assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort()));
+
+ shutdownServer();
+ }
+
+ /**
+ * Test run on already used port
+ * @throws IOException
+ */
+ @Test
+ public void testSocketAlreadyInUse() throws IOException {
+ int serverPort = 28001;
+ Socket firstBinder = new Socket();
+ boolean exceptionThrown = false;
+ try {
+ firstBinder.bind(new InetSocketAddress(serverAddress, serverPort));
+ } catch (Exception e) {
+ Assert.fail("Test precondition failed - not able to bind socket to port " + serverPort);