Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2012-03-12 11:59:31 -0400
committerMarkus Tiede2012-03-12 11:59:31 -0400
commit05524458dc025484ef6b4287a5325db936bf0d49 (patch)
tree09ae99d1b6e2e8468b1cf69658e2bb0558fbb039 /org.eclipse.jubula.autagent
parentbf0f01556141f48df1216bb6867ac43f688757de (diff)
downloadorg.eclipse.jubula.core-05524458dc025484ef6b4287a5325db936bf0d49.tar.gz
org.eclipse.jubula.core-05524458dc025484ef6b4287a5325db936bf0d49.tar.xz
org.eclipse.jubula.core-05524458dc025484ef6b4287a5325db936bf0d49.zip
Sprint task - fix for issue #2 in bug 373919: if not all necessary information for agent attaching are available no monitoring agent will be attached to the AUT. Nevertheless the AUT should start.
Diffstat (limited to 'org.eclipse.jubula.autagent')
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java53
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartRcpAutServerCommand.java2
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java2
3 files changed, 33 insertions, 24 deletions
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java
index c6ec9c9f8..e269a4d13 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java
@@ -15,6 +15,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -310,18 +311,30 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
}
/**
- * @param parameters The parameters for starting the AUT.
- * @return <code>true</code> if the AUT is being started with a
- * monitoring agent. Otherwise, <code>false</code>.
+ * @param parameters
+ * The parameters for starting the AUT.
+ * @return <code>true</code> if the AUT is supposed to be started with a
+ * monitoring agent and all necessary information are available.
+ * Otherwise <code>false</code>.
*/
- protected boolean isRunningWithMonitoring(Map parameters) {
+ protected boolean shouldAndCanRunWithMonitoring(Map parameters) {
+ List<String> requiredInformation = new ArrayList<String>();
+ requiredInformation.add((String) parameters
+ .get(AutConfigConstants.MONITORING_AGENT_ID));
+ requiredInformation.add((String) parameters
+ .get(AutConfigConstants.AUT_ID));
+
+ requiredInformation.add((String) parameters
+ .get(MonitoringConstants.BUNDLE_ID));
+ requiredInformation.add((String) parameters
+ .get(MonitoringConstants.AGENT_CLASS));
- String monitoringId = (String)parameters.get(
- AutConfigConstants.MONITORING_AGENT_ID);
- if (!StringUtils.isEmpty(monitoringId)) {
- return true;
- }
- return false;
+ for (String required : requiredInformation) {
+ if (StringUtils.isEmpty(required)) {
+ return false;
+ }
+ }
+ return true;
}
/**
@@ -337,7 +350,7 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
// set agent and locals
sb.append(JAVA_OPTIONS_INTRO);
- if (isRunningWithMonitoring(parameters)) {
+ if (shouldAndCanRunWithMonitoring(parameters)) {
sb.append(getMonitoringAgent(parameters))
.append(StringConstants.SPACE);
}
@@ -355,7 +368,7 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
.append(locale.getLanguage());
}
} else {
- if (isRunningWithMonitoring(parameters)) {
+ if (shouldAndCanRunWithMonitoring(parameters)) {
sb.append(JAVA_OPTIONS_INTRO)
.append(getMonitoringAgent(parameters));
}
@@ -390,23 +403,19 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
* or null if the monitoring agent String could't be generated
*/
protected String getMonitoringAgent(Map parameters) {
-
- String monitoringImplClass = (String)parameters.get(
- MonitoringConstants.AGENT_CLASS);
-
String autId = (String)parameters.get(
- AutConfigConstants.AUT_ID);
-
- String bundleId = (String)parameters.get(
- MonitoringConstants.BUNDLE_ID);
-
+ AutConfigConstants.AUT_ID);
MonitoringDataStore mds = MonitoringDataStore.getInstance();
boolean duplicate = MonitoringUtil.checkForDuplicateAutID(autId);
if (!duplicate) {
mds.putConfigMap(autId, parameters);
}
String agentString = null;
- if (isRunningWithMonitoring(parameters)) {
+ if (shouldAndCanRunWithMonitoring(parameters)) {
+ String monitoringImplClass = (String)parameters.get(
+ MonitoringConstants.AGENT_CLASS);
+ String bundleId = (String)parameters.get(
+ MonitoringConstants.BUNDLE_ID);
try {
Bundle bundle = Platform.getBundle(bundleId);
if (bundle == null) {
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartRcpAutServerCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartRcpAutServerCommand.java
index 292aceb3e..b597457c1 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartRcpAutServerCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartRcpAutServerCommand.java
@@ -215,7 +215,7 @@ public class StartRcpAutServerCommand extends AbstractStartJavaAut {
parameters, StartSwtAutServerCommand.ENV_VAR_PREFIX,
StartSwtAutServerCommand.ENV_VALUE_SEP));
- if (isRunningWithMonitoring(parameters)) {
+ if (shouldAndCanRunWithMonitoring(parameters)) {
StringBuffer sb = new StringBuffer();
sb.append(JAVA_OPTIONS_INTRO);
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java
index 7eebed1a6..6fa68aef3 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java
@@ -51,7 +51,7 @@ public class StartSwingAutServerCommand extends AbstractStartJavaAut {
protected String[] createEnvArray(Map parameters, boolean isAgentSet) {
if (isRunningFromExecutable(parameters)
- || isRunningWithMonitoring(parameters)) {
+ || shouldAndCanRunWithMonitoring(parameters)) {
setEnv(parameters);
boolean agentActive = true;
return super.createEnvArray(parameters, agentActive);

Back to the top