Skip to content
Snippets Groups Projects
Commit aa7c4f37 authored by gwen-soleil's avatar gwen-soleil
Browse files

fix test set up that was not waiting for the device initialisation completion.

parent db40ada1
Branches
Tags
No related merge requests found
......@@ -16,6 +16,7 @@ import static org.mockito.Mockito.when;
import java.lang.reflect.Array;
import java.util.Map;
import fr.esrf.TangoApi.DeviceProxy;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
......@@ -146,7 +147,7 @@ public class TangoParserTest {
private static SourceManager mngr = Mockito.spy(SourceManager.class);
@BeforeClass
public static void setUp() throws DevFailed {
public static void setUp() throws DevFailed, InterruptedException {
System.setProperty("org.tango.server.checkalarms", "false");
// assertThat(System.getProperty("TANGO_HOST"), notNullValue());
//System.setProperty("TANGO_HOST", "192.168.56.101:10000");
......@@ -305,33 +306,30 @@ public class TangoParserTest {
ServerManager.getInstance().addClass(TangoParser.class.getSimpleName(), TangoParser.class);
ServerManager.getInstance().start(new String[]{INSTANCE_NAME}, TangoParser.class.getSimpleName());
boolean launched = false;
boolean launched = true;
long maximumTime = 20000;
long timer = maximumTime;
long stepTime = 1500;
DevState startState = DevState.UNKNOWN;
while(!launched &&timer>0) {
final DeviceProxy tangoParser = new DeviceProxy(deviceNameParser);
DevState startState = tangoParser.state();
try {
while (startState.equals(DevState.INIT) && timer > 0) {
Thread.sleep(stepTime);
} catch (final InterruptedException e) {
}
try {
final TangoAttribute tangoParser = new TangoAttribute(deviceNameParser + "/state");
startState = (DevState)tangoParser.read();
System.out.println("State readed !");
launched = true;
}
catch (DevFailed e) {
launched = false;
}
startState = tangoParser.state();
System.out.println("State = " + startState);
timer -= stepTime;
}
launched = timer > 0;
} catch (DevFailed e) {
DevFailedUtils.printDevFailed(e);
throw e;
}
if (launched) {
System.out.println("Device started in " + Double.toString((maximumTime - timer) / 1000.0) + " seconds.");
System.out.println("Device state: " + startState.toString());
System.out.println("Device state: " + startState);
}else {
System.out.println("Device failed to start." + startState.toString());
System.out.println("Device start up took too much time, aborting");
}
System.out.println("Set up done");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment