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 [48/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/AntProperties.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/AntProperties.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/AntProperties.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/AntProperties.java Fri Aug 12 08:12:28 2005
@@ -1,1429 +1,1429 @@
-package org.apache.beehive.test.tools.tch.core;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-import org.apache.beehive.test.tools.tch.DebugLevels;
-import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationAggregate;
-import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationException;
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-import org.apache.beehive.test.tools.tch.util.GeneralUtil;
-import org.apache.beehive.test.tools.tch.util.NestedRuntimeException;
-import org.apache.beehive.test.tools.tch.util.PropertyResolver;
-import org.apache.beehive.test.tools.tch.util.ValueHandler;
-import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
-import org.apache.beehive.test.tools.tch.util.xml.DynamicPropNodeVisitor;
-import org.apache.beehive.test.tools.tch.util.xml.NestedXMLProcessingException;
-
-public final class AntProperties
- extends org.apache.beehive.test.tools.tch.util.AntProperties
- implements PropertyNames
-{
- private static Collection tchProps = new HashSet();
- private static Map defaults = new HashMap();
- private static Map forcedValues = new HashMap();
- private static Collection exclusions = new HashSet();
- private static Collection javaExclusions = new HashSet();
-
- public static void populate()
- {
- try
- {
- populateMetadata();
- }
- catch (Exception e)
- {
- throw new NestedRuntimeException(e);
- }
- }
-
- public static void validate()
- {
- validateTchProperties();
- }
-
- public static boolean isExcluded(String propName)
- {
- return exclusions.contains(propName);
- }
-
- public static boolean isJavaExcluded(String propName)
- {
- return javaExclusions.contains(propName);
- }
-
- public static Collection getTchExcludedPropNames()
- {
- return Collections.unmodifiableCollection(exclusions);
- }
-
- public static Collection getJavaExcludedPropNames()
- {
- return Collections.unmodifiableCollection(javaExclusions);
- }
-
- private static Map nondefaultForcedValProps = null;
- public static synchronized Map getNondefaultForcedValueProps()
- {
- if (nondefaultForcedValProps == null)
- {
- nondefaultForcedValProps = new HashMap();
- for (Iterator iter = forcedValues.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry)iter.next();
- if (!AntProperties
- .isDefault((String)entry.getKey(), (String)entry.getValue()))
- nondefaultForcedValProps.put(entry.getKey(), entry.getValue());
- }
- }
- return nondefaultForcedValProps;
- }
-
- public static boolean isForcedProp(String propName)
- {
- return forcedValues.containsKey(propName);
- }
-
- public static boolean isDefault(String propName, String propValue)
- {
- if (defaults.containsKey(propName))
- return defaults.get(propName).equals(propValue);
- else
- return false; //no default, so can't be a default value
- }
-
- public static String getDefault(String name)
- {
- return (String)defaults.get(name);
- }
-
- public static boolean getBooleanWithAutoDefault(String propname)
- {
- return getGlobalBoolean(propname, getDefault(propname));
- }
-
- public static boolean getLiveBooleanWithAutoDefault(String propname)
- {
- return getLiveGlobalBoolean(propname, getDefault(propname));
- }
-
- public static String getPropertyWithAutoDefault(String propname)
- {
- return getGlobalProperty(propname, getDefault(propname));
- }
-
- /**
- * Get the admin port used for management operations on Tch.
- * This will be the rmi registry port.
- * @return
- */
- public static int getTchAdminPort()
- {
- int rtn = -1;
- try
- {
- rtn =
- Integer.parseInt(
- getPropertyWithAutoDefault(
- appendTch(TCH_MANAGEMENT_ADMIN_PORT_PROPERTY))
- .trim());
- }
- catch (Exception ex)
- {
- // this will happen if AntProperties has not been initialized
- // (if running server-side, or in other VM). This shouldn't
- // ever get called.
- }
- return rtn;
- }
-
- //Descriptively named, typesafe methods for *all* the properties accessed!
- public static int getCodeCoverageEnabled()
- {
- // hack to get this working server-side for now
- int rtn = 0;
- try
- {
- rtn =
- Integer.parseInt(
- getPropertyWithAutoDefault(
- appendTch(TCH_CODECOVE_ENABLED_PROPERTY))
- .trim());
- }
- catch (Exception ex)
- {
- // this will happen if AntProperties has not been initialized
- // (if running server-side, or in other VM)
- }
- return rtn;
- }
-
- public static boolean isDebugOn()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_DEBUG_PROPERTY));
- }
-
- public static boolean isAntFileGenEnabled()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_ANT_FILE_GEN));
- }
-
- public static boolean isConfigureProcessesGloballyEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_CONFIGURE_GLOBALLY));
- }
-
- public static boolean isWriteProcessDataPropsFileEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_WRITE_PROCESS_ATTRIBUTES_FILE));
- }
-
- public static String getChangenumber()
- {
- return getGlobalProperty(appendTch(TCH_CHANGENUMBER));
- }
-
- public static String getHostname()
- {
- return getGlobalProperty(appendTch(TCH_HOSTNAME));
- }
-
- public static boolean isInitModeOnly()
- {
- return getLiveBooleanWithAutoDefault(
- appendTch(TCH_INIT_MODE_ONLY_PROPERTY));
- }
-
- public static boolean isSilentlyIgnoreFilteredTestsEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_FILTER_IGNORE_TEST_PROPERTY));
-
- }
-
- public static void setInitModeOnly(boolean in)
- {
- setProperty(
- appendTch(TCH_INIT_MODE_ONLY_PROPERTY),
- String.valueOf(in));
- }
-
- public static boolean isValidationFailed()
- {
- return getLiveBooleanWithAutoDefault(
- appendTch(TCH_INTERNAL_VALIDATION_FAILED));
- }
-
- public static boolean isTestNameLengthValidationEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_VALIDATE_TEST_NAME_LENGTH_PROPERTY));
- }
-
- public static boolean mergeProcessOutputStreams()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_MERGE_OUTPUT_STREAMS));
- }
-
- public static boolean shutdownVMTestVehicleAfterTest()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_TEST_VEHICLE_VM_SHUTDOWN_AFTER_TEST));
- }
-
- public static boolean shutdownVMTestVehicleIfProblem()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_TEST_VEHICLE_VM_SHUTDOWN_IF_PROBLEM));
- }
-
- public static boolean writeCmdFiles()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_WRITE_CMD_PROPERTY));
- }
-
- public static void setValidationFailed(boolean in)
- {
- setProperty(
- appendTch(TCH_INTERNAL_VALIDATION_FAILED),
- String.valueOf(in));
- }
-
- public static String getBaseDir()
- {
- return getGlobalProperty(appendTch(TCH_BASEDIR_PROPERTY));
- }
-
- public static File getLogBasedir()
- {
- return new File(
- getPropertyWithAutoDefault(appendTch(TCH_LOG_BASEDIR)));
- }
-
- public static File getLoggerConfFile()
- {
- return new File(
- getPropertyWithAutoDefault(appendTch(TCH_LOG_CONFFILE)));
- }
-
- public static File getProcessLogBasedir()
- {
- return new File(
- getPropertyWithAutoDefault(appendTch(TCH_PROCESS_LOG_BASEDIR)));
- }
-
- public static boolean isProcessLogBasedirSet()
- {
- return (
- getGlobalProperty(appendTch(TCH_PROCESS_LOG_BASEDIR)) != null);
- }
-
- public static String getGTLFLogExtension()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_LOG_GTLF_EXTENSION_PROPERTY));
- }
-
- public static String getHomeDir()
- {
- return getGlobalProperty(appendTch(TCH_HOME_PROPERTY));
- }
-
- public static boolean areJavaoptsSet()
- {
- return (getJavaopts() != null);
- }
-
- public static String getJavaopts()
- {
- return getGlobalProperty(appendTch(TCH_JAVAOPTS_PROPERTY));
- }
-
- public static Collection getIndividualTestNames()
- {
- String s = getGlobalProperty(appendTch(TCH_TEST_NAMES_PROPERTY));
- if (s != null)
- {
- List ret = new ArrayList();
- TchUtils.parseStringToStrings(s, DELIMITER, ret);
- return ret;
- }
- return null;
- }
-
- public static boolean isIndividualTestModeOn()
- {
- return (
- getIndividualTestNames() != null && !getIndividualTestNames().isEmpty());
- }
-
- public static boolean isJunitLogOnlyFailureEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_JUNIT_FORCE_FAILURE));
- }
-
- public static boolean isJunitValidateMethodNamesEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_JUNIT_VALIDATE_METHOD_NAMES));
- }
-
- public static boolean isJunitValidateClassEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_JUNIT_VALIDATE_CLASS));
- }
-
- public static boolean isIndividualJavatestMethodNamesSet()
- {
- return getGlobalProperty(appendTch(TCH_TEST_METHODS_PROPERTY))
- != null;
- }
-
- /**
- * Controls whether to do a 1ms sleep between timestamping each outcome result.
- * This insures that no two result outcomes in a single test run will have the
- * same exectime.
- *
- * @return indicates whether to sleep 1ms between outcome result timestamping
- */
- public static boolean isStaggerResultTimeEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_STAGGER_RESULT_TIME_PROPERTY));
- }
-
- private static final String DESCRIPTION = "description";
- private static final String USAGE = "usage";
- private static final String CR_LIST = "crlist";
- private static final String TEST_LEVEL = "testlevel";
- private static Collection fieldSet = new HashSet(4);
- static {
- fieldSet.add(DESCRIPTION);
- fieldSet.add(USAGE);
- fieldSet.add(CR_LIST);
- fieldSet.add(TEST_LEVEL);
- }
-
- public static Set getTestInfo() throws AntPropertiesException
- {
- String s = getGlobalProperty(appendTch(TCH_TEST_INFO_PROPERTY));
- if (s != null)
- {
- String[] arr = TchUtils.parseString(s, DELIMITER);
- Set printSet = new HashSet(arr.length);
- for (int i = 0; i < arr.length; i++)
- {
- String s1 = arr[i].toLowerCase(); //FIXME localize lowercase logic
- if (fieldSet.contains(s1))
- printSet.add(s1);
- else
- //VALIDATION ERROR
- throw new AntPropertiesException(
- "The values for the "
- + appendTch(TCH_TEST_INFO_PROPERTY)
- + " property must be one of these: "
- + fieldSet);
- }
- return printSet;
- }
- else
- return null;
- }
-
- public static boolean isProcessBaseHomeSet()
- {
- return (
- getGlobalProperty(appendTch(TCH_PROCESS_BASE_HOME_DIR)) != null);
- }
-
- public static File getProcessBaseHome()
- {
- return new File(
- getGlobalProperty(appendTch(TCH_PROCESS_BASE_HOME_DIR)));
- }
-
- public static String getBaseLogfileName()
- {
- return getPropertyWithAutoDefault(appendTch(TCH_LOG_NAME_PROPERTY));
- }
-
- public static Integer getLogDebugLevel()
- {
- String s =
- getPropertyWithAutoDefault(
- appendTch(TCH_LOG_DEBUG_LEVEL_PROPERTY));
- if (s == null)
- {
- /* display all debug messages by default */
- return new Integer(DebugLevels.ALL);
- }
- else
- {
- try
- {
- int debuglevel = Integer.parseInt(s);
- if (debuglevel > DebugLevels.ALL)
- {
- return new Integer(DebugLevels.ALL);
- }
- return new Integer(debuglevel);
- }
- catch (NumberFormatException nfe)
- {
- return new Integer(DebugLevels.ALL);
- }
- }
- }
-
- /**
- * Returns the string that represents how tch should be launched
- * for rerunning failures.
- * @return String
- */
- public static String getReplicationEntryPoint()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_REPLICATION_ENTRY_POINT_PROPERTY));
- }
-
- /**
- * Returns the string that represents how tch should be launched
- * for rerunning failures.
- * @return String
- */
- public static String getReplicationInfo()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_REPLICATION_INFO_PROPERTY));
- }
-
- /**
- * If false, our replication command line uses unix syntax for
- * referencing environment variables (${NAME})
- * If true, we print the same replication command line twice,
- * once with unix syntax and once with win syntax (%NAME%) for
- * referencing environment variables.
- *
- * Note that this switch is ignored if
- * tch.prop-val-subtitution is disabled.
- *
- * @return boolean
- */
- public static boolean isReplicationWinCmdlineEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_REPLICATION_PRINT_WIN_CMDLINE));
- }
-
- /**
- * Decides if for the tch command line (not the java command line)
- * we should set tch.javaopts. The default is true.
- *
- * Depending on the environment setup, this should be enabled or disabled.
- * If most classes Tch needs are in the system classpath ($CLASSPATH),
- * then typically we want to include tch.javaopts in the generated command
- * line, as it won't be too long, and contain any extra classes or VM settings
- * that are not part of the "standard" system configuration.
- *
- * However, if the system classpath is empty and if a custom ant wrapper is
- * used to launch Tch, which will setup the classpath, then tch.javaopts
- * should probably not be set on the Tch command line, as it makes it very long.
- * Instead, the entry point for Tch (see getReplicationEntryPoint()) should be
- * set to the custom ant script.
- *
- * @return boolean
- */
- public static boolean isReplicationJavaoptsEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_REPLICATION_ADD_JAVAOPTS_PROPERTY));
- }
-
- public static String getLogDateFormat()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_LOG_DATE_FORMAT_PROPERTY));
- }
-
- public static boolean getLogProgressInfo()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_PROGRESS_INFO_PROPERTY));
- }
-
- public static boolean isLogStdoutAsInform()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_STDOUT_AS_INFORM_PROPERTY));
- }
-
- public static boolean isLogInformAsDetails()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_INFORM_AS_DETAILS_PROPERTY));
- }
-
- public static String getGlobalTestVehicle()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_GLOBAL_TEST_VEHICLE_PROPERTY));
- }
-
- public static boolean isGlobalTestVehicleSet()
- {
- return (
- getGlobalProperty(appendTch(TCH_GLOBAL_TEST_VEHICLE_PROPERTY))
- != null);
- }
-
- public static String getGlobalTestVehicleProcess()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_GLOBAL_TEST_VEHICLE_PROCESS_PROPERTY));
- }
-
- public static boolean getTestInfoAlsoRun()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_TEST_INFO_ALSO_RUN_PROPERTY));
- }
-
- public static boolean isFilterAdoptTestNamesEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_FILTER_ADOPT_TESTNAMES));
- }
-
- public static Integer getTestLevelFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_TEST_LEVEL_PROPERTY));
- if (s != null)
- return new Integer(Integer.parseInt(s.trim()));
- else
- return null;
- }
-
- public static String getStatusFilter()
- {
- return getGlobalProperty(appendTch(TCH_FILTER_STATUS_PROPERTY));
- }
-
- public static Collection getDBListFilter()
- {
- String s = getGlobalProperty(appendTch(TCH_FILTER_DB_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getMiscInfoFilter()
- {
- String s = getGlobalProperty(appendTch(TCH_FILTER_MISC_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getOwnerListFilter()
- {
- String s = getGlobalProperty(appendTch(TCH_FILTER_OWNERS_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getDomainListFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_DOMAINS_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getServerModesListFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_SERVER_MODES_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getConversationsListFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_CONVERSATIONS_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getFrequenciesListFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_FREQUENCIES_PROPERTY));
- if (s != null)
- {
- // also accept '+' as delimter because the cc setup sucks.
- String delimiter = DELIMITER;
- if (s.indexOf('+') > -1)
- delimiter = "+";
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, delimiter, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getWebappsListFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_WEBAPPS_PROPERTY));
- if (s != null)
- {
- // also accept '+' as delimter because the cc setup sucks.
- String delimiter = DELIMITER;
- if (s.indexOf('+') > -1)
- delimiter = "+";
- Collection rtn = new HashSet();
- TchUtils.parseStringToStrings(s, delimiter, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static Collection getCRListFilter()
- {
- String s = getGlobalProperty(appendTch(TCH_FILTER_CRS_PROPERTY));
- if (s != null)
- {
- Collection rtn = new HashSet();
- TchUtils.parseStringToIntegers(s, DELIMITER, rtn);
- return rtn;
- }
- else
- return null;
- }
-
- public static boolean isCRListFilterMatchAll()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_FILTER_CRS_MATCH_ALL_PROPERTY));
- }
-
- public static boolean isLogBannersEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_BANNERS_PROPERTY));
- }
-
- public static boolean isLogToStdoutEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_TO_STDOUT_PROPERTY));
- }
-
- public static boolean isLogTestNamesEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_TEST_NAMES_PROPERTY));
- }
-
- public static boolean isLogGTLFEnabled()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_LOG_GTLF_PROPERTY));
- }
-
- /**
- * get the log-custom class, if it's specified
- * could return null
- */
- public static String getCustomLoggerClass()
- {
- return getGlobalProperty(appendTch(TCH_LOG_CUSTOM_PROPERTY));
- }
- public static String getCustomLogSuffix()
- {
- return getGlobalProperty(
- appendTch(TCH_LOG_CUSTOM_SUFFIX_PROPERTY),
- "log");
- }
-
- public static boolean isLogVerboseDebugEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_VERBOSE_DEBUG_PROPERTY));
- }
-
- public static boolean isLogComparisonEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_COMPARISON_PROPERTY));
- }
-
- public static boolean isLogCompositeEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_LOG_COMPOSITE_PROPERTY));
- }
-
- public static boolean threaddumpsEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_THREADDUMPS_PROPERTY));
- }
-
- public static Boolean getKnownFailuresFilter()
- {
- String s =
- getGlobalProperty(appendTch(TCH_FILTER_KNOWN_FAILURES_PROPERTY));
- if (s != null)
- return new Boolean(GeneralUtil.parseBoolean(s.trim()));
- else
- return null;
- }
-
- public static Boolean getSSLFilter()
- {
- String s = getGlobalProperty(appendTch(TCH_FILTER_SSL_PROPERTY));
- if (s != null)
- {
- if (s.equalsIgnoreCase("on"))
- return new Boolean(true);
- if (s.equalsIgnoreCase("off"))
- return new Boolean(false);
- //VALIDATION ERROR
- NonfatalValidationAggregate.addException(
- new NonfatalValidationException(
- ErrorMessageConstants.SSL_PROPERTY_ERROR_CODE,
- ErrorMessageConstants.PROPNAME,
- appendTch(TCH_FILTER_SSL_PROPERTY)));
- return null; //dummy
- }
- else
- return null;
- }
-
- public static String getClientTypeFilter()
- {
- return getGlobalProperty(
- appendTch(TCH_FILTER_CLIENT_TYPE_PROPERTY));
- }
-
- public static String getSecurityTypeFilter()
- {
- return getGlobalProperty(
- appendTch(TCH_FILTER_SECURITY_TYPE_PROPERTY));
- }
-
- public static String getProcessConfigName()
- {
- String rtn = getGlobalProperty(PROCESS_CONFIG_PROPERTY);
- if (rtn == null) //only check the old name if the new one is not defined
- rtn = getGlobalProperty(CONFIG_FILE_PROPERTY);
- return rtn;
- }
-
- private static List processConfigFiles = null;
-
- public synchronized static List getAllProcessConfigFiles()
- {
- if (processConfigFiles == null)
- {
- if (getProcessConfigName() == null)
- {
- return null;
- }
- processConfigFiles = new ArrayList(); // Files
- Collection fileNamesColl = new ArrayList(); // Strings
- TchUtils.parseStringToStrings(
- getProcessConfigName(),
- DELIMITER,
- fileNamesColl);
-
- for (Iterator iter = fileNamesColl.iterator(); iter.hasNext();)
- {
- String processConfigFileName = (String)iter.next();
- File processConfigFile = new File(processConfigFileName);
- if (!processConfigFile.isAbsolute())
- {
- processConfigFile =
- new File(AntProperties.getBaseDir(), processConfigFileName);
- processConfigFile = TchUtils.getCanonicalFile(processConfigFile);
- }
- processConfigFiles.add(processConfigFile);
- }
- processConfigFiles = Collections.unmodifiableList(processConfigFiles);
- }
- return processConfigFiles;
- }
-
- public static int getTestTimeoutSeconds()
- {
- return Integer.parseInt(
- getPropertyWithAutoDefault(
- appendTch(TCH_TEST_TIMEOUT_SECONDS_PROPERTY))
- .trim());
- }
-
- public static boolean isRunTimeoutEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_RUN_TIMEOUT_PROPERTY));
- }
-
- public static int getRunTimeoutSeconds()
- {
- return Integer.parseInt(
- getPropertyWithAutoDefault(
- appendTch(TCH_RUN_TIMEOUT_SECONDS_PROPERTY))
- .trim());
- }
-
- public static boolean isTestTimeoutEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_TEST_TIMEOUT_PROPERTY));
- }
-
- public static boolean isConfigDependecyExplicitlyDisabled()
- {
- return (isConfigDependencySet() && !isConfigDependenciesEnabled());
- }
-
- private static boolean isConfigDependencySet()
- {
- return (
- getGlobalProperty(appendTch(TCH_CONFIG_DEPENDENCY_ON_PROPERTY))
- != null);
- }
-
- public static boolean isConfigDependenciesEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_CONFIG_DEPENDENCY_ON_PROPERTY));
- }
-
- public static String getRootTestSuiteName()
- {
- return getGlobalProperty(TEST_SUITE_PROPERTY);
- }
-
- public static boolean isSchemaValidationOn()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_SCHEMA_VALIDATION_PROPERTY));
- }
-
- public static boolean isVerboseOn()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_VERBOSE_PROPERTY));
- }
-
- /**
- * Check whether verbose validation is turned on. This seems to control
- * whether validation failures are actually printed out, or if it just
- * results in a build exception.
- *
- * @return boolean state for this flag
- */
- public static boolean isVerboseValidationOn()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_VERBOSE_VALIDATION_PROPERTY));
- }
-
- public static boolean failBuild()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_FAIL_BUILD_PROPERTY));
- }
-
- public static boolean isFailfastValidationOn()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_FAILFAST_VALIDATION_PROPERTY));
- }
-
- public static File getValidationErrorMetadataFile()
- {
- return new File(
- getHomeDir(),
- getPropertyWithAutoDefault(
- appendTch(TCH_VALIDATION_METADATA_FILE_PROPERTY)));
- }
-
- public static boolean isPropValSubstitutionEnabled()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROP_VAL_SUBSTITUTION));
- }
-
- public static boolean isAutoStartSet()
- {
- return getGlobalProperty(appendTch(TCH_AUTO_START_PROPERTY))
- != null;
- }
-
- public static boolean getAutoStart()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_AUTO_START_PROPERTY));
- }
-
- public static boolean isWindowSet()
- {
- return getGlobalProperty(appendTch(TCH_WINDOW_PROPERTY)) != null;
- }
-
- public static boolean getWindow()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_WINDOW_PROPERTY));
- }
-
- public static boolean isKeepAliveOn()
- {
- if (getGlobalProperty(appendTch(TCH_KEEP_PROCESSES_ALIVE_PROPERTY))
- != null)
- {
- // deprecated
- return getBooleanWithAutoDefault(
- appendTch(TCH_KEEP_PROCESSES_ALIVE_PROPERTY));
- }
- else
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_KEEP_ALIVE_PROPERTY));
- }
- }
-
- public static boolean isCtrlCCleanupOn()
- {
- return getBooleanWithAutoDefault(
- appendTch(TCH_PROCESS_CTRLC_CLEANUP_PROPERTY));
- }
-
- public static String getUpdateJunitSource()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_UPDATE_JUNIT_SOURCE));
- }
-
- public static int getLocalListenerPort()
- {
- return Integer.parseInt(
- getPropertyWithAutoDefault(
- appendTch(TCH_LOCAL_LISTENER_PORT_PROPERTY))
- .trim());
- }
-
- public static String getSTFOperationFiles()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_STF_OPERATION_FILES_PROPERTY));
- }
-
- public static String getSTFComponentFiles()
- {
- return getPropertyWithAutoDefault(
- appendTch(TCH_STF_COMPONENT_FILES_PROPERTY));
- }
-
- public static Map sortProperties(Map properties)
- {
- Map rtn = new TreeMap(new PropertyComparator());
- rtn.putAll(properties);
- return rtn;
- }
-
- public static Map filterTchInternalProperties(Map properties)
- {
- for (Iterator iter = properties.keySet().iterator(); iter.hasNext();)
- {
- if (((String)iter.next()).startsWith(appendTch(TCH_INTERNAL)))
- iter.remove();
- }
- return properties;
- }
-
- private static Map environment = new HashMap();
- public synchronized static Map getEnvironment()
- {
- // a bit hacky, but basically the call to this method may happen
- // before Ant has loaded the environment
- // (this is assuming that we do load the environment in our tch-root file)
- // so we keep trying until we got some environment variables
- // this would fail on an OS that does not have any environment variables set,
- // which seems pretty much impossible
- if (environment.isEmpty())
- {
- for (Iterator iter = getGlobalProperties().entrySet().iterator();
- iter.hasNext();
- )
- {
- Map.Entry entry = (Map.Entry)iter.next();
- if (((String)entry.getKey()).startsWith(ENV_PREFIX))
- {
- environment.put(entry.getKey(), entry.getValue());
- }
- }
- if (!environment.isEmpty())
- environment = Collections.unmodifiableMap(environment);
- }
- return environment;
- }
-
- private static Map strippedDynamicProcessConfigProps = null;
- private static Map dynamicProcessConfigProps = null;
-
- public synchronized static Map getStrippedDynamicProcessConfigProps()
- {
- if (strippedDynamicProcessConfigProps == null)
- {
- strippedDynamicProcessConfigProps =
- getDynamicProcessConfigPropsInternal(true);
- }
- return strippedDynamicProcessConfigProps;
- }
-
- public synchronized static Map getDynamicProcessConfigProps()
- {
- if (dynamicProcessConfigProps == null)
- {
- dynamicProcessConfigProps = getDynamicProcessConfigPropsInternal(false);
- }
- return dynamicProcessConfigProps;
- }
-
- /**
- * Add the prefix back on to a stripped dynamic process config.
- */
- public static String getUnstrippedDynamicProcessConfigProp(String propname)
- {
- String expr = appendTch(TCH_DYNAMIC_PROCESS_PREFIX);
- return expr + propname;
- }
-
- /**
- * Return the stripped version of the dynamic property name passed in.
- */
- public static String getStrippedDynamicProcessConfigProp(String propname)
- {
- String expr = appendTch(TCH_DYNAMIC_PROCESS_CONFIG);
- int startInd = expr.length() - 1;
- return propname.substring(startInd);
- }
-
- private static Map getDynamicProcessConfigPropsInternal(boolean toStrip)
- {
- Map dynamicProcessConfigProps = new HashMap();
- // strippedDynamicProcessConfigProps = new HashMap();
- String expr = appendTch(TCH_DYNAMIC_PROCESS_CONFIG);
- for (Iterator iter = getGlobalProperties().entrySet().iterator();
- iter.hasNext();
- )
- {
- Map.Entry entry = (Map.Entry)iter.next();
- String key = (String)entry.getKey();
- if (matchesExpr(key, expr))
- {
- int startInd = toStrip ? expr.length() - 1 : 0;
- // strippedDynamicProcessConfigProps.put(
- // key.substring(startInd),
- // entry.getValue());
- dynamicProcessConfigProps.put(
- key.substring(startInd),
- entry.getValue());
- }
- }
- // return Collections.unmodifiableMap(strippedDynamicProcessConfigProps);
- return Collections.unmodifiableMap(dynamicProcessConfigProps);
- }
-
- private static Map commandLineProps = null;
- public synchronized static Map getCommandLineProps()
- {
- if (commandLineProps == null)
- {
- commandLineProps = new HashMap();
- for (Iterator iter = getGlobalProperties().entrySet().iterator();
- iter.hasNext();
- )
- {
- Map.Entry entry = (Map.Entry)iter.next();
- String key = (String)entry.getKey();
- if (matchesExpr(key, ".*"))
- {
- commandLineProps.put(key.substring(1), entry.getValue());
- }
- }
- commandLineProps = Collections.unmodifiableMap(commandLineProps);
- }
- return commandLineProps;
- }
-
- public static File getWsTestSettings()
- {
- return new File(
- getGlobalProperty(appendTch(TCH_WSTEST_CONFIG_FILE)));
- }
-
- public static boolean isWsTestVerbose()
- {
- return getBooleanWithAutoDefault(appendTch(TCH_WSTEST_VERBOSE));
- }
-
- public static String getWsTestHost()
- {
- return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_HOST));
- }
-
- public static String getWsTestBuildDir()
- {
- return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_BUILDDIR));
- }
-
- public static String getWsTestInstallDir()
- {
- return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_INSTALLDIR));
- }
-
- public static String appendTch(String propName)
- {
- return TCH_PREFIX + propName;
- }
-
- //private utils
- private static void validateTchProperties()
- {
- for (Iterator iter = getGlobalProperties().keySet().iterator();
- iter.hasNext();
- )
- {
- String prop = (String)iter.next();
- if (prop.startsWith(TCH_PREFIX)
- && !checkIfKnownPropAndRegister(prop))
- {
- Map params = new HashMap(2);
- params.put(ErrorMessageConstants.PROPNAME, prop);
- params.put(
- ErrorMessageConstants.PROPFILENAME,
- getHomeDir() + "/" + TCH_PROP_FILENAME);
- NonfatalValidationAggregate.addException(
- new NonfatalValidationException(
- ErrorMessageConstants.TCH_PROPERTIES_ERROR_CODE,
- params));
- }
- }
- }
-
- private static Map updateProps = null;
- public static Map getUpdateProps()
- {
- if (updateProps == null)
- {
- updateProps = new HashMap();
- String expr = appendTch(TCH_ALL_UPDATE_PROPS);
- for (Iterator iter = getGlobalProperties().entrySet().iterator();
- iter.hasNext();
- )
- {
- Map.Entry entry = (Map.Entry)iter.next();
- String key = (String)entry.getKey();
- if (matchesExpr(key, expr))
- {
- updateProps.put(key, entry.getValue());
- }
- }
- }
- return updateProps;
- }
-
- // for matching simple regular expression of form s1.s2.sn.*
- private static boolean matchesExpr(String propName, String propExpression)
- {
- if (propExpression.endsWith(".*"))
- {
- int maxLength = propExpression.length() - 1;
- if (propName.length() > maxLength)
- {
- String propExpressionSub = propExpression.substring(0, maxLength);
- if (propName.startsWith(propExpressionSub))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- private static boolean checkIfKnownPropAndRegister(String propName)
- {
- if (tchProps.contains(propName))
- {
- return true;
- }
- else
- {
- // quick way to support tch.foo.* in tch-props
- for (Iterator iter = tchProps.iterator(); iter.hasNext();)
- {
- String p = (String)iter.next();
- if (matchesExpr(propName, p))
- {
- // if this (simple) regexp is excluded, need to add this match
- // to the "excluded" Collection
- if (isExcluded(p))
- {
- exclusions.add(propName);
- }
- return true;
- }
- }
- }
- return false;
- }
-
- private static void populateMetadata()
- {
- //DOM code
- Document root = null;
- try
- {
- root =
- DomUtils.instantiateDom(
- new File(
- AntProperties.getHomeDir()
- + File.separator
- + TCH_PROP_FILENAME));
- }
- catch (NestedXMLProcessingException ex)
- {
- throw new NestedRuntimeException(ex);
- }
-
- AntProperties.resolveEnvironment(root);
-
- NodeList nl = root.getDocumentElement().getChildNodes();
- for (int i = 0; i < nl.getLength(); i++)
- {
- Node node = nl.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element elem = (Element)node;
- String name = appendTch(elem.getAttribute(NAME_ATT)).trim();
- tchProps.add(name);
-
- String defaultVal = elem.getAttribute(DEFAULT_ATT);
- if (defaultVal != null && !defaultVal.equals(""))
- defaults.put(name, defaultVal);
-
- String forcedVal =
- GeneralUtil.emptyStringOrNullToNull(
- elem.getAttribute(FORCE_VALUE_ATT));
- if (forcedVal != null)
- {
- forcedValues.put(name, forcedVal.trim());
- }
-
- // only deal with "excluded" if we don't want to "force-set" this
- // prop to a particular value for replication features
- if (forcedVal == null)
- {
-
- String excluded =
- GeneralUtil.emptyStringOrNullToNull(
- elem.getAttribute(EXCLUDED_ATT));
- if (excluded != null && GeneralUtil.parseBoolean(excluded))
- {
- exclusions.add(name);
- }
-
- // javaExcluded only affects the "java command line" replication
- String javaExcluded =
- GeneralUtil.emptyStringOrNullToNull(
- elem.getAttribute(JAVA_EXCLUDED_ATT));
-
- if (javaExcluded != null)
- {
- if (GeneralUtil.parseBoolean(javaExcluded))
- javaExclusions.add(name);
- }
- else
- {
- // if javaExcluded not set, "inherit" excluded setting.
- if (exclusions.contains(name))
- javaExclusions.add(name);
- }
- }
- }
- }
- }
-
- private static void resolveEnvironment(Document root)
- {
- Map env = new HashMap(AntProperties.getEnvironment());
- // also resolve tch.home
- env.put(TCH_PREFIX + TCH_HOME_PROPERTY, getHomeDir());
- ValueHandler handler = new ValueHandler(env, '%');
- handler.setReturnUnresolvedProp(true);
- DomUtils.visitDom(root, new DynamicPropNodeVisitor(handler));
- }
-
- private static final String TCH_PROP_FILENAME = "tch-props.xml";
- private static final String NAME_ATT = "name";
- private static final String DEFAULT_ATT = "default";
- private static final String EXCLUDED_ATT = "excluded";
- private static final String JAVA_EXCLUDED_ATT = "javaExcluded";
- private static final String FORCE_VALUE_ATT = "forceval";
-
- private static class PropertyComparator implements Comparator
- {
- public int compare(Object o1, Object o2)
- {
- String s1 = (String)o1;
- String s2 = (String)o2;
- int diff = getIndex(s1) - getIndex(s2);
- if (diff != 0)
- {
- return diff;
- }
- else
- return s1.compareTo(s2);
- }
-
- private int getIndex(String s)
- {
- if (s.startsWith(TCH_PREFIX))
- return 3;
- if (s.equals(TEST_SUITE_PROPERTY))
- return 1;
- if (s.equals(PROCESS_CONFIG_PROPERTY))
- return 2;
- else
- return 4;
- }
- }
-
-}
+package org.apache.beehive.test.tools.tch.core;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import org.apache.beehive.test.tools.tch.DebugLevels;
+import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationAggregate;
+import org.apache.beehive.test.tools.tch.core.configuration.NonfatalValidationException;
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+import org.apache.beehive.test.tools.tch.util.GeneralUtil;
+import org.apache.beehive.test.tools.tch.util.NestedRuntimeException;
+import org.apache.beehive.test.tools.tch.util.PropertyResolver;
+import org.apache.beehive.test.tools.tch.util.ValueHandler;
+import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
+import org.apache.beehive.test.tools.tch.util.xml.DynamicPropNodeVisitor;
+import org.apache.beehive.test.tools.tch.util.xml.NestedXMLProcessingException;
+
+public final class AntProperties
+ extends org.apache.beehive.test.tools.tch.util.AntProperties
+ implements PropertyNames
+{
+ private static Collection tchProps = new HashSet();
+ private static Map defaults = new HashMap();
+ private static Map forcedValues = new HashMap();
+ private static Collection exclusions = new HashSet();
+ private static Collection javaExclusions = new HashSet();
+
+ public static void populate()
+ {
+ try
+ {
+ populateMetadata();
+ }
+ catch (Exception e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+
+ public static void validate()
+ {
+ validateTchProperties();
+ }
+
+ public static boolean isExcluded(String propName)
+ {
+ return exclusions.contains(propName);
+ }
+
+ public static boolean isJavaExcluded(String propName)
+ {
+ return javaExclusions.contains(propName);
+ }
+
+ public static Collection getTchExcludedPropNames()
+ {
+ return Collections.unmodifiableCollection(exclusions);
+ }
+
+ public static Collection getJavaExcludedPropNames()
+ {
+ return Collections.unmodifiableCollection(javaExclusions);
+ }
+
+ private static Map nondefaultForcedValProps = null;
+ public static synchronized Map getNondefaultForcedValueProps()
+ {
+ if (nondefaultForcedValProps == null)
+ {
+ nondefaultForcedValProps = new HashMap();
+ for (Iterator iter = forcedValues.entrySet().iterator(); iter.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ if (!AntProperties
+ .isDefault((String)entry.getKey(), (String)entry.getValue()))
+ nondefaultForcedValProps.put(entry.getKey(), entry.getValue());
+ }
+ }
+ return nondefaultForcedValProps;
+ }
+
+ public static boolean isForcedProp(String propName)
+ {
+ return forcedValues.containsKey(propName);
+ }
+
+ public static boolean isDefault(String propName, String propValue)
+ {
+ if (defaults.containsKey(propName))
+ return defaults.get(propName).equals(propValue);
+ else
+ return false; //no default, so can't be a default value
+ }
+
+ public static String getDefault(String name)
+ {
+ return (String)defaults.get(name);
+ }
+
+ public static boolean getBooleanWithAutoDefault(String propname)
+ {
+ return getGlobalBoolean(propname, getDefault(propname));
+ }
+
+ public static boolean getLiveBooleanWithAutoDefault(String propname)
+ {
+ return getLiveGlobalBoolean(propname, getDefault(propname));
+ }
+
+ public static String getPropertyWithAutoDefault(String propname)
+ {
+ return getGlobalProperty(propname, getDefault(propname));
+ }
+
+ /**
+ * Get the admin port used for management operations on Tch.
+ * This will be the rmi registry port.
+ * @return
+ */
+ public static int getTchAdminPort()
+ {
+ int rtn = -1;
+ try
+ {
+ rtn =
+ Integer.parseInt(
+ getPropertyWithAutoDefault(
+ appendTch(TCH_MANAGEMENT_ADMIN_PORT_PROPERTY))
+ .trim());
+ }
+ catch (Exception ex)
+ {
+ // this will happen if AntProperties has not been initialized
+ // (if running server-side, or in other VM). This shouldn't
+ // ever get called.
+ }
+ return rtn;
+ }
+
+ //Descriptively named, typesafe methods for *all* the properties accessed!
+ public static int getCodeCoverageEnabled()
+ {
+ // hack to get this working server-side for now
+ int rtn = 0;
+ try
+ {
+ rtn =
+ Integer.parseInt(
+ getPropertyWithAutoDefault(
+ appendTch(TCH_CODECOVE_ENABLED_PROPERTY))
+ .trim());
+ }
+ catch (Exception ex)
+ {
+ // this will happen if AntProperties has not been initialized
+ // (if running server-side, or in other VM)
+ }
+ return rtn;
+ }
+
+ public static boolean isDebugOn()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_DEBUG_PROPERTY));
+ }
+
+ public static boolean isAntFileGenEnabled()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_ANT_FILE_GEN));
+ }
+
+ public static boolean isConfigureProcessesGloballyEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_CONFIGURE_GLOBALLY));
+ }
+
+ public static boolean isWriteProcessDataPropsFileEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_WRITE_PROCESS_ATTRIBUTES_FILE));
+ }
+
+ public static String getChangenumber()
+ {
+ return getGlobalProperty(appendTch(TCH_CHANGENUMBER));
+ }
+
+ public static String getHostname()
+ {
+ return getGlobalProperty(appendTch(TCH_HOSTNAME));
+ }
+
+ public static boolean isInitModeOnly()
+ {
+ return getLiveBooleanWithAutoDefault(
+ appendTch(TCH_INIT_MODE_ONLY_PROPERTY));
+ }
+
+ public static boolean isSilentlyIgnoreFilteredTestsEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_FILTER_IGNORE_TEST_PROPERTY));
+
+ }
+
+ public static void setInitModeOnly(boolean in)
+ {
+ setProperty(
+ appendTch(TCH_INIT_MODE_ONLY_PROPERTY),
+ String.valueOf(in));
+ }
+
+ public static boolean isValidationFailed()
+ {
+ return getLiveBooleanWithAutoDefault(
+ appendTch(TCH_INTERNAL_VALIDATION_FAILED));
+ }
+
+ public static boolean isTestNameLengthValidationEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_VALIDATE_TEST_NAME_LENGTH_PROPERTY));
+ }
+
+ public static boolean mergeProcessOutputStreams()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_MERGE_OUTPUT_STREAMS));
+ }
+
+ public static boolean shutdownVMTestVehicleAfterTest()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_TEST_VEHICLE_VM_SHUTDOWN_AFTER_TEST));
+ }
+
+ public static boolean shutdownVMTestVehicleIfProblem()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_TEST_VEHICLE_VM_SHUTDOWN_IF_PROBLEM));
+ }
+
+ public static boolean writeCmdFiles()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_WRITE_CMD_PROPERTY));
+ }
+
+ public static void setValidationFailed(boolean in)
+ {
+ setProperty(
+ appendTch(TCH_INTERNAL_VALIDATION_FAILED),
+ String.valueOf(in));
+ }
+
+ public static String getBaseDir()
+ {
+ return getGlobalProperty(appendTch(TCH_BASEDIR_PROPERTY));
+ }
+
+ public static File getLogBasedir()
+ {
+ return new File(
+ getPropertyWithAutoDefault(appendTch(TCH_LOG_BASEDIR)));
+ }
+
+ public static File getLoggerConfFile()
+ {
+ return new File(
+ getPropertyWithAutoDefault(appendTch(TCH_LOG_CONFFILE)));
+ }
+
+ public static File getProcessLogBasedir()
+ {
+ return new File(
+ getPropertyWithAutoDefault(appendTch(TCH_PROCESS_LOG_BASEDIR)));
+ }
+
+ public static boolean isProcessLogBasedirSet()
+ {
+ return (
+ getGlobalProperty(appendTch(TCH_PROCESS_LOG_BASEDIR)) != null);
+ }
+
+ public static String getGTLFLogExtension()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_LOG_GTLF_EXTENSION_PROPERTY));
+ }
+
+ public static String getHomeDir()
+ {
+ return getGlobalProperty(appendTch(TCH_HOME_PROPERTY));
+ }
+
+ public static boolean areJavaoptsSet()
+ {
+ return (getJavaopts() != null);
+ }
+
+ public static String getJavaopts()
+ {
+ return getGlobalProperty(appendTch(TCH_JAVAOPTS_PROPERTY));
+ }
+
+ public static Collection getIndividualTestNames()
+ {
+ String s = getGlobalProperty(appendTch(TCH_TEST_NAMES_PROPERTY));
+ if (s != null)
+ {
+ List ret = new ArrayList();
+ TchUtils.parseStringToStrings(s, DELIMITER, ret);
+ return ret;
+ }
+ return null;
+ }
+
+ public static boolean isIndividualTestModeOn()
+ {
+ return (
+ getIndividualTestNames() != null && !getIndividualTestNames().isEmpty());
+ }
+
+ public static boolean isJunitLogOnlyFailureEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_JUNIT_FORCE_FAILURE));
+ }
+
+ public static boolean isJunitValidateMethodNamesEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_JUNIT_VALIDATE_METHOD_NAMES));
+ }
+
+ public static boolean isJunitValidateClassEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_JUNIT_VALIDATE_CLASS));
+ }
+
+ public static boolean isIndividualJavatestMethodNamesSet()
+ {
+ return getGlobalProperty(appendTch(TCH_TEST_METHODS_PROPERTY))
+ != null;
+ }
+
+ /**
+ * Controls whether to do a 1ms sleep between timestamping each outcome result.
+ * This insures that no two result outcomes in a single test run will have the
+ * same exectime.
+ *
+ * @return indicates whether to sleep 1ms between outcome result timestamping
+ */
+ public static boolean isStaggerResultTimeEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_STAGGER_RESULT_TIME_PROPERTY));
+ }
+
+ private static final String DESCRIPTION = "description";
+ private static final String USAGE = "usage";
+ private static final String CR_LIST = "crlist";
+ private static final String TEST_LEVEL = "testlevel";
+ private static Collection fieldSet = new HashSet(4);
+ static {
+ fieldSet.add(DESCRIPTION);
+ fieldSet.add(USAGE);
+ fieldSet.add(CR_LIST);
+ fieldSet.add(TEST_LEVEL);
+ }
+
+ public static Set getTestInfo() throws AntPropertiesException
+ {
+ String s = getGlobalProperty(appendTch(TCH_TEST_INFO_PROPERTY));
+ if (s != null)
+ {
+ String[] arr = TchUtils.parseString(s, DELIMITER);
+ Set printSet = new HashSet(arr.length);
+ for (int i = 0; i < arr.length; i++)
+ {
+ String s1 = arr[i].toLowerCase(); //FIXME localize lowercase logic
+ if (fieldSet.contains(s1))
+ printSet.add(s1);
+ else
+ //VALIDATION ERROR
+ throw new AntPropertiesException(
+ "The values for the "
+ + appendTch(TCH_TEST_INFO_PROPERTY)
+ + " property must be one of these: "
+ + fieldSet);
+ }
+ return printSet;
+ }
+ else
+ return null;
+ }
+
+ public static boolean isProcessBaseHomeSet()
+ {
+ return (
+ getGlobalProperty(appendTch(TCH_PROCESS_BASE_HOME_DIR)) != null);
+ }
+
+ public static File getProcessBaseHome()
+ {
+ return new File(
+ getGlobalProperty(appendTch(TCH_PROCESS_BASE_HOME_DIR)));
+ }
+
+ public static String getBaseLogfileName()
+ {
+ return getPropertyWithAutoDefault(appendTch(TCH_LOG_NAME_PROPERTY));
+ }
+
+ public static Integer getLogDebugLevel()
+ {
+ String s =
+ getPropertyWithAutoDefault(
+ appendTch(TCH_LOG_DEBUG_LEVEL_PROPERTY));
+ if (s == null)
+ {
+ /* display all debug messages by default */
+ return new Integer(DebugLevels.ALL);
+ }
+ else
+ {
+ try
+ {
+ int debuglevel = Integer.parseInt(s);
+ if (debuglevel > DebugLevels.ALL)
+ {
+ return new Integer(DebugLevels.ALL);
+ }
+ return new Integer(debuglevel);
+ }
+ catch (NumberFormatException nfe)
+ {
+ return new Integer(DebugLevels.ALL);
+ }
+ }
+ }
+
+ /**
+ * Returns the string that represents how tch should be launched
+ * for rerunning failures.
+ * @return String
+ */
+ public static String getReplicationEntryPoint()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_REPLICATION_ENTRY_POINT_PROPERTY));
+ }
+
+ /**
+ * Returns the string that represents how tch should be launched
+ * for rerunning failures.
+ * @return String
+ */
+ public static String getReplicationInfo()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_REPLICATION_INFO_PROPERTY));
+ }
+
+ /**
+ * If false, our replication command line uses unix syntax for
+ * referencing environment variables (${NAME})
+ * If true, we print the same replication command line twice,
+ * once with unix syntax and once with win syntax (%NAME%) for
+ * referencing environment variables.
+ *
+ * Note that this switch is ignored if
+ * tch.prop-val-subtitution is disabled.
+ *
+ * @return boolean
+ */
+ public static boolean isReplicationWinCmdlineEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_REPLICATION_PRINT_WIN_CMDLINE));
+ }
+
+ /**
+ * Decides if for the tch command line (not the java command line)
+ * we should set tch.javaopts. The default is true.
+ *
+ * Depending on the environment setup, this should be enabled or disabled.
+ * If most classes Tch needs are in the system classpath ($CLASSPATH),
+ * then typically we want to include tch.javaopts in the generated command
+ * line, as it won't be too long, and contain any extra classes or VM settings
+ * that are not part of the "standard" system configuration.
+ *
+ * However, if the system classpath is empty and if a custom ant wrapper is
+ * used to launch Tch, which will setup the classpath, then tch.javaopts
+ * should probably not be set on the Tch command line, as it makes it very long.
+ * Instead, the entry point for Tch (see getReplicationEntryPoint()) should be
+ * set to the custom ant script.
+ *
+ * @return boolean
+ */
+ public static boolean isReplicationJavaoptsEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_REPLICATION_ADD_JAVAOPTS_PROPERTY));
+ }
+
+ public static String getLogDateFormat()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_LOG_DATE_FORMAT_PROPERTY));
+ }
+
+ public static boolean getLogProgressInfo()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_PROGRESS_INFO_PROPERTY));
+ }
+
+ public static boolean isLogStdoutAsInform()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_STDOUT_AS_INFORM_PROPERTY));
+ }
+
+ public static boolean isLogInformAsDetails()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_INFORM_AS_DETAILS_PROPERTY));
+ }
+
+ public static String getGlobalTestVehicle()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_GLOBAL_TEST_VEHICLE_PROPERTY));
+ }
+
+ public static boolean isGlobalTestVehicleSet()
+ {
+ return (
+ getGlobalProperty(appendTch(TCH_GLOBAL_TEST_VEHICLE_PROPERTY))
+ != null);
+ }
+
+ public static String getGlobalTestVehicleProcess()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_GLOBAL_TEST_VEHICLE_PROCESS_PROPERTY));
+ }
+
+ public static boolean getTestInfoAlsoRun()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_TEST_INFO_ALSO_RUN_PROPERTY));
+ }
+
+ public static boolean isFilterAdoptTestNamesEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_FILTER_ADOPT_TESTNAMES));
+ }
+
+ public static Integer getTestLevelFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_TEST_LEVEL_PROPERTY));
+ if (s != null)
+ return new Integer(Integer.parseInt(s.trim()));
+ else
+ return null;
+ }
+
+ public static String getStatusFilter()
+ {
+ return getGlobalProperty(appendTch(TCH_FILTER_STATUS_PROPERTY));
+ }
+
+ public static Collection getDBListFilter()
+ {
+ String s = getGlobalProperty(appendTch(TCH_FILTER_DB_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getMiscInfoFilter()
+ {
+ String s = getGlobalProperty(appendTch(TCH_FILTER_MISC_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getOwnerListFilter()
+ {
+ String s = getGlobalProperty(appendTch(TCH_FILTER_OWNERS_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getDomainListFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_DOMAINS_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getServerModesListFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_SERVER_MODES_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getConversationsListFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_CONVERSATIONS_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getFrequenciesListFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_FREQUENCIES_PROPERTY));
+ if (s != null)
+ {
+ // also accept '+' as delimter because the cc setup sucks.
+ String delimiter = DELIMITER;
+ if (s.indexOf('+') > -1)
+ delimiter = "+";
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, delimiter, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getWebappsListFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_WEBAPPS_PROPERTY));
+ if (s != null)
+ {
+ // also accept '+' as delimter because the cc setup sucks.
+ String delimiter = DELIMITER;
+ if (s.indexOf('+') > -1)
+ delimiter = "+";
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToStrings(s, delimiter, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static Collection getCRListFilter()
+ {
+ String s = getGlobalProperty(appendTch(TCH_FILTER_CRS_PROPERTY));
+ if (s != null)
+ {
+ Collection rtn = new HashSet();
+ TchUtils.parseStringToIntegers(s, DELIMITER, rtn);
+ return rtn;
+ }
+ else
+ return null;
+ }
+
+ public static boolean isCRListFilterMatchAll()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_FILTER_CRS_MATCH_ALL_PROPERTY));
+ }
+
+ public static boolean isLogBannersEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_BANNERS_PROPERTY));
+ }
+
+ public static boolean isLogToStdoutEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_TO_STDOUT_PROPERTY));
+ }
+
+ public static boolean isLogTestNamesEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_TEST_NAMES_PROPERTY));
+ }
+
+ public static boolean isLogGTLFEnabled()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_LOG_GTLF_PROPERTY));
+ }
+
+ /**
+ * get the log-custom class, if it's specified
+ * could return null
+ */
+ public static String getCustomLoggerClass()
+ {
+ return getGlobalProperty(appendTch(TCH_LOG_CUSTOM_PROPERTY));
+ }
+ public static String getCustomLogSuffix()
+ {
+ return getGlobalProperty(
+ appendTch(TCH_LOG_CUSTOM_SUFFIX_PROPERTY),
+ "log");
+ }
+
+ public static boolean isLogVerboseDebugEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_VERBOSE_DEBUG_PROPERTY));
+ }
+
+ public static boolean isLogComparisonEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_COMPARISON_PROPERTY));
+ }
+
+ public static boolean isLogCompositeEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_LOG_COMPOSITE_PROPERTY));
+ }
+
+ public static boolean threaddumpsEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_THREADDUMPS_PROPERTY));
+ }
+
+ public static Boolean getKnownFailuresFilter()
+ {
+ String s =
+ getGlobalProperty(appendTch(TCH_FILTER_KNOWN_FAILURES_PROPERTY));
+ if (s != null)
+ return new Boolean(GeneralUtil.parseBoolean(s.trim()));
+ else
+ return null;
+ }
+
+ public static Boolean getSSLFilter()
+ {
+ String s = getGlobalProperty(appendTch(TCH_FILTER_SSL_PROPERTY));
+ if (s != null)
+ {
+ if (s.equalsIgnoreCase("on"))
+ return new Boolean(true);
+ if (s.equalsIgnoreCase("off"))
+ return new Boolean(false);
+ //VALIDATION ERROR
+ NonfatalValidationAggregate.addException(
+ new NonfatalValidationException(
+ ErrorMessageConstants.SSL_PROPERTY_ERROR_CODE,
+ ErrorMessageConstants.PROPNAME,
+ appendTch(TCH_FILTER_SSL_PROPERTY)));
+ return null; //dummy
+ }
+ else
+ return null;
+ }
+
+ public static String getClientTypeFilter()
+ {
+ return getGlobalProperty(
+ appendTch(TCH_FILTER_CLIENT_TYPE_PROPERTY));
+ }
+
+ public static String getSecurityTypeFilter()
+ {
+ return getGlobalProperty(
+ appendTch(TCH_FILTER_SECURITY_TYPE_PROPERTY));
+ }
+
+ public static String getProcessConfigName()
+ {
+ String rtn = getGlobalProperty(PROCESS_CONFIG_PROPERTY);
+ if (rtn == null) //only check the old name if the new one is not defined
+ rtn = getGlobalProperty(CONFIG_FILE_PROPERTY);
+ return rtn;
+ }
+
+ private static List processConfigFiles = null;
+
+ public synchronized static List getAllProcessConfigFiles()
+ {
+ if (processConfigFiles == null)
+ {
+ if (getProcessConfigName() == null)
+ {
+ return null;
+ }
+ processConfigFiles = new ArrayList(); // Files
+ Collection fileNamesColl = new ArrayList(); // Strings
+ TchUtils.parseStringToStrings(
+ getProcessConfigName(),
+ DELIMITER,
+ fileNamesColl);
+
+ for (Iterator iter = fileNamesColl.iterator(); iter.hasNext();)
+ {
+ String processConfigFileName = (String)iter.next();
+ File processConfigFile = new File(processConfigFileName);
+ if (!processConfigFile.isAbsolute())
+ {
+ processConfigFile =
+ new File(AntProperties.getBaseDir(), processConfigFileName);
+ processConfigFile = TchUtils.getCanonicalFile(processConfigFile);
+ }
+ processConfigFiles.add(processConfigFile);
+ }
+ processConfigFiles = Collections.unmodifiableList(processConfigFiles);
+ }
+ return processConfigFiles;
+ }
+
+ public static int getTestTimeoutSeconds()
+ {
+ return Integer.parseInt(
+ getPropertyWithAutoDefault(
+ appendTch(TCH_TEST_TIMEOUT_SECONDS_PROPERTY))
+ .trim());
+ }
+
+ public static boolean isRunTimeoutEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_RUN_TIMEOUT_PROPERTY));
+ }
+
+ public static int getRunTimeoutSeconds()
+ {
+ return Integer.parseInt(
+ getPropertyWithAutoDefault(
+ appendTch(TCH_RUN_TIMEOUT_SECONDS_PROPERTY))
+ .trim());
+ }
+
+ public static boolean isTestTimeoutEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_TEST_TIMEOUT_PROPERTY));
+ }
+
+ public static boolean isConfigDependecyExplicitlyDisabled()
+ {
+ return (isConfigDependencySet() && !isConfigDependenciesEnabled());
+ }
+
+ private static boolean isConfigDependencySet()
+ {
+ return (
+ getGlobalProperty(appendTch(TCH_CONFIG_DEPENDENCY_ON_PROPERTY))
+ != null);
+ }
+
+ public static boolean isConfigDependenciesEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_CONFIG_DEPENDENCY_ON_PROPERTY));
+ }
+
+ public static String getRootTestSuiteName()
+ {
+ return getGlobalProperty(TEST_SUITE_PROPERTY);
+ }
+
+ public static boolean isSchemaValidationOn()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_SCHEMA_VALIDATION_PROPERTY));
+ }
+
+ public static boolean isVerboseOn()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_VERBOSE_PROPERTY));
+ }
+
+ /**
+ * Check whether verbose validation is turned on. This seems to control
+ * whether validation failures are actually printed out, or if it just
+ * results in a build exception.
+ *
+ * @return boolean state for this flag
+ */
+ public static boolean isVerboseValidationOn()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_VERBOSE_VALIDATION_PROPERTY));
+ }
+
+ public static boolean failBuild()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_FAIL_BUILD_PROPERTY));
+ }
+
+ public static boolean isFailfastValidationOn()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_FAILFAST_VALIDATION_PROPERTY));
+ }
+
+ public static File getValidationErrorMetadataFile()
+ {
+ return new File(
+ getHomeDir(),
+ getPropertyWithAutoDefault(
+ appendTch(TCH_VALIDATION_METADATA_FILE_PROPERTY)));
+ }
+
+ public static boolean isPropValSubstitutionEnabled()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROP_VAL_SUBSTITUTION));
+ }
+
+ public static boolean isAutoStartSet()
+ {
+ return getGlobalProperty(appendTch(TCH_AUTO_START_PROPERTY))
+ != null;
+ }
+
+ public static boolean getAutoStart()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_AUTO_START_PROPERTY));
+ }
+
+ public static boolean isWindowSet()
+ {
+ return getGlobalProperty(appendTch(TCH_WINDOW_PROPERTY)) != null;
+ }
+
+ public static boolean getWindow()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_WINDOW_PROPERTY));
+ }
+
+ public static boolean isKeepAliveOn()
+ {
+ if (getGlobalProperty(appendTch(TCH_KEEP_PROCESSES_ALIVE_PROPERTY))
+ != null)
+ {
+ // deprecated
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_KEEP_PROCESSES_ALIVE_PROPERTY));
+ }
+ else
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_KEEP_ALIVE_PROPERTY));
+ }
+ }
+
+ public static boolean isCtrlCCleanupOn()
+ {
+ return getBooleanWithAutoDefault(
+ appendTch(TCH_PROCESS_CTRLC_CLEANUP_PROPERTY));
+ }
+
+ public static String getUpdateJunitSource()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_UPDATE_JUNIT_SOURCE));
+ }
+
+ public static int getLocalListenerPort()
+ {
+ return Integer.parseInt(
+ getPropertyWithAutoDefault(
+ appendTch(TCH_LOCAL_LISTENER_PORT_PROPERTY))
+ .trim());
+ }
+
+ public static String getSTFOperationFiles()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_STF_OPERATION_FILES_PROPERTY));
+ }
+
+ public static String getSTFComponentFiles()
+ {
+ return getPropertyWithAutoDefault(
+ appendTch(TCH_STF_COMPONENT_FILES_PROPERTY));
+ }
+
+ public static Map sortProperties(Map properties)
+ {
+ Map rtn = new TreeMap(new PropertyComparator());
+ rtn.putAll(properties);
+ return rtn;
+ }
+
+ public static Map filterTchInternalProperties(Map properties)
+ {
+ for (Iterator iter = properties.keySet().iterator(); iter.hasNext();)
+ {
+ if (((String)iter.next()).startsWith(appendTch(TCH_INTERNAL)))
+ iter.remove();
+ }
+ return properties;
+ }
+
+ private static Map environment = new HashMap();
+ public synchronized static Map getEnvironment()
+ {
+ // a bit hacky, but basically the call to this method may happen
+ // before Ant has loaded the environment
+ // (this is assuming that we do load the environment in our tch-root file)
+ // so we keep trying until we got some environment variables
+ // this would fail on an OS that does not have any environment variables set,
+ // which seems pretty much impossible
+ if (environment.isEmpty())
+ {
+ for (Iterator iter = getGlobalProperties().entrySet().iterator();
+ iter.hasNext();
+ )
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ if (((String)entry.getKey()).startsWith(ENV_PREFIX))
+ {
+ environment.put(entry.getKey(), entry.getValue());
+ }
+ }
+ if (!environment.isEmpty())
+ environment = Collections.unmodifiableMap(environment);
+ }
+ return environment;
+ }
+
+ private static Map strippedDynamicProcessConfigProps = null;
+ private static Map dynamicProcessConfigProps = null;
+
+ public synchronized static Map getStrippedDynamicProcessConfigProps()
+ {
+ if (strippedDynamicProcessConfigProps == null)
+ {
+ strippedDynamicProcessConfigProps =
+ getDynamicProcessConfigPropsInternal(true);
+ }
+ return strippedDynamicProcessConfigProps;
+ }
+
+ public synchronized static Map getDynamicProcessConfigProps()
+ {
+ if (dynamicProcessConfigProps == null)
+ {
+ dynamicProcessConfigProps = getDynamicProcessConfigPropsInternal(false);
+ }
+ return dynamicProcessConfigProps;
+ }
+
+ /**
+ * Add the prefix back on to a stripped dynamic process config.
+ */
+ public static String getUnstrippedDynamicProcessConfigProp(String propname)
+ {
+ String expr = appendTch(TCH_DYNAMIC_PROCESS_PREFIX);
+ return expr + propname;
+ }
+
+ /**
+ * Return the stripped version of the dynamic property name passed in.
+ */
+ public static String getStrippedDynamicProcessConfigProp(String propname)
+ {
+ String expr = appendTch(TCH_DYNAMIC_PROCESS_CONFIG);
+ int startInd = expr.length() - 1;
+ return propname.substring(startInd);
+ }
+
+ private static Map getDynamicProcessConfigPropsInternal(boolean toStrip)
+ {
+ Map dynamicProcessConfigProps = new HashMap();
+ // strippedDynamicProcessConfigProps = new HashMap();
+ String expr = appendTch(TCH_DYNAMIC_PROCESS_CONFIG);
+ for (Iterator iter = getGlobalProperties().entrySet().iterator();
+ iter.hasNext();
+ )
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if (matchesExpr(key, expr))
+ {
+ int startInd = toStrip ? expr.length() - 1 : 0;
+ // strippedDynamicProcessConfigProps.put(
+ // key.substring(startInd),
+ // entry.getValue());
+ dynamicProcessConfigProps.put(
+ key.substring(startInd),
+ entry.getValue());
+ }
+ }
+ // return Collections.unmodifiableMap(strippedDynamicProcessConfigProps);
+ return Collections.unmodifiableMap(dynamicProcessConfigProps);
+ }
+
+ private static Map commandLineProps = null;
+ public synchronized static Map getCommandLineProps()
+ {
+ if (commandLineProps == null)
+ {
+ commandLineProps = new HashMap();
+ for (Iterator iter = getGlobalProperties().entrySet().iterator();
+ iter.hasNext();
+ )
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if (matchesExpr(key, ".*"))
+ {
+ commandLineProps.put(key.substring(1), entry.getValue());
+ }
+ }
+ commandLineProps = Collections.unmodifiableMap(commandLineProps);
+ }
+ return commandLineProps;
+ }
+
+ public static File getWsTestSettings()
+ {
+ return new File(
+ getGlobalProperty(appendTch(TCH_WSTEST_CONFIG_FILE)));
+ }
+
+ public static boolean isWsTestVerbose()
+ {
+ return getBooleanWithAutoDefault(appendTch(TCH_WSTEST_VERBOSE));
+ }
+
+ public static String getWsTestHost()
+ {
+ return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_HOST));
+ }
+
+ public static String getWsTestBuildDir()
+ {
+ return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_BUILDDIR));
+ }
+
+ public static String getWsTestInstallDir()
+ {
+ return getPropertyWithAutoDefault(appendTch(TCH_WSTEST_INSTALLDIR));
+ }
+
+ public static String appendTch(String propName)
+ {
+ return TCH_PREFIX + propName;
+ }
+
+ //private utils
+ private static void validateTchProperties()
+ {
+ for (Iterator iter = getGlobalProperties().keySet().iterator();
+ iter.hasNext();
+ )
+ {
+ String prop = (String)iter.next();
+ if (prop.startsWith(TCH_PREFIX)
+ && !checkIfKnownPropAndRegister(prop))
+ {
+ Map params = new HashMap(2);
+ params.put(ErrorMessageConstants.PROPNAME, prop);
+ params.put(
+ ErrorMessageConstants.PROPFILENAME,
+ getHomeDir() + "/" + TCH_PROP_FILENAME);
+ NonfatalValidationAggregate.addException(
+ new NonfatalValidationException(
+ ErrorMessageConstants.TCH_PROPERTIES_ERROR_CODE,
+ params));
+ }
+ }
+ }
+
+ private static Map updateProps = null;
+ public static Map getUpdateProps()
+ {
+ if (updateProps == null)
+ {
+ updateProps = new HashMap();
+ String expr = appendTch(TCH_ALL_UPDATE_PROPS);
+ for (Iterator iter = getGlobalProperties().entrySet().iterator();
+ iter.hasNext();
+ )
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if (matchesExpr(key, expr))
+ {
+ updateProps.put(key, entry.getValue());
+ }
+ }
+ }
+ return updateProps;
+ }
+
+ // for matching simple regular expression of form s1.s2.sn.*
+ private static boolean matchesExpr(String propName, String propExpression)
+ {
+ if (propExpression.endsWith(".*"))
+ {
+ int maxLength = propExpression.length() - 1;
+ if (propName.length() > maxLength)
+ {
+ String propExpressionSub = propExpression.substring(0, maxLength);
+ if (propName.startsWith(propExpressionSub))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean checkIfKnownPropAndRegister(String propName)
+ {
+ if (tchProps.contains(propName))
+ {
+ return true;
+ }
+ else
+ {
+ // quick way to support tch.foo.* in tch-props
+ for (Iterator iter = tchProps.iterator(); iter.hasNext();)
+ {
+ String p = (String)iter.next();
+ if (matchesExpr(propName, p))
+ {
+ // if this (simple) regexp is excluded, need to add this match
+ // to the "excluded" Collection
+ if (isExcluded(p))
+ {
+ exclusions.add(propName);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static void populateMetadata()
+ {
+ //DOM code
+ Document root = null;
+ try
+ {
+ root =
+ DomUtils.instantiateDom(
+ new File(
+ AntProperties.getHomeDir()
+ + File.separator
+ + TCH_PROP_FILENAME));
+ }
+ catch (NestedXMLProcessingException ex)
+ {
+ throw new NestedRuntimeException(ex);
+ }
+
+ AntProperties.resolveEnvironment(root);
+
+ NodeList nl = root.getDocumentElement().getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element elem = (Element)node;
+ String name = appendTch(elem.getAttribute(NAME_ATT)).trim();
+ tchProps.add(name);
+
+ String defaultVal = elem.getAttribute(DEFAULT_ATT);
+ if (defaultVal != null && !defaultVal.equals(""))
+ defaults.put(name, defaultVal);
+
+ String forcedVal =
+ GeneralUtil.emptyStringOrNullToNull(
+ elem.getAttribute(FORCE_VALUE_ATT));
+ if (forcedVal != null)
+ {
+ forcedValues.put(name, forcedVal.trim());
+ }
+
+ // only deal with "excluded" if we don't want to "force-set" this
+ // prop to a particular value for replication features
+ if (forcedVal == null)
+ {
+
+ String excluded =
+ GeneralUtil.emptyStringOrNullToNull(
+ elem.getAttribute(EXCLUDED_ATT));
+ if (excluded != null && GeneralUtil.parseBoolean(excluded))
+ {
+ exclusions.add(name);
+ }
+
+ // javaExcluded only affects the "java command line" replication
+ String javaExcluded =
+ GeneralUtil.emptyStringOrNullToNull(
+ elem.getAttribute(JAVA_EXCLUDED_ATT));
+
+ if (javaExcluded != null)
+ {
+ if (GeneralUtil.parseBoolean(javaExcluded))
+ javaExclusions.add(name);
+ }
+ else
+ {
+ // if javaExcluded not set, "inherit" excluded setting.
+ if (exclusions.contains(name))
+ javaExclusions.add(name);
+ }
+ }
+ }
+ }
+ }
+
+ private static void resolveEnvironment(Document root)
+ {
+ Map env = new HashMap(AntProperties.getEnvironment());
+ // also resolve tch.home
+ env.put(TCH_PREFIX + TCH_HOME_PROPERTY, getHomeDir());
+ ValueHandler handler = new ValueHandler(env, '%');
+ handler.setReturnUnresolvedProp(true);
+ DomUtils.visitDom(root, new DynamicPropNodeVisitor(handler));
+ }
+
+ private static final String TCH_PROP_FILENAME = "tch-props.xml";
+ private static final String NAME_ATT = "name";
+ private static final String DEFAULT_ATT = "default";
+ private static final String EXCLUDED_ATT = "excluded";
+ private static final String JAVA_EXCLUDED_ATT = "javaExcluded";
+ private static final String FORCE_VALUE_ATT = "forceval";
+
+ private static class PropertyComparator implements Comparator
+ {
+ public int compare(Object o1, Object o2)
+ {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+ int diff = getIndex(s1) - getIndex(s2);
+ if (diff != 0)
+ {
+ return diff;
+ }
+ else
+ return s1.compareTo(s2);
+ }
+
+ private int getIndex(String s)
+ {
+ if (s.startsWith(TCH_PREFIX))
+ return 3;
+ if (s.equals(TEST_SUITE_PROPERTY))
+ return 1;
+ if (s.equals(PROCESS_CONFIG_PROPERTY))
+ return 2;
+ else
+ return 4;
+ }
+ }
+
+}
Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/AntProperties.java
------------------------------------------------------------------------------
svn:eol-style = native