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;
}
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()));
}
Aggregations