@Test
    public void testMultipleJobsWithMultipleClients() {
        System.out.println("multipleJobsWithMultipleClients");

        final Random rnd = new Random();
        final Counter counter = new Counter();
        final Set<AssignmentListener> computingClients = new HashSet<AssignmentListener>();

        final AssignmentListener l = new AssignmentListener() {
            @Override
            public void receiveTask(Assignment task) {
                try {
                    Object tsk = task.getTask();

                    if (!(tsk instanceof Integer)) {
                        fail("Illegal task received");
                    }

                    Integer count = (Integer) tsk;

                    synchronized (task) {
                        task.wait(count);
                    }

                    counter.add(count);

                    task.submitResult(GenericResponses.OK);
                } catch (ConnectionException ex) {
                    fail("Connection to servr failed - " + ex);
                } catch (InterruptedException ex) {
                    fail("Waiting has been interrupted - " + ex);
                }
            }

            @Override
            public void cancelTask(Assignment task) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        };
        c.setAssignmentListener(new AssignmentListenerWrapper(computingClients, l));

        final int clientCount = rnd.nextInt(5) + 2;
        Client cl;
        for (int i = 0; i < clientCount - 1; i++) {
            try {
                cl = ClientImpl.initNewClient();
                cl.registerToServer(GlobalConstants.IP_LOOPBACK);
                cl.setAssignmentListener(new AssignmentListenerWrapper(computingClients, l));
                clients.add(cl);
            } catch (Exception ex) {
                fail("Initialization of one of the clients failed - " + ex);
            }
        }

        int cnt = 0, val;
        final int jobCount = clientCount * (rnd.nextInt(3) + 2);
        Set<Job> allJobs = new HashSet<Job>(jobCount);
        for (int i = 0; i < jobCount; i++) {
            val = (rnd.nextInt(4) + 1) * 10;
            cnt += val;
            allJobs.add(s.submitJob(val));
        }

        s.getJobManager().waitForAllJobs();

        // check all result if OK
        for (Job j : allJobs) {
            assertEquals(GenericResponses.OK, j.getResult(true));
        }

        assertEquals(cnt, counter.getCount());
        assertEquals(clientCount, computingClients.size());
    }