Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2013-11-13 09:32:21 -0500
committerMarkus Tiede2013-11-13 09:32:21 -0500
commit9b0c64aacbc86983fbc60959750e88419b516a14 (patch)
tree49b62504e6ce30e987662b374b50e1262c423f62 /org.eclipse.jubula.autagent
parent69d8dd93b84d80e6bf1a90a3e1e069a0b8765456 (diff)
downloadorg.eclipse.jubula.core-9b0c64aacbc86983fbc60959750e88419b516a14.tar.gz
org.eclipse.jubula.core-9b0c64aacbc86983fbc60959750e88419b516a14.tar.xz
org.eclipse.jubula.core-9b0c64aacbc86983fbc60959750e88419b516a14.zip
Sprint task - patch for JavaFX toolkit support reviewed and applied: see http://bugs.eclipse.org/421595 for further information.
Diffstat (limited to 'org.eclipse.jubula.autagent')
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAut.java8
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAutServer.java308
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartJavaFXAutServerCommand.java127
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartSwingAutServerCommand.java284
4 files changed, 451 insertions, 276 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 f8736acf4..ff9599224 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX GmbH.
+ * Copyright (c) 2004, 2010, 2013 BREDEX GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -190,7 +190,7 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
* @param parameters The parameters for starting the AUT.
* @return the main class
*/
- private String getMainClassFromManifest(Map parameters) {
+ protected String getMainClassFromManifest(Map parameters) {
String jarFile = createAbsoluteJarPath(parameters);
return getAttributeFromManifest("main-class", jarFile); //$NON-NLS-1$
}
@@ -201,7 +201,7 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
* @return the String value of the specified attribute name, or null if
* not found.
*/
- private String getAttributeFromManifest(
+ protected String getAttributeFromManifest(
String attributeName, String jarFile) {
if (jarFile == null || jarFile.length() < 1) {
@@ -229,7 +229,7 @@ public abstract class AbstractStartJavaAut extends AbstractStartToolkitAut {
* @param parameters The parameters for starting the AUT.
* @return the absolute path to the AUT jar file or null.
*/
- private String createAbsoluteJarPath(Map parameters) {
+ protected String createAbsoluteJarPath(Map parameters) {
File workingDir = getWorkingDir(parameters);
String jarPath = (String)parameters.get(AutConfigConstants.JAR_FILE);
if (jarPath != null && jarPath.length() > 0) {
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAutServer.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAutServer.java
new file mode 100644
index 000000000..cdebf0e32
--- /dev/null
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/AbstractStartJavaAutServer.java
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.autagent.commands;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.jubula.autagent.AutStarter;
+import org.eclipse.jubula.tools.constants.AutConfigConstants;
+import org.eclipse.jubula.tools.constants.CommandConstants;
+import org.eclipse.jubula.tools.constants.StringConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Upperclass for the JavaFX and SwingStart Server Command classes.
+ * This was created because the AbstractStartJavaAut already has more
+ * than 400 lines of code and it is also extended by StartRcpAutServerCommand.
+ * This class implements all methods that are the same for the
+ * JavaFX and Swing classes.
+ */
+public abstract class AbstractStartJavaAutServer extends AbstractStartJavaAut {
+
+ /** the logger */
+ private static final Logger LOG =
+ LoggerFactory.getLogger(AbstractStartJavaAutServer.class);
+
+ /** separates the environment variables */
+ private static final String ENV_SEPARATOR = "\n"; //$NON-NLS-1$
+
+ /**
+ *
+ * @return the Id of the specific rc bundle
+ */
+ protected abstract String getRcBundleClassPath();
+
+ @Override
+ protected abstract String getServerClassName();
+
+ @Override
+ protected abstract String[] createCmdArray(String baseCmd, Map parameters);
+
+ /**
+ * Sets -javaagent, JRE arguments and the arguments for
+ * the AutServer as environment variables.
+ * @param parameters The parameters for starting the AUT
+ * @param autServerClasspath The classpath of the AUT Server
+ */
+ protected void setEnv(Map parameters, String autServerClasspath) {
+ String env = (String)parameters.get(AutConfigConstants.ENVIRONMENT);
+ if (env == null) {
+ env = StringConstants.EMPTY;
+ } else {
+ env += ENV_SEPARATOR;
+ }
+ env += setJavaOptions(parameters);
+ if (isRunningFromExecutable(parameters)) {
+ // agent arguments
+ String serverPort = "null"; //$NON-NLS-1$
+ if (AutStarter.getInstance().getAutCommunicator() != null) {
+ serverPort = String.valueOf(AutStarter.getInstance()
+ .getAutCommunicator().getLocalPort());
+ }
+
+ env += ENV_SEPARATOR + "AUT_SERVER_PORT=" + serverPort; ////$NON-NLS-1$
+ env += ENV_SEPARATOR + "AUT_SERVER_CLASSPATH=" + autServerClasspath; //$NON-NLS-1$
+ env += ENV_SEPARATOR + "AUT_SERVER_NAME=" + getServerClassName(); //$NON-NLS-1$
+
+ // Aut Agent variables
+ env += ENV_SEPARATOR + AutConfigConstants.AUT_AGENT_HOST + "=" + parameters.get(AutConfigConstants.AUT_AGENT_HOST); //$NON-NLS-1$
+ env += ENV_SEPARATOR + AutConfigConstants.AUT_AGENT_PORT + "=" + parameters.get(AutConfigConstants.AUT_AGENT_PORT); //$NON-NLS-1$
+ env += ENV_SEPARATOR + AutConfigConstants.AUT_NAME + "=" + parameters.get(AutConfigConstants.AUT_NAME); //$NON-NLS-1$
+ }
+ // create environment
+ parameters.put(AutConfigConstants.ENVIRONMENT, env);
+ }
+
+ /**
+ *
+ * @return an array of Strings representing the launch classpath.
+ */
+ public String[] getLaunchClasspath() {
+ StringBuffer autServerClasspath = new StringBuffer();
+ createServerClasspath(autServerClasspath);
+ autServerClasspath.append(PATH_SEPARATOR)
+ .append(getRcBundleClassPath());
+ return autServerClasspath.toString().split(PATH_SEPARATOR);
+ }
+
+ /**
+ * Creates the Server classpath.
+ * @param serverClasspath the server classpath
+ */
+ protected void createServerClasspath(StringBuffer serverClasspath) {
+
+ String [] bundlesToAddToClasspath = {
+ CommandConstants.TOOLS_BUNDLE_ID,
+ CommandConstants.COMMUNICATION_BUNDLE_ID,
+ CommandConstants.RC_COMMON_BUNDLE_ID,
+ CommandConstants.SLF4J_JCL_BUNDLE_ID,
+ CommandConstants.SLF4J_API_BUNDLE_ID,
+ CommandConstants.COMMONS_LANG_BUNDLE_ID,
+ CommandConstants.APACHE_ORO_BUNDLE_ID,
+ CommandConstants.COMMONS_BEAN_UTILS_BUNDLE_ID,
+ CommandConstants.COMMONS_COLLECTIONS_BUNDLE_ID,
+ CommandConstants.LOGBACK_CLASSIC_BUNDLE_ID,
+ CommandConstants.LOGBACK_CORE_BUNDLE_ID,
+ CommandConstants.LOGBACK_SLF4J_BUNDLE_ID
+ };
+
+ for (String bundleId : bundlesToAddToClasspath) {
+ serverClasspath.append(
+ AbstractStartToolkitAut.getClasspathForBundleId(bundleId));
+ serverClasspath.append(PATH_SEPARATOR);
+ }
+
+
+ serverClasspath.append(getAbsExtImplClassesPath());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("serverClasspath" + serverClasspath); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Gets the absolute path of the location of the external ImplClasses.
+ * @return the absolute path
+ */
+ protected String getAbsExtImplClassesPath() {
+
+ final File implDir = new File(CommandConstants.EXT_IMPLCLASSES_PATH);
+ final StringBuffer paths = new StringBuffer(implDir.getAbsolutePath());
+ final File[] jars = implDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar"); //$NON-NLS-1$
+ }
+ });
+
+ if (jars != null) {
+ final int maxIdx = jars.length;
+ for (int i = 0; i < maxIdx; i++) {
+ File f = jars[i];
+ paths.append(PATH_SEPARATOR);
+ paths.append(f.getAbsolutePath());
+ }
+ }
+ return paths.toString();
+ }
+
+ /**
+ * Adds elements to the given cmds List.
+ * @param autServerClasspath the server classpath
+ * @param cmds the 1st part of the cmd array
+ * @param parameters The parameters for starting the AUT.
+ */
+ protected void createAutServerClasspath(StringBuffer autServerClasspath,
+ List cmds, Map parameters) {
+
+ if (AutStarter.getInstance().getAutCommunicator() != null) {
+ cmds.add(String.valueOf(
+ AutStarter.getInstance().getAutCommunicator()
+ .getLocalPort()));
+ } else {
+ cmds.add("null"); //$NON-NLS-1$
+ }
+
+ String autMain = getAUTMainClass(parameters);
+ if (autMain == null) {
+ return;
+ }
+ cmds.add(autMain);
+ autServerClasspath.append(PATH_SEPARATOR)
+ .append(getRcBundleClassPath());
+ cmds.add(autServerClasspath.toString());
+ cmds.add(getServerClassName());
+ }
+
+ /**
+ *
+ * @return the server base path including resources path
+ */
+ protected String createServerBasePath() {
+ return AbstractStartToolkitAut.getClasspathForBundleId(
+ CommandConstants.RC_COMMON_BUNDLE_ID);
+ }
+
+ /**
+ * @param parameters The parameters for starting the AUT.
+ * @return The arguments for the AUT that were found in the
+ * given parameters.
+ */
+ protected List createAutArguments(Map parameters) {
+ List argsList = new Vector();
+ if (parameters.get(AutConfigConstants.AUT_RUN_AUT_ARGUMENTS)
+ instanceof String[]) {
+ String[] autArgs = (String[])parameters
+ .get(AutConfigConstants.AUT_RUN_AUT_ARGUMENTS);
+ return Arrays.asList(autArgs);
+ }
+ String autArguments =
+ (String)parameters.get(AutConfigConstants.AUT_ARGUMENTS);
+
+ if (autArguments == null) {
+ autArguments = StringConstants.EMPTY;
+ }
+
+ StringTokenizer args = new StringTokenizer(autArguments,
+ WHITESPACE_DELIMITER);
+ while (args.hasMoreTokens()) {
+ String arg = args.nextToken();
+ argsList.add(arg);
+ }
+
+ return argsList;
+ }
+
+ /**
+ * @param cmds the commands list
+ * @param autServerClasspath the autServerClassPath to change
+ * @param parameters The parameters for starting the AUT.
+ */
+ protected void createAutServerLauncherClasspath(List cmds,
+ StringBuffer autServerClasspath, Map parameters) {
+
+ addBaseSettings(cmds, parameters);
+ cmds.add("-classpath"); //$NON-NLS-1$
+ StringBuffer autClassPath = createAutClasspath(parameters);
+ String serverBasePath = createServerBasePath();
+ cmds.add(
+ autClassPath.append(PATH_SEPARATOR)
+ .append(serverBasePath).toString());
+ // add classname of autLauncher
+ cmds.add(CommandConstants.AUT_SERVER_LAUNCHER);
+ // add autServerBase dirs to autServerClassPath
+ autServerClasspath.append(PATH_SEPARATOR).append(serverBasePath);
+ }
+
+
+ /** * Creates the AUT settings.
+ * @param cmds the commands list
+ * @param parameters The parameters for starting the AUT.
+ */
+ protected void addBaseSettings(List cmds, Map parameters) {
+ // add locale
+ addLocale(cmds, (Locale)parameters.get(IStartAut.LOCALE));
+
+ // add JRE params
+ final String jreParams = (String)parameters.get(
+ AutConfigConstants.JRE_PARAMETER);
+ if (jreParams != null && jreParams.length() > 0) {
+ StringTokenizer tok = new StringTokenizer(jreParams,
+ WHITESPACE_DELIMITER);
+ while (tok.hasMoreTokens()) {
+ cmds.add(tok.nextToken());
+ }
+ }
+
+ // add debug options (if neccessary)
+ addDebugParams(cmds, false);
+ // add -Duser.dir and workingDir here
+ }
+
+
+ /**
+ * Creates the AUT classpath.
+ * @param parameters The parameters for starting the AUT.
+ * @return The classpath of the AUT.
+ */
+ protected StringBuffer createAutClasspath(Map parameters) {
+ // Add AUT classpath
+ String autClassPathStr = (String)parameters.get(
+ AutConfigConstants.CLASSPATH);
+ if (autClassPathStr == null) {
+ autClassPathStr = StringConstants.EMPTY;
+ }
+ StringBuffer autClassPath = new StringBuffer(
+ convertClientSeparator(autClassPathStr));
+ if (autClassPath.length() > 0) {
+ autClassPath.append(PATH_SEPARATOR);
+ }
+ String jarFile = (String)parameters.get(AutConfigConstants.JAR_FILE);
+ if (jarFile == null) {
+ jarFile = StringConstants.EMPTY;
+ }
+ String manifestClassPath = getClassPathFromManifest(parameters);
+ if (manifestClassPath.length() > 0) {
+ autClassPath.append(manifestClassPath).append(PATH_SEPARATOR);
+ }
+ autClassPath.append(jarFile);
+ if (jarFile != null && jarFile.length() > 0) {
+ autClassPath.append(PATH_SEPARATOR);
+ }
+ return autClassPath;
+ }
+}
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartJavaFXAutServerCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartJavaFXAutServerCommand.java
new file mode 100644
index 000000000..24fb41d93
--- /dev/null
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StartJavaFXAutServerCommand.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.autagent.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.jubula.tools.constants.AutConfigConstants;
+import org.eclipse.jubula.tools.constants.CommandConstants;
+import org.eclipse.jubula.tools.utils.MonitoringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author BREDEX GmbH
+ * @created September 25, 2013
+ *
+ */
+public class StartJavaFXAutServerCommand extends AbstractStartJavaAutServer {
+
+ /** the logger */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(StartJavaFXAutServerCommand.class);
+
+ /** separates the environment variables */
+ private static final String ENV_SEPARATOR = "\n"; //$NON-NLS-1$
+
+ /** the classpath of the Aut Server */
+ private String m_autServerClasspath = "AutServerClasspath"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String[] createCmdArray(String baseCmd, Map parameters) {
+ List cmds = new Vector();
+ cmds.add(baseCmd);
+
+ StringBuffer autServerClasspath = new StringBuffer();
+ createServerClasspath(autServerClasspath);
+
+ List autAgentArgs = new ArrayList();
+ autAgentArgs.add(String.valueOf(parameters
+ .get(AutConfigConstants.AUT_AGENT_HOST)));
+ autAgentArgs.add(String.valueOf(parameters
+ .get(AutConfigConstants.AUT_AGENT_PORT)));
+ autAgentArgs.add(String.valueOf(parameters
+ .get(AutConfigConstants.AUT_NAME)));
+
+ if (!isRunningFromExecutable(parameters)) {
+ createAutServerLauncherClasspath(cmds, autServerClasspath,
+ parameters);
+ createAutServerClasspath(autServerClasspath, cmds, parameters);
+ cmds.addAll(autAgentArgs);
+ // information for aut server that agent is not used
+ cmds.add(CommandConstants.RC_COMMON_AGENT_INACTIVE);
+ } else {
+ String serverBasePath = createServerBasePath();
+ autServerClasspath.append(PATH_SEPARATOR).append(serverBasePath)
+ .append(PATH_SEPARATOR).append(getRcBundleClassPath());
+ m_autServerClasspath = autServerClasspath.toString();
+
+ }
+ cmds.addAll(createAutArguments(parameters));
+ return (String[]) cmds.toArray(new String[cmds.size()]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String getServerClassName() {
+ return CommandConstants.AUT_JAVAFX_SERVER;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ protected String getRcBundleId() {
+ return CommandConstants.RC_JAVAFX_BUNDLE_ID;
+ }
+
+ @Override
+ protected String[] createEnvArray(Map parameters, boolean isAgentSet) {
+
+ if (isRunningFromExecutable(parameters)
+ || MonitoringUtil.shouldAndCanRunWithMonitoring(parameters)) {
+ setEnv(parameters, m_autServerClasspath);
+ boolean agentActive = true;
+ return super.createEnvArray(parameters, agentActive);
+ }
+
+ return super.createEnvArray(parameters, isAgentSet);
+
+ }
+
+
+ /**
+ *
+ * @return the class path corresponding to the receiver's RC bundle.
+ */
+ protected String getRcBundleClassPath() {
+ return AbstractStartToolkitAut.getClasspathForBundleId(getRcBundleId());
+ }
+
+ @Override
+ protected String getMainClassFromManifest(Map parameters) {
+ String jarFile = createAbsoluteJarPath(parameters);
+ String attr = getAttributeFromManifest("main-class", jarFile); //$NON-NLS-1$
+ /*
+ * Replacing "/" with "." because, in the Manifest file of an
+ * Application that was build with JavaFX-Ant-Tasks, the path to the
+ * JavaFX loader class has slashes but for the Classloader we need the
+ * qualified class name with dots.
+ */
+ return attr.replace("/", "."); //$NON-NLS-1$//$NON-NLS-2$
+ }
+}
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 32f774bea..433ccc8dd 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX GmbH.
+ * Copyright (c) 2004, 2010, 2013 BREDEX GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,20 +10,13 @@
*******************************************************************************/
package org.eclipse.jubula.autagent.commands;
-import java.io.File;
-import java.io.FilenameFilter;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
-import java.util.StringTokenizer;
import java.util.Vector;
-import org.eclipse.jubula.autagent.AutStarter;
import org.eclipse.jubula.tools.constants.AutConfigConstants;
import org.eclipse.jubula.tools.constants.CommandConstants;
-import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.utils.MonitoringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,71 +27,18 @@ import org.slf4j.LoggerFactory;
* @created Jul 6, 2007
*
*/
-public class StartSwingAutServerCommand extends AbstractStartJavaAut {
+public class StartSwingAutServerCommand extends AbstractStartJavaAutServer {
/** the logger */
private static final Logger LOG =
LoggerFactory.getLogger(StartSwingAutServerCommand.class);
- /** separates the environment variables */
- private static final String ENV_SEPARATOR = "\n"; //$NON-NLS-1$
-
/** the classpath of the Aut Server */
private String m_autServerClasspath = "AutServerClasspath"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
- protected String[] createEnvArray(Map parameters, boolean isAgentSet) {
-
- if (isRunningFromExecutable(parameters)
- || MonitoringUtil.shouldAndCanRunWithMonitoring(parameters)) {
- setEnv(parameters);
- boolean agentActive = true;
- return super.createEnvArray(parameters, agentActive);
- }
-
- return super.createEnvArray(parameters, isAgentSet);
-
- }
-
- /**
- * Sets -javaagent, JRE arguments and the arguments for
- * the AutServer as environment variables.
- * @param parameters The parameters for starting the AUT
- */
- private void setEnv(Map parameters) {
- String env = (String)parameters.get(AutConfigConstants.ENVIRONMENT);
- if (env == null) {
- env = StringConstants.EMPTY;
- } else {
- env += ENV_SEPARATOR;
- }
- env += setJavaOptions(parameters);
- if (isRunningFromExecutable(parameters)) {
- // agent arguments
- String serverPort = "null"; //$NON-NLS-1$
- if (AutStarter.getInstance().getAutCommunicator() != null) {
- serverPort = String.valueOf(AutStarter.getInstance()
- .getAutCommunicator().getLocalPort());
- }
-
- env += ENV_SEPARATOR + "AUT_SERVER_PORT=" + serverPort; ////$NON-NLS-1$
- env += ENV_SEPARATOR + "AUT_SERVER_CLASSPATH=" + m_autServerClasspath; //$NON-NLS-1$
- env += ENV_SEPARATOR + "AUT_SERVER_NAME=" + getServerClassName(); //$NON-NLS-1$
-
- // Aut Agent variables
- env += ENV_SEPARATOR + AutConfigConstants.AUT_AGENT_HOST + "=" + parameters.get(AutConfigConstants.AUT_AGENT_HOST); //$NON-NLS-1$
- env += ENV_SEPARATOR + AutConfigConstants.AUT_AGENT_PORT + "=" + parameters.get(AutConfigConstants.AUT_AGENT_PORT); //$NON-NLS-1$
- env += ENV_SEPARATOR + AutConfigConstants.AUT_NAME + "=" + parameters.get(AutConfigConstants.AUT_NAME); //$NON-NLS-1$
- }
- // create environment
- parameters.put(AutConfigConstants.ENVIRONMENT, env);
- }
-
- /**
- * {@inheritDoc}
- */
protected String[] createCmdArray(String baseCmd, Map parameters) {
List cmds = new Vector();
cmds.add(baseCmd);
@@ -132,164 +72,19 @@ public class StartSwingAutServerCommand extends AbstractStartJavaAut {
cmds.addAll(createAutArguments(parameters));
return (String[])cmds.toArray(new String[cmds.size()]);
}
-
- /**
- *
- * @return an array of Strings representing the launch classpath.
- */
- public String[] getLaunchClasspath() {
- StringBuffer autServerClasspath = new StringBuffer();
- createServerClasspath(autServerClasspath);
- autServerClasspath.append(PATH_SEPARATOR)
- .append(getRcBundleClassPath());
- return autServerClasspath.toString().split(PATH_SEPARATOR);
- }
-
- /** * Creates the AUT settings.
- * @param cmds the commands list
- * @param parameters The parameters for starting the AUT.
- */
- private void addBaseSettings(List cmds, Map parameters) {
- // add locale
- addLocale(cmds, (Locale)parameters.get(IStartAut.LOCALE));
-
- // add JRE params
- final String jreParams = (String)parameters.get(
- AutConfigConstants.JRE_PARAMETER);
- if (jreParams != null && jreParams.length() > 0) {
- StringTokenizer tok = new StringTokenizer(jreParams,
- WHITESPACE_DELIMITER);
- while (tok.hasMoreTokens()) {
- cmds.add(tok.nextToken());
- }
- }
-
- // add debug options (if neccessary)
- addDebugParams(cmds, false);
- // add -Duser.dir and workingDir here
- }
- /**
- * Creates the Server classpath.
- * @param serverClasspath the server classpath
- */
- private void createServerClasspath(StringBuffer serverClasspath) {
- String [] bundlesToAddToClasspath = {
- CommandConstants.TOOLS_BUNDLE_ID,
- CommandConstants.COMMUNICATION_BUNDLE_ID,
- CommandConstants.RC_COMMON_BUNDLE_ID,
- CommandConstants.SLF4J_JCL_BUNDLE_ID,
- CommandConstants.SLF4J_API_BUNDLE_ID,
- CommandConstants.COMMONS_LANG_BUNDLE_ID,
- CommandConstants.APACHE_ORO_BUNDLE_ID,
- CommandConstants.COMMONS_BEAN_UTILS_BUNDLE_ID,
- CommandConstants.COMMONS_COLLECTIONS_BUNDLE_ID,
- CommandConstants.LOGBACK_CLASSIC_BUNDLE_ID,
- CommandConstants.LOGBACK_CORE_BUNDLE_ID,
- CommandConstants.LOGBACK_SLF4J_BUNDLE_ID
- };
-
- for (String bundleId : bundlesToAddToClasspath) {
- serverClasspath.append(
- AbstractStartToolkitAut.getClasspathForBundleId(bundleId));
- serverClasspath.append(PATH_SEPARATOR);
- }
-
-
- serverClasspath.append(getAbsExtImplClassesPath());
- if (LOG.isDebugEnabled()) {
- LOG.debug("serverClasspath" + serverClasspath); //$NON-NLS-1$
- }
- }
-
- /**
- * @param cmds the commands list
- * @param autServerClasspath the autServerClassPath to change
- * @param parameters The parameters for starting the AUT.
- */
- private void createAutServerLauncherClasspath(List cmds,
- StringBuffer autServerClasspath, Map parameters) {
-
- addBaseSettings(cmds, parameters);
- cmds.add("-classpath"); //$NON-NLS-1$
- StringBuffer autClassPath = createAutClasspath(parameters);
- String serverBasePath = createServerBasePath();
- cmds.add(
- autClassPath.append(PATH_SEPARATOR)
- .append(serverBasePath).toString());
- // add classname of autLauncher
- cmds.add(CommandConstants.AUT_SERVER_LAUNCHER);
- // add autServerBase dirs to autServerClassPath
- autServerClasspath.append(PATH_SEPARATOR).append(serverBasePath);
- }
-
- /**
- * Creates the AUT classpath.
- * @param parameters The parameters for starting the AUT.
- * @return The classpath of the AUT.
- */
- private StringBuffer createAutClasspath(Map parameters) {
- // Add AUT classpath
- String autClassPathStr = (String)parameters.get(
- AutConfigConstants.CLASSPATH);
- if (autClassPathStr == null) {
- autClassPathStr = StringConstants.EMPTY;
- }
- StringBuffer autClassPath = new StringBuffer(
- convertClientSeparator(autClassPathStr));
- if (autClassPath.length() > 0) {
- autClassPath.append(PATH_SEPARATOR);
- }
- String jarFile = (String)parameters.get(AutConfigConstants.JAR_FILE);
- if (jarFile == null) {
- jarFile = StringConstants.EMPTY;
- }
- String manifestClassPath = getClassPathFromManifest(parameters);
- if (manifestClassPath.length() > 0) {
- autClassPath.append(manifestClassPath).append(PATH_SEPARATOR);
- }
- autClassPath.append(jarFile);
- if (jarFile != null && jarFile.length() > 0) {
- autClassPath.append(PATH_SEPARATOR);
- }
- return autClassPath;
- }
-
- /**
- *
- * @return the server base path including resources path
- */
- private String createServerBasePath() {
- return AbstractStartToolkitAut.getClasspathForBundleId(
- CommandConstants.RC_COMMON_BUNDLE_ID);
- }
-
- /**
- * Adds elements to the given cmds List.
- * @param autServerClasspath the server classpath
- * @param cmds the 1st part of the cmd array
- * @param parameters The parameters for starting the AUT.
- */
- private void createAutServerClasspath(StringBuffer autServerClasspath,
- List cmds, Map parameters) {
+ @Override
+ protected String[] createEnvArray(Map parameters, boolean isAgentSet) {
- if (AutStarter.getInstance().getAutCommunicator() != null) {
- cmds.add(String.valueOf(
- AutStarter.getInstance().getAutCommunicator()
- .getLocalPort()));
- } else {
- cmds.add("null"); //$NON-NLS-1$
- }
+ if (isRunningFromExecutable(parameters)
+ || MonitoringUtil.shouldAndCanRunWithMonitoring(parameters)) {
+ setEnv(parameters, m_autServerClasspath);
+ boolean agentActive = true;
+ return super.createEnvArray(parameters, agentActive);
+ }
+
+ return super.createEnvArray(parameters, isAgentSet);
- String autMain = getAUTMainClass(parameters);
- if (autMain == null) {
- return;
- }
- cmds.add(autMain);
- autServerClasspath.append(PATH_SEPARATOR)
- .append(getRcBundleClassPath());
- cmds.add(autServerClasspath.toString());
- cmds.add(getServerClassName());
}
/**
@@ -309,61 +104,6 @@ public class StartSwingAutServerCommand extends AbstractStartJavaAut {
}
/**
- * @param parameters The parameters for starting the AUT.
- * @return The arguments for the AUT that were found in the
- * given parameters.
- */
- private List createAutArguments(Map parameters) {
- List argsList = new Vector();
- if (parameters.get(AutConfigConstants.AUT_RUN_AUT_ARGUMENTS)
- instanceof String[]) {
- String[] autArgs = (String[])parameters
- .get(AutConfigConstants.AUT_RUN_AUT_ARGUMENTS);
- return Arrays.asList(autArgs);
- }
- String autArguments =
- (String)parameters.get(AutConfigConstants.AUT_ARGUMENTS);
-
- if (autArguments == null) {
- autArguments = StringConstants.EMPTY;
- }
-
- StringTokenizer args = new StringTokenizer(autArguments,
- WHITESPACE_DELIMITER);
- while (args.hasMoreTokens()) {
- String arg = args.nextToken();
- argsList.add(arg);
- }
-
- return argsList;
- }
-
- /**
- * Gets the absolute path of the location of the external ImplClasses.
- * @return the absolute path
- */
- private String getAbsExtImplClassesPath() {
-
- final File implDir = new File(CommandConstants.EXT_IMPLCLASSES_PATH);
- final StringBuffer paths = new StringBuffer(implDir.getAbsolutePath());
- final File[] jars = implDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar"); //$NON-NLS-1$
- }
- });
-
- if (jars != null) {
- final int maxIdx = jars.length;
- for (int i = 0; i < maxIdx; i++) {
- File f = jars[i];
- paths.append(PATH_SEPARATOR);
- paths.append(f.getAbsolutePath());
- }
- }
- return paths.toString();
- }
-
- /**
* Gets the absolute path of the RCAgent.jar file.
* @return the absolute path
*/

Back to the top