@@ -0,0 +1,2916 @@
+package tests.eu.qualimaster.common;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.net.ServerSocket;%0D%0Aimport java.net.Socket;%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.List;%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport org.apache.log4j.Logger;%0D%0A%0D%0Aimport eu.qualimaster.common.hardware.MultiHardwareThreadsExecutor;%0D%0A%0D%0A/**%0D%0A * Test for multiple hardware threads.%0D%0A * @author Cui Qin%0D%0A *%0D%0A */%0D%0Apublic class MultiHardwareThreadsExecutorTest %7B%0D%0A    private static final Logger LOGGER = Logger.getLogger(MultiHardwareThreadsExecutorTest.class);    %0D%0A    /**%0D%0A     * Define a server.%0D%0A     * @author Cui Qin%0D%0A     *%0D%0A     */%0D%0A    public static class Server implements Runnable %7B%0D%0A        private int port;%0D%0A        /**%0D%0A         * Creates a server with the given port.%0D%0A         * @param port the port number%0D%0A         */%0D%0A        public Server(int port) %7B%0D%0A            this.port = port;%0D%0A            try %7B%0D%0A                @SuppressWarnings(%7B %22unused%22, %22resource%22 %7D)%0D%0A                ServerSocket serverSocket = new ServerSocket(port);%0D%0A            %7D catch (IOException e) %7B%0D%0A                e.printStackTrace();%0D%0A            %7D%0D%0A        %7D%0D%0A        @Override%0D%0A        public void run() %7B%0D%0A            //do nothing%0D%0A        %7D%0D%0A        %0D%0A        /**%0D%0A         * Starts the server.%0D%0A         */%0D%0A        public void start() %7B%0D%0A            new Thread(this).start();%0D%0A            LOGGER.info(%22Server thread started with the port: %22 + port);%0D%0A        %7D%0D%0A        %0D%0A    %7D%0D%0A    /**%0D%0A     * A client thread handler.%0D%0A     * @author Cui Qin%0D%0A     *%0D%0A     */%0D%0A    public static class ClientThreadHandler implements Runnable %7B%0D%0A        /**%0D%0A         * Creates a client thread handler.%0D%0A         * @param ip the ip %0D%0A         * @param port the port%0D%0A         */%0D%0A        public ClientThreadHandler(String ip, int port) %7B%0D%0A            try %7B%0D%0A                @SuppressWarnings(%7B %22unused%22, %22resource%22 %7D)%0D%0A                Socket socket = new Socket(ip, port);%0D%0A            %7D catch (IOException e) %7B%0D%0A                e.printStackTrace();%0D%0A            %7D%0D%0A        %7D%0D%0A        @Override%0D%0A        public void run() %7B%0D%0A            //do nothing%0D%0A        %7D%0D%0A        %0D%0A    %7D%0D%0A    /**%0D%0A     * Performs the test.%0D%0A     * @param args ignored%0D%0A     */%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        //Start the servers%0D%0A        Server server1 = new Server(8000);%0D%0A        server1.start();%0D%0A        %0D%0A        Server server2 = new Server(8001);%0D%0A        server2.start();%0D%0A        %0D%0A        List%3CInteger%3E ports = new ArrayList%3CInteger%3E();%0D%0A        ports.add(8000);%0D%0A        ports.add(8001);%0D%0A        Map%3CString, List%3CInteger%3E%3E servers = new HashMap%3CString, List%3CInteger%3E%3E();%0D%0A        servers.put(%22localhost%22, ports);%0D%0A        %0D%0A        MultiHardwareThreadsExecutor executor = new MultiHardwareThreadsExecutor(servers%0D%0A                , ClientThreadHandler.class, ports.size());%0D%0A        executor.createMultiThreads();%0D%0A    %7D%0D%0A%0D%0A%7D%0D%0A

Test for multiple thread executor