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 [64/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/core/test/ResultHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandler.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandler.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandler.java Fri Aug 12 08:12:28 2005
@@ -1,19 +1,19 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.io.Serializable;
-
-import org.apache.beehive.test.tools.tch.util.TestResultBean;
-
-/**
- * Interface implemented by all result handlers which a result can be submitted to
- */
-public interface ResultHandler
- extends Serializable
-{
-
- public void submitResult(TestResultBean tr);
-
- public void submitResult(TestResultBean tr, String resultName);
-
-}
-
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.io.Serializable;
+
+import org.apache.beehive.test.tools.tch.util.TestResultBean;
+
+/**
+ * Interface implemented by all result handlers which a result can be submitted to
+ */
+public interface ResultHandler
+ extends Serializable
+{
+
+ public void submitResult(TestResultBean tr);
+
+ public void submitResult(TestResultBean tr, String resultName);
+
+}
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandlerAdapter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandlerAdapter.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandlerAdapter.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandlerAdapter.java Fri Aug 12 08:12:28 2005
@@ -1,47 +1,47 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.rmi.RemoteException;
-
-import org.apache.beehive.test.tools.tch.core.remote.RemoteResultHandler;
-import org.apache.beehive.test.tools.tch.util.TestResultBean;
-
-/**
- * Adapter: ResultHandler --> RemoteResultHandler
- *
- * Adapter class which is used to submit a result via {@link org.apache.beehive.test.tools.tch.core.remote.RemoteResultHandler}
- * which is the rmi interface for submitting results from a remote test-vehicle back to the Tch VM
- */
-public class ResultHandlerAdapter implements ResultHandler
-{
-
- private RemoteResultHandler remoteResultHandler = null;
-
- public ResultHandlerAdapter(RemoteResultHandler in)
- {
- remoteResultHandler = in;
- }
-
- public void submitResult(TestResultBean tr)
- {
- try
- {
- remoteResultHandler.submitResult(tr);
- }
- catch (RemoteException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public void submitResult(TestResultBean tr, String resultName)
- {
- try
- {
- remoteResultHandler.submitResult(tr, resultName);
- }
- catch (RemoteException ex)
- {
- ex.printStackTrace();
- }
- }
-}
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.rmi.RemoteException;
+
+import org.apache.beehive.test.tools.tch.core.remote.RemoteResultHandler;
+import org.apache.beehive.test.tools.tch.util.TestResultBean;
+
+/**
+ * Adapter: ResultHandler --> RemoteResultHandler
+ *
+ * Adapter class which is used to submit a result via {@link org.apache.beehive.test.tools.tch.core.remote.RemoteResultHandler}
+ * which is the rmi interface for submitting results from a remote test-vehicle back to the Tch VM
+ */
+public class ResultHandlerAdapter implements ResultHandler
+{
+
+ private RemoteResultHandler remoteResultHandler = null;
+
+ public ResultHandlerAdapter(RemoteResultHandler in)
+ {
+ remoteResultHandler = in;
+ }
+
+ public void submitResult(TestResultBean tr)
+ {
+ try
+ {
+ remoteResultHandler.submitResult(tr);
+ }
+ catch (RemoteException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void submitResult(TestResultBean tr, String resultName)
+ {
+ try
+ {
+ remoteResultHandler.submitResult(tr, resultName);
+ }
+ catch (RemoteException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/ResultHandlerAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestEntryKey.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestEntryKey.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestEntryKey.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestEntryKey.java Fri Aug 12 08:12:28 2005
@@ -1,131 +1,131 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.apache.beehive.test.tools.tch.util.CaseInsensitiveStringKey;
-
-/**
- * A TestEntryKey is a combination of the test's name, and the set of subtests names
- * this test will run (may be null if this test has no subtests).
- *
- * The toString method only does not bother returning subtest names, by design.
- *
- */
-public class TestEntryKey implements Cloneable
-{
- private CaseInsensitiveStringKey testName = null;
- private Collection subtestNames = null;
-
- public TestEntryKey(String inName)
- {
- this(new CaseInsensitiveStringKey(inName));
- }
-
- public TestEntryKey(CaseInsensitiveStringKey inName)
- {
- this(inName, null);
- }
-
- public TestEntryKey(CaseInsensitiveStringKey inName, Collection inSubtestNames)
- {
- testName = inName;
- if (inSubtestNames != null)
- subtestNames = new HashSet(inSubtestNames);
- }
-
- public int hashCode()
- {
- return testName.hashCode() ^ String.valueOf(subtestNames).hashCode();
- }
-
- public boolean equals(Object o)
- {
- if (o instanceof TestEntryKey)
- {
- TestEntryKey other = (TestEntryKey)o;
- if (testName.equals(other.getStringKey()))
- {
- if (subtestNames != null && other.subtestNames != null)
- {
- return subtestNames.equals(other.getSubtestNames());
- }
- else if (subtestNames == null && other.subtestNames == null)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public String toString()
- {
- //return testName.toString();
- return dump();
- }
-
- public String dump()
- {
- StringBuffer sb = new StringBuffer(testName.toString());
- if (getSubtestNames() != null)
- sb.append(" ").append(getSubtestNames());
- return sb.toString();
- }
-
- public String getTestName()
- {
- return getStringKey().toString();
- }
-
- private CaseInsensitiveStringKey getStringKey()
- {
- return testName;
- }
-
- private void setName(CaseInsensitiveStringKey name)
- {
- testName = name;
- }
-
- private void setSubtestNames(Collection inSubtestNames)
- {
- subtestNames = inSubtestNames;
- }
-
- private Collection getSubtestNames()
- {
- return subtestNames;
- }
-
- private void resetSubtestNames()
- {
- subtestNames = null;
- }
-
- public TestEntryKey getInstanceWithoutSubtests()
- {
- TestEntryKey twin = (TestEntryKey)clone();
- twin.resetSubtestNames();
- return twin;
- }
-
- public Object clone()
- {
- TestEntryKey ret = null;
- try
- {
- ret = (TestEntryKey)super.clone();
- } catch (CloneNotSupportedException ex)
- {
- // unexpected
- ex.printStackTrace();
- }
- ret.setName(getStringKey());
- ret.setSubtestNames(getSubtestNames());
-
- return ret;
- }
-
-}
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.apache.beehive.test.tools.tch.util.CaseInsensitiveStringKey;
+
+/**
+ * A TestEntryKey is a combination of the test's name, and the set of subtests names
+ * this test will run (may be null if this test has no subtests).
+ *
+ * The toString method only does not bother returning subtest names, by design.
+ *
+ */
+public class TestEntryKey implements Cloneable
+{
+ private CaseInsensitiveStringKey testName = null;
+ private Collection subtestNames = null;
+
+ public TestEntryKey(String inName)
+ {
+ this(new CaseInsensitiveStringKey(inName));
+ }
+
+ public TestEntryKey(CaseInsensitiveStringKey inName)
+ {
+ this(inName, null);
+ }
+
+ public TestEntryKey(CaseInsensitiveStringKey inName, Collection inSubtestNames)
+ {
+ testName = inName;
+ if (inSubtestNames != null)
+ subtestNames = new HashSet(inSubtestNames);
+ }
+
+ public int hashCode()
+ {
+ return testName.hashCode() ^ String.valueOf(subtestNames).hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o instanceof TestEntryKey)
+ {
+ TestEntryKey other = (TestEntryKey)o;
+ if (testName.equals(other.getStringKey()))
+ {
+ if (subtestNames != null && other.subtestNames != null)
+ {
+ return subtestNames.equals(other.getSubtestNames());
+ }
+ else if (subtestNames == null && other.subtestNames == null)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ //return testName.toString();
+ return dump();
+ }
+
+ public String dump()
+ {
+ StringBuffer sb = new StringBuffer(testName.toString());
+ if (getSubtestNames() != null)
+ sb.append(" ").append(getSubtestNames());
+ return sb.toString();
+ }
+
+ public String getTestName()
+ {
+ return getStringKey().toString();
+ }
+
+ private CaseInsensitiveStringKey getStringKey()
+ {
+ return testName;
+ }
+
+ private void setName(CaseInsensitiveStringKey name)
+ {
+ testName = name;
+ }
+
+ private void setSubtestNames(Collection inSubtestNames)
+ {
+ subtestNames = inSubtestNames;
+ }
+
+ private Collection getSubtestNames()
+ {
+ return subtestNames;
+ }
+
+ private void resetSubtestNames()
+ {
+ subtestNames = null;
+ }
+
+ public TestEntryKey getInstanceWithoutSubtests()
+ {
+ TestEntryKey twin = (TestEntryKey)clone();
+ twin.resetSubtestNames();
+ return twin;
+ }
+
+ public Object clone()
+ {
+ TestEntryKey ret = null;
+ try
+ {
+ ret = (TestEntryKey)super.clone();
+ } catch (CloneNotSupportedException ex)
+ {
+ // unexpected
+ ex.printStackTrace();
+ }
+ ret.setName(getStringKey());
+ ret.setSubtestNames(getSubtestNames());
+
+ return ret;
+ }
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestEntryKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestLogicTask.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestLogicTask.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestLogicTask.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestLogicTask.java Fri Aug 12 08:12:28 2005
@@ -1,24 +1,24 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import org.apache.beehive.test.tools.tch.core.process.ProcessEngine;
-import org.apache.beehive.test.tools.tch.task.Task;
-import org.apache.beehive.test.tools.tch.task.TaskContext;
-import org.apache.beehive.test.tools.tch.task.TaskException;
-
-/**
- * TestLogicTasks are just like regular Tasks, but support a few more Test
- * specific actions.
- *
- */
-
-public interface TestLogicTask extends Task
-{
- public ResultHandler getResultHandler();
- public void setResultHandler(ResultHandler in);
- public ProcessEngine getProcessEngine();
- public void setProcessEngine(ProcessEngine in);
- public void notifyTimeout();
- public boolean isCanLogStdout();
- public boolean isMustLogStdout();
- public TaskContext run(TaskContext inContext) throws TaskException;
-}
+package org.apache.beehive.test.tools.tch.core.test;
+
+import org.apache.beehive.test.tools.tch.core.process.ProcessEngine;
+import org.apache.beehive.test.tools.tch.task.Task;
+import org.apache.beehive.test.tools.tch.task.TaskContext;
+import org.apache.beehive.test.tools.tch.task.TaskException;
+
+/**
+ * TestLogicTasks are just like regular Tasks, but support a few more Test
+ * specific actions.
+ *
+ */
+
+public interface TestLogicTask extends Task
+{
+ public ResultHandler getResultHandler();
+ public void setResultHandler(ResultHandler in);
+ public ProcessEngine getProcessEngine();
+ public void setProcessEngine(ProcessEngine in);
+ public void notifyTimeout();
+ public boolean isCanLogStdout();
+ public boolean isMustLogStdout();
+ public TaskContext run(TaskContext inContext) throws TaskException;
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestLogicTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestNameResolutionException.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestNameResolutionException.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestNameResolutionException.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestNameResolutionException.java Fri Aug 12 08:12:28 2005
@@ -1,32 +1,32 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.beehive.test.tools.tch.core.LogicalTest;
-import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationException;
-
-public class TestNameResolutionException extends NonfatalValidationException
-{
- public TestNameResolutionException(LogicalTest test, LogicalTest otherTest)
- {
- super();
-
- Map params = new HashMap();
- int errorID = -1;
-
- params.put(ErrorMessageConstants.TESTNAME, test.getName());
-
- params.put(ErrorMessageConstants.CALLINGCHAIN, test.getCallingChain());
- params.put(
- ErrorMessageConstants.CALLINGCHAIN2,
- otherTest.getCallingChain());
- params.put(
- ErrorMessageConstants.LINE_SEPARATOR,
- System.getProperty("line.separator"));
- errorID = ErrorMessageConstants.TEST_NAME_COLLISION_ERROR_CODE;
-
- setInfo(errorID, params);
- }
-}
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.beehive.test.tools.tch.core.LogicalTest;
+import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationException;
+
+public class TestNameResolutionException extends NonfatalValidationException
+{
+ public TestNameResolutionException(LogicalTest test, LogicalTest otherTest)
+ {
+ super();
+
+ Map params = new HashMap();
+ int errorID = -1;
+
+ params.put(ErrorMessageConstants.TESTNAME, test.getName());
+
+ params.put(ErrorMessageConstants.CALLINGCHAIN, test.getCallingChain());
+ params.put(
+ ErrorMessageConstants.CALLINGCHAIN2,
+ otherTest.getCallingChain());
+ params.put(
+ ErrorMessageConstants.LINE_SEPARATOR,
+ System.getProperty("line.separator"));
+ errorID = ErrorMessageConstants.TEST_NAME_COLLISION_ERROR_CODE;
+
+ setInfo(errorID, params);
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestNameResolutionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestRegistry.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestRegistry.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestRegistry.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestRegistry.java Fri Aug 12 08:12:28 2005
@@ -1,1021 +1,1021 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.regexp.RE;
-
-import org.apache.beehive.test.tools.tch.core.AntProperties;
-import org.apache.beehive.test.tools.tch.core.DirtyClass;
-import org.apache.beehive.test.tools.tch.core.EntryPoint;
-import org.apache.beehive.test.tools.tch.core.LogicalTest;
-import org.apache.beehive.test.tools.tch.core.NonExistentLogicalTest;
-import org.apache.beehive.test.tools.tch.core.NoopLogicalTest;
-import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationAggregate;
-import org.apache.beehive.test.tools.tch.core.configuration.UnitConfigurationInfo;
-import org.apache.beehive.test.tools.tch.core.process.Process;
-import org.apache.beehive.test.tools.tch.core.process.ProcessRegistry;
-import org.apache.beehive.test.tools.tch.core.test.vehicle.TestVehicleRegistry;
-import org.apache.beehive.test.tools.tch.util.GeneralUtil;
-import org.apache.beehive.test.tools.tch.util.NoopCollection;
-import org.apache.beehive.test.tools.tch.util.OrderedMap;
-import org.apache.beehive.test.tools.tch.util.OrderedSet;
-
-public class TestRegistry
-{
- public static String sep = System.getProperty("line.separator");
-
- private static TestRegistry reg = null;
-
- private static TestVehicleRegistry testVehicleRegistry =
- TestVehicleRegistry.getRegistry();
- private static ProcessRegistry processRegistry =
- ProcessRegistry.getRegistry();
-
- //CaseInsensitiveStringKey -> Entry
- private OrderedMap testMap = new OrderedMap();
-
- // cache for the number of results we expect to log
- private static Integer expectedNumTests = null;
-
- private TestRegistry()
- {
- }
-
- public synchronized static TestRegistry getRegistry()
- {
- if (reg == null)
- reg = new TestRegistry();
- return reg;
- }
-
- private String getSubtestName(
- LogicalTest test,
- String fullyQualifiedTestName)
- {
- if (test.getNonQualifiedSubtestNames() != null)
- {
- for (Iterator iter = test.getNonQualifiedSubtestNames().iterator();
- iter.hasNext();
- )
- {
- String subtestName = (String)iter.next();
- if (fullyQualifiedTestName.endsWith(subtestName))
- return subtestName;
- }
- }
- return null;
- }
-
- /**
- * Given the tests that will run, returns all processes that need to be configured.
- * Note: This does not currently return admin servers in cases where only the managed
- * is mapped. It also does not return processes in a cluster.
- * @return Collection of Strings
- */
- public Collection getActiveProcessNames()
- {
- Collection rtn = new HashSet();
- if (AntProperties.isConfigureProcessesGloballyEnabled())
- {
- System.out.println("Global process configuration enabled");
- for (Iterator iter = processRegistry.getEntryIterator(); iter.hasNext();)
- {
- ProcessRegistry.Entry entry = (ProcessRegistry.Entry)iter.next();
- rtn.add(entry.getProcess().getName());
- }
- }
- else
- {
- for (Iterator iter = getAllTestEntryPointsThatWillRun().iterator();
- iter.hasNext();
- )
- {
- EntryPoint entrypoint = (EntryPoint)iter.next();
- // Test registry has no Entry for test-suite
- rtn.addAll(entrypoint.getContainedProcessNames());
- }
- }
- return rtn;
- }
-
- public synchronized void addLogicalTest(
- String name,
- LogicalTest inLogicalTest)
- throws TestNameResolutionException
- {
- checkForUniqueness(inLogicalTest);
- addLogicalTest(inLogicalTest);
- // add another key that maps to the same entry
- // that does not consider the subtests
- // so we can easily look this test up by name
- // (used for requiresRun/Success and also below in checkForUniqueness)
- addLogicalTest(
- inLogicalTest.getKey().getInstanceWithoutSubtests(),
- getLogicalTestEntry(inLogicalTest.getKey()));
- setReferencedExplicitly(name, inLogicalTest);
- registerSubtests(getLogicalTestEntry(inLogicalTest.getKey()));
- }
-
- private void checkForUniqueness(LogicalTest inLogicalTest)
- throws TestNameResolutionException
- {
-
- // VALIDATION ERROR
-
- // see if there would be a collision, ignoring any subtests.
- // (any logical test, with or without subtests, has at least one
- // key that does *not* honor its subtests.)
- // since at the xml level there is no "native" way to access subtests,
- // we need to start looking for collisions at the test level
- LogicalTest otherLogicalTest =
- getLogicalTest(inLogicalTest.getKey().getInstanceWithoutSubtests());
-
- if (otherLogicalTest != null)
- {
- // if the keys are the same, then this is a clear collision.
- if (inLogicalTest.getKey().equals(otherLogicalTest.getKey()))
- throw new TestNameResolutionException(inLogicalTest, otherLogicalTest);
- else
- {
- // there is still potential for collision here, check subtest situation
- Collection otherSubtests =
- otherLogicalTest.getNonQualifiedSubtestNames();
- Collection inSubtests = inLogicalTest.getNonQualifiedSubtestNames();
- // if they both don't log subtests, its a collision
- if (otherSubtests != null && inSubtests != null)
- {
- for (Iterator iter = inSubtests.iterator(); iter.hasNext();)
- {
- if (otherSubtests.contains(iter.next()))
- {
- // this is a collision with a logical test that we
- // already have stored (at least one subtest name is the same).
- // however, the keys for these
- // two logical tests are different, and so we have to
- // do something tricky.
- // as far as the map (testMap) is concerned, the logical test
- // we're trying to add here does not collide with
- // an existing entry.
- // so we're going to register a dummy logical test for it
- // that thinks it is filtered out. at runtime, this will
- // cause the duplicate test to not run
- NoopLogicalTest noop = new NoopLogicalTest();
- noop.setPassedFilter(false);
- addLogicalTest(inLogicalTest.getKey(), noop);
- throw new TestNameResolutionException(
- inLogicalTest,
- otherLogicalTest);
- }
- }
- }
- }
- }
- }
-
- private void addLogicalTest(LogicalTest test)
- {
- addLogicalTest(test.getKey(), test);
- }
-
- private void addLogicalTest(TestEntryKey key, LogicalTest test)
- {
- TestRegistry.Entry entry = getLogicalTestEntry(key);
- if (entry == null)
- entry = new TestRegistry.Entry(test);
- else
- entry.setLogicalTest(test);
- addLogicalTest(key, entry);
- }
-
- private void addLogicalTest(TestEntryKey key, TestRegistry.Entry entry)
- {
- testMap.put(key, entry);
- }
-
- private void setReferencedExplicitly(String name, LogicalTest logicalTest)
- {
- // kind of hacky
- if (AntProperties.isIndividualTestModeOn())
- for (Iterator iter = AntProperties.getIndividualTestNames().iterator();
- iter.hasNext();
- )
- if (name.equalsIgnoreCase((String)iter.next()))
- logicalTest.setExplicitlyReferenced();
- }
-
- // here we just add more keys to the map, all the fully qualified
- // subtest names. they all map to the same entry.
- private void registerSubtests(Entry entry)
- {
- if (entry.getLogicalTest().getFullyQualifiedSubtestNames() != null)
- {
- for (Iterator iter =
- entry.getLogicalTest().getFullyQualifiedSubtestNames().iterator();
- iter.hasNext();
- )
- {
- String name = (String)iter.next();
- setReferencedExplicitly(name, entry.getLogicalTest());
- addLogicalTest(new TestEntryKey(name), entry);
- }
- }
- }
-
- // adds a test vehicle to the entry
- public synchronized void addTestVehicle(
- TestEntryKey key,
- String inTestVehicleType,
- String inTestVehicleProcessName)
- {
- if (hasLogicalTestEntry(key))
- {
- getLogicalTestEntry(key).addTestVehicle(
- inTestVehicleType,
- inTestVehicleProcessName);
- }
- else
- {
- TestRegistry.Entry tre =
- new TestRegistry.Entry(inTestVehicleType, inTestVehicleProcessName);
- testMap.put(key, tre);
- }
- }
-
- /**
- * Returns test task by fully qualified name.
- */
- public LogicalTest getLogicalTest(String fullyQualifiedName)
- {
- return getLogicalTest(new TestEntryKey(fullyQualifiedName));
- }
-
- /**
- * Returns test task using a TestEntryKey.
- * A TestTask knows how to produce its key
- */
- public LogicalTest getLogicalTest(TestEntryKey key)
- {
- // System.out.println("+++++++++++++");
- // for (Iterator iter = testMap.keySet().iterator(); iter.hasNext();)
- // {
- // TestEntryKey foo = (TestEntryKey)iter.next();
- // System.out.println("key in map " + foo.dump());
- // System.out.println("THE KEY " + key.dump());
- // System.out.println("equal? " + foo.equals(key) + "\n");
- // }
- // System.out.println("+++++++++++++");
- Entry entry = getLogicalTestEntry(key);
- if (entry == null)
- {
- return null;
- }
- return entry.getLogicalTest();
- }
-
- /**
- * @param testName. Fully qualified logical test name.
- * @return boolean. True if test with this name has run, false otherwise.
- */
- public boolean hasRun(String testName)
- {
- return hasRun(new TestEntryKey(testName));
- }
-
- /**
- * @param key. A LogicalTest knows how to produce its own key.
- * @return True if the LogicalTest that produced the key has run, false otherwise.
- */
- public boolean hasRun(TestEntryKey key)
- {
- return hasResult(key);
- }
-
- public boolean hasSucceeded(String testName)
- {
- if (!hasRun(testName))
- {
- return false;
- }
- boolean succeeded =
- getLogicalTestEntry(testName).getResult().booleanValue();
- return succeeded;
- }
-
- private boolean hasResult(TestEntryKey key)
- {
- if (testMap.containsKey(key))
- {
- TestRegistry.Entry e = (TestRegistry.Entry)testMap.get(key);
- return e.hasResult();
- }
- return false;
- }
-
- private boolean hasLogicalTestEntry(TestEntryKey key)
- {
- return (getLogicalTestEntry(key) != null);
- }
-
- private TestRegistry.Entry getLogicalTestEntry(String name)
- {
- return getLogicalTestEntry(new TestEntryKey(name));
- }
-
- public TestRegistry.Entry getLogicalTestEntry(TestEntryKey key)
- {
- return (Entry)testMap.get(key);
- }
-
- /*
- * Skips all tests that will run that are currently in the registry.
- * Does this by first scanning through the test entries and marking them
- * skipped. Then we set DirtyClass to the "run" phase, and call perform()
- * on each task.
- * This is done so that the additional xml parse does not need to be done
- * in the event of a process auto-start problem
- * since skipAllTests can be called from AutoStartProcessesTask during the
- * init phase.
- */
- public void skipAllTests(String message)
- {
- Collection allTests = getAllLogicalTestEntriesThatWillRun();
-
- // Loop through tests in registry and mark them skipped
- Iterator iter = allTests.iterator();
- while (iter.hasNext())
- {
- Entry entry = (Entry)iter.next();
- LogicalTest logicalTest = entry.getLogicalTest();
- logicalTest.skip(message);
- }
- // Change to run mode (second pass)
- DirtyClass.setFirstPass(false);
- // Actually run these tests by calling perform() on each test. This will allow us
- // to utilize the skip processing for each test, which only happens at runtime,
- // without having to do the second XML parse. Currently the tests in the registry
- // were created from the init phase parse. We are assuming that the skip
- // will cause each test to actually log a skip result.. we are not expecting the
- // the tests to actually run anyway so this should be okay.
- iter = allTests.iterator();
- while (iter.hasNext())
- {
- Entry entry = (Entry)iter.next();
- LogicalTest logicalTest = entry.getLogicalTest();
- logicalTest.perform();
- }
- }
-
- /**
- * Add all tests which the specified LogicalTest depends on. This recursively
- * traverses requires clauses, as well as across all members of a independent-test-
- * @param testSet Ordered set of LogicalTests
- */
- private void addTestsBelow(Entry startTestEntry, OrderedSet testSet)
- {
- if (!startTestEntry.isValidationSkippedAtInitTime())
- {
- LogicalTest startTest = startTestEntry.getLogicalTest();
- String[] requiresRun = startTest.getRequiresRun();
- String[] requiresSuccess = startTest.getRequiresSuccess();
- int rr_len = (requiresRun == null) ? 0 : requiresRun.length;
- int rs_len = (requiresSuccess == null) ? 0 : requiresSuccess.length;
- String[] requiresArray = new String[rr_len + rs_len];
-
- int i = 0;
- for (i = 0; i < rr_len; ++i)
- {
- requiresArray[i] = requiresRun[i];
- }
- for (int j = 0; j < rs_len; ++j)
- {
- requiresArray[i + j] = requiresSuccess[j];
- }
-
- for (i = 0; i < requiresArray.length; ++i)
- {
- // Add all tests in the same entry point as the requires tests
- LogicalTest requireTest = getLogicalTest(requiresArray[i]);
- EntryPoint entryPoint = requireTest.getEntryPoint();
- Collection containedTests = entryPoint.getContainedLogicalTests();
- Iterator iter = containedTests.iterator();
- while (iter.hasNext())
- {
- Entry sameEntryPointTestEntry =
- getLogicalTestEntry(((LogicalTest)iter.next()).getKey());
- if (sameEntryPointTestEntry != startTestEntry)
- {
- // only need recursive call if this is not the same test entry. This will
- // short-circuit the recursion
- // recursively call this on each logical test in the requires
- addTestsBelow(sameEntryPointTestEntry, testSet);
- }
- }
- }
- }
- // add self
- testSet.add(startTestEntry);
- }
-
- // returns all test entries that will run. The collection is ordered
- // in the sequence that the tests will be run.
- public Collection getAllLogicalTestEntriesThatWillRun()
- {
- Collection logicalTestEntries = null;
- if (AntProperties.isIndividualTestModeOn())
- {
- Collection entryPoints = getAllTestEntryPointsThatWillRun();
- // the test entries will contain all test entries in the entrypoints
- // specified, as well as tests that are required by those entries
- logicalTestEntries = getAllLogicalTestEntriesForEntryPoints(entryPoints);
- }
- else
- logicalTestEntries = new OrderedSet(testMap.values());
-
- Set rtn = new OrderedSet(logicalTestEntries.size());
- for (Iterator iter = logicalTestEntries.iterator(); iter.hasNext();)
- {
- Entry entry = (Entry)iter.next();
- if (entry.willRun())
- rtn.add(entry);
- }
- return rtn;
- }
-
- /**
- * @see #getTestEntryPointsThatExistByName(Collection, Collection, Collection)
- *
- * @param testNames. The test names we are looking for.
- * @return Collection of EntryPoints
- */
- private Collection getTestEntryPointsThatExistByName(Collection testNames)
- {
- return getTestEntryPointsThatExistByName(
- testNames,
- new NoopCollection(),
- new NoopCollection());
- }
-
- /**
- * Given a Collection of testNames, returns the matching EntryPoint Objects.
- * Ignores testNames for which there's no matching entry.
- * The last two arguments are fake return values. They should not be
- * null, but otherwise have no effect on the behavior of this method.
- *
- * @param testNames. The test names for which we want to get EntryPoint Objects.
- * @param unresolvedNames. The test names that do not exist.
- * @param illegalNames. The test names that are invalid (applies to regular expressions only).
- * @return Collection of EntryPoints
- */
- public Collection getTestEntryPointsThatExistByName(
- Collection testNames,
- Collection unresolvedNames,
- Collection illegalNames)
- {
- OrderedSet ret = new OrderedSet();
- Collection matchingTestKeys =
- GeneralUtil.getRegexMatches(
- testNames,
- testMap.keySet(),
- unresolvedNames,
- illegalNames,
- RE.MATCH_CASEINDEPENDENT);
- for (Iterator iter = matchingTestKeys.iterator(); iter.hasNext();)
- {
- TestEntryKey key = (TestEntryKey)iter.next();
- Entry testEntry = getLogicalTestEntry(key);
-
- // add testEntry.willRun() check to prevent NPE in
- // configureSubtestsToRun()->isSubtest()
- // when TestRunner calls this after an auto-start failure causes all tests
- // to be skipped (testEntries will have a null LogicalTest)
- if ((testEntry != null) && (testEntry.willRun()))
- {
- configureSubtestsToRun(key.getTestName(), testEntry);
- LogicalTest logicalTest = testEntry.getLogicalTest();
- EntryPoint entryPoint = logicalTest.getEntryPoint();
- ret.add(entryPoint);
- }
- }
- return ret;
- }
-
- private void configureSubtestsToRun(
- String fullyQualifiedTestName,
- Entry testEntry)
- {
- String subtestName =
- getSubtestName(testEntry.getLogicalTest(), fullyQualifiedTestName);
-
- // if subtest name is null, we are not running a subtest
- if (subtestName != null)
- testEntry.addSubtestToRun(subtestName);
- }
-
- /**
- * Gets a Collection of all logical test entries in the system. This returns entries
- * even if Entry.willRun() returns false (metadata filters, or if failfast-validation=false,
- * tests that had validation failures get filtered).
- * Currently this is only called by the reference check validation.
- */
- public Collection getAllLogicalTestEntries()
- {
- Collection logicalTestEntries = new OrderedSet(testMap.values());
- return logicalTestEntries;
- }
-
- /**
- * Gets all test entries corresponding to the collection of entry points passed in.
- * It will also get all test entries which are required by those test entries as
- * specified in a requiresRun or requiresSuccess attribute.
- * Ordering is preserved since test entries should be returned in the order in
- * which they will run.
- */
- private Collection getAllLogicalTestEntriesForEntryPoints(Collection entryPoints)
- {
- OrderedSet ret = new OrderedSet();
- for (Iterator iter = entryPoints.iterator(); iter.hasNext();)
- {
- EntryPoint entryPoint = (EntryPoint)iter.next();
- Collection containedEntries = getContainedLogicalTestEntries(entryPoint);
- for (Iterator contained_iter = containedEntries.iterator();
- contained_iter.hasNext();
- )
- {
- // for each entry, call the recursive method
- Entry testEntry = (Entry)contained_iter.next();
- addTestsBelow(testEntry, ret);
- }
- }
- return ret;
- }
-
- private Collection getContainedLogicalTestEntries(EntryPoint entryPoint)
- {
- Collection ret = new OrderedSet();
- for (Iterator iter = entryPoint.getContainedLogicalTests().iterator();
- iter.hasNext();
- )
- {
- LogicalTest logicalTest = (LogicalTest)iter.next();
- Entry entry = getLogicalTestEntry(logicalTest.getKey());
- ret.add(entry);
- }
- return ret;
- }
-
- public Collection getAllTestEntryPointsThatWillRun()
- {
- Collection testEntryPoints = null;
- if (AntProperties.isIndividualTestModeOn())
- {
- Collection testNames = AntProperties.getIndividualTestNames();
- testEntryPoints = getTestEntryPointsThatExistByName(testNames);
- }
- else
- {
- testEntryPoints = new OrderedSet();
- // if test names not set, take everything
- for (Iterator iter = testMap.values().iterator(); iter.hasNext();)
- {
- LogicalTest test = ((Entry)iter.next()).getLogicalTest();
- testEntryPoints.add(test.getEntryPoint());
- }
- }
- return testEntryPoints;
- }
-
- /**
- * Returns number of tests we expect to log an outcome result for.
- * Can only be called after init-mode is complete.
- *
- * @return int
- */
- public synchronized int getExpectedNumTests()
- {
- if (expectedNumTests == null)
- {
- int numTests = 0;
- for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
- iter.hasNext();
- )
- {
- Entry entry = (Entry)iter.next();
- numTests += entry.getLogicalTest().getNumOutcomes();
- }
- expectedNumTests = new Integer(numTests);
- }
- return expectedNumTests.intValue();
- }
-
- /**
- * Returns number of tests we expect to validation skip.
- */
- public int getValidationSkippedNumTests()
- {
- int numTests = 0;
- for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
- iter.hasNext();
- )
- {
- Entry entry = (Entry)iter.next();
- if (entry.isValidationSkippedAtInitTime())
- numTests += entry.getLogicalTest().getNumOutcomes();
- }
- return numTests;
- }
-
- public NonfatalValidationAggregate getValidationErrorsForAllTestsConfiguredToRun()
- {
- NonfatalValidationAggregate localAggregate =
- new NonfatalValidationAggregate();
- for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
- iter.hasNext();
- )
- {
- Entry entry = (Entry)iter.next();
- LogicalTest test = entry.getLogicalTest();
- if (!test.isValid())
- localAggregate.addAll(test.getNonfatalValidationAggregate());
- }
- return localAggregate;
- }
-
- public String dump()
- {
- StringBuffer sb = new StringBuffer();
- sb.append("<test-reg>").append(sep);
- for (Iterator iter = testMap.keySet().iterator(); iter.hasNext();)
- {
- TestEntryKey key = (TestEntryKey)iter.next();
- Entry entry = (Entry)testMap.get(key);
- LogicalTest logicalTest = entry.getLogicalTest();
-
- sb
- .append("<test name=\"")
- .append(key.toString())
- .append("\">")
- .append(sep)
- .append(" <entry hash-code=\"")
- .append(entry.hashCode())
- .append("\">")
- .append(sep)
- .append("<logical-test>");
- if (logicalTest != null)
- sb
- .append(" <logical-test hash-code=\"")
- .append(logicalTest.hashCode())
- .append("\">")
- .append(sep)
- .append(" <logical-test-name>")
- .append(logicalTest.getName())
- .append(" </logical-test-name>")
- .append(sep);
- sb
- .append(" </logical-test>")
- .append(sep)
- .append(" </entry>")
- .append(sep)
- .append("</test>")
- .append(sep);
- }
- sb.append("</test-reg>").append(sep);
- return sb.toString();
- }
-
- public String toString()
- {
- return "Logical tests: " + testMap.keySet().toString() + "\n\n";
- }
-
- public class Entry
- {
- private Boolean result = null;
- private LogicalTest logicalTest = null;
-
- // All the processNames (Strings) mapped for this test
- private Collection processNames = new HashSet();
-
- // Process -> Collection of UnitConfigurationInfo,
- // not all Processes in here perhaps
- private Map unitConfigInfoMap = new HashMap();
-
- // An entry can have >1 test vehicle types (e.g. test-block with
- // multiple test-vehicles). Need to store the multiple types here
- // for proper domain gen purposes.
-
- // This maps testVehicleType -> (collection of process names)
- // This is only used for configuration dependency, not test execution.
- private Map testVehicleProcessMap = new HashMap();
-
- // which subtests are configured to run. default is all,
- // but if test-names set on command line, might include
- // subtests
- private Collection subtestsConfiguredToRun = null;
-
- public Entry(LogicalTest in)
- {
- logicalTest = in;
- }
-
- public Entry(String inTestVehicleType, String inTestVehicleProcessName)
- {
- // just add the initial test vehicle and process to the map
-
- // if test vehicle is local, there's no associated process
- Collection coll = new HashSet();
- if (!TestVehicleRegistry.isLocalTestVehicle(inTestVehicleType))
- {
- coll.add(inTestVehicleProcessName);
- }
- testVehicleProcessMap.put(inTestVehicleType, coll);
- }
-
- public Boolean getResult()
- {
- return result;
- }
-
- public void setLogicalTest(LogicalTest in)
- {
- logicalTest = in;
- }
-
- public void addSubtestToRun(String subtestName)
- {
- if (subtestsConfiguredToRun == null)
- {
- subtestsConfiguredToRun = new OrderedSet();
- }
- subtestsConfiguredToRun.add(subtestName);
- }
-
- public Collection getSubtestsConfiguredToRun()
- {
- return subtestsConfiguredToRun;
- }
-
- public void setResult(Boolean in)
- {
- result = in;
- }
-
- public boolean hasResult()
- {
- return result != null;
- }
-
- public LogicalTest getLogicalTest()
- {
- return logicalTest;
- }
-
- public boolean hasLogicalTest()
- {
- return logicalTest != null;
- }
-
- public boolean willRun()
- {
- if (logicalTest != null)
- return passedFilter();
- else
- return false;
- }
-
- /**
- * Internal method to check whether the logical test has passed its filter checks.
- *
- * @return true if filters have been passed
- */
- private boolean passedFilter()
- {
- return logicalTest.passedFilter();
- }
-
- public boolean isValidationSkippedAtInitTime()
- {
- if (logicalTest != null)
- return logicalTest.isValidationSkippedAtInitTime();
- else
- return false;
- }
-
- /**
- * Takes a Collection of Strings
- */
- public void setProcessNames(Collection in)
- {
- processNames = in;
- }
-
- /**
- * Returns a Collection of Strings
- */
- public Collection getProcessNames()
- {
- return processNames;
- }
-
- /**
- * Get all process types that correspond to the specified vehicle type
- * @return Collection of Strings
- */
- public Collection getTestVehicleProcessNames(String vehicleType)
- {
- Collection testVehicleProcessNames =
- (Collection)testVehicleProcessMap.get(vehicleType);
- return testVehicleProcessNames;
- }
-
- /**
- * Add the specified test vehicle / process name combination to the internal
- * map.
- * @param inVehicleType
- * @param inProcessName
- */
- public void addTestVehicle(String inVehicleType, String inProcessName)
- {
- Collection coll = (Collection)testVehicleProcessMap.get(inVehicleType);
- if (coll == null)
- {
- coll = new HashSet();
- coll.add(inProcessName);
- testVehicleProcessMap.put(inVehicleType, coll);
- }
- else
- {
- coll.add(inProcessName);
- }
- }
-
- /**
- * Get a list of all process names corresponding to test vehicles
- * which are a part of this entry.
- * @return Collection
- */
- public Collection getAllTestVehicleProcessNames()
- {
- HashSet rtn = new HashSet();
- Iterator iter = testVehicleProcessMap.keySet().iterator();
- // loop through all test vehicles in the map
- while (iter.hasNext())
- {
- String testVehicleType = (String)iter.next();
- Collection processNames =
- (Collection)testVehicleProcessMap.get(testVehicleType);
- rtn.addAll(processNames);
- }
- return rtn;
- }
-
- /**
- * Return a list of all test vehicle types
- * @param p
- * @return
- */
- public Collection getAllTestVehicleTypes()
- {
- return testVehicleProcessMap.keySet();
- }
-
- /**
- * Returns a collection of UnitConfigurationInfo
- */
- public Collection getUnitConfigurationInfo(Process p)
- {
- return (Collection)unitConfigInfoMap.get(p);
- }
-
- /**
- * Get a collection of all UnitConfigurationInfo for a specific process.
- * This would correspond to all UnitConfigurationInfo required for the current
- * entry.
- * This is only called by domain gen in order to map process handlers to their
- * associated UnitConfigurationInfo
- * @return collection of UnitConfigurationInfo
- */
- public Collection getTestVehicleUnitConfigurationInfo(String inProcessName)
- {
- ArrayList unitConfigList = new ArrayList();
- Iterator iter = testVehicleProcessMap.keySet().iterator();
- // loop through all test vehicles in the map
- while (iter.hasNext())
- {
- String testVehicleType = (String)iter.next();
- TestVehicleRegistry.Entry tvEntry =
- testVehicleRegistry.getTestVehicleEntry(testVehicleType);
- UnitConfigurationInfo info = null;
- if (tvEntry != null)
- {
- // get all process names which are associated with the current test vehicle (in the current entry)
- // Note: for normal situations, there will only be one item in the collection. However, for
- // test-block, there is only a single entry, but there could be multiple instances of the same
- // test-vehicle type using different processes nested in the block. In this case, all the process
- // names for that test-vehicle type will be in this collection
- Collection processNameList =
- (Collection)testVehicleProcessMap.get(testVehicleType);
- Iterator iter2 = processNameList.iterator();
- // loop through all process names associated with the current test vehicle and see
- // if it matches what we want.
- while (iter2.hasNext())
- {
- String processName = (String)iter2.next();
- // need to get the unit configuration info by using the
- // process type.
- if (inProcessName.equals(processName))
- {
- info =
- tvEntry.getUnitConfigurationInfo(
- processRegistry
- .getProcessEntryAssumeValidated(processName)
- .getProcessType()
- .getName());
- if (info != null)
- unitConfigList.add(info);
- }
- }
- }
- }
- return unitConfigList;
- }
-
- public synchronized void addUnitConfigurationInfo(
- Process p,
- UnitConfigurationInfo info)
- {
- Collection c = (Collection)unitConfigInfoMap.get(p);
- if (c == null)
- {
- c = new ArrayList();
- unitConfigInfoMap.put(p, c);
- }
- c.add(info);
- }
-
- /**
- * Takes Collection of UnitConfigurationInfo objects
- */
- private void addUnitConfigurationInfo(Process p, Collection info)
- {
- for (Iterator iter = info.iterator(); iter.hasNext();)
- {
- addUnitConfigurationInfo(p, (UnitConfigurationInfo)iter.next());
- }
- }
-
- /**
- * Takes Map of Process -> Collection of UnitConfigurationInfo objects
- */
- public void addUnitConfigurationInfo(Map info)
- {
- for (Iterator iter = info.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry)iter.next();
- addUnitConfigurationInfo(
- (Process)entry.getKey(),
- (Collection)entry.getValue());
- }
- }
-
- /*
- * Return a stringified form of test vehicle -> process mappings
- */
- public String testVehicleProcessToString()
- {
- StringBuffer map_string = new StringBuffer();
- Collection test_vehicle_types = getAllTestVehicleTypes();
- Iterator iter = test_vehicle_types.iterator();
- while (iter.hasNext())
- {
- String tv_type = (String)iter.next();
- map_string.append(tv_type);
- map_string.append(" -> [");
- Collection process_names = getTestVehicleProcessNames(tv_type);
- Iterator iter2 = process_names.iterator();
- while (iter2.hasNext())
- {
- String proc_name = (String)iter2.next();
- map_string.append(" " + proc_name + " ");
- }
- map_string.append("]\n");
- }
- return map_string.toString();
- }
-
- public String toString()
- {
- return "LogicalTest: "
- + logicalTest
- + "\n"
- + "subtests configured to run "
- + getSubtestsConfiguredToRun()
- + "\n";
- }
- }
-}
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.regexp.RE;
+
+import org.apache.beehive.test.tools.tch.core.AntProperties;
+import org.apache.beehive.test.tools.tch.core.DirtyClass;
+import org.apache.beehive.test.tools.tch.core.EntryPoint;
+import org.apache.beehive.test.tools.tch.core.LogicalTest;
+import org.apache.beehive.test.tools.tch.core.NonExistentLogicalTest;
+import org.apache.beehive.test.tools.tch.core.NoopLogicalTest;
+import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationAggregate;
+import org.apache.beehive.test.tools.tch.core.configuration.UnitConfigurationInfo;
+import org.apache.beehive.test.tools.tch.core.process.Process;
+import org.apache.beehive.test.tools.tch.core.process.ProcessRegistry;
+import org.apache.beehive.test.tools.tch.core.test.vehicle.TestVehicleRegistry;
+import org.apache.beehive.test.tools.tch.util.GeneralUtil;
+import org.apache.beehive.test.tools.tch.util.NoopCollection;
+import org.apache.beehive.test.tools.tch.util.OrderedMap;
+import org.apache.beehive.test.tools.tch.util.OrderedSet;
+
+public class TestRegistry
+{
+ public static String sep = System.getProperty("line.separator");
+
+ private static TestRegistry reg = null;
+
+ private static TestVehicleRegistry testVehicleRegistry =
+ TestVehicleRegistry.getRegistry();
+ private static ProcessRegistry processRegistry =
+ ProcessRegistry.getRegistry();
+
+ //CaseInsensitiveStringKey -> Entry
+ private OrderedMap testMap = new OrderedMap();
+
+ // cache for the number of results we expect to log
+ private static Integer expectedNumTests = null;
+
+ private TestRegistry()
+ {
+ }
+
+ public synchronized static TestRegistry getRegistry()
+ {
+ if (reg == null)
+ reg = new TestRegistry();
+ return reg;
+ }
+
+ private String getSubtestName(
+ LogicalTest test,
+ String fullyQualifiedTestName)
+ {
+ if (test.getNonQualifiedSubtestNames() != null)
+ {
+ for (Iterator iter = test.getNonQualifiedSubtestNames().iterator();
+ iter.hasNext();
+ )
+ {
+ String subtestName = (String)iter.next();
+ if (fullyQualifiedTestName.endsWith(subtestName))
+ return subtestName;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Given the tests that will run, returns all processes that need to be configured.
+ * Note: This does not currently return admin servers in cases where only the managed
+ * is mapped. It also does not return processes in a cluster.
+ * @return Collection of Strings
+ */
+ public Collection getActiveProcessNames()
+ {
+ Collection rtn = new HashSet();
+ if (AntProperties.isConfigureProcessesGloballyEnabled())
+ {
+ System.out.println("Global process configuration enabled");
+ for (Iterator iter = processRegistry.getEntryIterator(); iter.hasNext();)
+ {
+ ProcessRegistry.Entry entry = (ProcessRegistry.Entry)iter.next();
+ rtn.add(entry.getProcess().getName());
+ }
+ }
+ else
+ {
+ for (Iterator iter = getAllTestEntryPointsThatWillRun().iterator();
+ iter.hasNext();
+ )
+ {
+ EntryPoint entrypoint = (EntryPoint)iter.next();
+ // Test registry has no Entry for test-suite
+ rtn.addAll(entrypoint.getContainedProcessNames());
+ }
+ }
+ return rtn;
+ }
+
+ public synchronized void addLogicalTest(
+ String name,
+ LogicalTest inLogicalTest)
+ throws TestNameResolutionException
+ {
+ checkForUniqueness(inLogicalTest);
+ addLogicalTest(inLogicalTest);
+ // add another key that maps to the same entry
+ // that does not consider the subtests
+ // so we can easily look this test up by name
+ // (used for requiresRun/Success and also below in checkForUniqueness)
+ addLogicalTest(
+ inLogicalTest.getKey().getInstanceWithoutSubtests(),
+ getLogicalTestEntry(inLogicalTest.getKey()));
+ setReferencedExplicitly(name, inLogicalTest);
+ registerSubtests(getLogicalTestEntry(inLogicalTest.getKey()));
+ }
+
+ private void checkForUniqueness(LogicalTest inLogicalTest)
+ throws TestNameResolutionException
+ {
+
+ // VALIDATION ERROR
+
+ // see if there would be a collision, ignoring any subtests.
+ // (any logical test, with or without subtests, has at least one
+ // key that does *not* honor its subtests.)
+ // since at the xml level there is no "native" way to access subtests,
+ // we need to start looking for collisions at the test level
+ LogicalTest otherLogicalTest =
+ getLogicalTest(inLogicalTest.getKey().getInstanceWithoutSubtests());
+
+ if (otherLogicalTest != null)
+ {
+ // if the keys are the same, then this is a clear collision.
+ if (inLogicalTest.getKey().equals(otherLogicalTest.getKey()))
+ throw new TestNameResolutionException(inLogicalTest, otherLogicalTest);
+ else
+ {
+ // there is still potential for collision here, check subtest situation
+ Collection otherSubtests =
+ otherLogicalTest.getNonQualifiedSubtestNames();
+ Collection inSubtests = inLogicalTest.getNonQualifiedSubtestNames();
+ // if they both don't log subtests, its a collision
+ if (otherSubtests != null && inSubtests != null)
+ {
+ for (Iterator iter = inSubtests.iterator(); iter.hasNext();)
+ {
+ if (otherSubtests.contains(iter.next()))
+ {
+ // this is a collision with a logical test that we
+ // already have stored (at least one subtest name is the same).
+ // however, the keys for these
+ // two logical tests are different, and so we have to
+ // do something tricky.
+ // as far as the map (testMap) is concerned, the logical test
+ // we're trying to add here does not collide with
+ // an existing entry.
+ // so we're going to register a dummy logical test for it
+ // that thinks it is filtered out. at runtime, this will
+ // cause the duplicate test to not run
+ NoopLogicalTest noop = new NoopLogicalTest();
+ noop.setPassedFilter(false);
+ addLogicalTest(inLogicalTest.getKey(), noop);
+ throw new TestNameResolutionException(
+ inLogicalTest,
+ otherLogicalTest);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void addLogicalTest(LogicalTest test)
+ {
+ addLogicalTest(test.getKey(), test);
+ }
+
+ private void addLogicalTest(TestEntryKey key, LogicalTest test)
+ {
+ TestRegistry.Entry entry = getLogicalTestEntry(key);
+ if (entry == null)
+ entry = new TestRegistry.Entry(test);
+ else
+ entry.setLogicalTest(test);
+ addLogicalTest(key, entry);
+ }
+
+ private void addLogicalTest(TestEntryKey key, TestRegistry.Entry entry)
+ {
+ testMap.put(key, entry);
+ }
+
+ private void setReferencedExplicitly(String name, LogicalTest logicalTest)
+ {
+ // kind of hacky
+ if (AntProperties.isIndividualTestModeOn())
+ for (Iterator iter = AntProperties.getIndividualTestNames().iterator();
+ iter.hasNext();
+ )
+ if (name.equalsIgnoreCase((String)iter.next()))
+ logicalTest.setExplicitlyReferenced();
+ }
+
+ // here we just add more keys to the map, all the fully qualified
+ // subtest names. they all map to the same entry.
+ private void registerSubtests(Entry entry)
+ {
+ if (entry.getLogicalTest().getFullyQualifiedSubtestNames() != null)
+ {
+ for (Iterator iter =
+ entry.getLogicalTest().getFullyQualifiedSubtestNames().iterator();
+ iter.hasNext();
+ )
+ {
+ String name = (String)iter.next();
+ setReferencedExplicitly(name, entry.getLogicalTest());
+ addLogicalTest(new TestEntryKey(name), entry);
+ }
+ }
+ }
+
+ // adds a test vehicle to the entry
+ public synchronized void addTestVehicle(
+ TestEntryKey key,
+ String inTestVehicleType,
+ String inTestVehicleProcessName)
+ {
+ if (hasLogicalTestEntry(key))
+ {
+ getLogicalTestEntry(key).addTestVehicle(
+ inTestVehicleType,
+ inTestVehicleProcessName);
+ }
+ else
+ {
+ TestRegistry.Entry tre =
+ new TestRegistry.Entry(inTestVehicleType, inTestVehicleProcessName);
+ testMap.put(key, tre);
+ }
+ }
+
+ /**
+ * Returns test task by fully qualified name.
+ */
+ public LogicalTest getLogicalTest(String fullyQualifiedName)
+ {
+ return getLogicalTest(new TestEntryKey(fullyQualifiedName));
+ }
+
+ /**
+ * Returns test task using a TestEntryKey.
+ * A TestTask knows how to produce its key
+ */
+ public LogicalTest getLogicalTest(TestEntryKey key)
+ {
+ // System.out.println("+++++++++++++");
+ // for (Iterator iter = testMap.keySet().iterator(); iter.hasNext();)
+ // {
+ // TestEntryKey foo = (TestEntryKey)iter.next();
+ // System.out.println("key in map " + foo.dump());
+ // System.out.println("THE KEY " + key.dump());
+ // System.out.println("equal? " + foo.equals(key) + "\n");
+ // }
+ // System.out.println("+++++++++++++");
+ Entry entry = getLogicalTestEntry(key);
+ if (entry == null)
+ {
+ return null;
+ }
+ return entry.getLogicalTest();
+ }
+
+ /**
+ * @param testName. Fully qualified logical test name.
+ * @return boolean. True if test with this name has run, false otherwise.
+ */
+ public boolean hasRun(String testName)
+ {
+ return hasRun(new TestEntryKey(testName));
+ }
+
+ /**
+ * @param key. A LogicalTest knows how to produce its own key.
+ * @return True if the LogicalTest that produced the key has run, false otherwise.
+ */
+ public boolean hasRun(TestEntryKey key)
+ {
+ return hasResult(key);
+ }
+
+ public boolean hasSucceeded(String testName)
+ {
+ if (!hasRun(testName))
+ {
+ return false;
+ }
+ boolean succeeded =
+ getLogicalTestEntry(testName).getResult().booleanValue();
+ return succeeded;
+ }
+
+ private boolean hasResult(TestEntryKey key)
+ {
+ if (testMap.containsKey(key))
+ {
+ TestRegistry.Entry e = (TestRegistry.Entry)testMap.get(key);
+ return e.hasResult();
+ }
+ return false;
+ }
+
+ private boolean hasLogicalTestEntry(TestEntryKey key)
+ {
+ return (getLogicalTestEntry(key) != null);
+ }
+
+ private TestRegistry.Entry getLogicalTestEntry(String name)
+ {
+ return getLogicalTestEntry(new TestEntryKey(name));
+ }
+
+ public TestRegistry.Entry getLogicalTestEntry(TestEntryKey key)
+ {
+ return (Entry)testMap.get(key);
+ }
+
+ /*
+ * Skips all tests that will run that are currently in the registry.
+ * Does this by first scanning through the test entries and marking them
+ * skipped. Then we set DirtyClass to the "run" phase, and call perform()
+ * on each task.
+ * This is done so that the additional xml parse does not need to be done
+ * in the event of a process auto-start problem
+ * since skipAllTests can be called from AutoStartProcessesTask during the
+ * init phase.
+ */
+ public void skipAllTests(String message)
+ {
+ Collection allTests = getAllLogicalTestEntriesThatWillRun();
+
+ // Loop through tests in registry and mark them skipped
+ Iterator iter = allTests.iterator();
+ while (iter.hasNext())
+ {
+ Entry entry = (Entry)iter.next();
+ LogicalTest logicalTest = entry.getLogicalTest();
+ logicalTest.skip(message);
+ }
+ // Change to run mode (second pass)
+ DirtyClass.setFirstPass(false);
+ // Actually run these tests by calling perform() on each test. This will allow us
+ // to utilize the skip processing for each test, which only happens at runtime,
+ // without having to do the second XML parse. Currently the tests in the registry
+ // were created from the init phase parse. We are assuming that the skip
+ // will cause each test to actually log a skip result.. we are not expecting the
+ // the tests to actually run anyway so this should be okay.
+ iter = allTests.iterator();
+ while (iter.hasNext())
+ {
+ Entry entry = (Entry)iter.next();
+ LogicalTest logicalTest = entry.getLogicalTest();
+ logicalTest.perform();
+ }
+ }
+
+ /**
+ * Add all tests which the specified LogicalTest depends on. This recursively
+ * traverses requires clauses, as well as across all members of a independent-test-
+ * @param testSet Ordered set of LogicalTests
+ */
+ private void addTestsBelow(Entry startTestEntry, OrderedSet testSet)
+ {
+ if (!startTestEntry.isValidationSkippedAtInitTime())
+ {
+ LogicalTest startTest = startTestEntry.getLogicalTest();
+ String[] requiresRun = startTest.getRequiresRun();
+ String[] requiresSuccess = startTest.getRequiresSuccess();
+ int rr_len = (requiresRun == null) ? 0 : requiresRun.length;
+ int rs_len = (requiresSuccess == null) ? 0 : requiresSuccess.length;
+ String[] requiresArray = new String[rr_len + rs_len];
+
+ int i = 0;
+ for (i = 0; i < rr_len; ++i)
+ {
+ requiresArray[i] = requiresRun[i];
+ }
+ for (int j = 0; j < rs_len; ++j)
+ {
+ requiresArray[i + j] = requiresSuccess[j];
+ }
+
+ for (i = 0; i < requiresArray.length; ++i)
+ {
+ // Add all tests in the same entry point as the requires tests
+ LogicalTest requireTest = getLogicalTest(requiresArray[i]);
+ EntryPoint entryPoint = requireTest.getEntryPoint();
+ Collection containedTests = entryPoint.getContainedLogicalTests();
+ Iterator iter = containedTests.iterator();
+ while (iter.hasNext())
+ {
+ Entry sameEntryPointTestEntry =
+ getLogicalTestEntry(((LogicalTest)iter.next()).getKey());
+ if (sameEntryPointTestEntry != startTestEntry)
+ {
+ // only need recursive call if this is not the same test entry. This will
+ // short-circuit the recursion
+ // recursively call this on each logical test in the requires
+ addTestsBelow(sameEntryPointTestEntry, testSet);
+ }
+ }
+ }
+ }
+ // add self
+ testSet.add(startTestEntry);
+ }
+
+ // returns all test entries that will run. The collection is ordered
+ // in the sequence that the tests will be run.
+ public Collection getAllLogicalTestEntriesThatWillRun()
+ {
+ Collection logicalTestEntries = null;
+ if (AntProperties.isIndividualTestModeOn())
+ {
+ Collection entryPoints = getAllTestEntryPointsThatWillRun();
+ // the test entries will contain all test entries in the entrypoints
+ // specified, as well as tests that are required by those entries
+ logicalTestEntries = getAllLogicalTestEntriesForEntryPoints(entryPoints);
+ }
+ else
+ logicalTestEntries = new OrderedSet(testMap.values());
+
+ Set rtn = new OrderedSet(logicalTestEntries.size());
+ for (Iterator iter = logicalTestEntries.iterator(); iter.hasNext();)
+ {
+ Entry entry = (Entry)iter.next();
+ if (entry.willRun())
+ rtn.add(entry);
+ }
+ return rtn;
+ }
+
+ /**
+ * @see #getTestEntryPointsThatExistByName(Collection, Collection, Collection)
+ *
+ * @param testNames. The test names we are looking for.
+ * @return Collection of EntryPoints
+ */
+ private Collection getTestEntryPointsThatExistByName(Collection testNames)
+ {
+ return getTestEntryPointsThatExistByName(
+ testNames,
+ new NoopCollection(),
+ new NoopCollection());
+ }
+
+ /**
+ * Given a Collection of testNames, returns the matching EntryPoint Objects.
+ * Ignores testNames for which there's no matching entry.
+ * The last two arguments are fake return values. They should not be
+ * null, but otherwise have no effect on the behavior of this method.
+ *
+ * @param testNames. The test names for which we want to get EntryPoint Objects.
+ * @param unresolvedNames. The test names that do not exist.
+ * @param illegalNames. The test names that are invalid (applies to regular expressions only).
+ * @return Collection of EntryPoints
+ */
+ public Collection getTestEntryPointsThatExistByName(
+ Collection testNames,
+ Collection unresolvedNames,
+ Collection illegalNames)
+ {
+ OrderedSet ret = new OrderedSet();
+ Collection matchingTestKeys =
+ GeneralUtil.getRegexMatches(
+ testNames,
+ testMap.keySet(),
+ unresolvedNames,
+ illegalNames,
+ RE.MATCH_CASEINDEPENDENT);
+ for (Iterator iter = matchingTestKeys.iterator(); iter.hasNext();)
+ {
+ TestEntryKey key = (TestEntryKey)iter.next();
+ Entry testEntry = getLogicalTestEntry(key);
+
+ // add testEntry.willRun() check to prevent NPE in
+ // configureSubtestsToRun()->isSubtest()
+ // when TestRunner calls this after an auto-start failure causes all tests
+ // to be skipped (testEntries will have a null LogicalTest)
+ if ((testEntry != null) && (testEntry.willRun()))
+ {
+ configureSubtestsToRun(key.getTestName(), testEntry);
+ LogicalTest logicalTest = testEntry.getLogicalTest();
+ EntryPoint entryPoint = logicalTest.getEntryPoint();
+ ret.add(entryPoint);
+ }
+ }
+ return ret;
+ }
+
+ private void configureSubtestsToRun(
+ String fullyQualifiedTestName,
+ Entry testEntry)
+ {
+ String subtestName =
+ getSubtestName(testEntry.getLogicalTest(), fullyQualifiedTestName);
+
+ // if subtest name is null, we are not running a subtest
+ if (subtestName != null)
+ testEntry.addSubtestToRun(subtestName);
+ }
+
+ /**
+ * Gets a Collection of all logical test entries in the system. This returns entries
+ * even if Entry.willRun() returns false (metadata filters, or if failfast-validation=false,
+ * tests that had validation failures get filtered).
+ * Currently this is only called by the reference check validation.
+ */
+ public Collection getAllLogicalTestEntries()
+ {
+ Collection logicalTestEntries = new OrderedSet(testMap.values());
+ return logicalTestEntries;
+ }
+
+ /**
+ * Gets all test entries corresponding to the collection of entry points passed in.
+ * It will also get all test entries which are required by those test entries as
+ * specified in a requiresRun or requiresSuccess attribute.
+ * Ordering is preserved since test entries should be returned in the order in
+ * which they will run.
+ */
+ private Collection getAllLogicalTestEntriesForEntryPoints(Collection entryPoints)
+ {
+ OrderedSet ret = new OrderedSet();
+ for (Iterator iter = entryPoints.iterator(); iter.hasNext();)
+ {
+ EntryPoint entryPoint = (EntryPoint)iter.next();
+ Collection containedEntries = getContainedLogicalTestEntries(entryPoint);
+ for (Iterator contained_iter = containedEntries.iterator();
+ contained_iter.hasNext();
+ )
+ {
+ // for each entry, call the recursive method
+ Entry testEntry = (Entry)contained_iter.next();
+ addTestsBelow(testEntry, ret);
+ }
+ }
+ return ret;
+ }
+
+ private Collection getContainedLogicalTestEntries(EntryPoint entryPoint)
+ {
+ Collection ret = new OrderedSet();
+ for (Iterator iter = entryPoint.getContainedLogicalTests().iterator();
+ iter.hasNext();
+ )
+ {
+ LogicalTest logicalTest = (LogicalTest)iter.next();
+ Entry entry = getLogicalTestEntry(logicalTest.getKey());
+ ret.add(entry);
+ }
+ return ret;
+ }
+
+ public Collection getAllTestEntryPointsThatWillRun()
+ {
+ Collection testEntryPoints = null;
+ if (AntProperties.isIndividualTestModeOn())
+ {
+ Collection testNames = AntProperties.getIndividualTestNames();
+ testEntryPoints = getTestEntryPointsThatExistByName(testNames);
+ }
+ else
+ {
+ testEntryPoints = new OrderedSet();
+ // if test names not set, take everything
+ for (Iterator iter = testMap.values().iterator(); iter.hasNext();)
+ {
+ LogicalTest test = ((Entry)iter.next()).getLogicalTest();
+ testEntryPoints.add(test.getEntryPoint());
+ }
+ }
+ return testEntryPoints;
+ }
+
+ /**
+ * Returns number of tests we expect to log an outcome result for.
+ * Can only be called after init-mode is complete.
+ *
+ * @return int
+ */
+ public synchronized int getExpectedNumTests()
+ {
+ if (expectedNumTests == null)
+ {
+ int numTests = 0;
+ for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
+ iter.hasNext();
+ )
+ {
+ Entry entry = (Entry)iter.next();
+ numTests += entry.getLogicalTest().getNumOutcomes();
+ }
+ expectedNumTests = new Integer(numTests);
+ }
+ return expectedNumTests.intValue();
+ }
+
+ /**
+ * Returns number of tests we expect to validation skip.
+ */
+ public int getValidationSkippedNumTests()
+ {
+ int numTests = 0;
+ for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
+ iter.hasNext();
+ )
+ {
+ Entry entry = (Entry)iter.next();
+ if (entry.isValidationSkippedAtInitTime())
+ numTests += entry.getLogicalTest().getNumOutcomes();
+ }
+ return numTests;
+ }
+
+ public NonfatalValidationAggregate getValidationErrorsForAllTestsConfiguredToRun()
+ {
+ NonfatalValidationAggregate localAggregate =
+ new NonfatalValidationAggregate();
+ for (Iterator iter = getAllLogicalTestEntriesThatWillRun().iterator();
+ iter.hasNext();
+ )
+ {
+ Entry entry = (Entry)iter.next();
+ LogicalTest test = entry.getLogicalTest();
+ if (!test.isValid())
+ localAggregate.addAll(test.getNonfatalValidationAggregate());
+ }
+ return localAggregate;
+ }
+
+ public String dump()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<test-reg>").append(sep);
+ for (Iterator iter = testMap.keySet().iterator(); iter.hasNext();)
+ {
+ TestEntryKey key = (TestEntryKey)iter.next();
+ Entry entry = (Entry)testMap.get(key);
+ LogicalTest logicalTest = entry.getLogicalTest();
+
+ sb
+ .append("<test name=\"")
+ .append(key.toString())
+ .append("\">")
+ .append(sep)
+ .append(" <entry hash-code=\"")
+ .append(entry.hashCode())
+ .append("\">")
+ .append(sep)
+ .append("<logical-test>");
+ if (logicalTest != null)
+ sb
+ .append(" <logical-test hash-code=\"")
+ .append(logicalTest.hashCode())
+ .append("\">")
+ .append(sep)
+ .append(" <logical-test-name>")
+ .append(logicalTest.getName())
+ .append(" </logical-test-name>")
+ .append(sep);
+ sb
+ .append(" </logical-test>")
+ .append(sep)
+ .append(" </entry>")
+ .append(sep)
+ .append("</test>")
+ .append(sep);
+ }
+ sb.append("</test-reg>").append(sep);
+ return sb.toString();
+ }
+
+ public String toString()
+ {
+ return "Logical tests: " + testMap.keySet().toString() + "\n\n";
+ }
+
+ public class Entry
+ {
+ private Boolean result = null;
+ private LogicalTest logicalTest = null;
+
+ // All the processNames (Strings) mapped for this test
+ private Collection processNames = new HashSet();
+
+ // Process -> Collection of UnitConfigurationInfo,
+ // not all Processes in here perhaps
+ private Map unitConfigInfoMap = new HashMap();
+
+ // An entry can have >1 test vehicle types (e.g. test-block with
+ // multiple test-vehicles). Need to store the multiple types here
+ // for proper domain gen purposes.
+
+ // This maps testVehicleType -> (collection of process names)
+ // This is only used for configuration dependency, not test execution.
+ private Map testVehicleProcessMap = new HashMap();
+
+ // which subtests are configured to run. default is all,
+ // but if test-names set on command line, might include
+ // subtests
+ private Collection subtestsConfiguredToRun = null;
+
+ public Entry(LogicalTest in)
+ {
+ logicalTest = in;
+ }
+
+ public Entry(String inTestVehicleType, String inTestVehicleProcessName)
+ {
+ // just add the initial test vehicle and process to the map
+
+ // if test vehicle is local, there's no associated process
+ Collection coll = new HashSet();
+ if (!TestVehicleRegistry.isLocalTestVehicle(inTestVehicleType))
+ {
+ coll.add(inTestVehicleProcessName);
+ }
+ testVehicleProcessMap.put(inTestVehicleType, coll);
+ }
+
+ public Boolean getResult()
+ {
+ return result;
+ }
+
+ public void setLogicalTest(LogicalTest in)
+ {
+ logicalTest = in;
+ }
+
+ public void addSubtestToRun(String subtestName)
+ {
+ if (subtestsConfiguredToRun == null)
+ {
+ subtestsConfiguredToRun = new OrderedSet();
+ }
+ subtestsConfiguredToRun.add(subtestName);
+ }
+
+ public Collection getSubtestsConfiguredToRun()
+ {
+ return subtestsConfiguredToRun;
+ }
+
+ public void setResult(Boolean in)
+ {
+ result = in;
+ }
+
+ public boolean hasResult()
+ {
+ return result != null;
+ }
+
+ public LogicalTest getLogicalTest()
+ {
+ return logicalTest;
+ }
+
+ public boolean hasLogicalTest()
+ {
+ return logicalTest != null;
+ }
+
+ public boolean willRun()
+ {
+ if (logicalTest != null)
+ return passedFilter();
+ else
+ return false;
+ }
+
+ /**
+ * Internal method to check whether the logical test has passed its filter checks.
+ *
+ * @return true if filters have been passed
+ */
+ private boolean passedFilter()
+ {
+ return logicalTest.passedFilter();
+ }
+
+ public boolean isValidationSkippedAtInitTime()
+ {
+ if (logicalTest != null)
+ return logicalTest.isValidationSkippedAtInitTime();
+ else
+ return false;
+ }
+
+ /**
+ * Takes a Collection of Strings
+ */
+ public void setProcessNames(Collection in)
+ {
+ processNames = in;
+ }
+
+ /**
+ * Returns a Collection of Strings
+ */
+ public Collection getProcessNames()
+ {
+ return processNames;
+ }
+
+ /**
+ * Get all process types that correspond to the specified vehicle type
+ * @return Collection of Strings
+ */
+ public Collection getTestVehicleProcessNames(String vehicleType)
+ {
+ Collection testVehicleProcessNames =
+ (Collection)testVehicleProcessMap.get(vehicleType);
+ return testVehicleProcessNames;
+ }
+
+ /**
+ * Add the specified test vehicle / process name combination to the internal
+ * map.
+ * @param inVehicleType
+ * @param inProcessName
+ */
+ public void addTestVehicle(String inVehicleType, String inProcessName)
+ {
+ Collection coll = (Collection)testVehicleProcessMap.get(inVehicleType);
+ if (coll == null)
+ {
+ coll = new HashSet();
+ coll.add(inProcessName);
+ testVehicleProcessMap.put(inVehicleType, coll);
+ }
+ else
+ {
+ coll.add(inProcessName);
+ }
+ }
+
+ /**
+ * Get a list of all process names corresponding to test vehicles
+ * which are a part of this entry.
+ * @return Collection
+ */
+ public Collection getAllTestVehicleProcessNames()
+ {
+ HashSet rtn = new HashSet();
+ Iterator iter = testVehicleProcessMap.keySet().iterator();
+ // loop through all test vehicles in the map
+ while (iter.hasNext())
+ {
+ String testVehicleType = (String)iter.next();
+ Collection processNames =
+ (Collection)testVehicleProcessMap.get(testVehicleType);
+ rtn.addAll(processNames);
+ }
+ return rtn;
+ }
+
+ /**
+ * Return a list of all test vehicle types
+ * @param p
+ * @return
+ */
+ public Collection getAllTestVehicleTypes()
+ {
+ return testVehicleProcessMap.keySet();
+ }
+
+ /**
+ * Returns a collection of UnitConfigurationInfo
+ */
+ public Collection getUnitConfigurationInfo(Process p)
+ {
+ return (Collection)unitConfigInfoMap.get(p);
+ }
+
+ /**
+ * Get a collection of all UnitConfigurationInfo for a specific process.
+ * This would correspond to all UnitConfigurationInfo required for the current
+ * entry.
+ * This is only called by domain gen in order to map process handlers to their
+ * associated UnitConfigurationInfo
+ * @return collection of UnitConfigurationInfo
+ */
+ public Collection getTestVehicleUnitConfigurationInfo(String inProcessName)
+ {
+ ArrayList unitConfigList = new ArrayList();
+ Iterator iter = testVehicleProcessMap.keySet().iterator();
+ // loop through all test vehicles in the map
+ while (iter.hasNext())
+ {
+ String testVehicleType = (String)iter.next();
+ TestVehicleRegistry.Entry tvEntry =
+ testVehicleRegistry.getTestVehicleEntry(testVehicleType);
+ UnitConfigurationInfo info = null;
+ if (tvEntry != null)
+ {
+ // get all process names which are associated with the current test vehicle (in the current entry)
+ // Note: for normal situations, there will only be one item in the collection. However, for
+ // test-block, there is only a single entry, but there could be multiple instances of the same
+ // test-vehicle type using different processes nested in the block. In this case, all the process
+ // names for that test-vehicle type will be in this collection
+ Collection processNameList =
+ (Collection)testVehicleProcessMap.get(testVehicleType);
+ Iterator iter2 = processNameList.iterator();
+ // loop through all process names associated with the current test vehicle and see
+ // if it matches what we want.
+ while (iter2.hasNext())
+ {
+ String processName = (String)iter2.next();
+ // need to get the unit configuration info by using the
+ // process type.
+ if (inProcessName.equals(processName))
+ {
+ info =
+ tvEntry.getUnitConfigurationInfo(
+ processRegistry
+ .getProcessEntryAssumeValidated(processName)
+ .getProcessType()
+ .getName());
+ if (info != null)
+ unitConfigList.add(info);
+ }
+ }
+ }
+ }
+ return unitConfigList;
+ }
+
+ public synchronized void addUnitConfigurationInfo(
+ Process p,
+ UnitConfigurationInfo info)
+ {
+ Collection c = (Collection)unitConfigInfoMap.get(p);
+ if (c == null)
+ {
+ c = new ArrayList();
+ unitConfigInfoMap.put(p, c);
+ }
+ c.add(info);
+ }
+
+ /**
+ * Takes Collection of UnitConfigurationInfo objects
+ */
+ private void addUnitConfigurationInfo(Process p, Collection info)
+ {
+ for (Iterator iter = info.iterator(); iter.hasNext();)
+ {
+ addUnitConfigurationInfo(p, (UnitConfigurationInfo)iter.next());
+ }
+ }
+
+ /**
+ * Takes Map of Process -> Collection of UnitConfigurationInfo objects
+ */
+ public void addUnitConfigurationInfo(Map info)
+ {
+ for (Iterator iter = info.entrySet().iterator(); iter.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ addUnitConfigurationInfo(
+ (Process)entry.getKey(),
+ (Collection)entry.getValue());
+ }
+ }
+
+ /*
+ * Return a stringified form of test vehicle -> process mappings
+ */
+ public String testVehicleProcessToString()
+ {
+ StringBuffer map_string = new StringBuffer();
+ Collection test_vehicle_types = getAllTestVehicleTypes();
+ Iterator iter = test_vehicle_types.iterator();
+ while (iter.hasNext())
+ {
+ String tv_type = (String)iter.next();
+ map_string.append(tv_type);
+ map_string.append(" -> [");
+ Collection process_names = getTestVehicleProcessNames(tv_type);
+ Iterator iter2 = process_names.iterator();
+ while (iter2.hasNext())
+ {
+ String proc_name = (String)iter2.next();
+ map_string.append(" " + proc_name + " ");
+ }
+ map_string.append("]\n");
+ }
+ return map_string.toString();
+ }
+
+ public String toString()
+ {
+ return "LogicalTest: "
+ + logicalTest
+ + "\n"
+ + "subtests configured to run "
+ + getSubtestsConfiguredToRun()
+ + "\n";
+ }
+ }
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestSuiteRegistry.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestSuiteRegistry.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestSuiteRegistry.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestSuiteRegistry.java Fri Aug 12 08:12:28 2005
@@ -1,71 +1,71 @@
-package org.apache.beehive.test.tools.tch.core.test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.beehive.test.tools.tch.core.TestSuiteTask;
-
-public class TestSuiteRegistry
-{
- private static TestSuiteRegistry reg = null;
-
- private Map entryMap = new HashMap(); //String -> Entry
-
- private TestSuiteRegistry() {}
-
- public synchronized static TestSuiteRegistry getRegistry()
- {
- if (reg == null)
- reg = new TestSuiteRegistry();
- return reg;
- }
-
- public synchronized void addEntry(Object key, TestSuiteTask t)
- // throws TestSuiteResolutionException
- {
- if(entryMap.containsKey(key))
- {
- //VALIDATION_ERROR
- //throw new TestSuiteResolutionException(key,t);
- }
- else
- entryMap.put(key, new TestSuiteRegistry.Entry(t));
- }
-
- public TestSuiteRegistry.Entry getEntry(Object key)
- {
- return (TestSuiteRegistry.Entry)entryMap
- .get(key);
- }
-
- public String toString()
- {
- return entryMap.toString();
- }
-
- public class Entry
- {
- private TestSuiteTask task = null;
-
- public Entry(TestSuiteTask inTask)
- {
- task = inTask;
- }
-
- public TestSuiteTask getInitTimeTaskInstance()
- {
- return task;
- }
-
- public String toString()
- {
- return "TestSuiteTask: "+task+"\n";
- }
- }
-}
-
-
-
-
-
-
+package org.apache.beehive.test.tools.tch.core.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.beehive.test.tools.tch.core.TestSuiteTask;
+
+public class TestSuiteRegistry
+{
+ private static TestSuiteRegistry reg = null;
+
+ private Map entryMap = new HashMap(); //String -> Entry
+
+ private TestSuiteRegistry() {}
+
+ public synchronized static TestSuiteRegistry getRegistry()
+ {
+ if (reg == null)
+ reg = new TestSuiteRegistry();
+ return reg;
+ }
+
+ public synchronized void addEntry(Object key, TestSuiteTask t)
+ // throws TestSuiteResolutionException
+ {
+ if(entryMap.containsKey(key))
+ {
+ //VALIDATION_ERROR
+ //throw new TestSuiteResolutionException(key,t);
+ }
+ else
+ entryMap.put(key, new TestSuiteRegistry.Entry(t));
+ }
+
+ public TestSuiteRegistry.Entry getEntry(Object key)
+ {
+ return (TestSuiteRegistry.Entry)entryMap
+ .get(key);
+ }
+
+ public String toString()
+ {
+ return entryMap.toString();
+ }
+
+ public class Entry
+ {
+ private TestSuiteTask task = null;
+
+ public Entry(TestSuiteTask inTask)
+ {
+ task = inTask;
+ }
+
+ public TestSuiteTask getInitTimeTaskInstance()
+ {
+ return task;
+ }
+
+ public String toString()
+ {
+ return "TestSuiteTask: "+task+"\n";
+ }
+ }
+}
+
+
+
+
+
+
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/test/TestSuiteRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native