Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Schladebeck2013-05-15 13:40:50 +0000
committerAlexandra Schladebeck2013-05-15 13:40:50 +0000
commitf31d16eaf7ea5b9c3ca48e89770ed7784984b7ca (patch)
tree0fbc55e5540dc330688df5b1a89649a4e8522f05
parent80761318605df520084b2327bd744cfba7e43b23 (diff)
parent5dc11aa918a40c476ceab72e6f6946360dcee789 (diff)
downloadorg.eclipse.jubula.core-f31d16eaf7ea5b9c3ca48e89770ed7784984b7ca.tar.gz
org.eclipse.jubula.core-f31d16eaf7ea5b9c3ca48e89770ed7784984b7ca.tar.xz
org.eclipse.jubula.core-f31d16eaf7ea5b9c3ca48e89770ed7784984b7ca.zip
Merge branch 'master' of ssh://gatekeeper.bredex.de:2407/jubula/org.eclipse.jubula.core
-rw-r--r--org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java18
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java50
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java10
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java4
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java23
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java7
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java2
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/AUTEvent.java27
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java132
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/commands/AUTServerStateCommand.java2
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/communication/AUTConnection.java15
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestExecutionContributor.java24
-rw-r--r--org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/PrepareForShutdownMessage.java57
-rw-r--r--org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/RestartAutMessage.java24
-rw-r--r--org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/commands/PrepareForShutdownCommand.java153
-rw-r--r--org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/WorkaroundUtil.java11
-rw-r--r--org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/common/adapter/SwingAdapterFactory.java18
-rw-r--r--org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/SwingAUTServer.java9
-rw-r--r--org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/components/AUTSwingHierarchy.java15
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/constants/CommandConstants.java6
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/EnvironmentUtils.java15
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/TimeUtil.java23
22 files changed, 485 insertions, 160 deletions
diff --git a/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java b/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
index b3326921b..dad6eec79 100644
--- a/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
+++ b/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
@@ -52,8 +52,8 @@ import org.eclipse.jubula.client.core.businessprocess.compcheck.CompletenessGuar
import org.eclipse.jubula.client.core.businessprocess.db.TestSuiteBP;
import org.eclipse.jubula.client.core.businessprocess.problems.IProblem;
import org.eclipse.jubula.client.core.businessprocess.problems.ProblemFactory;
-import org.eclipse.jubula.client.core.communication.ConnectionException;
import org.eclipse.jubula.client.core.communication.AutAgentConnection;
+import org.eclipse.jubula.client.core.communication.ConnectionException;
import org.eclipse.jubula.client.core.model.IAUTConfigPO;
import org.eclipse.jubula.client.core.model.IAUTMainPO;
import org.eclipse.jubula.client.core.model.ICapPO;
@@ -78,7 +78,6 @@ import org.eclipse.jubula.tools.exception.JBException;
import org.eclipse.jubula.tools.i18n.I18n;
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
import org.eclipse.jubula.tools.registration.AutIdentifier;
-import org.eclipse.jubula.tools.utils.EnvironmentUtils;
import org.eclipse.jubula.tools.utils.FileUtils;
import org.eclipse.jubula.tools.utils.TimeUtil;
import org.eclipse.osgi.util.NLS;
@@ -623,19 +622,8 @@ public class ExecutionController implements IAUTServerEventListener,
* this method delays the test execution start during AUT startup
*/
private void waitExternalTime() {
- int timeToWait = AUT_STARTUP_DELAY_DEFAULT;
- try {
- String value = EnvironmentUtils.getProcessEnvironment()
- .getProperty(AUT_STARTUP_DELAY_VAR);
- if (value == null) {
- value = System.getProperty(AUT_STARTUP_DELAY_VAR);
- }
-
- timeToWait = Integer.valueOf(value).intValue();
- } catch (NumberFormatException e) {
- // ignore invalid formatted values and use default instead
- }
- TimeUtil.delay(timeToWait);
+ TimeUtil.delayDefaultOrExternalTime(AUT_STARTUP_DELAY_DEFAULT,
+ AUT_STARTUP_DELAY_VAR);
}
/**
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
index 1a40c48ef..49ec2ad0d 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
@@ -41,6 +41,7 @@ import org.eclipse.jubula.tools.exception.CommunicationException;
import org.eclipse.jubula.tools.exception.JBVersionException;
import org.eclipse.jubula.tools.registration.AutIdentifier;
import org.eclipse.jubula.tools.utils.StringParsing;
+import org.eclipse.jubula.tools.utils.TimeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,6 +54,14 @@ import org.slf4j.LoggerFactory;
* @created Dec 1, 2009
*/
public class AutAgent {
+ /**
+ * the default value to wait after a proper AUT termination (== de-registration)
+ */
+ public static final int AUT_POST_DEREGISTRATION_DELAY_DEFAULT = 2000;
+ /**
+ * Name of the variable to override the AUTs proper AUT de-registration delay
+ */
+ public static final String AUT_POST_DEREGISTRATION_DELAY_VAR = "TEST_AUT_POST_DEREGISTRATION_DELAY"; //$NON-NLS-1$
/** property name for collection of registered AUTs */
public static final String PROP_NAME_AUTS = "auts"; //$NON-NLS-1$
@@ -440,7 +449,9 @@ public class AutAgent {
/**
* Removes the given AUT from the collection of registered AUTs.
- * @param autId The ID of the AUT to deregister.
+ *
+ * @param autId
+ * The ID of the AUT to deregister.
*/
private void removeAut(AutIdentifier autId) {
boolean wasSetChanged = false;
@@ -450,7 +461,8 @@ public class AutAgent {
Communicator autCommunicator = m_auts.remove(autId);
if (autCommunicator != null) {
try {
- autCommunicator.send(new PrepareForShutdownMessage());
+ autCommunicator.send(
+ new PrepareForShutdownMessage());
} catch (CommunicationException e) {
// As a result of not being able to send the message,
// the AUT will end with a different exit code. This
@@ -569,29 +581,47 @@ public class AutAgent {
/**
* Stops the given AUT.
*
- * @param autId The ID of the Running AUT to stop.
+ * @param autId
+ * The ID of the Running AUT to stop.
+ * @param force
+ * indicates whether the AUT should be forced to quit or whether
+ * the AUT will terminate by itself
*/
- public void stopAut(AutIdentifier autId) {
+ public void stopAut(AutIdentifier autId, boolean force) {
synchronized (m_auts) {
Communicator autCommunicator = m_auts.get(autId);
if (autCommunicator != null) {
- removeAut(autId);
- autCommunicator.close();
+ if (force) {
+ removeAut(autId);
+ }
+ }
+ }
+ if (!force) {
+ while (m_auts.containsKey(autId)) {
+ TimeUtil.delay(250);
}
+ // The AUT has just unregistered itself - which must not be exactly
+ // the same as terminated - therefore we wait for another moment of time
+ TimeUtil.delayDefaultOrExternalTime(
+ AUT_POST_DEREGISTRATION_DELAY_DEFAULT,
+ AUT_POST_DEREGISTRATION_DELAY_VAR);
}
}
/**
* Restarts the AUT with the given ID.
*
- * @param autId The ID of the Running AUT to restart.
+ * @param autId
+ * The ID of the Running AUT to restart.
+ * @param force
+ * indicates whether the AUT should be forced to quit or whether
+ * the AUT will terminate by itself
*/
- public void restartAut(AutIdentifier autId) {
+ public void restartAut(AutIdentifier autId, boolean force) {
// cache the start method
final IRestartAutHandler message = m_autIdToRestartHandler.get(autId);
- message.restartAut(this);
-
+ message.restartAut(this, force);
}
/**
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
index 6b80d9c68..58fe05ce3 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
@@ -21,9 +21,13 @@ public interface IRestartAutHandler {
/**
*
- * @param agent The AUT Agent with which the AUT to be restarted is
- * registered. This may be used, for example, to stop the AUT.
+ * @param agent
+ * The AUT Agent with which the AUT to be restarted is
+ * registered. This may be used, for example, to stop the AUT.
+ * @param force
+ * indicates whether the AUT should be forced to quit or whether
+ * the AUT will terminate by itself
*/
- public void restartAut(AutAgent agent);
+ public void restartAut(AutAgent agent, boolean force);
}
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
index a2cbc1e55..335bc0dae 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
@@ -60,7 +60,7 @@ public class RestartAutAutRun implements IRestartAutHandler {
/**
* {@inheritDoc}
*/
- public void restartAut(AutAgent agent) {
+ public void restartAut(AutAgent agent, boolean force) {
try {
PrintWriter writer = new PrintWriter(
m_autrunSocket.getOutputStream(), true);
@@ -68,7 +68,7 @@ public class RestartAutAutRun implements IRestartAutHandler {
writer.println(RestartAutProtocol.REQ_PREPARE_FOR_RESTART);
m_socketReader.readLine();
- agent.stopAut(m_autId);
+ agent.stopAut(m_autId, force);
writer.println(RestartAutProtocol.REQ_RESTART);
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
index b059613a8..2924e6617 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
@@ -14,10 +14,9 @@ import org.eclipse.jubula.autagent.commands.StartAUTServerCommand;
import org.eclipse.jubula.communication.message.StartAUTServerMessage;
import org.eclipse.jubula.tools.registration.AutIdentifier;
-
/**
* Restarts an AUT that was started via an AUT Configuration.
- *
+ *
* @author BREDEX GmbH
* @created Mar 26, 2010
*/
@@ -25,31 +24,29 @@ public class RestartAutConfiguration implements IRestartAutHandler {
/** the message used to start the AUT */
private StartAUTServerMessage m_startAutMessage;
-
+
/** the ID of the the started AUT */
private AutIdentifier m_autId;
/**
* Constructor
*
- * @param autId The ID of the started AUT.
- * @param startAutMessage The message used to start the AUT.
+ * @param autId
+ * The ID of the started AUT.
+ * @param startAutMessage
+ * The message used to start the AUT.
*/
- public RestartAutConfiguration(AutIdentifier autId,
+ public RestartAutConfiguration(AutIdentifier autId,
StartAUTServerMessage startAutMessage) {
m_startAutMessage = startAutMessage;
m_autId = autId;
}
- /**
- * {@inheritDoc}
- */
- public void restartAut(AutAgent agent) {
-
- agent.stopAut(m_autId);
+ /** {@inheritDoc} */
+ public void restartAut(AutAgent agent, boolean force) {
+ agent.stopAut(m_autId, force);
StartAUTServerCommand startCommand = new StartAUTServerCommand();
startCommand.setMessage(m_startAutMessage);
startCommand.execute();
}
-
}
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
index 8f7e4ba9d..3176353eb 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
@@ -18,6 +18,7 @@ import org.eclipse.jubula.communication.ICommand;
import org.eclipse.jubula.communication.message.Message;
import org.eclipse.jubula.communication.message.RestartAutMessage;
import org.eclipse.jubula.tools.constants.AutConfigConstants;
+import org.eclipse.jubula.tools.registration.AutIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
@@ -38,13 +39,15 @@ public class RestartAutCommand implements ICommand {
* {@inheritDoc}
*/
public Message execute() {
+ AutIdentifier autId = m_message.getAutId();
String monitoringId = m_cm.getConfigValue(
- m_message.getAutId().getExecutableName(),
+ autId.getExecutableName(),
AutConfigConstants.MONITORING_AGENT_ID);
if (!StringUtils.isEmpty(monitoringId)) {
invokeMonitoringRestartMethod();
}
- AutStarter.getInstance().getAgent().restartAut(m_message.getAutId());
+ AutStarter.getInstance().getAgent()
+ .restartAut(autId, m_message.isForceAUTTermination());
return null;
}
/**
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
index 54de4bbd6..10007c1fe 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
@@ -79,7 +79,7 @@ public class StopAUTServerCommand implements ICommand {
final AutAgent agent = AutStarter.getInstance().getAgent();
if (agent != null) {
- agent.stopAut(m_message.getAutId());
+ agent.stopAut(m_message.getAutId(), true);
return new StopAUTServerStateMessage();
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/AUTEvent.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/AUTEvent.java
index 532152fba..47b107c15 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/AUTEvent.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/AUTEvent.java
@@ -42,26 +42,33 @@ public class AUTEvent {
/** constant signaling that the AUT is restarted and running */
public static final int AUT_RESTARTED = AUT_CLASS_VERSION_ERROR + 1;
-
+
+ /** constant signaling that the AUT is about to terminate */
+ public static final int AUT_ABOUT_TO_TERMINATE = AUT_RESTARTED + 1;
+
/** description of AUT_STARTED for logging purpose */
private static final String AUT_STARTED_DESCRIPTION =
- "aut started"; //$NON-NLS-1$
+ "AUT started"; //$NON-NLS-1$
/** description of AUT_RESTARTED for logging purpose */
private static final String AUT_RESTARTED_DESCRIPTION =
- "aut restarted"; //$NON-NLS-1$
+ "AUT restarted"; //$NON-NLS-1$
+
+ /** description of AUT_ABOUT_TO_TERMINATE_DESCRIPTION for logging purpose */
+ private static final String AUT_ABOUT_TO_TERMINATE_DESCRIPTION =
+ "AUT about to terminate"; //$NON-NLS-1$
/** description of AUT_STOPPED for logging purpose */
private static final String AUT_STOPPED_DESCRIPTION =
- "aut stopped"; //$NON-NLS-1$
+ "AUT stopped"; //$NON-NLS-1$
/** description of AUT_ABORTED for logging purpose */
private static final String AUT_ABORTED_DESCRIPTION =
- "aut aborted"; //$NON-NLS-1$
+ "AUT aborted"; //$NON-NLS-1$
/** description of AUT_NOT_FOUND for logging purpose */
private static final String AUT_NOT_FOUND_DESCRIPTION =
- "starting aut failed: aut not found"; //$NON-NLS-1$
+ "starting AUT failed: AUT not found"; //$NON-NLS-1$
/** description of AUT_MAIN_NOT_FOUND for logging purpose */
private static final String AUT_MAIN_NOT_FOUND_DESCRIPTION =
@@ -69,11 +76,11 @@ public class AUTEvent {
/** description of AUT_START_FAILED for logging purpose */
private static final String AUT_START_FAILED_DESCRIPTION =
- "starting aut failed"; //$NON-NLS-1$
+ "starting AUT failed"; //$NON-NLS-1$
/** constant signaling that the AUT could not started */
private static final String AUT_CLASS_VERSION_ERROR_DECRIPTION =
- "aut class version is not compatible to used JRE"; //$NON-NLS-1$
+ "AUT class version is not compatible to used JRE"; //$NON-NLS-1$
/** description of unknown state (this means it's an programming error)
* for logging purpose */
@@ -120,7 +127,9 @@ public class AUTEvent {
case AUT_CLASS_VERSION_ERROR:
return AUT_CLASS_VERSION_ERROR_DECRIPTION;
case AUT_RESTARTED:
- return AUT_RESTARTED_DESCRIPTION;
+ return AUT_RESTARTED_DESCRIPTION;
+ case AUT_ABOUT_TO_TERMINATE:
+ return AUT_ABOUT_TO_TERMINATE_DESCRIPTION;
default:
return US_DESCRIPTION;
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
index 49f05a196..8f8bfdea4 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
@@ -26,9 +26,11 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jubula.client.core.AUTEvent;
import org.eclipse.jubula.client.core.Activator;
import org.eclipse.jubula.client.core.ClientTest;
import org.eclipse.jubula.client.core.ClientTestFactory;
+import org.eclipse.jubula.client.core.IClientTest;
import org.eclipse.jubula.client.core.MessageFactory;
import org.eclipse.jubula.client.core.agent.AutAgentRegistration;
import org.eclipse.jubula.client.core.agent.AutRegistrationEvent;
@@ -79,6 +81,7 @@ import org.eclipse.jubula.communication.message.Message;
import org.eclipse.jubula.communication.message.MessageCap;
import org.eclipse.jubula.communication.message.MessageParam;
import org.eclipse.jubula.communication.message.NullMessage;
+import org.eclipse.jubula.communication.message.PrepareForShutdownMessage;
import org.eclipse.jubula.communication.message.ResetMonitoringDataMessage;
import org.eclipse.jubula.communication.message.RestartAutMessage;
import org.eclipse.jubula.communication.message.TakeScreenshotMessage;
@@ -1707,10 +1710,63 @@ public class TestExecution {
* @author BREDEX GmbH
* @created 30.04.2013
*/
- public class PrepareForShutdownCmd implements IPostExecutionCommand {
+ private static class AUTTerminationListener
+ implements IAutRegistrationListener {
+ /**
+ * indicates whether the AUT terminated or not
+ */
+ private boolean m_autTerminated = false;
+ /**
+ * the AUTs ID to monitor
+ */
+ private AutIdentifier m_autId = null;
+ /**
+ * flag indicating that the AUT has been re-started
+ */
+ private AtomicBoolean m_hasAutRestarted = new AtomicBoolean(false);
+
+ /**
+ * @param autID
+ * the AUTs ID to monitor
+ */
+ public AUTTerminationListener(AutIdentifier autID) {
+ m_autId = autID;
+ }
+
/** {@inheritDoc} */
- public TestErrorEvent execute() throws JBException {
- return null;
+ public void handleAutRegistration(
+ AutRegistrationEvent event) {
+ if (m_autId.equals(event.getAutId())) {
+ if (event.getStatus()
+ == RegistrationStatus.Deregister) {
+ setAutTerminated(true);
+ }
+ if (hasAutTerminated() && event.getStatus()
+ == RegistrationStatus.Register) {
+ hasAutRestarted().set(true);
+ }
+ }
+ }
+
+ /**
+ * @return the isAutRestarted
+ */
+ public AtomicBoolean hasAutRestarted() {
+ return m_hasAutRestarted;
+ }
+
+ /**
+ * @return the autTerminated
+ */
+ public boolean hasAutTerminated() {
+ return m_autTerminated;
+ }
+
+ /**
+ * @param autTerminated the autTerminated to set
+ */
+ private void setAutTerminated(boolean autTerminated) {
+ m_autTerminated = autTerminated;
}
}
@@ -1718,43 +1774,39 @@ public class TestExecution {
* @author BREDEX GmbH
* @created 30.04.2013
*/
- public class SyncShutdownAndRestartCmd implements IPostExecutionCommand {
+ public class PrepareForShutdownCmd implements IPostExecutionCommand {
/** {@inheritDoc} */
public TestErrorEvent execute() throws JBException {
+ AUTConnection.getInstance().getCommunicator()
+ .send(new PrepareForShutdownMessage(false, m_stepSpeed));
return null;
}
}
/**
- *
* @author BREDEX GmbH
- * @created Aug 22, 2006
+ * @created 30.04.2013
*/
- public class RestartCmd implements IPostExecutionCommand {
-
+ public class SyncShutdownAndRestartCmd extends AbstractRestartCmd {
+ @Override
+ protected Message getRestartMessage(AutIdentifier autId) {
+ return new RestartAutMessage(autId, false);
+ }
+ }
+
+ /**
+ * @author BREDEX GmbH
+ * @created 30.04.2013
+ */
+ public abstract class AbstractRestartCmd implements IPostExecutionCommand {
/**
* {@inheritDoc}
*/
- public TestErrorEvent execute() throws JBException {
+ public final TestErrorEvent execute() throws JBException {
final AutIdentifier autId = getConnectedAutId();
- final AtomicBoolean isAutRestarted = new AtomicBoolean(false);
- IAutRegistrationListener registrationListener =
- new IAutRegistrationListener() {
- private boolean m_autEnded = false;
- public void handleAutRegistration(
- AutRegistrationEvent event) {
- if (autId.equals(event.getAutId())) {
- if (event.getStatus()
- == RegistrationStatus.Deregister) {
- m_autEnded = true;
- }
- if (m_autEnded && event.getStatus()
- == RegistrationStatus.Register) {
- isAutRestarted.set(true);
- }
- }
- }
- };
+ AUTTerminationListener registrationListener =
+ new AUTTerminationListener(autId);
+
try {
TimeUtil.delay(2000);
@@ -1770,9 +1822,13 @@ public class TestExecution {
boolean wasInterrupted = Thread.interrupted();
AutAgentRegistration.getInstance().addListener(
registrationListener);
+ IClientTest clientTest = ClientTestFactory.getClientTest();
+ clientTest.fireAUTStateChanged(new AUTEvent(
+ AUTEvent.AUT_ABOUT_TO_TERMINATE));
+
AutAgentConnection.getInstance().send(
- new RestartAutMessage(autId));
- while (!isAutRestarted.get()) {
+ getRestartMessage(autId));
+ while (!registrationListener.hasAutRestarted().get()) {
// wait for AUT registration
try {
Thread.sleep(250);
@@ -1807,6 +1863,24 @@ public class TestExecution {
}
}
}
+
+ /**
+ * @param autId
+ * the AUT id to use
+ * @return the message used to restart the AUT
+ */
+ protected abstract Message getRestartMessage(AutIdentifier autId);
+ }
+
+ /**
+ * @author BREDEX GmbH
+ * @created Aug 22, 2006
+ */
+ public class RestartCmd extends AbstractRestartCmd {
+ @Override
+ protected Message getRestartMessage(AutIdentifier autId) {
+ return new RestartAutMessage(autId, true);
+ }
}
/**
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/commands/AUTServerStateCommand.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/commands/AUTServerStateCommand.java
index 2bbacc5e7..dd74ca011 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/commands/AUTServerStateCommand.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/commands/AUTServerStateCommand.java
@@ -59,7 +59,7 @@ public class AUTServerStateCommand implements ICommand {
* In case of READY, the AUT is started by returning the message
* AUTStartMessage.
* The state "READY" is mapped to "AUT_RESTARTED" because we cannot differ
- * whether the AUT is sarted for the first time or if it was a restart.
+ * whether the AUT is started for the first time or if it was a restart.
* So these two events are treated equally.
*
* {@inheritDoc}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/communication/AUTConnection.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/communication/AUTConnection.java
index 6e0dd7afa..b78fe785a 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/communication/AUTConnection.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/communication/AUTConnection.java
@@ -19,6 +19,7 @@ import org.eclipse.jubula.client.core.AUTEvent;
import org.eclipse.jubula.client.core.AUTServerEvent;
import org.eclipse.jubula.client.core.ClientTestFactory;
import org.eclipse.jubula.client.core.IAUTInfoListener;
+import org.eclipse.jubula.client.core.IClientTest;
import org.eclipse.jubula.client.core.ServerEvent;
import org.eclipse.jubula.client.core.agent.AutAgentRegistration;
import org.eclipse.jubula.client.core.commands.ConnectToAutResponseCommand;
@@ -339,14 +340,12 @@ public class AUTConnection extends BaseConnection {
disconnectFromAut();
DataEventDispatcher.getInstance().fireAutServerConnectionChanged(
ServerState.Disconnected);
- ClientTestFactory.getClientTest().
- fireAUTServerStateChanged(new AUTServerEvent(
- AUTServerEvent.TESTING_MODE));
- ClientTestFactory.getClientTest().fireAUTStateChanged(
- new AUTEvent(AUTEvent.AUT_STOPPED));
- ClientTestFactory.getClientTest().fireAUTServerStateChanged(
- new AUTServerEvent(ServerEvent.CONNECTION_CLOSED));
-
+ IClientTest clientTest = ClientTestFactory.getClientTest();
+ clientTest.fireAUTServerStateChanged(new AUTServerEvent(
+ AUTServerEvent.TESTING_MODE));
+ clientTest.fireAUTStateChanged(new AUTEvent(AUTEvent.AUT_STOPPED));
+ clientTest.fireAUTServerStateChanged(new AUTServerEvent(
+ ServerEvent.CONNECTION_CLOSED));
}
/**
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestExecutionContributor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestExecutionContributor.java
index 6bcb7baca..5ba043518 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestExecutionContributor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestExecutionContributor.java
@@ -104,22 +104,22 @@ public class TestExecutionContributor
* dispose()..
*/
private void registerAsListener() {
- ClientTestFactory.getClientTest().addTestEventListener(this);
- ClientTestFactory.getClientTest().addAutAgentEventListener(this);
- ClientTestFactory.getClientTest().addAUTServerEventListener(this);
- ClientTestFactory.getClientTest().addTestExecutionEventListener(this);
+ IClientTest clientTest = ClientTestFactory.getClientTest();
+ clientTest.addTestEventListener(this);
+ clientTest.addAutAgentEventListener(this);
+ clientTest.addAUTServerEventListener(this);
+ clientTest.addTestExecutionEventListener(this);
}
/**
* deregister this as listener
*/
private void deregister() {
- ClientTestFactory.getClientTest().removeTestEventListener(this);
- ClientTestFactory.getClientTest().removeAutAgentEventListener(
- this);
- ClientTestFactory.getClientTest().removeAUTServerEventListener(this);
- ClientTestFactory.getClientTest()
- .removeTestExecutionEventListener(this);
+ IClientTest clientTest = ClientTestFactory.getClientTest();
+ clientTest.removeTestEventListener(this);
+ clientTest.removeAutAgentEventListener(this);
+ clientTest.removeAUTServerEventListener(this);
+ clientTest.removeTestExecutionEventListener(this);
}
/**
@@ -221,9 +221,13 @@ public class TestExecutionContributor
fireAndSetAutState(false);
break;
case AUTEvent.AUT_RESTARTED:
+ m_clientTest.addAUTServerEventListener(this);
fireAndSetAutState(true);
// only important for TestExecution
break;
+ case AUTEvent.AUT_ABOUT_TO_TERMINATE:
+ m_clientTest.removeAUTServerEventListener(this);
+ break;
default:
Assert.notReached(Messages.UnknownAUTState
+ String.valueOf(event.getState()));
diff --git a/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/PrepareForShutdownMessage.java b/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/PrepareForShutdownMessage.java
index 5672c3698..efd0ad881 100644
--- a/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/PrepareForShutdownMessage.java
+++ b/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/PrepareForShutdownMessage.java
@@ -19,9 +19,36 @@ import org.eclipse.jubula.tools.constants.CommandConstants;
* @created Mar 23, 2010
*/
public class PrepareForShutdownMessage extends Message {
-
/** Static version */
private static final double VERSION = 1.0;
+ /**
+ * indicates whether the AUT should be forced to quit or whether the AUT
+ * will terminate by itself
+ */
+ private boolean m_force = true;
+ /**
+ * the additional delay to use when AUT terminates normally
+ */
+ private int m_additionalDelay;
+
+ /**
+ * necessary for deserialization
+ */
+ public PrepareForShutdownMessage() {
+ // empty
+ }
+
+ /**
+ * @param force
+ * indicates whether the AUT should be forced to quit or whether
+ * the AUT will terminate by itself
+ * @param additionalDelay
+ * an additional delay to use if the AUT terminates non-forced
+ */
+ public PrepareForShutdownMessage(boolean force, int additionalDelay) {
+ setAdditionalDelay(additionalDelay);
+ setForce(force);
+ }
/** {@inheritDoc} */
public String getCommandClass() {
@@ -32,4 +59,32 @@ public class PrepareForShutdownMessage extends Message {
public double getVersion() {
return VERSION;
}
+
+ /**
+ * @return the force
+ */
+ public boolean isForce() {
+ return m_force;
+ }
+
+ /**
+ * @param force the force to set
+ */
+ public void setForce(boolean force) {
+ m_force = force;
+ }
+
+ /**
+ * @return the additionalDelay
+ */
+ public int getAdditionalDelay() {
+ return m_additionalDelay;
+ }
+
+ /**
+ * @param additionalDelay the additionalDelay to set
+ */
+ public void setAdditionalDelay(int additionalDelay) {
+ m_additionalDelay = additionalDelay;
+ }
}
diff --git a/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/RestartAutMessage.java b/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/RestartAutMessage.java
index 3c90c2de8..2c03a331b 100644
--- a/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/RestartAutMessage.java
+++ b/org.eclipse.jubula.communication/src/org/eclipse/jubula/communication/message/RestartAutMessage.java
@@ -23,6 +23,11 @@ public class RestartAutMessage extends Message {
/** the ID of the Running AUT to restart */
private AutIdentifier m_autId;
+
+ /**
+ * flag indicating whether the AUT should be closed or not
+ */
+ private boolean m_forceAUTTermination = true;
/**
* Constructor for use in framework methods. Do not use for normal
@@ -39,9 +44,12 @@ public class RestartAutMessage extends Message {
*
* @param autId
* The ID of the Running AUT to restart.
+ * @param forceAUTTermination
+ * flag indicating whether the AUT should be forced to quit
*/
- public RestartAutMessage(AutIdentifier autId) {
+ public RestartAutMessage(AutIdentifier autId, boolean forceAUTTermination) {
m_autId = autId;
+ m_forceAUTTermination = forceAUTTermination;
}
/** {@inheritDoc} */
@@ -66,4 +74,18 @@ public class RestartAutMessage extends Message {
public void setAutId(AutIdentifier autId) {
m_autId = autId;
}
+
+ /**
+ * @return the forceAUTTermination
+ */
+ public boolean isForceAUTTermination() {
+ return m_forceAUTTermination;
+ }
+
+ /**
+ * @param forceAUTTermination the forceAUTTermination to set
+ */
+ public void setForceAUTTermination(boolean forceAUTTermination) {
+ m_forceAUTTermination = forceAUTTermination;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/commands/PrepareForShutdownCommand.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/commands/PrepareForShutdownCommand.java
index 791c6b7f6..6ebd6ff12 100644
--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/commands/PrepareForShutdownCommand.java
+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/commands/PrepareForShutdownCommand.java
@@ -14,23 +14,120 @@ import org.eclipse.jubula.communication.Communicator;
import org.eclipse.jubula.communication.ICommand;
import org.eclipse.jubula.communication.connection.Connection;
import org.eclipse.jubula.communication.listener.IErrorHandler;
+import org.eclipse.jubula.communication.message.CAPTestResponseMessage;
import org.eclipse.jubula.communication.message.Message;
+import org.eclipse.jubula.communication.message.MessageCap;
import org.eclipse.jubula.communication.message.MessageHeader;
import org.eclipse.jubula.communication.message.PrepareForShutdownMessage;
import org.eclipse.jubula.rc.common.AUTServer;
import org.eclipse.jubula.tools.constants.AUTServerExitConstants;
+import org.eclipse.jubula.tools.exception.CommunicationException;
+import org.eclipse.jubula.tools.objects.ComponentIdentifier;
+import org.eclipse.jubula.tools.utils.EnvironmentUtils;
+import org.eclipse.jubula.tools.utils.TimeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Prepares the AUT Server for shutdown (i.e. deregisters communication
+ * Prepares the AUT and AUT Server for shutdown (i.e. deregisters communication
* error listeners).
- *
+ *
* @author BREDEX GmbH
* @created Mar 23, 2010
*/
public class PrepareForShutdownCommand implements ICommand {
+ /**
+ * Amount of milliseconds to delay the AUTs termination
+ */
+ public static final int AUT_KEEP_ALIVE_DELAY_DEFAULT = 2000;
+
+ /**
+ * Name of the variable to override the AUTs termination delay
+ */
+ public static final String AUT_KEEP_ALIVE_DELAY_VAR = "TEST_AUT_KEEP_ALIVE_DELAY"; //$NON-NLS-1$
+
+ /**
+ * flag to indicate whether this AUTs JVM has already been prepared for a
+ * proper shutdown
+ */
+ private static boolean hasAlreadyBeenPreparedForShutdown = false;
+
+ /**
+ * @author BREDEX GmbH
+ * Shutdown hook runnable to allow a proper AUT termination
+ */
+ private static class AUTProperTerminationShutdownHook implements Runnable {
+ /**
+ * to represent an additional delay to use when keeping the AUT alive
+ */
+ private int m_addDelay;
+
+ /**
+ * @param addDelay the additional delay to use
+ */
+ public AUTProperTerminationShutdownHook(int addDelay) {
+ setAddDelay(addDelay);
+ }
+
+ /** {@inheritDoc} */
+ public void run() {
+ AUTServer autRC = AUTServer.getInstance();
+ // FIXME improve AUT toolkit handling
+ if (!autRC.isRcpAccessible()) {
+ // send fake message back - say last CAP execution went OK
+ // this is necessary as e.g. in Swing the AUT event thread blocks
+ // and thereby our event confirming until the AUT terminates
+ sendFakeCAPTestReponseMessage(autRC);
+ }
+
+ // keep the AUT alive to perform proper AUT termination synchronization
+ long timeToWait = AUT_KEEP_ALIVE_DELAY_DEFAULT;
+ try {
+ String value = EnvironmentUtils
+ .getProcessOrSystemProperty(AUT_KEEP_ALIVE_DELAY_VAR);
+ timeToWait = Long.valueOf(value).longValue();
+ } catch (NumberFormatException e) {
+ // ignore invalid formatted values and use default instead
+ }
+ TimeUtil.delay(timeToWait + getAddDelay());
+ }
+
+ /**
+ * @param autRC
+ * the AUT-Server instance to use
+ */
+ private void sendFakeCAPTestReponseMessage(AUTServer autRC) {
+ Communicator iteCom = autRC.getCommunicator();
+ CAPTestResponseMessage fakeMessage =
+ new CAPTestResponseMessage();
+ MessageCap fakeMessageCap = new MessageCap();
+ fakeMessageCap.setCi(new ComponentIdentifier());
+ fakeMessage.setMessageCap(fakeMessageCap);
+ try {
+ iteCom.send(fakeMessage);
+ } catch (CommunicationException e) {
+ // This might also occur if hook has been registered but
+ // AUT terminates without a connection to the ITE e.g.
+ // normal AUT shutdown
+ LOG.error(e.getLocalizedMessage(), e);
+ }
+ }
+
+ /**
+ * @return the addDelay
+ */
+ public int getAddDelay() {
+ return m_addDelay;
+ }
+
+ /**
+ * @param addDelay the addDelay to set
+ */
+ public void setAddDelay(int addDelay) {
+ m_addDelay = addDelay;
+ }
+ }
/** the logger */
private static final Logger LOG =
@@ -49,27 +146,38 @@ public class PrepareForShutdownCommand implements ICommand {
agentCommunicator.clearListeners();
}
Connection autAgentConnection = agentCommunicator.getConnection();
- if (autAgentConnection != null) {
- // Add a listener to exit the AUT normally when the connection is
- // closed
- autAgentConnection.addErrorHandler(new IErrorHandler() {
-
- public void shutDown() {
- terminate();
- }
-
- public void sendFailed(MessageHeader header, String message) {
- terminate();
- }
-
- private void terminate() {
- try {
- AUTServer.getInstance().shutdown();
- } finally {
- System.exit(AUTServerExitConstants.EXIT_OK);
+ PrepareForShutdownMessage message = m_message;
+ boolean isForce = message.isForce();
+ if (isForce) {
+ if (autAgentConnection != null) {
+ // Add a listener to exit the AUT normally when the connection is
+ // closed
+ autAgentConnection.addErrorHandler(new IErrorHandler() {
+ public void shutDown() {
+ terminate();
}
- }
- });
+ public void sendFailed(MessageHeader header,
+ String message) {
+ terminate();
+ }
+ private void terminate() {
+ try {
+ AUTServer.getInstance().shutdown();
+ } finally {
+ System.exit(AUTServerExitConstants.EXIT_OK);
+ }
+ }
+ });
+ }
+ } else {
+ if (!hasAlreadyBeenPreparedForShutdown) {
+ int addDelay = message.getAdditionalDelay();
+ Runtime.getRuntime().addShutdownHook(
+ new Thread(new AUTProperTerminationShutdownHook(
+ addDelay)));
+ hasAlreadyBeenPreparedForShutdown = true;
+ }
+
}
return null;
}
@@ -94,5 +202,4 @@ public class PrepareForShutdownCommand implements ICommand {
public void timeout() {
LOG.error(this.getClass().getName() + "timeout() called"); //$NON-NLS-1$
}
-
}
diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/WorkaroundUtil.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/WorkaroundUtil.java
index f9130672e..bfc1adeaa 100644
--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/WorkaroundUtil.java
+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/WorkaroundUtil.java
@@ -51,14 +51,9 @@ public class WorkaroundUtil {
* Otherwise <code>false</code>.
*/
public static boolean isIgnoreTimeout() {
- String value =
- EnvironmentUtils.getProcessEnvironment().getProperty(
- IGNORE_TIMEOUT_VAR);
- if (value == null) {
- value = System.getProperty(IGNORE_TIMEOUT_VAR);
- }
-
- return Boolean.valueOf(value).booleanValue();
+ String value = EnvironmentUtils
+ .getProcessOrSystemProperty(IGNORE_TIMEOUT_VAR);
+ return Boolean.valueOf(value).booleanValue();
}
}
diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/common/adapter/SwingAdapterFactory.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/common/adapter/SwingAdapterFactory.java
index 0288a923d..b03f363ae 100644
--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/common/adapter/SwingAdapterFactory.java
+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/common/adapter/SwingAdapterFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.jubula.rc.common.adapter;
+import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@@ -52,12 +53,14 @@ public class SwingAdapterFactory implements IAdapterFactory {
/**
* the supported classes
*/
- private static final Class[] SUPPORTEDCLASSES = new Class[] {
- JButton.class, JCheckBox.class, JRadioButton.class,
- JMenuBar.class, JMenuItem.class, JTree.class ,
- JCheckBox.class, JRadioButton.class, JTable.class, JPopupMenu.class,
- JList.class, JTextComponent.class, JComboBox.class,
- JLabel.class , JTabbedPane.class};
+ private static final Class[] SUPPORTEDCLASSES = new Class[] {
+ AbstractButton.class, JButton.class, JCheckBox.class,
+ JRadioButton.class,
+ JMenuBar.class, JMenuItem.class, JTree.class,
+ JCheckBox.class, JRadioButton.class, JTable.class,
+ JPopupMenu.class,
+ JList.class, JTextComponent.class, JComboBox.class,
+ JLabel.class, JTabbedPane.class };
/** {@inheritDoc} */
public Class[] getSupportedClasses() {
@@ -95,6 +98,9 @@ public class SwingAdapterFactory implements IAdapterFactory {
returnvalue = new JLabelAdapter(objectToAdapt);
} else if (objectToAdapt instanceof JTabbedPane) {
returnvalue = new JTabbedPaneAdapter(objectToAdapt);
+ } else if (objectToAdapt instanceof AbstractButton) {
+ // pick up every button which is not specialized
+ returnvalue = new AbstractButtonAdapter(objectToAdapt);
}
return returnvalue;
diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/SwingAUTServer.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/SwingAUTServer.java
index 3b0be2a50..ddd012a73 100644
--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/SwingAUTServer.java
+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/SwingAUTServer.java
@@ -164,13 +164,8 @@ public class SwingAUTServer extends AUTServer {
protected void startTasks() throws ExceptionInInitializerError,
InvocationTargetException, NoSuchMethodException {
- String edtNameRegEx =
- EnvironmentUtils.getProcessEnvironment()
- .getProperty(EDT_NAME_REGEX_KEY);
- if (edtNameRegEx == null) {
- edtNameRegEx =
- System.getProperty(EDT_NAME_REGEX_KEY);
- }
+ String edtNameRegEx = EnvironmentUtils
+ .getProcessOrSystemProperty(EDT_NAME_REGEX_KEY);
if (edtNameRegEx != null) {
// fail fast if the regex is malformed
try {
diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/components/AUTSwingHierarchy.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/components/AUTSwingHierarchy.java
index 7d1a6cc57..9ea10e317 100644
--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/components/AUTSwingHierarchy.java
+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/components/AUTSwingHierarchy.java
@@ -118,18 +118,11 @@ public class AUTSwingHierarchy extends AUTHierarchy
* Constructor
*/
public AUTSwingHierarchy() {
- String syncListenersRegistrationValue =
- EnvironmentUtils.getProcessEnvironment().getProperty(
- ENV_VAR_SYNC_REGISTER_LISTENERS);
-
- if (syncListenersRegistrationValue == null) {
- // Use JVM property as fallback
- syncListenersRegistrationValue =
- System.getProperty(ENV_VAR_SYNC_REGISTER_LISTENERS);
- }
+ String syncListenersRegistrationValue = EnvironmentUtils
+ .getProcessOrSystemProperty(ENV_VAR_SYNC_REGISTER_LISTENERS);
- m_syncListenerRegistration =
- Boolean.valueOf(syncListenersRegistrationValue).booleanValue();
+ m_syncListenerRegistration = Boolean.valueOf(
+ syncListenersRegistrationValue).booleanValue();
if (!m_syncListenerRegistration) {
Thread registrationThread =
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/constants/CommandConstants.java b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/constants/CommandConstants.java
index de543fe5e..09a94f265 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/constants/CommandConstants.java
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/constants/CommandConstants.java
@@ -222,9 +222,15 @@ public abstract class CommandConstants {
/** AUT Server - prepares for shutdown via Stop AUT */
public static final String PREPARE_FOR_SHUTDOWN_COMMAND = "org.eclipse.jubula.rc.common.commands.PrepareForShutdownCommand"; //$NON-NLS-1$
+
+ /** AUT Server - prepares for shutdown via Stop AUT */
+ public static final String PREPARE_FOR_SHUTDOWN_RESPONSE_COMMAND = "org.eclipse.jubula.autagent.commands.PrepareForShutdownResponseCommand"; //$NON-NLS-1$
/** AUT Server - restarts an AUT */
public static final String RESTART_AUT_COMMAND = "org.eclipse.jubula.autagent.commands.RestartAutCommand"; //$NON-NLS-1$
+
+ /** AUT Server - wait for termination and restart an AUT */
+ public static final String WAIT_FOR_AUT_TERMINATION_AND_RESTART_COMMAND = "org.eclipse.jubula.autagent.commands.WaitForAUTTerminationAndRestartCommand"; //$NON-NLS-1$
/** AUT Agent - display the manual test step to perform */
public static final String DISPLAY_MANUAL_TEST_STEP_COMMAND = "org.eclipse.jubula.autagent.commands.DisplayManualTestStepCommand"; //$NON-NLS-1$
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/EnvironmentUtils.java b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/EnvironmentUtils.java
index 7f880dd4b..4f53a1716 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/EnvironmentUtils.java
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/EnvironmentUtils.java
@@ -317,4 +317,19 @@ public class EnvironmentUtils {
}
return port;
}
+
+ /**
+ * @param key
+ * the key to retrieve the property for
+ * @return if set either the process environment property or if not set the
+ * system environment property. Returns <code>null</code> if non of
+ * both is set
+ */
+ public static String getProcessOrSystemProperty(final String key) {
+ String value = getProcessEnvironment().getProperty(key);
+ if (value == null) {
+ value = System.getProperty(key);
+ }
+ return value;
+ }
}
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/TimeUtil.java b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/TimeUtil.java
index f8ca6072b..3401baf23 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/TimeUtil.java
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/utils/TimeUtil.java
@@ -54,6 +54,29 @@ public abstract class TimeUtil {
}
/**
+ * Delay for a certain amount of time. Uses if set the given keys property
+ * value as a delay
+ *
+ * @param defaultDelay
+ * the delay in ms, must not be negative
+ * @param delayPropertyKey
+ * the property key; can be used to override / allow external
+ * setting of amount of delay
+ */
+ public static void delayDefaultOrExternalTime(final long defaultDelay,
+ final String delayPropertyKey) {
+ long timeToWait = defaultDelay;
+ try {
+ String value = EnvironmentUtils
+ .getProcessOrSystemProperty(delayPropertyKey);
+ timeToWait = Long.valueOf(value).longValue();
+ } catch (NumberFormatException e) {
+ // ignore invalid formatted values and use default instead
+ }
+ TimeUtil.delay(timeToWait);
+ }
+
+ /**
* @param startTime The start time.
* @param endTime The end time.
* @return a String representation of the difference between the provided

Back to the top