You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/08/12 17:23:08 UTC
svn commit: r232310 [70/92] - in /beehive/trunk/controls/test: common/
infra/gtlf/ infra/gtlf/xsl/ infra/mantis/ infra/tch/ infra/tch/messages/
infra/tch/runtime/ infra/tch/schema/ perf/ perf/bin/ perf/cases/
perf/ctlsrc/org/apache/beehive/controls/per...
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerExecTask.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerExecTask.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerExecTask.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerExecTask.java Fri Aug 12 08:12:28 2005
@@ -1,518 +1,518 @@
-package org.apache.beehive.test.tools.tch.extension.exectask.wstest;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.apache.beehive.test.tools.tch.compose.Parameters;
-import org.apache.beehive.test.tools.tch.core.AbstractExecutionTask;
-import org.apache.beehive.test.tools.tch.core.AntProperties;
-import org.apache.beehive.test.tools.tch.core.ExecutionTaskValidationException;
-import org.apache.beehive.test.tools.tch.core.ParamContainer;
-import org.apache.beehive.test.tools.tch.core.ProcessEngineContainer;
-import org.apache.beehive.test.tools.tch.core.process.ProcessEngine;
-import org.apache.beehive.test.tools.tch.core.test.AbstractTestLogicTask;
-import org.apache.beehive.test.tools.tch.core.test.BasicInternalParameters;
-import org.apache.beehive.test.tools.tch.core.test.InternalParameters;
-import org.apache.beehive.test.tools.tch.core.test.ResultHandler;
-import org.apache.beehive.test.tools.tch.core.test.TestLogicTask;
-import org.apache.beehive.test.tools.tch.task.TaskContext;
-import org.apache.beehive.test.tools.tch.util.TestResultAdapter;
-
-import org.apache.beehive.test.tools.tch.compose.InvalidTestClassException;
-import org.apache.beehive.test.tools.tch.compose.internal.TestNode;
-import org.apache.beehive.test.tools.tch.compose.internal.context.AtomicTestContext;
-import org.apache.beehive.test.tools.tch.core.PropertyNames;
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-
-import org.apache.beehive.test.tools.tch.extension.exectask.common.TestClassInfoResultHandler;
-import org.apache.beehive.test.tools.tch.extension.exectask.common.ResultHelper;
-
-/**
- */
-public class WebServerExecTask extends AbstractExecutionTask
-{
-
- private TestLogicTask wsTestLogicTask = null;
-
- private static final Collection ALL_METHODS = null;
- // yes, on purpose this is null
-
- private String testClassName = null;
- private String methodNamesAttribute = null;
- private boolean verbose = AntProperties.isWsTestVerbose();
-
- //list of web servers
- private ArrayList wsList = new ArrayList();
-
- // attribute setters
- public void setTestClass(String in)
- {
- testClassName = handleValue(in);
- }
-
- public void setMethodNames(String in)
- {
- methodNamesAttribute = handleValue(in);
- }
-
- /* !!! replaced with test-parameter
- public void setWebServers(String in)
- {
- webServers = handleValue(in);
- }
-
- public void setWebServersToExclude(String in)
- {
- webServersToExclude = handleValue(in);
- }
- */
-
- /**
- * The default web server list is retrieved from the webServerSettings.xml file
- * as the list of all enabled web servers. A test can provide a specific list
- * of web servers with the 'webservers' attribute: however only the enabled web
- * servers within that list will execute. A test can also specify a list of web
- * servers to exclude with the 'webServersToExclude' parameter.
- *
- * Note: accept 'webserver' invalid values 'nows' (no web server) for a test without
- * a web server or load balancer. Such a test should probably not be written as
- * a wstest.
- */
- public ArrayList getWebServerList()
- {
- //1. get the list of enabled web servers
- ArrayList webServerList = null;
- try
- {
- webServerList = WSTestSettingsXMLReader.getInstance().getWebServerList();
- // if (verbose)
- // debugListDump(webServerList, "initList");
- }
- catch (Exception e)
- {
- System.out.println("exception thrown accessing WSTestSettings.xml");
- System.out.println(e.getMessage());
- e.printStackTrace();
- webServerList = new ArrayList();
- }
-
- if (webServerList.size() == 0)
- return webServerList; //no tests to run
-
- InternalParameters inparams = getInternalParameters();
- Properties props = inparams.getProperties();
-
- //Reduce the list of enabled web servers to those specified
- //in webservers (else use all enabled web servers).
- String webServers = props.getProperty("webservers");
- //2. check for specific web servers list for this test
- if (webServers != null)
- {
- ArrayList list = tokenizeList(webServers, ",");
- // if (verbose)
- // debugListDump(list, "specific ws list");
-
- //remove from webServerList any entry not in list
- ArrayList newWebServerList = new ArrayList();
- for (int i = 0; i < webServerList.size(); i++)
- {
- String wsName = (String)webServerList.get(i);
- if (list.contains(wsName))
- newWebServerList.add(wsName);
- }
- webServerList = newWebServerList;
- }
-
- if (webServerList.size() == 0) //no tests to run
- return webServerList;
-
- //Any web server in the webserverstoexclude list is removed from
- //the list of enabled web servers.
- String webServersToExclude = props.getProperty("webserverstoexclude");
- if (webServersToExclude != null)
- {
- ArrayList list = tokenizeList(webServersToExclude, ",");
- // if (verbose)
- // debugListDump(list, "exclude ws list");
-
- //remove from webServerList any entry in list
- ArrayList newWebServerList = new ArrayList();
- for (int i = 0; i < webServerList.size(); i++)
- {
- String wsName = (String)webServerList.get(i);
- if (!list.contains(wsName))
- newWebServerList.add(wsName);
- }
- webServerList = newWebServerList;
- }
-
- if (webServerList.size() == 0) //no tests to run
- return webServerList;
-
- //When a test file is included with a currentwebservers argument,
- //the webservers list is reduced to the values in common.
- String currentWebServers = props.getProperty("currentwebservers");
- if (currentWebServers != null)
- {
- ArrayList list = tokenizeList(currentWebServers, ",");
- // if (verbose)
- // debugListDump(list, "current ws list");
-
- //reduce list to currentWebServers and webServerList common values
- ArrayList newWebServerList = new ArrayList();
- for (int i = 0; i < webServerList.size(); i++)
- {
- String wsName = (String)webServerList.get(i);
- if (list.contains(wsName))
- newWebServerList.add(wsName);
- }
- webServerList = newWebServerList;
- }
-
- // if (webServerList.size()==0) //no tests to run
- // return webServerList;
-
- // if (verbose)
- // debugListDump(webServerList, "finalList");
- return webServerList;
- }
-
- // private void debugListDump(ArrayList list, String name) {
- // System.out.println("List"+ name +".size() is " + list.size());
- // for (int i=0; i<list.size(); i++)
- // System.out.println("List" + name +"("+i+")= " + list.get(i));
- // }
-
- private ArrayList tokenizeList(String param, String token)
- {
- ArrayList list = new ArrayList();
- if (param == null)
- return list;
-
- StringTokenizer st = new StringTokenizer(param, token);
- while (st.hasMoreTokens())
- {
- String next = (String)st.nextElement();
- next = next.trim();
- if (next.length() > 0)
- list.add(next);
- }
-
- return list;
- }
-
- //called at start of process
- public void validate() throws ExecutionTaskValidationException
- {
- // if (getSubtestsConfiguredToRun()!=null) //tests specified on the command line
- // parseReRunList();
-
- wsList = getWebServerList();
- //do not cancel test run just because one of the tests do not apply
- //if (wsList.isEmpty())
- // throw new ExecutionTaskValidationException("no web servers enabled");
-
- try
- {
- TestNode n = getLocalTestNode();
- }
- catch (Throwable th) // really want to catch *everything* here
- {
- throw new ExecutionTaskValidationException(
- th,
- "WebServerTask had a problem initializing");
- }
-
- }
-
- //called after validate
- //determines the number of tests to run
- private Collection getTestMethodNamesAsCollection()
- {
-
- Collection c = new ArrayList();
- if (methodNamesAttribute != null)
- {
- TchUtils.parseStringToStrings(
- methodNamesAttribute,
- PropertyNames.DELIMITER,
- c);
- }
- else //methodNamesAttribute==null => all methods
- {
- try
- {
- c = getLocalTestNode(ALL_METHODS).getTestMethods();
- }
- catch (InvalidTestClassException ex)
- {
- return new ArrayList();
- //will not happen here: this exception is thrown during validation
- }
- }
- return c;
- }
-
- private TestNode getLocalTestNode()
- {
- if (methodNamesAttribute != null)
- return getLocalTestNode(getTestMethodNamesAsCollection());
- else
- return getLocalTestNode(ALL_METHODS);
- }
-
- private TestNode getLocalTestNode(Collection methods)
- {
- TestNode n = new AtomicTestContext(testClassName, getParameters(), methods);
- n.setResultHandler(
- new TestClassInfoResultHandler(getResultHandler(), testClassName));
-
- return n;
- }
-
- // if particular method names are set in xml, we'll only run those
- // else we'll run all
- public Collection getAllSubtestNames()
- {
- Collection cTestNames = getTestMethodNamesAsCollection();
- if (cTestNames == null || cTestNames.size() == 0)
- return new ArrayList(); //no tests to run
-
- if (wsList.isEmpty())
- return new ArrayList(); //no tests to run
-
- //build collection as (method name list)x(web server list)
- Collection cWithSuffix = new ArrayList();
- for (Iterator iter = cTestNames.iterator(); iter.hasNext();)
- {
- String mName = (String)iter.next();
- for (int j = 0; j < wsList.size(); j++)
- {
- cWithSuffix.add(mName + "-" + (String)wsList.get(j));
- }
- }
-
- return cWithSuffix;
- }
-
- /* unknown API: do not know how to access the parameters required.
- also do not know if available in parallel runs.
- parsing "replicated-failover.wApacheSingleServerDeathTest-rep.testPrimaryServerDeath-apache20"
- private void parseReRunList() {
- String methodWithWS = getTestTask().getName();
- System.out.println("methodWithWS " + methodWithWS);
- StringTokenizer st = new StringTokenizer(methodWithWS, "-");
- String next=null;
- while (st.hasMoreTokens())
- next=st.nextToken();
- webServers=next;
- System.out.println("methodNamesAttribute " + methodNamesAttribute);
- System.out.println("webServers " + webServers);
- }
- */
-
- public TestLogicTask getTestLogicTask()
- {
- // if (getSubtestsConfiguredToRun()!=null) //tests specified on the command line
- // parseReRunList();
-
- TestLogicTask wsTestLogicTask =
- new WebServerTestLogicTask(
- getWebServerList(),
- getTestMethodNamesAsCollection(),
- getResultHandler());
- return wsTestLogicTask;
- }
-
- public class WebServerTestLogicTask
- extends AbstractTestLogicTask
- implements ProcessEngineContainer
- {
- private boolean timedOut = false;
- private ArrayList _wsList = null;
- private Collection _methodNames = null;
-
- public WebServerTestLogicTask(
- ArrayList wsList,
- Collection methodNames,
- ResultHandler inResultHandler)
- {
- super("WebServerTestLogicTask", inResultHandler);
- _wsList = wsList;
- _methodNames = methodNames;
- }
-
- public TaskContext run(TaskContext in)
- {
- // if (verbose) {
- // ResultHelper.submitDebug(getResultHandler(), "running ...");
- // ResultHelper.submitDebug(getResultHandler(), "_wsList.size() is " + _wsList.size());
- // }
-
- ArrayList aTestMethod = new ArrayList();
- ArrayList testThreadList = new ArrayList();
-
- for (int i = 0; i < _wsList.size(); i++)
- {
- String webServerName = (String)_wsList.get(i);
- // if (verbose)
- // ResultHelper.submitDebug(getResultHandler(),"webServerName is " + webServerName);
- for (Iterator iter = _methodNames.iterator(); iter.hasNext();)
- {
- if (timedOut)
- return null;
-
- String methodToRun = (String)iter.next();
- // if (verbose)
- // ResultHelper.submitDebug(getResultHandler(),"running " + methodToRun);
- aTestMethod.clear();
- aTestMethod.add(methodToRun);
-
- //settings added to internal parameters are:
- // webServerName
- // testName
- // methodToRun
- // host (default)
- // all WSTestSettings.xml webserver entries (port no. ...etc.)
- // verbose
-
- BasicInternalParameters myParams = new BasicInternalParameters();
- //copy in current params
- InternalParameters inparams = getInternalParameters();
- Properties currentProps = inparams.getProperties();
- for (Enumeration e = currentProps.propertyNames();
- e.hasMoreElements();
- )
- {
- String key = (String)e.nextElement();
- if (key != null && currentProps.getProperty(key) != null)
- myParams.setParam(key, currentProps.getProperty(key));
- }
-
- //add web server name to parameters
- if (webServerName == null)
- webServerName = "nows";
- myParams.setParam("webServerName", webServerName);
- //set test name
- myParams.setParam(
- "testName",
- getTestTask().getName() + "-" + methodToRun + "-" + webServerName);
- if (methodToRun != null)
- myParams.setParam("methodToRun", methodToRun);
- //get current properties & add default properties only if
- //not already set (with entry in text xml)
- Properties props = myParams.getProperties();
- if (props.getProperty("host") == null
- && AntProperties.getWsTestHost() != null)
- myParams.setParam("host", AntProperties.getWsTestHost());
- if (props.getProperty("builddir") == null
- && AntProperties.getWsTestBuildDir() != null)
- myParams.setParam("builddir", AntProperties.getWsTestBuildDir());
- if (props.getProperty("installdir") == null
- && AntProperties.getWsTestInstallDir() != null)
- myParams.setParam(
- "installdir",
- AntProperties.getWsTestInstallDir());
-
- //add settings from WSTestSettings.xml except
- try
- {
- //add web server settings
- HashMap map =
- WSTestSettingsXMLReader.getInstance().getWebServerSettings(
- webServerName);
- if (map != null)
- {
- Iterator keyIter = map.keySet().iterator();
- while (keyIter.hasNext())
- {
- String key = (String)keyIter.next();
- if (key != null && map.get(key) != null)
- myParams.setParam(key, (String)map.get(key));
- //port settings & any additional web server specific settings
- }
- }
-
- //add defaults if the value is not already set by the test
- HashMap dmap = WSTestSettingsXMLReader.getInstance().getDefaults();
- Iterator dkeyIter = dmap.keySet().iterator();
- while (dkeyIter.hasNext())
- {
- String key = (String)dkeyIter.next();
- if (key != null && dmap.get(key) != null)
- {
- if (myParams.lookup(key) == null) //if the property is not set
- myParams.setParam(key, (String)dmap.get(key));
- //then set to default
- }
- }
-
- }
- catch (Exception e)
- {
- ResultHelper.submitDebug(
- getResultHandler(),
- "exception thrown accessing WSTestSettings.xml");
- ResultHelper.submitDebug(getResultHandler(), e.getMessage());
- e.printStackTrace();
- }
-
- //debug on setting overrides test settings
- if (AntProperties.isWsTestVerbose())
- myParams.setParam("verbose", "true");
-
- WSTestContext test =
- new WSTestContext(testClassName, myParams, aTestMethod);
- test.setResultHandler(
- new WebServerResultHandler(
- getResultHandler(),
- testClassName,
- webServerName));
- test.setProcessEngine(WebServerExecTask.this.getProcessEngine());
- Thread testThread = new Thread(test);
- testThread.start();
- testThreadList.add(testThread);
- // if (verbose)
- // ResultHelper.submitDebug(getResultHandler(),"launched " + methodToRun);
- }
- }
-
- //wait for each test to complete (required?)
- for (int i = 0; i < testThreadList.size(); i++)
- {
- Thread testThread = (Thread)testThreadList.get(i);
- try
- {
- testThread.join(); //wait for test to complete
- }
- catch (Exception e)
- {
- ResultHelper.submitDebug(
- getResultHandler(),
- "join exception thrown " + e.getMessage());
- }
- // if (verbose)
- // ResultHelper.submitDebug(getResultHandler(),"completed " + testThread);
- testThread = null;
- }
-
- return null;
- }
-
- public void notifyTimeout()
- {
- timedOut = true;
- }
-
- public boolean isCanLogStdout()
- {
- return true;
- }
- }
-
-}
+package org.apache.beehive.test.tools.tch.extension.exectask.wstest;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.beehive.test.tools.tch.compose.Parameters;
+import org.apache.beehive.test.tools.tch.core.AbstractExecutionTask;
+import org.apache.beehive.test.tools.tch.core.AntProperties;
+import org.apache.beehive.test.tools.tch.core.ExecutionTaskValidationException;
+import org.apache.beehive.test.tools.tch.core.ParamContainer;
+import org.apache.beehive.test.tools.tch.core.ProcessEngineContainer;
+import org.apache.beehive.test.tools.tch.core.process.ProcessEngine;
+import org.apache.beehive.test.tools.tch.core.test.AbstractTestLogicTask;
+import org.apache.beehive.test.tools.tch.core.test.BasicInternalParameters;
+import org.apache.beehive.test.tools.tch.core.test.InternalParameters;
+import org.apache.beehive.test.tools.tch.core.test.ResultHandler;
+import org.apache.beehive.test.tools.tch.core.test.TestLogicTask;
+import org.apache.beehive.test.tools.tch.task.TaskContext;
+import org.apache.beehive.test.tools.tch.util.TestResultAdapter;
+
+import org.apache.beehive.test.tools.tch.compose.InvalidTestClassException;
+import org.apache.beehive.test.tools.tch.compose.internal.TestNode;
+import org.apache.beehive.test.tools.tch.compose.internal.context.AtomicTestContext;
+import org.apache.beehive.test.tools.tch.core.PropertyNames;
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+
+import org.apache.beehive.test.tools.tch.extension.exectask.common.TestClassInfoResultHandler;
+import org.apache.beehive.test.tools.tch.extension.exectask.common.ResultHelper;
+
+/**
+ */
+public class WebServerExecTask extends AbstractExecutionTask
+{
+
+ private TestLogicTask wsTestLogicTask = null;
+
+ private static final Collection ALL_METHODS = null;
+ // yes, on purpose this is null
+
+ private String testClassName = null;
+ private String methodNamesAttribute = null;
+ private boolean verbose = AntProperties.isWsTestVerbose();
+
+ //list of web servers
+ private ArrayList wsList = new ArrayList();
+
+ // attribute setters
+ public void setTestClass(String in)
+ {
+ testClassName = handleValue(in);
+ }
+
+ public void setMethodNames(String in)
+ {
+ methodNamesAttribute = handleValue(in);
+ }
+
+ /* !!! replaced with test-parameter
+ public void setWebServers(String in)
+ {
+ webServers = handleValue(in);
+ }
+
+ public void setWebServersToExclude(String in)
+ {
+ webServersToExclude = handleValue(in);
+ }
+ */
+
+ /**
+ * The default web server list is retrieved from the webServerSettings.xml file
+ * as the list of all enabled web servers. A test can provide a specific list
+ * of web servers with the 'webservers' attribute: however only the enabled web
+ * servers within that list will execute. A test can also specify a list of web
+ * servers to exclude with the 'webServersToExclude' parameter.
+ *
+ * Note: accept 'webserver' invalid values 'nows' (no web server) for a test without
+ * a web server or load balancer. Such a test should probably not be written as
+ * a wstest.
+ */
+ public ArrayList getWebServerList()
+ {
+ //1. get the list of enabled web servers
+ ArrayList webServerList = null;
+ try
+ {
+ webServerList = WSTestSettingsXMLReader.getInstance().getWebServerList();
+ // if (verbose)
+ // debugListDump(webServerList, "initList");
+ }
+ catch (Exception e)
+ {
+ System.out.println("exception thrown accessing WSTestSettings.xml");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ webServerList = new ArrayList();
+ }
+
+ if (webServerList.size() == 0)
+ return webServerList; //no tests to run
+
+ InternalParameters inparams = getInternalParameters();
+ Properties props = inparams.getProperties();
+
+ //Reduce the list of enabled web servers to those specified
+ //in webservers (else use all enabled web servers).
+ String webServers = props.getProperty("webservers");
+ //2. check for specific web servers list for this test
+ if (webServers != null)
+ {
+ ArrayList list = tokenizeList(webServers, ",");
+ // if (verbose)
+ // debugListDump(list, "specific ws list");
+
+ //remove from webServerList any entry not in list
+ ArrayList newWebServerList = new ArrayList();
+ for (int i = 0; i < webServerList.size(); i++)
+ {
+ String wsName = (String)webServerList.get(i);
+ if (list.contains(wsName))
+ newWebServerList.add(wsName);
+ }
+ webServerList = newWebServerList;
+ }
+
+ if (webServerList.size() == 0) //no tests to run
+ return webServerList;
+
+ //Any web server in the webserverstoexclude list is removed from
+ //the list of enabled web servers.
+ String webServersToExclude = props.getProperty("webserverstoexclude");
+ if (webServersToExclude != null)
+ {
+ ArrayList list = tokenizeList(webServersToExclude, ",");
+ // if (verbose)
+ // debugListDump(list, "exclude ws list");
+
+ //remove from webServerList any entry in list
+ ArrayList newWebServerList = new ArrayList();
+ for (int i = 0; i < webServerList.size(); i++)
+ {
+ String wsName = (String)webServerList.get(i);
+ if (!list.contains(wsName))
+ newWebServerList.add(wsName);
+ }
+ webServerList = newWebServerList;
+ }
+
+ if (webServerList.size() == 0) //no tests to run
+ return webServerList;
+
+ //When a test file is included with a currentwebservers argument,
+ //the webservers list is reduced to the values in common.
+ String currentWebServers = props.getProperty("currentwebservers");
+ if (currentWebServers != null)
+ {
+ ArrayList list = tokenizeList(currentWebServers, ",");
+ // if (verbose)
+ // debugListDump(list, "current ws list");
+
+ //reduce list to currentWebServers and webServerList common values
+ ArrayList newWebServerList = new ArrayList();
+ for (int i = 0; i < webServerList.size(); i++)
+ {
+ String wsName = (String)webServerList.get(i);
+ if (list.contains(wsName))
+ newWebServerList.add(wsName);
+ }
+ webServerList = newWebServerList;
+ }
+
+ // if (webServerList.size()==0) //no tests to run
+ // return webServerList;
+
+ // if (verbose)
+ // debugListDump(webServerList, "finalList");
+ return webServerList;
+ }
+
+ // private void debugListDump(ArrayList list, String name) {
+ // System.out.println("List"+ name +".size() is " + list.size());
+ // for (int i=0; i<list.size(); i++)
+ // System.out.println("List" + name +"("+i+")= " + list.get(i));
+ // }
+
+ private ArrayList tokenizeList(String param, String token)
+ {
+ ArrayList list = new ArrayList();
+ if (param == null)
+ return list;
+
+ StringTokenizer st = new StringTokenizer(param, token);
+ while (st.hasMoreTokens())
+ {
+ String next = (String)st.nextElement();
+ next = next.trim();
+ if (next.length() > 0)
+ list.add(next);
+ }
+
+ return list;
+ }
+
+ //called at start of process
+ public void validate() throws ExecutionTaskValidationException
+ {
+ // if (getSubtestsConfiguredToRun()!=null) //tests specified on the command line
+ // parseReRunList();
+
+ wsList = getWebServerList();
+ //do not cancel test run just because one of the tests do not apply
+ //if (wsList.isEmpty())
+ // throw new ExecutionTaskValidationException("no web servers enabled");
+
+ try
+ {
+ TestNode n = getLocalTestNode();
+ }
+ catch (Throwable th) // really want to catch *everything* here
+ {
+ throw new ExecutionTaskValidationException(
+ th,
+ "WebServerTask had a problem initializing");
+ }
+
+ }
+
+ //called after validate
+ //determines the number of tests to run
+ private Collection getTestMethodNamesAsCollection()
+ {
+
+ Collection c = new ArrayList();
+ if (methodNamesAttribute != null)
+ {
+ TchUtils.parseStringToStrings(
+ methodNamesAttribute,
+ PropertyNames.DELIMITER,
+ c);
+ }
+ else //methodNamesAttribute==null => all methods
+ {
+ try
+ {
+ c = getLocalTestNode(ALL_METHODS).getTestMethods();
+ }
+ catch (InvalidTestClassException ex)
+ {
+ return new ArrayList();
+ //will not happen here: this exception is thrown during validation
+ }
+ }
+ return c;
+ }
+
+ private TestNode getLocalTestNode()
+ {
+ if (methodNamesAttribute != null)
+ return getLocalTestNode(getTestMethodNamesAsCollection());
+ else
+ return getLocalTestNode(ALL_METHODS);
+ }
+
+ private TestNode getLocalTestNode(Collection methods)
+ {
+ TestNode n = new AtomicTestContext(testClassName, getParameters(), methods);
+ n.setResultHandler(
+ new TestClassInfoResultHandler(getResultHandler(), testClassName));
+
+ return n;
+ }
+
+ // if particular method names are set in xml, we'll only run those
+ // else we'll run all
+ public Collection getAllSubtestNames()
+ {
+ Collection cTestNames = getTestMethodNamesAsCollection();
+ if (cTestNames == null || cTestNames.size() == 0)
+ return new ArrayList(); //no tests to run
+
+ if (wsList.isEmpty())
+ return new ArrayList(); //no tests to run
+
+ //build collection as (method name list)x(web server list)
+ Collection cWithSuffix = new ArrayList();
+ for (Iterator iter = cTestNames.iterator(); iter.hasNext();)
+ {
+ String mName = (String)iter.next();
+ for (int j = 0; j < wsList.size(); j++)
+ {
+ cWithSuffix.add(mName + "-" + (String)wsList.get(j));
+ }
+ }
+
+ return cWithSuffix;
+ }
+
+ /* unknown API: do not know how to access the parameters required.
+ also do not know if available in parallel runs.
+ parsing "replicated-failover.wApacheSingleServerDeathTest-rep.testPrimaryServerDeath-apache20"
+ private void parseReRunList() {
+ String methodWithWS = getTestTask().getName();
+ System.out.println("methodWithWS " + methodWithWS);
+ StringTokenizer st = new StringTokenizer(methodWithWS, "-");
+ String next=null;
+ while (st.hasMoreTokens())
+ next=st.nextToken();
+ webServers=next;
+ System.out.println("methodNamesAttribute " + methodNamesAttribute);
+ System.out.println("webServers " + webServers);
+ }
+ */
+
+ public TestLogicTask getTestLogicTask()
+ {
+ // if (getSubtestsConfiguredToRun()!=null) //tests specified on the command line
+ // parseReRunList();
+
+ TestLogicTask wsTestLogicTask =
+ new WebServerTestLogicTask(
+ getWebServerList(),
+ getTestMethodNamesAsCollection(),
+ getResultHandler());
+ return wsTestLogicTask;
+ }
+
+ public class WebServerTestLogicTask
+ extends AbstractTestLogicTask
+ implements ProcessEngineContainer
+ {
+ private boolean timedOut = false;
+ private ArrayList _wsList = null;
+ private Collection _methodNames = null;
+
+ public WebServerTestLogicTask(
+ ArrayList wsList,
+ Collection methodNames,
+ ResultHandler inResultHandler)
+ {
+ super("WebServerTestLogicTask", inResultHandler);
+ _wsList = wsList;
+ _methodNames = methodNames;
+ }
+
+ public TaskContext run(TaskContext in)
+ {
+ // if (verbose) {
+ // ResultHelper.submitDebug(getResultHandler(), "running ...");
+ // ResultHelper.submitDebug(getResultHandler(), "_wsList.size() is " + _wsList.size());
+ // }
+
+ ArrayList aTestMethod = new ArrayList();
+ ArrayList testThreadList = new ArrayList();
+
+ for (int i = 0; i < _wsList.size(); i++)
+ {
+ String webServerName = (String)_wsList.get(i);
+ // if (verbose)
+ // ResultHelper.submitDebug(getResultHandler(),"webServerName is " + webServerName);
+ for (Iterator iter = _methodNames.iterator(); iter.hasNext();)
+ {
+ if (timedOut)
+ return null;
+
+ String methodToRun = (String)iter.next();
+ // if (verbose)
+ // ResultHelper.submitDebug(getResultHandler(),"running " + methodToRun);
+ aTestMethod.clear();
+ aTestMethod.add(methodToRun);
+
+ //settings added to internal parameters are:
+ // webServerName
+ // testName
+ // methodToRun
+ // host (default)
+ // all WSTestSettings.xml webserver entries (port no. ...etc.)
+ // verbose
+
+ BasicInternalParameters myParams = new BasicInternalParameters();
+ //copy in current params
+ InternalParameters inparams = getInternalParameters();
+ Properties currentProps = inparams.getProperties();
+ for (Enumeration e = currentProps.propertyNames();
+ e.hasMoreElements();
+ )
+ {
+ String key = (String)e.nextElement();
+ if (key != null && currentProps.getProperty(key) != null)
+ myParams.setParam(key, currentProps.getProperty(key));
+ }
+
+ //add web server name to parameters
+ if (webServerName == null)
+ webServerName = "nows";
+ myParams.setParam("webServerName", webServerName);
+ //set test name
+ myParams.setParam(
+ "testName",
+ getTestTask().getName() + "-" + methodToRun + "-" + webServerName);
+ if (methodToRun != null)
+ myParams.setParam("methodToRun", methodToRun);
+ //get current properties & add default properties only if
+ //not already set (with entry in text xml)
+ Properties props = myParams.getProperties();
+ if (props.getProperty("host") == null
+ && AntProperties.getWsTestHost() != null)
+ myParams.setParam("host", AntProperties.getWsTestHost());
+ if (props.getProperty("builddir") == null
+ && AntProperties.getWsTestBuildDir() != null)
+ myParams.setParam("builddir", AntProperties.getWsTestBuildDir());
+ if (props.getProperty("installdir") == null
+ && AntProperties.getWsTestInstallDir() != null)
+ myParams.setParam(
+ "installdir",
+ AntProperties.getWsTestInstallDir());
+
+ //add settings from WSTestSettings.xml except
+ try
+ {
+ //add web server settings
+ HashMap map =
+ WSTestSettingsXMLReader.getInstance().getWebServerSettings(
+ webServerName);
+ if (map != null)
+ {
+ Iterator keyIter = map.keySet().iterator();
+ while (keyIter.hasNext())
+ {
+ String key = (String)keyIter.next();
+ if (key != null && map.get(key) != null)
+ myParams.setParam(key, (String)map.get(key));
+ //port settings & any additional web server specific settings
+ }
+ }
+
+ //add defaults if the value is not already set by the test
+ HashMap dmap = WSTestSettingsXMLReader.getInstance().getDefaults();
+ Iterator dkeyIter = dmap.keySet().iterator();
+ while (dkeyIter.hasNext())
+ {
+ String key = (String)dkeyIter.next();
+ if (key != null && dmap.get(key) != null)
+ {
+ if (myParams.lookup(key) == null) //if the property is not set
+ myParams.setParam(key, (String)dmap.get(key));
+ //then set to default
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ ResultHelper.submitDebug(
+ getResultHandler(),
+ "exception thrown accessing WSTestSettings.xml");
+ ResultHelper.submitDebug(getResultHandler(), e.getMessage());
+ e.printStackTrace();
+ }
+
+ //debug on setting overrides test settings
+ if (AntProperties.isWsTestVerbose())
+ myParams.setParam("verbose", "true");
+
+ WSTestContext test =
+ new WSTestContext(testClassName, myParams, aTestMethod);
+ test.setResultHandler(
+ new WebServerResultHandler(
+ getResultHandler(),
+ testClassName,
+ webServerName));
+ test.setProcessEngine(WebServerExecTask.this.getProcessEngine());
+ Thread testThread = new Thread(test);
+ testThread.start();
+ testThreadList.add(testThread);
+ // if (verbose)
+ // ResultHelper.submitDebug(getResultHandler(),"launched " + methodToRun);
+ }
+ }
+
+ //wait for each test to complete (required?)
+ for (int i = 0; i < testThreadList.size(); i++)
+ {
+ Thread testThread = (Thread)testThreadList.get(i);
+ try
+ {
+ testThread.join(); //wait for test to complete
+ }
+ catch (Exception e)
+ {
+ ResultHelper.submitDebug(
+ getResultHandler(),
+ "join exception thrown " + e.getMessage());
+ }
+ // if (verbose)
+ // ResultHelper.submitDebug(getResultHandler(),"completed " + testThread);
+ testThread = null;
+ }
+
+ return null;
+ }
+
+ public void notifyTimeout()
+ {
+ timedOut = true;
+ }
+
+ public boolean isCanLogStdout()
+ {
+ return true;
+ }
+ }
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerExecTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerResultHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerResultHandler.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerResultHandler.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerResultHandler.java Fri Aug 12 08:12:28 2005
@@ -1,41 +1,41 @@
-package org.apache.beehive.test.tools.tch.extension.exectask.wstest;
-
-import org.apache.beehive.test.tools.tch.core.test.ResultHandler;
-import org.apache.beehive.test.tools.tch.util.TestResultBean;
-
-public class WebServerResultHandler
- implements ResultHandler
-{
- private String fullyQualifiedTestClassName = null;
- private String webServerName = null;
- private ResultHandler resultHandler = null;
-
- public WebServerResultHandler(ResultHandler inResultHandler,
- String inFullyQualifiedTestClassName,
- String inWebServerName)
- {
- resultHandler = inResultHandler;
- fullyQualifiedTestClassName = inFullyQualifiedTestClassName;
- if (inWebServerName!=null)
- webServerName = "-"+inWebServerName;
- else
- webServerName = "-nows";
- }
-
- public void submitResult(TestResultBean tr)
- {
- tr.setCustomPath(fullyQualifiedTestClassName);
- submitResult(tr, tr.getName());
- }
-
- public void submitResult(TestResultBean tr, String resultName)
- {
- tr.setCustomPath(fullyQualifiedTestClassName);
- if (resultName!=null)
- resultName=resultName+webServerName;
- tr.setSubtestName(resultName);
- resultHandler.submitResult(tr, resultName);
- }
-
-
-}
+package org.apache.beehive.test.tools.tch.extension.exectask.wstest;
+
+import org.apache.beehive.test.tools.tch.core.test.ResultHandler;
+import org.apache.beehive.test.tools.tch.util.TestResultBean;
+
+public class WebServerResultHandler
+ implements ResultHandler
+{
+ private String fullyQualifiedTestClassName = null;
+ private String webServerName = null;
+ private ResultHandler resultHandler = null;
+
+ public WebServerResultHandler(ResultHandler inResultHandler,
+ String inFullyQualifiedTestClassName,
+ String inWebServerName)
+ {
+ resultHandler = inResultHandler;
+ fullyQualifiedTestClassName = inFullyQualifiedTestClassName;
+ if (inWebServerName!=null)
+ webServerName = "-"+inWebServerName;
+ else
+ webServerName = "-nows";
+ }
+
+ public void submitResult(TestResultBean tr)
+ {
+ tr.setCustomPath(fullyQualifiedTestClassName);
+ submitResult(tr, tr.getName());
+ }
+
+ public void submitResult(TestResultBean tr, String resultName)
+ {
+ tr.setCustomPath(fullyQualifiedTestClassName);
+ if (resultName!=null)
+ resultName=resultName+webServerName;
+ tr.setSubtestName(resultName);
+ resultHandler.submitResult(tr, resultName);
+ }
+
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/exectask/wstest/WebServerResultHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfiguration.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfiguration.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfiguration.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfiguration.java Fri Aug 12 08:12:28 2005
@@ -1,42 +1,42 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import java.util.Map;
-
-import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
-import org.apache.beehive.test.tools.tch.core.process.CloneOverrideable;
-import org.apache.beehive.test.tools.tch.core.process.ProcessOverride;
-
-public class ExecProcessConfiguration
- implements ProcessConfiguration, CloneOverrideable
-{
- private MinimalConfigurationInfo info = null;
-
- public ExecProcessConfiguration(MinimalConfigurationInfo inInfo)
- {
- info = inInfo;
- }
-
- public MinimalConfigurationInfo getContainedMinimalConfigurationInfo()
- {
- return info;
- }
-
- public Object cloneWithOverride(ProcessOverride processOverride)
- {
- // right now just return a clone since there's nothing here to override
- // this is currently just a shallow clone since we currently won't be
- // calling this anyway
- return this;
- }
-
- public Object cloneWithOverride(
- ProcessOverride processOverride,
- Map overrideHandlerMap)
- {
- // right now just return a clone since there's nothing here to override
- // this is currently just a shallow clone since we currently won't be
- // calling this anyway
- return this;
- }
-}
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import java.util.Map;
+
+import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
+import org.apache.beehive.test.tools.tch.core.process.CloneOverrideable;
+import org.apache.beehive.test.tools.tch.core.process.ProcessOverride;
+
+public class ExecProcessConfiguration
+ implements ProcessConfiguration, CloneOverrideable
+{
+ private MinimalConfigurationInfo info = null;
+
+ public ExecProcessConfiguration(MinimalConfigurationInfo inInfo)
+ {
+ info = inInfo;
+ }
+
+ public MinimalConfigurationInfo getContainedMinimalConfigurationInfo()
+ {
+ return info;
+ }
+
+ public Object cloneWithOverride(ProcessOverride processOverride)
+ {
+ // right now just return a clone since there's nothing here to override
+ // this is currently just a shallow clone since we currently won't be
+ // calling this anyway
+ return this;
+ }
+
+ public Object cloneWithOverride(
+ ProcessOverride processOverride,
+ Map overrideHandlerMap)
+ {
+ // right now just return a clone since there's nothing here to override
+ // this is currently just a shallow clone since we currently won't be
+ // calling this anyway
+ return this;
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfigurationManager.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfigurationManager.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfigurationManager.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfigurationManager.java Fri Aug 12 08:12:28 2005
@@ -1,22 +1,22 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import java.util.Collection;
-
-import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
-import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfigurationManager;
-
-public class ExecProcessConfigurationManager
- implements ProcessConfigurationManager
-{
- public ProcessConfiguration configure(MinimalConfigurationInfo in)
- {
- return new ExecProcessConfiguration(in);
- }
-
- public ProcessConfiguration configure(MinimalConfigurationInfo in,
- Collection units)
- {
- return new ExecProcessConfiguration(in);
- }
-}
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import java.util.Collection;
+
+import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
+import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfigurationManager;
+
+public class ExecProcessConfigurationManager
+ implements ProcessConfigurationManager
+{
+ public ProcessConfiguration configure(MinimalConfigurationInfo in)
+ {
+ return new ExecProcessConfiguration(in);
+ }
+
+ public ProcessConfiguration configure(MinimalConfigurationInfo in,
+ Collection units)
+ {
+ return new ExecProcessConfiguration(in);
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessConfigurationManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessHandler.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessHandler.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessHandler.java Fri Aug 12 08:12:28 2005
@@ -1,56 +1,56 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import org.apache.beehive.test.tools.tch.core.process.OutputProducerProcessHandler;
-import org.apache.beehive.test.tools.tch.core.process.ProcessHandler;
-
-public interface ExecProcessHandler
- extends OutputProducerProcessHandler, ProcessHandler
-{
- /**
- * Blocks until the exec'd process has terminated.
- */
- public void waitForProcessExit();
-
- /**
- * Returns this process' command line.
- * @return The command line used to start this process, as a String.
- */
- public String getCmd();
-
- /**
- * Returns the process exit value of the server. If the server has not exited yet, will
- * return null.
- */
- public Integer getExitValue();
-
- /**
- * Returns the directory this process will start/started in.
- * @return The directory this process lives in, as a String.
- */
- public String getHome();
-
- /**
- * Checks if process has exited.
- * @return true if process exited, else false.
- */
- public boolean processTerminated();
-
- /**
- * Returns absolute path to file that this exec process' stdout is drained to.
- * @return String, absolute path to stdout drain file.
- */
- public String getStdoutDrainFileName();
-
- /**
- * Returns absolute path to file that this exec process' stderr is drained to.
- * @return String, absolute path to stderr drain file.
- */
- public String getStderrDrainFileName();
-
- /**
- * Returns true/false depending on attempt made to startup the server.
- * @return boolean, If an attempt has been made to startup the server.
- */
- public boolean isRunning();
-
-}
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import org.apache.beehive.test.tools.tch.core.process.OutputProducerProcessHandler;
+import org.apache.beehive.test.tools.tch.core.process.ProcessHandler;
+
+public interface ExecProcessHandler
+ extends OutputProducerProcessHandler, ProcessHandler
+{
+ /**
+ * Blocks until the exec'd process has terminated.
+ */
+ public void waitForProcessExit();
+
+ /**
+ * Returns this process' command line.
+ * @return The command line used to start this process, as a String.
+ */
+ public String getCmd();
+
+ /**
+ * Returns the process exit value of the server. If the server has not exited yet, will
+ * return null.
+ */
+ public Integer getExitValue();
+
+ /**
+ * Returns the directory this process will start/started in.
+ * @return The directory this process lives in, as a String.
+ */
+ public String getHome();
+
+ /**
+ * Checks if process has exited.
+ * @return true if process exited, else false.
+ */
+ public boolean processTerminated();
+
+ /**
+ * Returns absolute path to file that this exec process' stdout is drained to.
+ * @return String, absolute path to stdout drain file.
+ */
+ public String getStdoutDrainFileName();
+
+ /**
+ * Returns absolute path to file that this exec process' stderr is drained to.
+ * @return String, absolute path to stderr drain file.
+ */
+ public String getStderrDrainFileName();
+
+ /**
+ * Returns true/false depending on attempt made to startup the server.
+ * @return boolean, If an attempt has been made to startup the server.
+ */
+ public boolean isRunning();
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessManager.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessManager.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessManager.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessManager.java Fri Aug 12 08:12:28 2005
@@ -1,150 +1,150 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.beehive.test.tools.tch.core.AntProperties;
-import org.apache.beehive.test.tools.tch.core.process.AbstractProcessManagerWithListener;
-import org.apache.beehive.test.tools.tch.core.process.Process;
-import org.apache.beehive.test.tools.tch.core.process.ProcessManagementRuntimeException;
-import org.apache.beehive.test.tools.tch.core.remote.ExecTask;
-import org.apache.beehive.test.tools.tch.core.remote.UnknownExecTaskException;
-import org.apache.beehive.test.tools.tch.task.TaskException;
-
-public class ExecProcessManager extends AbstractProcessManagerWithListener
-{
- private boolean mergeOutputStreams = false;
- private boolean processLogBaseDirIsSet = false;
- private boolean writeCmdToFile = false;
- private File processLogBaseDir = null;
-
- public ExecProcessManager()
- {
- populateProperties();
- }
-
- public void startup(Process inProcess)
- {
- inProcess.setIsRunning(true);
- execCmdline(inProcess, getConfiguration(inProcess).getCmd());
- }
-
- public void shutdown(Process inProcess)
- {
- destroyProcess(inProcess);
- inProcess.setIsRunning(false);
- }
-
- public String getCmd(Process inProcess)
- {
- return getCmd(inProcess, getConfiguration(inProcess).getCmd());
- }
-
- protected String getCmd(Process inProcess, String cmd)
- {
- ExecTask execTask = getExecTask(inProcess, cmd);
- return execTask.getProcessSummary().getCommand();
- }
-
- public final boolean processTerminated(Process inProcess)
- {
- return processHasExited(inProcess);
- }
-
- public final Integer getProcessReturnCode(Process inProcess)
- {
- try
- {
- return getProcessSummary(inProcess).getExitValue();
- }
- catch (UnknownExecTaskException ex)
- {
- throw new ProcessManagementRuntimeException(ex);
- }
- }
-
- protected final void execCmdline(Process inProcess, String cmdline)
- {
- ExecTask execTask = getExecTask(inProcess, cmdline);
- try
- {
- runExecTask(inProcess, execTask);
- }
- catch (TaskException ex)
- {
- throw new ProcessManagementRuntimeException(ex);
- }
- }
-
- // should this happen at init time for every kind of process manager?
- public final void writeCmdlineFile(Process process, String cmd)
- {
- if (!writeCmdToFile)
- return;
- ExecTask execTask = getExecTask(process, cmd);
- execTask.writeCmdFile();
- System.out.println(
- "Writing command line that would be used to start '"
- + process.getName()
- + "' to file "
- + execTask.getProcessSummary().getCmdFileName());
- }
-
- protected final File getCmdlineFile(Process process)
- {
- return new File(
- getExecTask(process, "").getProcessSummary().getCmdFileName());
- }
-
- private void populateProperties()
- {
- writeCmdToFile = AntProperties.writeCmdFiles();
- mergeOutputStreams = AntProperties.mergeProcessOutputStreams();
- processLogBaseDirIsSet = AntProperties.isProcessLogBasedirSet();
- if (processLogBaseDirIsSet)
- processLogBaseDir = AntProperties.getProcessLogBasedir();
- }
-
- private synchronized ExecTask getExecTask(Process process, String cmdline)
- {
- //ExecTask task = (ExecTask)execTasks.get(process.getName());
- // there might be issues with calling run more than once on
- // the same ExecTask instance.
- // Until a functest2 run (or equivalent, that starts/stops the same servers)
- // has been tested, disable the caching.
- ExecTask task =
- new ExecTask(
- process.getName() + process.getCmdFileModifier(),
- cmdline,
- process.getHome(),
- process.startInOwnWindow());
-
- task.setDrainStreamsToSameFile(mergeOutputStreams);
- task.setWriteCmdToFile(writeCmdToFile);
-
- if (processLogBaseDirIsSet)
- task.setDrainFileHome(processLogBaseDir);
-
- return task;
- }
-
- private ExecProcessMinimalConfigurationInfo getConfiguration(Process in)
- {
- return (ExecProcessMinimalConfigurationInfo)
- ((ExecProcessConfiguration)in.getProcessConfiguration())
- .getContainedMinimalConfigurationInfo();
- }
-
- /**
- * @param p
- */
- public void writeOutCommandLine(Process p)
- {
- return;
- }
-
- public boolean isRunning(Process p)
- {
- return p.getIsRunning();
- }
-}
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.beehive.test.tools.tch.core.AntProperties;
+import org.apache.beehive.test.tools.tch.core.process.AbstractProcessManagerWithListener;
+import org.apache.beehive.test.tools.tch.core.process.Process;
+import org.apache.beehive.test.tools.tch.core.process.ProcessManagementRuntimeException;
+import org.apache.beehive.test.tools.tch.core.remote.ExecTask;
+import org.apache.beehive.test.tools.tch.core.remote.UnknownExecTaskException;
+import org.apache.beehive.test.tools.tch.task.TaskException;
+
+public class ExecProcessManager extends AbstractProcessManagerWithListener
+{
+ private boolean mergeOutputStreams = false;
+ private boolean processLogBaseDirIsSet = false;
+ private boolean writeCmdToFile = false;
+ private File processLogBaseDir = null;
+
+ public ExecProcessManager()
+ {
+ populateProperties();
+ }
+
+ public void startup(Process inProcess)
+ {
+ inProcess.setIsRunning(true);
+ execCmdline(inProcess, getConfiguration(inProcess).getCmd());
+ }
+
+ public void shutdown(Process inProcess)
+ {
+ destroyProcess(inProcess);
+ inProcess.setIsRunning(false);
+ }
+
+ public String getCmd(Process inProcess)
+ {
+ return getCmd(inProcess, getConfiguration(inProcess).getCmd());
+ }
+
+ protected String getCmd(Process inProcess, String cmd)
+ {
+ ExecTask execTask = getExecTask(inProcess, cmd);
+ return execTask.getProcessSummary().getCommand();
+ }
+
+ public final boolean processTerminated(Process inProcess)
+ {
+ return processHasExited(inProcess);
+ }
+
+ public final Integer getProcessReturnCode(Process inProcess)
+ {
+ try
+ {
+ return getProcessSummary(inProcess).getExitValue();
+ }
+ catch (UnknownExecTaskException ex)
+ {
+ throw new ProcessManagementRuntimeException(ex);
+ }
+ }
+
+ protected final void execCmdline(Process inProcess, String cmdline)
+ {
+ ExecTask execTask = getExecTask(inProcess, cmdline);
+ try
+ {
+ runExecTask(inProcess, execTask);
+ }
+ catch (TaskException ex)
+ {
+ throw new ProcessManagementRuntimeException(ex);
+ }
+ }
+
+ // should this happen at init time for every kind of process manager?
+ public final void writeCmdlineFile(Process process, String cmd)
+ {
+ if (!writeCmdToFile)
+ return;
+ ExecTask execTask = getExecTask(process, cmd);
+ execTask.writeCmdFile();
+ System.out.println(
+ "Writing command line that would be used to start '"
+ + process.getName()
+ + "' to file "
+ + execTask.getProcessSummary().getCmdFileName());
+ }
+
+ protected final File getCmdlineFile(Process process)
+ {
+ return new File(
+ getExecTask(process, "").getProcessSummary().getCmdFileName());
+ }
+
+ private void populateProperties()
+ {
+ writeCmdToFile = AntProperties.writeCmdFiles();
+ mergeOutputStreams = AntProperties.mergeProcessOutputStreams();
+ processLogBaseDirIsSet = AntProperties.isProcessLogBasedirSet();
+ if (processLogBaseDirIsSet)
+ processLogBaseDir = AntProperties.getProcessLogBasedir();
+ }
+
+ private synchronized ExecTask getExecTask(Process process, String cmdline)
+ {
+ //ExecTask task = (ExecTask)execTasks.get(process.getName());
+ // there might be issues with calling run more than once on
+ // the same ExecTask instance.
+ // Until a functest2 run (or equivalent, that starts/stops the same servers)
+ // has been tested, disable the caching.
+ ExecTask task =
+ new ExecTask(
+ process.getName() + process.getCmdFileModifier(),
+ cmdline,
+ process.getHome(),
+ process.startInOwnWindow());
+
+ task.setDrainStreamsToSameFile(mergeOutputStreams);
+ task.setWriteCmdToFile(writeCmdToFile);
+
+ if (processLogBaseDirIsSet)
+ task.setDrainFileHome(processLogBaseDir);
+
+ return task;
+ }
+
+ private ExecProcessMinimalConfigurationInfo getConfiguration(Process in)
+ {
+ return (ExecProcessMinimalConfigurationInfo)
+ ((ExecProcessConfiguration)in.getProcessConfiguration())
+ .getContainedMinimalConfigurationInfo();
+ }
+
+ /**
+ * @param p
+ */
+ public void writeOutCommandLine(Process p)
+ {
+ return;
+ }
+
+ public boolean isRunning(Process p)
+ {
+ return p.getIsRunning();
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessMinimalConfigurationInfo.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessMinimalConfigurationInfo.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessMinimalConfigurationInfo.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessMinimalConfigurationInfo.java Fri Aug 12 08:12:28 2005
@@ -1,46 +1,46 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import java.util.Map;
-
-import org.apache.tools.ant.BuildException;
-
-import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.process.ProcessOverride;
-
-/**
- * Dumb container for information we need
- */
-
-public class ExecProcessMinimalConfigurationInfo
- implements MinimalConfigurationInfo
-{
- private String cmd = null;
-
- public ExecProcessMinimalConfigurationInfo(String inCmd)
- {
- cmd = inCmd;
- }
-
- public String getCmd()
- {
- return cmd;
- }
-
- public String toString()
- {
- return getCmd();
- }
-
- public Object cloneWithOverride(ProcessOverride processOverride)
- {
- throw new BuildException("cloneWithOverride unsupported in ExecProcessMinimalConfigurationInfo");
- }
-
- public Object cloneWithOverride(
- ProcessOverride processOverride,
- Map overrideHandlerMap)
- {
- throw new BuildException("cloneWithOverride unsupported in ExecProcessMinimalConfigurationInfo");
- }
-
-}
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+
+import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.process.ProcessOverride;
+
+/**
+ * Dumb container for information we need
+ */
+
+public class ExecProcessMinimalConfigurationInfo
+ implements MinimalConfigurationInfo
+{
+ private String cmd = null;
+
+ public ExecProcessMinimalConfigurationInfo(String inCmd)
+ {
+ cmd = inCmd;
+ }
+
+ public String getCmd()
+ {
+ return cmd;
+ }
+
+ public String toString()
+ {
+ return getCmd();
+ }
+
+ public Object cloneWithOverride(ProcessOverride processOverride)
+ {
+ throw new BuildException("cloneWithOverride unsupported in ExecProcessMinimalConfigurationInfo");
+ }
+
+ public Object cloneWithOverride(
+ ProcessOverride processOverride,
+ Map overrideHandlerMap)
+ {
+ throw new BuildException("cloneWithOverride unsupported in ExecProcessMinimalConfigurationInfo");
+ }
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessMinimalConfigurationInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessXMLHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessXMLHandler.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessXMLHandler.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessXMLHandler.java Fri Aug 12 08:12:28 2005
@@ -1,34 +1,34 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import org.apache.tools.ant.Location;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.beehive.test.tools.tch.core.CallingChain;
-import org.apache.beehive.test.tools.tch.core.configuration.ElementConstants;
-import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.configuration.UnitConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.configuration.XMLHandler;
-import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
-
-public class ExecProcessXMLHandler
- implements XMLHandler
-{
- private static final String COMMAND_NAME = "cmd";
-
- public UnitConfigurationInfo getUnitConfigurationInfo(Document doc, Location inLocation, CallingChain inChain)
- {
- return null;
- }
-
- public MinimalConfigurationInfo getMinimalConfigurationInfo(Document doc)
- {
- // assuming validated xml
- Node command = doc.getDocumentElement().getElementsByTagName(COMMAND_NAME).item(0);
- String cmd = command.getFirstChild().getNodeValue();
- return new ExecProcessMinimalConfigurationInfo(cmd.trim());
- }
-}
-
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import org.apache.tools.ant.Location;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.beehive.test.tools.tch.core.CallingChain;
+import org.apache.beehive.test.tools.tch.core.configuration.ElementConstants;
+import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.configuration.UnitConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.configuration.XMLHandler;
+import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
+
+public class ExecProcessXMLHandler
+ implements XMLHandler
+{
+ private static final String COMMAND_NAME = "cmd";
+
+ public UnitConfigurationInfo getUnitConfigurationInfo(Document doc, Location inLocation, CallingChain inChain)
+ {
+ return null;
+ }
+
+ public MinimalConfigurationInfo getMinimalConfigurationInfo(Document doc)
+ {
+ // assuming validated xml
+ Node command = doc.getDocumentElement().getElementsByTagName(COMMAND_NAME).item(0);
+ String cmd = command.getFirstChild().getNodeValue();
+ return new ExecProcessMinimalConfigurationInfo(cmd.trim());
+ }
+}
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/ExecProcessXMLHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/TestExecProcessStuff.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/TestExecProcessStuff.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/TestExecProcessStuff.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/TestExecProcessStuff.java Fri Aug 12 08:12:28 2005
@@ -1,54 +1,54 @@
-package org.apache.beehive.test.tools.tch.extension.process.exec;
-
-import org.apache.beehive.test.tools.tch.util.GeneralUtil;
-
-public class TestExecProcessStuff
-{
- public static void main(String args[])
- {
- if (GeneralUtil.isSet(args, "-sleep"))
- sleep(Integer.parseInt(GeneralUtil.getValueFor(args, "-sleep")));
- else
- printStuffToStdoutAndStderr();
- }
-
- private static void sleep(int millis)
- {
- System.out.println("Going to sleep for " + millis + " millis");
- try
- {
- Thread.sleep(millis);
- } catch (InterruptedException ex) {}
- System.out.println("Done sleeping for " + millis + " millis");
- }
-
- private static void printStuffToStdoutAndStderr()
- {
- stdout("1");
- stderr("2");
- stdout("3");
- stderr("4");
- stdout("5");
- stderr("6");
- stdout("7");
- stderr("8");
- stdout("9");
- stderr("10");
- stdout("11");
- stderr("12");
- }
-
- private static void stdout(String s)
- {
- System.out.println("[stdout] " + s);
- }
-
- private static void stderr(String s)
- {
- System.err.println("[stderr] " + s);
- }
-}
-
-
-
-
+package org.apache.beehive.test.tools.tch.extension.process.exec;
+
+import org.apache.beehive.test.tools.tch.util.GeneralUtil;
+
+public class TestExecProcessStuff
+{
+ public static void main(String args[])
+ {
+ if (GeneralUtil.isSet(args, "-sleep"))
+ sleep(Integer.parseInt(GeneralUtil.getValueFor(args, "-sleep")));
+ else
+ printStuffToStdoutAndStderr();
+ }
+
+ private static void sleep(int millis)
+ {
+ System.out.println("Going to sleep for " + millis + " millis");
+ try
+ {
+ Thread.sleep(millis);
+ } catch (InterruptedException ex) {}
+ System.out.println("Done sleeping for " + millis + " millis");
+ }
+
+ private static void printStuffToStdoutAndStderr()
+ {
+ stdout("1");
+ stderr("2");
+ stdout("3");
+ stderr("4");
+ stdout("5");
+ stderr("6");
+ stdout("7");
+ stderr("8");
+ stdout("9");
+ stderr("10");
+ stdout("11");
+ stderr("12");
+ }
+
+ private static void stdout(String s)
+ {
+ System.out.println("[stdout] " + s);
+ }
+
+ private static void stderr(String s)
+ {
+ System.err.println("[stderr] " + s);
+ }
+}
+
+
+
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/exec/TestExecProcessStuff.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/AbstractListenerProcessManager.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/AbstractListenerProcessManager.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/AbstractListenerProcessManager.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/AbstractListenerProcessManager.java Fri Aug 12 08:12:28 2005
@@ -1,39 +1,39 @@
-package org.apache.beehive.test.tools.tch.extension.process.listener;
-
-import org.apache.beehive.test.tools.tch.core.process.AbstractProcessManager;
-import org.apache.beehive.test.tools.tch.core.process.Process;
-import org.apache.beehive.test.tools.tch.util.time.Time;
-
-public abstract class AbstractListenerProcessManager
- extends AbstractProcessManager
-{
- public void cleanup(Process process)
- {
- super.cleanup(process);
- shutdown(process);
- }
-
- public String getJavaopts(Process inProcess)
- {
- return getConfiguration(inProcess).getJavaopts();
- }
-
- protected RemoteListenerMinimalConfigurationInfo getConfiguration(Process in)
- {
- return (RemoteListenerMinimalConfigurationInfo)in
- .getConfiguredProcess()
- .getMinimalConfigurationInfo();
- }
-
- /** @deprecated Use getStartupTimeout(org.apache.beehive.test.tools.tch.core.process.Process) instead. */
- protected Time getStartupTimeout()
- {
- // FIXME, should be made configurable in process-config
- return new Time(10, Time.SECONDS);
- }
-
- protected Time getStartupTimeout(Process inProcess)
- {
- return getConfiguration(inProcess).getStartupTimeout();
- }
-}
+package org.apache.beehive.test.tools.tch.extension.process.listener;
+
+import org.apache.beehive.test.tools.tch.core.process.AbstractProcessManager;
+import org.apache.beehive.test.tools.tch.core.process.Process;
+import org.apache.beehive.test.tools.tch.util.time.Time;
+
+public abstract class AbstractListenerProcessManager
+ extends AbstractProcessManager
+{
+ public void cleanup(Process process)
+ {
+ super.cleanup(process);
+ shutdown(process);
+ }
+
+ public String getJavaopts(Process inProcess)
+ {
+ return getConfiguration(inProcess).getJavaopts();
+ }
+
+ protected RemoteListenerMinimalConfigurationInfo getConfiguration(Process in)
+ {
+ return (RemoteListenerMinimalConfigurationInfo)in
+ .getConfiguredProcess()
+ .getMinimalConfigurationInfo();
+ }
+
+ /** @deprecated Use getStartupTimeout(org.apache.beehive.test.tools.tch.core.process.Process) instead. */
+ protected Time getStartupTimeout()
+ {
+ // FIXME, should be made configurable in process-config
+ return new Time(10, Time.SECONDS);
+ }
+
+ protected Time getStartupTimeout(Process inProcess)
+ {
+ return getConfiguration(inProcess).getStartupTimeout();
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/AbstractListenerProcessManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/LocalListenerProcessManager.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/LocalListenerProcessManager.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/LocalListenerProcessManager.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/LocalListenerProcessManager.java Fri Aug 12 08:12:28 2005
@@ -1,71 +1,71 @@
-package org.apache.beehive.test.tools.tch.extension.process.listener;
-
-import java.rmi.RemoteException;
-
-import org.apache.beehive.test.tools.tch.core.process.Process;
-import org.apache.beehive.test.tools.tch.core.process.ProcessManagementRuntimeException;
-import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunner;
-import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunnerImpl;
-
-public class LocalListenerProcessManager
- extends AbstractListenerProcessManager
-{
- private RemoteExecTaskRunner remoteExecTaskRunner = null;
- // we keep a single RemoteExecTaskRunner which will exec all processes
- // that
- // i) do not have an environment defined in process-config
- // ii) run on some host as tch
-
- private boolean alreadyShutdown = false;
-
- public void startup(Process inProcess)
- {}
-
- public void shutdown(Process inProcess)
- {
- // since we're running locally, we'll shutdown whenever the local
- // VM shuts down. Do this only once.
- if (!alreadyShutdown)
- try
- {
- remoteExecTaskRunner.destroyAllProcesses();
- alreadyShutdown = true;
- }
- catch (RemoteException ex)
- {
- throw new ProcessManagementRuntimeException(ex);
- }
-
- }
-
- public boolean isAlive(Process inProcess)
- {
- // The VM we're running in must be alive, so yes
- return true;
- }
-
-
- public synchronized RemoteExecTaskRunner lookup(Process inProcess)
- throws RemoteException
- {
- if (remoteExecTaskRunner == null)
- {
- System.out.println("Creating local tch agent");
- remoteExecTaskRunner = new RemoteExecTaskRunnerImpl();
- }
- return remoteExecTaskRunner;
- }
-
- public int getPort(Process inProcess)
- {
- //FIXME this should move out of the super class so we don't
- // have to implement it here
- throw new RuntimeException("Should never get called");
- }
-}
-
-
-
-
-
-
+package org.apache.beehive.test.tools.tch.extension.process.listener;
+
+import java.rmi.RemoteException;
+
+import org.apache.beehive.test.tools.tch.core.process.Process;
+import org.apache.beehive.test.tools.tch.core.process.ProcessManagementRuntimeException;
+import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunner;
+import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunnerImpl;
+
+public class LocalListenerProcessManager
+ extends AbstractListenerProcessManager
+{
+ private RemoteExecTaskRunner remoteExecTaskRunner = null;
+ // we keep a single RemoteExecTaskRunner which will exec all processes
+ // that
+ // i) do not have an environment defined in process-config
+ // ii) run on some host as tch
+
+ private boolean alreadyShutdown = false;
+
+ public void startup(Process inProcess)
+ {}
+
+ public void shutdown(Process inProcess)
+ {
+ // since we're running locally, we'll shutdown whenever the local
+ // VM shuts down. Do this only once.
+ if (!alreadyShutdown)
+ try
+ {
+ remoteExecTaskRunner.destroyAllProcesses();
+ alreadyShutdown = true;
+ }
+ catch (RemoteException ex)
+ {
+ throw new ProcessManagementRuntimeException(ex);
+ }
+
+ }
+
+ public boolean isAlive(Process inProcess)
+ {
+ // The VM we're running in must be alive, so yes
+ return true;
+ }
+
+
+ public synchronized RemoteExecTaskRunner lookup(Process inProcess)
+ throws RemoteException
+ {
+ if (remoteExecTaskRunner == null)
+ {
+ System.out.println("Creating local tch agent");
+ remoteExecTaskRunner = new RemoteExecTaskRunnerImpl();
+ }
+ return remoteExecTaskRunner;
+ }
+
+ public int getPort(Process inProcess)
+ {
+ //FIXME this should move out of the super class so we don't
+ // have to implement it here
+ throw new RuntimeException("Should never get called");
+ }
+}
+
+
+
+
+
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/LocalListenerProcessManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListener.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListener.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListener.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListener.java Fri Aug 12 08:12:28 2005
@@ -1,51 +1,51 @@
-package org.apache.beehive.test.tools.tch.extension.process.listener;
-
-import java.net.InetAddress;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-
-import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunnerImpl;
-import org.apache.beehive.test.tools.tch.util.TchConstants;
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-import org.apache.beehive.test.tools.tch.util.GeneralUtil;
-
-public class RemoteListener
-{
- public static final String
- PORT_PARAM = "-port",
- BINDNAME_PARAM = "-bindname";
-
- public static void main(String[] inArgs)
- throws Exception
- {
- String portString =
- GeneralUtil.getValueFor(inArgs,
- PORT_PARAM,
- "" + TchConstants.DEFAULT_RMI_REG_PORT);
-
- String bindname =
- GeneralUtil.getValueFor(inArgs,
- BINDNAME_PARAM,
- TchConstants.DEFAULT_REMOTE_LISTENER_BINDNAME);
- System.out.println("");
- TchUtils.log("Starting remote listener...");
- try {
- Registry reg =
- LocateRegistry.createRegistry(Integer.parseInt(portString.trim()));
- reg.rebind(bindname, new RemoteExecTaskRunnerImpl(false));
- } catch (java.rmi.server.ExportException ex)
- {
- ex.printStackTrace();
- TchUtils.log("Caught: " + ex.toString());
- TchUtils.log("Assuming remote listener is already up");
- }
- String hostname = InetAddress.getLocalHost().getHostName();
- String url = "rmi://" + hostname + ":" + portString + "/" + bindname;
- TchUtils.log("Bound remote listener, to lookup, use url: ");
- TchUtils.log(url + "\n");
- }
-}
-
-
-
-
+package org.apache.beehive.test.tools.tch.extension.process.listener;
+
+import java.net.InetAddress;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.beehive.test.tools.tch.core.remote.RemoteExecTaskRunnerImpl;
+import org.apache.beehive.test.tools.tch.util.TchConstants;
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+import org.apache.beehive.test.tools.tch.util.GeneralUtil;
+
+public class RemoteListener
+{
+ public static final String
+ PORT_PARAM = "-port",
+ BINDNAME_PARAM = "-bindname";
+
+ public static void main(String[] inArgs)
+ throws Exception
+ {
+ String portString =
+ GeneralUtil.getValueFor(inArgs,
+ PORT_PARAM,
+ "" + TchConstants.DEFAULT_RMI_REG_PORT);
+
+ String bindname =
+ GeneralUtil.getValueFor(inArgs,
+ BINDNAME_PARAM,
+ TchConstants.DEFAULT_REMOTE_LISTENER_BINDNAME);
+ System.out.println("");
+ TchUtils.log("Starting remote listener...");
+ try {
+ Registry reg =
+ LocateRegistry.createRegistry(Integer.parseInt(portString.trim()));
+ reg.rebind(bindname, new RemoteExecTaskRunnerImpl(false));
+ } catch (java.rmi.server.ExportException ex)
+ {
+ ex.printStackTrace();
+ TchUtils.log("Caught: " + ex.toString());
+ TchUtils.log("Assuming remote listener is already up");
+ }
+ String hostname = InetAddress.getLocalHost().getHostName();
+ String url = "rmi://" + hostname + ":" + portString + "/" + bindname;
+ TchUtils.log("Bound remote listener, to lookup, use url: ");
+ TchUtils.log(url + "\n");
+ }
+}
+
+
+
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListenerConfigurationManager.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListenerConfigurationManager.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListenerConfigurationManager.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListenerConfigurationManager.java Fri Aug 12 08:12:28 2005
@@ -1,21 +1,21 @@
-package org.apache.beehive.test.tools.tch.extension.process.listener;
-
-import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
-import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfigurationManager;
-
-public class RemoteListenerConfigurationManager
- implements ProcessConfigurationManager
-{
- public ProcessConfiguration configure(MinimalConfigurationInfo in)
- {
- return null;
- }
-
- public ProcessConfiguration configure(MinimalConfigurationInfo in,
- java.util.Collection units)
- {
- //FIXME
- return configure(in);
- }
-}
+package org.apache.beehive.test.tools.tch.extension.process.listener;
+
+import org.apache.beehive.test.tools.tch.core.configuration.MinimalConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfiguration;
+import org.apache.beehive.test.tools.tch.core.configuration.ProcessConfigurationManager;
+
+public class RemoteListenerConfigurationManager
+ implements ProcessConfigurationManager
+{
+ public ProcessConfiguration configure(MinimalConfigurationInfo in)
+ {
+ return null;
+ }
+
+ public ProcessConfiguration configure(MinimalConfigurationInfo in,
+ java.util.Collection units)
+ {
+ //FIXME
+ return configure(in);
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/process/listener/RemoteListenerConfigurationManager.java
------------------------------------------------------------------------------
svn:eol-style = native