Search in sources :

Example 1 with MasterNodeLocal

use of org.evosuite.rmi.service.MasterNodeLocal in project evosuite by EvoSuite.

the class TestGenerationJob method runEvoSuite.

protected ArrayList<TestGenerationResult> runEvoSuite(final IProgressMonitor monitor) {
    monitor.beginTask("EvoSuite test suite generation", 100);
    ArrayList<TestGenerationResult> tgrs = new ArrayList<TestGenerationResult>();
    try {
        List<String> commands = createCommand();
        commands.addAll(getAdditionalParameters());
        String[] command = new String[commands.size()];
        commands.toArray(command);
        System.out.println("* EvoSuite command: " + Arrays.asList(command));
        setupRMI();
        Thread progressMonitor = new Thread() {

            @Override
            public void run() {
                int percent = 0;
                int last = 0;
                String subTask = "";
                // try {
                while (percent != -1 && !isInterrupted()) {
                    MasterNodeLocal masterNode = MasterServices.getInstance().getMasterNode();
                    if (masterNode != null) {
                        Collection<ClientStateInformation> currentStates = MasterServices.getInstance().getMasterNode().getCurrentStateInformation();
                        if (currentStates.size() == 1) {
                            ClientStateInformation currentState = currentStates.iterator().next();
                            lastState = currentState;
                            percent = currentState.getOverallProgress();
                            if (percent >= 100 && currentState.getState() == ClientState.NOT_STARTED)
                                continue;
                            String currentTask = currentState.getState().getDescription();
                            // + "%]";
                            if (percent > last || !subTask.equals(currentTask)) {
                                subTask = currentTask;
                                monitor.worked(percent - last);
                                monitor.subTask(subTask);
                                last = percent;
                            }
                        }
                    }
                    try {
                        // TODO - should use observer pattern
                        sleep(250);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                        System.out.println("* Shut down progress monitor");
                    }
                // } catch (Exception e) {
                // System.err.println(this.getClass().getCanonicalName() + ": Exception while reading output of client process " + e);
                // System.err.println(e.getStackTrace().toString());
                // }
                }
            }
        };
        progressMonitor.start();
        tgrs = launchProcess(command);
        progressMonitor.interrupt();
        try {
            target.getProject().refreshLocal(IProject.DEPTH_INFINITE, null);
        } catch (CoreException e) {
            e.printStackTrace();
        }
        System.out.println("Job returned normally");
        monitor.done();
    /*
			GenerationResult result = new GenerationResult(shell, SWT.DIALOG_TRIM
			        | SWT.APPLICATION_MODAL);
			result.open();
			return Status.OK_STATUS;
			*/
    } catch (Exception e) {
        System.out.println(e.toString());
        e.printStackTrace();
    }
    return tgrs;
}
Also used : ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) FileNotFoundException(java.io.FileNotFoundException) JavaModelException(org.eclipse.jdt.core.JavaModelException) IOException(java.io.IOException) TestGenerationResult(org.evosuite.result.TestGenerationResult) CoreException(org.eclipse.core.runtime.CoreException) ClientStateInformation(org.evosuite.rmi.service.ClientStateInformation) MasterNodeLocal(org.evosuite.rmi.service.MasterNodeLocal)

Example 2 with MasterNodeLocal

use of org.evosuite.rmi.service.MasterNodeLocal in project evosuite by EvoSuite.

the class ServicesTest method testMasterClientCommunication.

@Test
public void testMasterClientCommunication() throws Exception {
    MasterServices master = new MasterServices();
    master.startRegistry();
    master.registerServices();
    Properties.PROCESS_COMMUNICATION_PORT = master.getRegistryPort();
    ClientServices clients = new ClientServices();
    clients.registerServices();
    ClientNodeLocal clientNode = clients.getClientNode();
    clientNode.changeState(ClientState.STARTED);
    MasterNodeLocal masterNode = master.getMasterNode();
    String summary = masterNode.getSummaryOfClientStatuses();
    Assert.assertNotNull(summary);
    Assert.assertTrue("summary=" + summary, summary.contains(ClientState.STARTED.toString()));
}
Also used : ClientNodeLocal(org.evosuite.rmi.service.ClientNodeLocal) MasterNodeLocal(org.evosuite.rmi.service.MasterNodeLocal) Test(org.junit.Test)

Aggregations

MasterNodeLocal (org.evosuite.rmi.service.MasterNodeLocal)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 PartInitException (org.eclipse.ui.PartInitException)1 TestGenerationResult (org.evosuite.result.TestGenerationResult)1 ClientNodeLocal (org.evosuite.rmi.service.ClientNodeLocal)1 ClientStateInformation (org.evosuite.rmi.service.ClientStateInformation)1 Test (org.junit.Test)1