Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2013-05-15 08:47:00 +0000
committerMarkus Tiede2013-05-15 08:47:00 +0000
commit7b257fc0a645220a64a8dba6a351b728ccec0932 (patch)
treeffd6ea8941db69adbaf34622c66a22e4ac2b29d3
parent5dfc89c8b75acfabc520721bfa06e37e105e9011 (diff)
downloadorg.eclipse.jubula.core-7b257fc0a645220a64a8dba6a351b728ccec0932.tar.gz
org.eclipse.jubula.core-7b257fc0a645220a64a8dba6a351b728ccec0932.tar.xz
org.eclipse.jubula.core-7b257fc0a645220a64a8dba6a351b728ccec0932.zip
Minor refactoring - add utility method to retrieve external properties: either set in the process env or as a JVM property.
-rw-r--r--org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java7
-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/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/utils/EnvironmentUtils.java15
5 files changed, 26 insertions, 31 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..0ca22eb1c 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
@@ -625,11 +625,8 @@ public class ExecutionController implements IAUTServerEventListener,
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);
- }
+ String value = EnvironmentUtils
+ .getProcessOrSystemProperty(AUT_STARTUP_DELAY_VAR);
timeToWait = Integer.valueOf(value).intValue();
} catch (NumberFormatException e) {
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/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/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;
+ }
}

Back to the top