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 [86/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/util/gtlf/GTLFDocument.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFDocument.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFDocument.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFDocument.java Fri Aug 12 08:12:28 2005
@@ -1,706 +1,706 @@
-package org.apache.beehive.test.tools.tch.util.gtlf;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-import org.apache.beehive.test.tools.tch.util.TchConstants;
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-import org.apache.beehive.test.tools.tch.util.DomAsMap;
-import org.apache.beehive.test.tools.tch.util.ParamValidator;
-import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
-
-/*
- * This class provides helper methods for manipulating 
- * a document that conforms to the Generic Test Log Format (GTLF).
- * Uses DOM.
- *
- * @version 1.0, November 17th, 2001
- *
- * REVIEW - the merge method does not take into account the header
- * information of this GTLF, except the environment. 
- *
- */
-public class GTLFDocument implements GTLFConstants
-{
-
-  public static String sep = System.getProperty("line.separator");
-
-  //=========================================================================
-  // Private Variables
-
-  private Document root = null; // dom
-  private Map environment = null; // top level env params of this GTLF
-  private Map testLog = null; // test-log attributes
-  private Map headerInfo = null; // header-info attributes
-  private String name = ""; // optional name
-  private File sourceFile = null; // File, if we know about it
-  private boolean verbose = Boolean.getBoolean("verbose"); // if 'true' print more info to stdout
-  private boolean debug = Boolean.getBoolean("debug"); // if 'true', print debug
-
-  //=========================================================================
-  // Constructors
-
-  /**
-   * Initialize from InputSource. 
-   * Assumes InputSource in in gtlf.
-   */
-  public GTLFDocument(InputSource is) throws Exception
-  {
-    boolean validate = true;
-    root = DomUtils.instantiateDom(is, validate);
-    initHeaders();
-  }
-
-  /**
-   * Initializes from File.
-   * Assumes File is in GTLF.
-   */
-  public GTLFDocument(File f) throws Exception
-  {
-    boolean validate = true;
-    root = DomUtils.instantiateDom(f, validate);
-    environment = getTestEnvironment(root.getDocumentElement());
-    initHeaders();
-    sourceFile = f;
-    setName(f.getName());
-  }
-
-  //=========================================================================
-  // Public Methods
-
-  /**
-   * Returns name of this GTLFDocument.
-   */
-  public String getName()
-  {
-    return name;
-  }
-
-  /**
-   * Set name for this GTLFDocument.
-   */
-  public void setName(String inName)
-  {
-    name = inName;
-  }
-
-  /**
-   * Returns Document Object of the DOM.
-   */
-  public Document getRoot()
-  {
-    return root;
-  }
-
-  /**
-   * Returns top level environment, if defined in GTLF.
-   */
-  public Map getEnvironment()
-  {
-    return environment;
-  }
-
-  /**
-   * Returns all attributes of the <header-info> element.
-   */
-  public Map getHeaderInfoAttributes()
-  {
-    return headerInfo;
-  }
-
-  /**
-   * Returns all attributes of the <test-log> element.
-   */
-  public Map getTestLogAttributes()
-  {
-    return testLog;
-  }
-
-  /**
-   * Uses a ParamValidator to validate the GTLF Header information.
-   */
-  public boolean validateHeader(ParamValidator validator)
-  {
-    Map m = new HashMap();
-    m.putAll(getEnvironment());
-    m.putAll(getTestLogAttributes());
-    m.putAll(getHeaderInfoAttributes());
-    boolean FailOnUndeclaredParams = true;
-    String message = "GTLF Header: " + sep + m.toString() + sep;
-    validator.setValidatingSubject(message);
-    return validator.validate(m, FailOnUndeclaredParams);
-
-  }
-
-  /**
-   * Uses a ParamValidator to validate the GTLF results.
-   */
-  public boolean validateResults(ParamValidator validator)
-  {
-    boolean status = true;
-    GTLFTestResultAdapter result = getGTLFResultObjects();
-    validator.setValidatingSubject(result);
-    boolean FailOnUndeclaredParams = true;
-    status = validator.validate(result.toMap(), FailOnUndeclaredParams);
-    Iterator i = result.getInnerResultsIterator();
-    while (i != null && i.hasNext())
-    {
-      result = (GTLFTestResultAdapter)i.next();
-      validator.setValidatingSubject(result);
-      boolean resultOk =
-        validator.validate(result.toMap(), FailOnUndeclaredParams);
-      status = status && resultOk;
-    }
-    return status;
-  }
-
-  /**
-   * Creates a result object for each xml result node.
-   * Note: The GTLFTestResultAdapter this method returns has nested results.
-   * 
-   * @return GTLFTestResultAdapter
-   */
-  public GTLFTestResultAdapter getGTLFResultObjects()
-  {
-    NodeList resultNodes = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-    GTLFTestResultAdapter result = new GTLFTestResultAdapter();
-    result.init(resultNodes);
-    return result;
-  }
-
-  /**
-   * Merges this GTLFDocument with inGTL, accordording to these rules: 
-   *   - if a test result 'x' exists in inGTLF, but not in this GTLFDocument,
-   *     impport 'x' into this GTLFDocument.
-   *
-   *   - if a test result 'x' exists both in inGTLF and in this GTLFDocument,
-   *     (= they are equal, see below), import 'x' into this GTLFDocument if 
-   *     'x' in inGTLF is SUCCESS, and 'x' in this GTLFDocument is not a 
-   *     SUCCESS.
-   *
-   *   What determines if two results are equal?
-   *     - testcasename, testunit, parameters, environment.
-   */
-  public void merge(GTLFDocument inGTLF)
-  {
-    // loop through nodes in passed in tree and compare to this tree
-    // only modify this tree
-
-    Set usedTestPointsSet = new HashSet();
-
-    NodeList inChildren =
-      inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-    for (int i = 0, iL = inChildren.getLength(); i < iL; i++)
-    {
-      Node currentInNode = inChildren.item(i);
-      // just to get the name...
-      Map tempMap = new HashMap();
-      DomUtils.treeAttributesToMap(currentInNode, tempMap);
-      String currentInName = (String)tempMap.get(PARAM_TEST_CASE_NAME);
-      String currentInResult =
-        getAttributeValue(currentInNode, PARAM_RESULT_RESULT);
-      NodeList children = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-      boolean foundSameResult = false;
-      for (int k = 0, kL = children.getLength(); k < kL; k++)
-      {
-        Node currentNode = children.item(k);
-        if (usedTestPointsSet.contains(currentNode))
-          continue;
-        foundSameResult =
-          equalTestPoints(inGTLF, currentInNode, this, currentNode);
-        if (foundSameResult)
-        {
-          // remember which node we already looked at
-          usedTestPointsSet.add(currentNode);
-          // found same result, check value of 'result' (SUCCESS|ABORT..)
-          String currentResult =
-            getAttributeValue(currentNode, PARAM_RESULT_RESULT);
-
-          if (verbose)
-            TchUtils.log("Considering merging... " + currentInName);
-
-          if (TchConstants.SUCCESS_LEVEL_STR.equals(currentResult))
-          {
-            if (verbose)
-              TchUtils.log(name + " is SUCCESS, will not replace it");
-          }
-          else
-            if (currentResult.equals(currentInResult))
-            {
-              if (verbose)
-                TchUtils.log(
-                  name + " has same result in both logs: " + currentResult);
-            }
-            else
-              if (TchConstants.SUCCESS_LEVEL_STR.equals(currentInResult))
-              {
-                if (verbose)
-                  TchUtils.log("Will merge: " + name);
-                // need to remove result from this tree
-                removeNode(currentNode);
-                // and append the result from passed in tree
-                appendNode(currentInNode);
-              }
-              else
-              {
-                // some other combination of bad results, like
-                // FAILURE and ABORT
-                if (verbose)
-                  TchUtils.log(
-                    "For test case: "
-                      + name
-                      + " found results: "
-                      + currentResult
-                      + " and "
-                      + currentInResult
-                      + ". Will not do anything.");
-              }
-          break;
-        }
-      }
-      if (!foundSameResult)
-      {
-        if (verbose)
-        {
-          TchUtils.log("need to append: " + currentInName);
-          TchUtils.log("Will append node: " + currentInNode.getNodeName());
-        }
-        appendNode(currentInNode);
-      }
-    }
-    updateResultCountAttributes();
-  }
-
-  /**
-   * Generates a 'diff' type output between this GTLFDocument and inGTLF
-   * Looks for same test points with different results (SUCCESS, FAILURE, etc).
-   * 
-   */
-  public void diffResults(GTLFDocument inGTLF)
-  {
-    diffResults(inGTLF, new PrintWriter(System.out));
-  }
-
-  /**
-   * Generates a 'diff' type output between this GTLFDocument and inGTLF
-   * Looks for same test points with different results (SUCCESS, FAILURE, etc).
-   * 
-   */
-  public void diffResults(GTLFDocument inGTLF, PrintWriter pw)
-  {
-
-    String missingFromThis = ">>>>>>>>>>>>>>>",
-      missingFromIn = "<<<<<<<<<<<<<<<";
-
-    Set inUsedTestPointsSet = new HashSet();
-
-    pw.println(
-      "Running result diff between " + getName() + " and " + inGTLF.getName());
-
-    NodeList nl = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-    for (int i = 0, iL = nl.getLength(); i < iL; i++)
-    {
-      Node n = nl.item(i);
-      NodeList inNl =
-        inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-      for (int j = 0, jL = inNl.getLength(); j < jL; j++)
-      {
-        Node in = inNl.item(j);
-        if (inUsedTestPointsSet.contains(in))
-          continue;
-        if (equalTestPoints(this, n, inGTLF, in))
-        {
-          inUsedTestPointsSet.add(in);
-          String r = getAttributeValue(n, PARAM_RESULT_RESULT);
-          String inr = getAttributeValue(in, PARAM_RESULT_RESULT);
-          if (!r.equals(inr))
-          {
-            StringBuffer buf = new StringBuffer();
-            GTLFTestResultAdapter res = new GTLFTestResultAdapter();
-
-            res.init(n);
-            buf.append(missingFromIn).append(sep).append(
-              res.toShortString()).append(
-              sep);
-
-            res.init(in);
-            buf.append(missingFromThis).append(sep).append(
-              res.toShortString()).append(
-              sep);
-
-            pw.print(buf.toString());
-            pw.flush();
-
-          }
-          break;
-        }
-      }
-    }
-  }
-
-  /**
-   * Generates a 'diff' type output between this GTLFDocument and inGTLF
-   * Looks for different Test Points.
-   */
-  public void diffTestPoints(GTLFDocument inGTLF)
-  {
-    diffTestPoints(inGTLF, new PrintWriter(System.out));
-  }
-
-  /**
-   * Generates a 'diff' type output between this GTLFDocument and inGTLF
-   * Looks for different Test Points.
-   */
-  public void diffTestPoints(GTLFDocument inGTLF, PrintWriter pw)
-  {
-    Set testPointsSet =
-      loadSet(getRoot().getElementsByTagName(TEST_RESULT_ELEMENT));
-    Set inTestPointsSet =
-      loadSet(inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT));
-
-    Set usedTestPointsSet = new HashSet();
-    Set inUsedTestPointsSet = new HashSet();
-
-    NodeList nl = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-    for (int i = 0, iL = nl.getLength(); i < iL; i++)
-    {
-      Node n = nl.item(i);
-      NodeList inNl =
-        inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
-      for (int j = 0, jL = inNl.getLength(); j < jL; j++)
-      {
-        Node in = inNl.item(j);
-        if (inUsedTestPointsSet.contains(in))
-          continue;
-        if (equalTestPoints(this, n, inGTLF, in))
-        {
-          usedTestPointsSet.add(n);
-          inUsedTestPointsSet.add(in);
-          break;
-        }
-      }
-    }
-
-    testPointsSet.removeAll(usedTestPointsSet);
-    inTestPointsSet.removeAll(inUsedTestPointsSet);
-
-    pw.println(
-      "Running test point diff between "
-        + getName()
-        + " and "
-        + inGTLF.getName());
-    buildDiffString(testPointsSet, inTestPointsSet, pw);
-  }
-
-  /**
-   * Returns a string representation of this GTLFDocument.
-   */
-  public String toString()
-  {
-    StringBuffer buf = new StringBuffer();
-    buf
-      .append("Name: " + getName())
-      .append(sep)
-      .append(ENVIRONMENT_ELEMENT + ": " + getEnvironment())
-      .append(sep)
-      .append(TEST_LOG_ELEMENT + ": " + getTestLogAttributes())
-      .append(sep)
-      .append(HEADER_INFO_ELEMENT + ": " + getHeaderInfoAttributes());
-    return buf.toString();
-  }
-
-  //=========================================================================
-  // Private Helper Methods
-
-  private String getAttributeValue(Node n, String attrName)
-  {
-    String value = null;
-    NamedNodeMap attributes = n.getAttributes();
-    Node valueNode = attributes.getNamedItem(attrName);
-    if (valueNode != null)
-    {
-      value = valueNode.getNodeValue();
-    }
-    return value;
-  }
-
-  private boolean mapSubsetOfMap(Map m1, Map m2)
-  {
-    // is everything in m1 also in m2?
-    Iterator i = m1.keySet().iterator();
-    boolean isSubset = true;
-    while (i.hasNext())
-    {
-      String key = (String)i.next();
-      if (!m1.get(key).equals(m2.get(key)))
-      {
-        isSubset = false;
-        break;
-      }
-    }
-    return isSubset;
-  }
-
-  private Set loadSet(NodeList nl)
-  {
-    Set s = new HashSet();
-    if (nl != null)
-      for (int i = 0, iL = nl.getLength(); i < iL; i++)
-        s.add(nl.item(i));
-    return s;
-  }
-
-  private void buildDiffString(Set base, Set s, PrintWriter pw)
-  {
-
-    String missingFromThis = ">>>>>>>>>>>>>>>",
-      missingFromIn = "<<<<<<<<<<<<<<<";
-
-    Iterator tpIter2 = base.iterator();
-    while (tpIter2.hasNext())
-    {
-      Node n = (Node)tpIter2.next();
-      GTLFTestResultAdapter res = new GTLFTestResultAdapter();
-      res.init(n);
-      StringBuffer buf = new StringBuffer();
-      buf.append(missingFromIn).append(sep).append(res.toShortString()).append(
-        sep);
-      pw.print(buf.toString());
-    }
-    Iterator inTpIter2 = s.iterator();
-    while (inTpIter2.hasNext())
-    {
-      Node in = (Node)inTpIter2.next();
-      GTLFTestResultAdapter res = new GTLFTestResultAdapter();
-      res.init(in);
-      StringBuffer buf = new StringBuffer();
-      buf.append(missingFromThis).append(sep).append(
-        res.toShortString()).append(
-        sep);
-      pw.print(buf.toString());
-    }
-
-    if (base.isEmpty() && s.isEmpty())
-    {
-      StringBuffer buf = new StringBuffer();
-      buf.append("=====").append(" no diff ").append("=====").append(
-        sep).append(
-        sep);
-      pw.print(buf.toString());
-    }
-    pw.flush();
-  }
-
-  private int countResults()
-  {
-    return getRoot().getElementsByTagName(TEST_RESULT_ELEMENT).getLength();
-  }
-
-  // If we added results to this gtlf log
-  // need to update checksum and resultcount
-  private void updateResultCountAttributes()
-  {
-    NodeList l = getRoot().getElementsByTagName(HEADER_INFO_ELEMENT);
-    if (l != null && l.getLength() > 0)
-    {
-      Node n = l.item(0);
-      NamedNodeMap map = n.getAttributes();
-      int count = countResults();
-      if (map.getNamedItem(PARAM_HEAD_CHKSUM) != null)
-        map.getNamedItem(PARAM_HEAD_CHKSUM).setNodeValue(String.valueOf(count));
-      if (map.getNamedItem(PARAM_HEAD_RESULTCOUNT) != null)
-        map.getNamedItem(PARAM_HEAD_RESULTCOUNT).setNodeValue(
-          String.valueOf(count));
-    }
-  }
-
-  private boolean equalTestParameters(Node n1, Node n2)
-  {
-    boolean result = false;
-    String paramStr1 = getTestParameters(n1);
-    String paramStr2 = getTestParameters(n2);
-    if (verbose)
-    {
-      TchUtils.log("Comparing params...");
-    }
-    if (String.valueOf(paramStr1).equals(String.valueOf(paramStr2)))
-    {
-      result = true;
-      if (debug)
-        TchUtils.log("Params are equal");
-    }
-    else
-    {
-      result = false;
-      if (debug)
-        TchUtils.log("Params not equal");
-    }
-    return result;
-  }
-
-  private String getTestParameters(Node n)
-  {
-    String testParams = null;
-    NodeList children = n.getChildNodes();
-    int length = children.getLength();
-    for (int i = 0; i < length; i++)
-    {
-      Node p = children.item(i);
-      if (p.getNodeName().equals(TEST_PARAMETERS_ELEMENT))
-      {
-        testParams = p.getFirstChild().getNodeValue();
-      }
-    }
-    // make sure we do not count white space as parameter
-    if (testParams != null)
-    {
-      StringTokenizer st = new StringTokenizer(testParams, sep);
-      StringBuffer buf = new StringBuffer();
-      while (st.hasMoreTokens())
-      {
-        buf.append(st.nextToken().trim());
-      }
-      testParams = buf.toString();
-    }
-    if (debug)
-      TchUtils.log("Params are: " + testParams);
-    return testParams;
-  }
-
-  /**
-   * Checks if two test points are equal.
-   *   What determines if two results are equal?
-   *     - testcasename, testunit, parameters, environment.
-   */
-  private boolean equalTestPoints(
-    GTLFDocument d1,
-    Node rNode1,
-    GTLFDocument d2,
-    Node rNode2)
-  {
-    boolean testPointsAreEqual = false;
-    Map rNode1Attr = new HashMap();
-    DomUtils.treeAttributesToMap(rNode1, rNode1Attr);
-    // first only check testcasename and testunit
-    Map search = new HashMap();
-    search.put(PARAM_TEST_CASE_NAME, rNode1Attr.get(PARAM_TEST_CASE_NAME));
-    search.put(PARAM_TEST_UNIT, rNode1Attr.get(PARAM_TEST_UNIT));
-    Map rNode2Attr = new HashMap();
-    DomUtils.treeAttributesToMap(rNode2, rNode2Attr);
-    if (mapSubsetOfMap(search, rNode2Attr))
-    {
-      // now check the values of parameters and test environments...
-      if (equalTestParameters(rNode1, rNode2)
-        && equalTestEnvironments(d1, rNode1, d2, rNode2))
-      {
-        testPointsAreEqual = true;
-      }
-    }
-    if (debug)
-      TchUtils.log("equalTestPoints: " + testPointsAreEqual);
-    return testPointsAreEqual;
-  }
-
-  private boolean equalTestEnvironments(
-    GTLFDocument d1,
-    Node n1,
-    GTLFDocument d2,
-    Node n2)
-  {
-    Map resultEnv1 = d1.getResultEnv(n1);
-    Map resultEnv2 = d2.getResultEnv(n2);
-    if (debug)
-    {
-      TchUtils.log("Env1 " + n1.getNodeName() + ": " + resultEnv1);
-      TchUtils.log("Env2 " + n2.getNodeName() + ": " + resultEnv2);
-    }
-    boolean result = resultEnv1.equals(resultEnv2);
-    if (debug)
-      TchUtils.log("Envs are equals: " + result);
-    return result;
-  }
-
-  private Map getTestEnvironment(Node n)
-  {
-    Map env = new HashMap();
-    NodeList children = n.getChildNodes();
-    int length = children.getLength();
-    for (int i = 0; i < length; i++)
-    {
-      if (children.item(i).getNodeName().equals(ENVIRONMENT_ELEMENT))
-      {
-        Map m = new HashMap();
-        DomAsMap.load(children.item(i), m);
-        int numEnvAttributes = DomAsMap.getSizeForEntry(m, ENV_ATT_ELEMENT);
-        for (int j = 1; j <= numEnvAttributes; j++)
-        {
-          env.put(
-            m.get(ENV_ATT_ELEMENT + "!" + j + "#name"),
-            m.get(ENV_ATT_ELEMENT + "!" + j + "#value"));
-        }
-        break;
-      }
-    }
-    return env;
-  }
-
-  /**
-   * Extracts 'test-log', 'header-info' and 'env'
-   */
-  private void initHeaders()
-  {
-    NodeList l = getRoot().getElementsByTagName(TEST_LOG_ELEMENT);
-    testLog = DomUtils.attributesToMap(l.item(0));
-
-    l = getRoot().getElementsByTagName(HEADER_INFO_ELEMENT);
-    headerInfo = DomUtils.attributesToMap(l.item(0));
-
-    environment = getTestEnvironment(getRoot().getDocumentElement());
-  }
-
-  /**
-   * Takes a result node and returns the complete
-   * environment map for that result
-   */
-  private Map getResultEnv(Node n)
-  {
-    // clone the top level environment of this GTLF
-    Map allEnv = new HashMap(environment);
-    Map resultEnv = getTestEnvironment(n);
-    // override things in top level env
-    allEnv.putAll(resultEnv);
-    return allEnv;
-  }
-
-  private void removeNode(Node deleteMe)
-  {
-    if (deleteMe != getRoot().getDocumentElement())
-    {
-      // get the parent of "deleteMe"
-      Node parent = deleteMe.getParentNode();
-      // remove "deleteMe"
-      parent.removeChild(deleteMe);
-    }
-  }
-
-  /**
-   * Appends passed in Node to this GTLFDocument's root
-   */
-  private void appendNode(Node inNode)
-  {
-    Node newNode = getRoot().importNode(inNode, true);
-    getRoot().getDocumentElement().appendChild(newNode);
-  }
-}
+package org.apache.beehive.test.tools.tch.util.gtlf;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import org.apache.beehive.test.tools.tch.util.TchConstants;
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+import org.apache.beehive.test.tools.tch.util.DomAsMap;
+import org.apache.beehive.test.tools.tch.util.ParamValidator;
+import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
+
+/*
+ * This class provides helper methods for manipulating 
+ * a document that conforms to the Generic Test Log Format (GTLF).
+ * Uses DOM.
+ *
+ * @version 1.0, November 17th, 2001
+ *
+ * REVIEW - the merge method does not take into account the header
+ * information of this GTLF, except the environment. 
+ *
+ */
+public class GTLFDocument implements GTLFConstants
+{
+
+  public static String sep = System.getProperty("line.separator");
+
+  //=========================================================================
+  // Private Variables
+
+  private Document root = null; // dom
+  private Map environment = null; // top level env params of this GTLF
+  private Map testLog = null; // test-log attributes
+  private Map headerInfo = null; // header-info attributes
+  private String name = ""; // optional name
+  private File sourceFile = null; // File, if we know about it
+  private boolean verbose = Boolean.getBoolean("verbose"); // if 'true' print more info to stdout
+  private boolean debug = Boolean.getBoolean("debug"); // if 'true', print debug
+
+  //=========================================================================
+  // Constructors
+
+  /**
+   * Initialize from InputSource. 
+   * Assumes InputSource in in gtlf.
+   */
+  public GTLFDocument(InputSource is) throws Exception
+  {
+    boolean validate = true;
+    root = DomUtils.instantiateDom(is, validate);
+    initHeaders();
+  }
+
+  /**
+   * Initializes from File.
+   * Assumes File is in GTLF.
+   */
+  public GTLFDocument(File f) throws Exception
+  {
+    boolean validate = true;
+    root = DomUtils.instantiateDom(f, validate);
+    environment = getTestEnvironment(root.getDocumentElement());
+    initHeaders();
+    sourceFile = f;
+    setName(f.getName());
+  }
+
+  //=========================================================================
+  // Public Methods
+
+  /**
+   * Returns name of this GTLFDocument.
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Set name for this GTLFDocument.
+   */
+  public void setName(String inName)
+  {
+    name = inName;
+  }
+
+  /**
+   * Returns Document Object of the DOM.
+   */
+  public Document getRoot()
+  {
+    return root;
+  }
+
+  /**
+   * Returns top level environment, if defined in GTLF.
+   */
+  public Map getEnvironment()
+  {
+    return environment;
+  }
+
+  /**
+   * Returns all attributes of the &lt;header-info&gt; element.
+   */
+  public Map getHeaderInfoAttributes()
+  {
+    return headerInfo;
+  }
+
+  /**
+   * Returns all attributes of the &lt;test-log&gt; element.
+   */
+  public Map getTestLogAttributes()
+  {
+    return testLog;
+  }
+
+  /**
+   * Uses a ParamValidator to validate the GTLF Header information.
+   */
+  public boolean validateHeader(ParamValidator validator)
+  {
+    Map m = new HashMap();
+    m.putAll(getEnvironment());
+    m.putAll(getTestLogAttributes());
+    m.putAll(getHeaderInfoAttributes());
+    boolean FailOnUndeclaredParams = true;
+    String message = "GTLF Header: " + sep + m.toString() + sep;
+    validator.setValidatingSubject(message);
+    return validator.validate(m, FailOnUndeclaredParams);
+
+  }
+
+  /**
+   * Uses a ParamValidator to validate the GTLF results.
+   */
+  public boolean validateResults(ParamValidator validator)
+  {
+    boolean status = true;
+    GTLFTestResultAdapter result = getGTLFResultObjects();
+    validator.setValidatingSubject(result);
+    boolean FailOnUndeclaredParams = true;
+    status = validator.validate(result.toMap(), FailOnUndeclaredParams);
+    Iterator i = result.getInnerResultsIterator();
+    while (i != null && i.hasNext())
+    {
+      result = (GTLFTestResultAdapter)i.next();
+      validator.setValidatingSubject(result);
+      boolean resultOk =
+        validator.validate(result.toMap(), FailOnUndeclaredParams);
+      status = status && resultOk;
+    }
+    return status;
+  }
+
+  /**
+   * Creates a result object for each xml result node.
+   * Note: The GTLFTestResultAdapter this method returns has nested results.
+   * 
+   * @return GTLFTestResultAdapter
+   */
+  public GTLFTestResultAdapter getGTLFResultObjects()
+  {
+    NodeList resultNodes = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+    GTLFTestResultAdapter result = new GTLFTestResultAdapter();
+    result.init(resultNodes);
+    return result;
+  }
+
+  /**
+   * Merges this GTLFDocument with inGTL, accordording to these rules: 
+   *   - if a test result 'x' exists in inGTLF, but not in this GTLFDocument,
+   *     impport 'x' into this GTLFDocument.
+   *
+   *   - if a test result 'x' exists both in inGTLF and in this GTLFDocument,
+   *     (= they are equal, see below), import 'x' into this GTLFDocument if 
+   *     'x' in inGTLF is SUCCESS, and 'x' in this GTLFDocument is not a 
+   *     SUCCESS.
+   *
+   *   What determines if two results are equal?
+   *     - testcasename, testunit, parameters, environment.
+   */
+  public void merge(GTLFDocument inGTLF)
+  {
+    // loop through nodes in passed in tree and compare to this tree
+    // only modify this tree
+
+    Set usedTestPointsSet = new HashSet();
+
+    NodeList inChildren =
+      inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+    for (int i = 0, iL = inChildren.getLength(); i < iL; i++)
+    {
+      Node currentInNode = inChildren.item(i);
+      // just to get the name...
+      Map tempMap = new HashMap();
+      DomUtils.treeAttributesToMap(currentInNode, tempMap);
+      String currentInName = (String)tempMap.get(PARAM_TEST_CASE_NAME);
+      String currentInResult =
+        getAttributeValue(currentInNode, PARAM_RESULT_RESULT);
+      NodeList children = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+      boolean foundSameResult = false;
+      for (int k = 0, kL = children.getLength(); k < kL; k++)
+      {
+        Node currentNode = children.item(k);
+        if (usedTestPointsSet.contains(currentNode))
+          continue;
+        foundSameResult =
+          equalTestPoints(inGTLF, currentInNode, this, currentNode);
+        if (foundSameResult)
+        {
+          // remember which node we already looked at
+          usedTestPointsSet.add(currentNode);
+          // found same result, check value of 'result' (SUCCESS|ABORT..)
+          String currentResult =
+            getAttributeValue(currentNode, PARAM_RESULT_RESULT);
+
+          if (verbose)
+            TchUtils.log("Considering merging... " + currentInName);
+
+          if (TchConstants.SUCCESS_LEVEL_STR.equals(currentResult))
+          {
+            if (verbose)
+              TchUtils.log(name + " is SUCCESS, will not replace it");
+          }
+          else
+            if (currentResult.equals(currentInResult))
+            {
+              if (verbose)
+                TchUtils.log(
+                  name + " has same result in both logs: " + currentResult);
+            }
+            else
+              if (TchConstants.SUCCESS_LEVEL_STR.equals(currentInResult))
+              {
+                if (verbose)
+                  TchUtils.log("Will merge: " + name);
+                // need to remove result from this tree
+                removeNode(currentNode);
+                // and append the result from passed in tree
+                appendNode(currentInNode);
+              }
+              else
+              {
+                // some other combination of bad results, like
+                // FAILURE and ABORT
+                if (verbose)
+                  TchUtils.log(
+                    "For test case: "
+                      + name
+                      + " found results: "
+                      + currentResult
+                      + " and "
+                      + currentInResult
+                      + ". Will not do anything.");
+              }
+          break;
+        }
+      }
+      if (!foundSameResult)
+      {
+        if (verbose)
+        {
+          TchUtils.log("need to append: " + currentInName);
+          TchUtils.log("Will append node: " + currentInNode.getNodeName());
+        }
+        appendNode(currentInNode);
+      }
+    }
+    updateResultCountAttributes();
+  }
+
+  /**
+   * Generates a 'diff' type output between this GTLFDocument and inGTLF
+   * Looks for same test points with different results (SUCCESS, FAILURE, etc).
+   * 
+   */
+  public void diffResults(GTLFDocument inGTLF)
+  {
+    diffResults(inGTLF, new PrintWriter(System.out));
+  }
+
+  /**
+   * Generates a 'diff' type output between this GTLFDocument and inGTLF
+   * Looks for same test points with different results (SUCCESS, FAILURE, etc).
+   * 
+   */
+  public void diffResults(GTLFDocument inGTLF, PrintWriter pw)
+  {
+
+    String missingFromThis = ">>>>>>>>>>>>>>>",
+      missingFromIn = "<<<<<<<<<<<<<<<";
+
+    Set inUsedTestPointsSet = new HashSet();
+
+    pw.println(
+      "Running result diff between " + getName() + " and " + inGTLF.getName());
+
+    NodeList nl = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+    for (int i = 0, iL = nl.getLength(); i < iL; i++)
+    {
+      Node n = nl.item(i);
+      NodeList inNl =
+        inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+      for (int j = 0, jL = inNl.getLength(); j < jL; j++)
+      {
+        Node in = inNl.item(j);
+        if (inUsedTestPointsSet.contains(in))
+          continue;
+        if (equalTestPoints(this, n, inGTLF, in))
+        {
+          inUsedTestPointsSet.add(in);
+          String r = getAttributeValue(n, PARAM_RESULT_RESULT);
+          String inr = getAttributeValue(in, PARAM_RESULT_RESULT);
+          if (!r.equals(inr))
+          {
+            StringBuffer buf = new StringBuffer();
+            GTLFTestResultAdapter res = new GTLFTestResultAdapter();
+
+            res.init(n);
+            buf.append(missingFromIn).append(sep).append(
+              res.toShortString()).append(
+              sep);
+
+            res.init(in);
+            buf.append(missingFromThis).append(sep).append(
+              res.toShortString()).append(
+              sep);
+
+            pw.print(buf.toString());
+            pw.flush();
+
+          }
+          break;
+        }
+      }
+    }
+  }
+
+  /**
+   * Generates a 'diff' type output between this GTLFDocument and inGTLF
+   * Looks for different Test Points.
+   */
+  public void diffTestPoints(GTLFDocument inGTLF)
+  {
+    diffTestPoints(inGTLF, new PrintWriter(System.out));
+  }
+
+  /**
+   * Generates a 'diff' type output between this GTLFDocument and inGTLF
+   * Looks for different Test Points.
+   */
+  public void diffTestPoints(GTLFDocument inGTLF, PrintWriter pw)
+  {
+    Set testPointsSet =
+      loadSet(getRoot().getElementsByTagName(TEST_RESULT_ELEMENT));
+    Set inTestPointsSet =
+      loadSet(inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT));
+
+    Set usedTestPointsSet = new HashSet();
+    Set inUsedTestPointsSet = new HashSet();
+
+    NodeList nl = getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+    for (int i = 0, iL = nl.getLength(); i < iL; i++)
+    {
+      Node n = nl.item(i);
+      NodeList inNl =
+        inGTLF.getRoot().getElementsByTagName(TEST_RESULT_ELEMENT);
+      for (int j = 0, jL = inNl.getLength(); j < jL; j++)
+      {
+        Node in = inNl.item(j);
+        if (inUsedTestPointsSet.contains(in))
+          continue;
+        if (equalTestPoints(this, n, inGTLF, in))
+        {
+          usedTestPointsSet.add(n);
+          inUsedTestPointsSet.add(in);
+          break;
+        }
+      }
+    }
+
+    testPointsSet.removeAll(usedTestPointsSet);
+    inTestPointsSet.removeAll(inUsedTestPointsSet);
+
+    pw.println(
+      "Running test point diff between "
+        + getName()
+        + " and "
+        + inGTLF.getName());
+    buildDiffString(testPointsSet, inTestPointsSet, pw);
+  }
+
+  /**
+   * Returns a string representation of this GTLFDocument.
+   */
+  public String toString()
+  {
+    StringBuffer buf = new StringBuffer();
+    buf
+      .append("Name: " + getName())
+      .append(sep)
+      .append(ENVIRONMENT_ELEMENT + ": " + getEnvironment())
+      .append(sep)
+      .append(TEST_LOG_ELEMENT + ": " + getTestLogAttributes())
+      .append(sep)
+      .append(HEADER_INFO_ELEMENT + ": " + getHeaderInfoAttributes());
+    return buf.toString();
+  }
+
+  //=========================================================================
+  // Private Helper Methods
+
+  private String getAttributeValue(Node n, String attrName)
+  {
+    String value = null;
+    NamedNodeMap attributes = n.getAttributes();
+    Node valueNode = attributes.getNamedItem(attrName);
+    if (valueNode != null)
+    {
+      value = valueNode.getNodeValue();
+    }
+    return value;
+  }
+
+  private boolean mapSubsetOfMap(Map m1, Map m2)
+  {
+    // is everything in m1 also in m2?
+    Iterator i = m1.keySet().iterator();
+    boolean isSubset = true;
+    while (i.hasNext())
+    {
+      String key = (String)i.next();
+      if (!m1.get(key).equals(m2.get(key)))
+      {
+        isSubset = false;
+        break;
+      }
+    }
+    return isSubset;
+  }
+
+  private Set loadSet(NodeList nl)
+  {
+    Set s = new HashSet();
+    if (nl != null)
+      for (int i = 0, iL = nl.getLength(); i < iL; i++)
+        s.add(nl.item(i));
+    return s;
+  }
+
+  private void buildDiffString(Set base, Set s, PrintWriter pw)
+  {
+
+    String missingFromThis = ">>>>>>>>>>>>>>>",
+      missingFromIn = "<<<<<<<<<<<<<<<";
+
+    Iterator tpIter2 = base.iterator();
+    while (tpIter2.hasNext())
+    {
+      Node n = (Node)tpIter2.next();
+      GTLFTestResultAdapter res = new GTLFTestResultAdapter();
+      res.init(n);
+      StringBuffer buf = new StringBuffer();
+      buf.append(missingFromIn).append(sep).append(res.toShortString()).append(
+        sep);
+      pw.print(buf.toString());
+    }
+    Iterator inTpIter2 = s.iterator();
+    while (inTpIter2.hasNext())
+    {
+      Node in = (Node)inTpIter2.next();
+      GTLFTestResultAdapter res = new GTLFTestResultAdapter();
+      res.init(in);
+      StringBuffer buf = new StringBuffer();
+      buf.append(missingFromThis).append(sep).append(
+        res.toShortString()).append(
+        sep);
+      pw.print(buf.toString());
+    }
+
+    if (base.isEmpty() && s.isEmpty())
+    {
+      StringBuffer buf = new StringBuffer();
+      buf.append("=====").append(" no diff ").append("=====").append(
+        sep).append(
+        sep);
+      pw.print(buf.toString());
+    }
+    pw.flush();
+  }
+
+  private int countResults()
+  {
+    return getRoot().getElementsByTagName(TEST_RESULT_ELEMENT).getLength();
+  }
+
+  // If we added results to this gtlf log
+  // need to update checksum and resultcount
+  private void updateResultCountAttributes()
+  {
+    NodeList l = getRoot().getElementsByTagName(HEADER_INFO_ELEMENT);
+    if (l != null && l.getLength() > 0)
+    {
+      Node n = l.item(0);
+      NamedNodeMap map = n.getAttributes();
+      int count = countResults();
+      if (map.getNamedItem(PARAM_HEAD_CHKSUM) != null)
+        map.getNamedItem(PARAM_HEAD_CHKSUM).setNodeValue(String.valueOf(count));
+      if (map.getNamedItem(PARAM_HEAD_RESULTCOUNT) != null)
+        map.getNamedItem(PARAM_HEAD_RESULTCOUNT).setNodeValue(
+          String.valueOf(count));
+    }
+  }
+
+  private boolean equalTestParameters(Node n1, Node n2)
+  {
+    boolean result = false;
+    String paramStr1 = getTestParameters(n1);
+    String paramStr2 = getTestParameters(n2);
+    if (verbose)
+    {
+      TchUtils.log("Comparing params...");
+    }
+    if (String.valueOf(paramStr1).equals(String.valueOf(paramStr2)))
+    {
+      result = true;
+      if (debug)
+        TchUtils.log("Params are equal");
+    }
+    else
+    {
+      result = false;
+      if (debug)
+        TchUtils.log("Params not equal");
+    }
+    return result;
+  }
+
+  private String getTestParameters(Node n)
+  {
+    String testParams = null;
+    NodeList children = n.getChildNodes();
+    int length = children.getLength();
+    for (int i = 0; i < length; i++)
+    {
+      Node p = children.item(i);
+      if (p.getNodeName().equals(TEST_PARAMETERS_ELEMENT))
+      {
+        testParams = p.getFirstChild().getNodeValue();
+      }
+    }
+    // make sure we do not count white space as parameter
+    if (testParams != null)
+    {
+      StringTokenizer st = new StringTokenizer(testParams, sep);
+      StringBuffer buf = new StringBuffer();
+      while (st.hasMoreTokens())
+      {
+        buf.append(st.nextToken().trim());
+      }
+      testParams = buf.toString();
+    }
+    if (debug)
+      TchUtils.log("Params are: " + testParams);
+    return testParams;
+  }
+
+  /**
+   * Checks if two test points are equal.
+   *   What determines if two results are equal?
+   *     - testcasename, testunit, parameters, environment.
+   */
+  private boolean equalTestPoints(
+    GTLFDocument d1,
+    Node rNode1,
+    GTLFDocument d2,
+    Node rNode2)
+  {
+    boolean testPointsAreEqual = false;
+    Map rNode1Attr = new HashMap();
+    DomUtils.treeAttributesToMap(rNode1, rNode1Attr);
+    // first only check testcasename and testunit
+    Map search = new HashMap();
+    search.put(PARAM_TEST_CASE_NAME, rNode1Attr.get(PARAM_TEST_CASE_NAME));
+    search.put(PARAM_TEST_UNIT, rNode1Attr.get(PARAM_TEST_UNIT));
+    Map rNode2Attr = new HashMap();
+    DomUtils.treeAttributesToMap(rNode2, rNode2Attr);
+    if (mapSubsetOfMap(search, rNode2Attr))
+    {
+      // now check the values of parameters and test environments...
+      if (equalTestParameters(rNode1, rNode2)
+        && equalTestEnvironments(d1, rNode1, d2, rNode2))
+      {
+        testPointsAreEqual = true;
+      }
+    }
+    if (debug)
+      TchUtils.log("equalTestPoints: " + testPointsAreEqual);
+    return testPointsAreEqual;
+  }
+
+  private boolean equalTestEnvironments(
+    GTLFDocument d1,
+    Node n1,
+    GTLFDocument d2,
+    Node n2)
+  {
+    Map resultEnv1 = d1.getResultEnv(n1);
+    Map resultEnv2 = d2.getResultEnv(n2);
+    if (debug)
+    {
+      TchUtils.log("Env1 " + n1.getNodeName() + ": " + resultEnv1);
+      TchUtils.log("Env2 " + n2.getNodeName() + ": " + resultEnv2);
+    }
+    boolean result = resultEnv1.equals(resultEnv2);
+    if (debug)
+      TchUtils.log("Envs are equals: " + result);
+    return result;
+  }
+
+  private Map getTestEnvironment(Node n)
+  {
+    Map env = new HashMap();
+    NodeList children = n.getChildNodes();
+    int length = children.getLength();
+    for (int i = 0; i < length; i++)
+    {
+      if (children.item(i).getNodeName().equals(ENVIRONMENT_ELEMENT))
+      {
+        Map m = new HashMap();
+        DomAsMap.load(children.item(i), m);
+        int numEnvAttributes = DomAsMap.getSizeForEntry(m, ENV_ATT_ELEMENT);
+        for (int j = 1; j <= numEnvAttributes; j++)
+        {
+          env.put(
+            m.get(ENV_ATT_ELEMENT + "!" + j + "#name"),
+            m.get(ENV_ATT_ELEMENT + "!" + j + "#value"));
+        }
+        break;
+      }
+    }
+    return env;
+  }
+
+  /**
+   * Extracts 'test-log', 'header-info' and 'env'
+   */
+  private void initHeaders()
+  {
+    NodeList l = getRoot().getElementsByTagName(TEST_LOG_ELEMENT);
+    testLog = DomUtils.attributesToMap(l.item(0));
+
+    l = getRoot().getElementsByTagName(HEADER_INFO_ELEMENT);
+    headerInfo = DomUtils.attributesToMap(l.item(0));
+
+    environment = getTestEnvironment(getRoot().getDocumentElement());
+  }
+
+  /**
+   * Takes a result node and returns the complete
+   * environment map for that result
+   */
+  private Map getResultEnv(Node n)
+  {
+    // clone the top level environment of this GTLF
+    Map allEnv = new HashMap(environment);
+    Map resultEnv = getTestEnvironment(n);
+    // override things in top level env
+    allEnv.putAll(resultEnv);
+    return allEnv;
+  }
+
+  private void removeNode(Node deleteMe)
+  {
+    if (deleteMe != getRoot().getDocumentElement())
+    {
+      // get the parent of "deleteMe"
+      Node parent = deleteMe.getParentNode();
+      // remove "deleteMe"
+      parent.removeChild(deleteMe);
+    }
+  }
+
+  /**
+   * Appends passed in Node to this GTLFDocument's root
+   */
+  private void appendNode(Node inNode)
+  {
+    Node newNode = getRoot().importNode(inNode, true);
+    getRoot().getDocumentElement().appendChild(newNode);
+  }
+}

Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFEntityResolver.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFEntityResolver.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFEntityResolver.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFEntityResolver.java Fri Aug 12 08:12:28 2005
@@ -1,49 +1,49 @@
-package org.apache.beehive.test.tools.tch.util.gtlf;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-public class GTLFEntityResolver implements EntityResolver
-{
-
-  public static String REMOTE_GTLF_DTD_V10 =
-    "http://incubator.apache.org/beehive/dtd/gtlf/gtlf-config-1.0.dtd";
-  public static String LOCAL_GTLF_DTD_V10 = "gtlf-config-1-0.dtd";
-
-  public static String REMOTE_GTLF_DTD_V20 =
-    "http://incubator.apache.org/beehive/dtd/gtlf/gtlf-config-2.0.dtd";
-  public static String LOCAL_GTLF_DTD_V20 = "gtlf-config-2-0.dtd";
-
-  public static String REMOTE_VALID_VALUES_DTD_V10 =
-    "http://incubator.apache.org/beehive/dtd/gtlf/valid-values-1.0.dtd";
-  public static String LOCAL_VALID_VALUES_DTD_V10 = "valid-values-1-0.dtd";
-
-  private static Map mappings = new HashMap();
-
-  static {
-    mappings.put(REMOTE_GTLF_DTD_V10, LOCAL_GTLF_DTD_V10);
-    mappings.put(REMOTE_GTLF_DTD_V20, LOCAL_GTLF_DTD_V20);
-    mappings.put(REMOTE_VALID_VALUES_DTD_V10, LOCAL_VALID_VALUES_DTD_V10);
-  }
- 
-  public InputSource resolveEntity(String publicId, String systemId)
-  {
-    InputSource is = null;
-    if (mappings.containsKey(systemId))
-    {
-      // search in classpath (it is in tchx.jar file)
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      String local = (String)mappings.get(systemId);
-      InputStream dtdInputStream = cl.getResourceAsStream(local);
-      if (dtdInputStream != null)
-      {
-        is = new InputSource(dtdInputStream);
-      }
-    }
-    return is;
-  }
-}
+package org.apache.beehive.test.tools.tch.util.gtlf;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+public class GTLFEntityResolver implements EntityResolver
+{
+
+  public static String REMOTE_GTLF_DTD_V10 =
+    "http://incubator.apache.org/beehive/dtd/gtlf/gtlf-config-1.0.dtd";
+  public static String LOCAL_GTLF_DTD_V10 = "gtlf-config-1-0.dtd";
+
+  public static String REMOTE_GTLF_DTD_V20 =
+    "http://incubator.apache.org/beehive/dtd/gtlf/gtlf-config-2.0.dtd";
+  public static String LOCAL_GTLF_DTD_V20 = "gtlf-config-2-0.dtd";
+
+  public static String REMOTE_VALID_VALUES_DTD_V10 =
+    "http://incubator.apache.org/beehive/dtd/gtlf/valid-values-1.0.dtd";
+  public static String LOCAL_VALID_VALUES_DTD_V10 = "valid-values-1-0.dtd";
+
+  private static Map mappings = new HashMap();
+
+  static {
+    mappings.put(REMOTE_GTLF_DTD_V10, LOCAL_GTLF_DTD_V10);
+    mappings.put(REMOTE_GTLF_DTD_V20, LOCAL_GTLF_DTD_V20);
+    mappings.put(REMOTE_VALID_VALUES_DTD_V10, LOCAL_VALID_VALUES_DTD_V10);
+  }
+ 
+  public InputSource resolveEntity(String publicId, String systemId)
+  {
+    InputSource is = null;
+    if (mappings.containsKey(systemId))
+    {
+      // search in classpath (it is in tchx.jar file)
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      String local = (String)mappings.get(systemId);
+      InputStream dtdInputStream = cl.getResourceAsStream(local);
+      if (dtdInputStream != null)
+      {
+        is = new InputSource(dtdInputStream);
+      }
+    }
+    return is;
+  }
+}

Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFEntityResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFLogMerger.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFLogMerger.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFLogMerger.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFLogMerger.java Fri Aug 12 08:12:28 2005
@@ -1,167 +1,167 @@
-package org.apache.beehive.test.tools.tch.util.gtlf;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.xml.sax.InputSource;
-
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
-
-/**
- * Merges any number of GTLF files.
- * 
- * @version 1.0, Feb 20, 2001
- */
-public class GTLFLogMerger
-{
-
-  public static String sep = System.getProperty("line.separator");
-
-  public static String HELP_MESSAGE =
-    sep
-      + "GTLFMerger takes any number of GTLF test result files and "
-      + "merges them."
-      + sep
-      + sep
-      + "Usage: "
-      + sep
-      + sep
-      + "  java org.apache.beehive.test.tools.tch.utils.gtlf.GTLFLogMerger <merged file name> <file1> "
-      + "[<file2> ... <fileN>]"
-      + sep
-      + sep
-      + "About duplicate results:"
-      + sep
-      + "  Duplicate results are results that have the same testcase name, "
-      + "testunit,"
-      + sep
-      + "  parameters and env values. If GTLFMerger sees duplicate results, the"
-      + sep
-      + "  following rule applies:"
-      + sep
-      + "    - If one result is a SUCCESS, and the other is not, then"
-      + sep
-      + "        keep the SUCCESS result and discard the other one."
-      + sep
-      + sep
-      + "For questions or comments, email wls-tools-qa@bea.com"
-      + sep
-      + sep;
-
-  private GTLFDocument merger;
-  private List fileNames;
-  private String outFileName;
-
-  // ======================================================
-  // Public Methods
-
-  public void init(String inOutFileName, List inFileNames)
-  {
-    fileNames = inFileNames;
-    outFileName = inOutFileName;
-    String fileStr = (String)fileNames.get(0);
-    try
-    {
-      TchUtils.log("  Base file is: " + fileStr);
-      merger = new GTLFDocument(new InputSource(fileStr));
-      merger.setName(fileStr);
-      fileNames.remove(fileStr);
-    }
-    catch (Exception e)
-    {
-      TchUtils.log("Unable to instantiate DOM for file: " + fileStr);
-      TchUtils.log(e.getClass().getName() + ": " + e.getMessage());
-    }
-  }
-
-  public void run()
-  {
-    if (merger == null)
-    {
-      TchUtils.log("Merger is empty, giving up");
-      return;
-    }
-    Iterator i = fileNames.iterator();
-    String fileStr = "";
-    while (i.hasNext())
-    {
-      try
-      {
-        fileStr = (String)i.next();
-        TchUtils.log("  Reading file: " + fileStr);
-        GTLFDocument d = new GTLFDocument(new InputSource(fileStr));
-        d.setName(fileStr);
-        merger.merge(d);
-      }
-      catch (Exception e)
-      {
-        TchUtils.log("Unable to instantiate DOM for file: " + fileStr);
-        TchUtils.log(e.toString());
-      }
-    }
-    // write to a file
-    try
-    {
-      PrintWriter pw =
-        new PrintWriter(new FileOutputStream(new File(outFileName)));
-
-      DomUtils.writeDom(merger.getRoot(), pw);
-      
-      TchUtils.log("Written merged gtlf to " + outFileName);
-    }
-    catch (Exception e)
-    {
-      TchUtils.log("Unable to write file");
-      TchUtils.log(e);
-    }
-  }
-
-  // ======================= main ========================
-
-  public static void main(String[] args)
-  {
-    if (args.length == 0)
-    {
-      System.out.println(HELP_MESSAGE);
-      return;
-    }
-    else if (args.length <= 1)
-    {
-      System.out.println("Incomplete args." + sep + HELP_MESSAGE);
-      return;
-    }
-
-    TchUtils.log("Starting GTLFLogMerger");
-
-    String outFileName = args[0];
-
-    List logs = new ArrayList();
-    for (int i = 1; i < args.length; i++)
-    {
-      if (!new File(args[i]).exists())
-      {
-        TchUtils.log("Could not find file " + args[i]);
-      }
-      else
-      {
-        logs.add(args[i]);
-      }
-    }
-    if (logs.isEmpty())
-    {
-      TchUtils.log("Nothing to merge...");
-      TchUtils.log("Giving up.");
-      return;
-    }
-
-    GTLFLogMerger m = new GTLFLogMerger();
-    m.init(outFileName, logs);
-    m.run();
-    TchUtils.log("Done");
-  }
-}
+package org.apache.beehive.test.tools.tch.util.gtlf;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.InputSource;
+
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
+
+/**
+ * Merges any number of GTLF files.
+ * 
+ * @version 1.0, Feb 20, 2001
+ */
+public class GTLFLogMerger
+{
+
+  public static String sep = System.getProperty("line.separator");
+
+  public static String HELP_MESSAGE =
+    sep
+      + "GTLFMerger takes any number of GTLF test result files and "
+      + "merges them."
+      + sep
+      + sep
+      + "Usage: "
+      + sep
+      + sep
+      + "  java org.apache.beehive.test.tools.tch.utils.gtlf.GTLFLogMerger <merged file name> <file1> "
+      + "[<file2> ... <fileN>]"
+      + sep
+      + sep
+      + "About duplicate results:"
+      + sep
+      + "  Duplicate results are results that have the same testcase name, "
+      + "testunit,"
+      + sep
+      + "  parameters and env values. If GTLFMerger sees duplicate results, the"
+      + sep
+      + "  following rule applies:"
+      + sep
+      + "    - If one result is a SUCCESS, and the other is not, then"
+      + sep
+      + "        keep the SUCCESS result and discard the other one."
+      + sep
+      + sep
+      + "For questions or comments, email wls-tools-qa@bea.com"
+      + sep
+      + sep;
+
+  private GTLFDocument merger;
+  private List fileNames;
+  private String outFileName;
+
+  // ======================================================
+  // Public Methods
+
+  public void init(String inOutFileName, List inFileNames)
+  {
+    fileNames = inFileNames;
+    outFileName = inOutFileName;
+    String fileStr = (String)fileNames.get(0);
+    try
+    {
+      TchUtils.log("  Base file is: " + fileStr);
+      merger = new GTLFDocument(new InputSource(fileStr));
+      merger.setName(fileStr);
+      fileNames.remove(fileStr);
+    }
+    catch (Exception e)
+    {
+      TchUtils.log("Unable to instantiate DOM for file: " + fileStr);
+      TchUtils.log(e.getClass().getName() + ": " + e.getMessage());
+    }
+  }
+
+  public void run()
+  {
+    if (merger == null)
+    {
+      TchUtils.log("Merger is empty, giving up");
+      return;
+    }
+    Iterator i = fileNames.iterator();
+    String fileStr = "";
+    while (i.hasNext())
+    {
+      try
+      {
+        fileStr = (String)i.next();
+        TchUtils.log("  Reading file: " + fileStr);
+        GTLFDocument d = new GTLFDocument(new InputSource(fileStr));
+        d.setName(fileStr);
+        merger.merge(d);
+      }
+      catch (Exception e)
+      {
+        TchUtils.log("Unable to instantiate DOM for file: " + fileStr);
+        TchUtils.log(e.toString());
+      }
+    }
+    // write to a file
+    try
+    {
+      PrintWriter pw =
+        new PrintWriter(new FileOutputStream(new File(outFileName)));
+
+      DomUtils.writeDom(merger.getRoot(), pw);
+      
+      TchUtils.log("Written merged gtlf to " + outFileName);
+    }
+    catch (Exception e)
+    {
+      TchUtils.log("Unable to write file");
+      TchUtils.log(e);
+    }
+  }
+
+  // ======================= main ========================
+
+  public static void main(String[] args)
+  {
+    if (args.length == 0)
+    {
+      System.out.println(HELP_MESSAGE);
+      return;
+    }
+    else if (args.length <= 1)
+    {
+      System.out.println("Incomplete args." + sep + HELP_MESSAGE);
+      return;
+    }
+
+    TchUtils.log("Starting GTLFLogMerger");
+
+    String outFileName = args[0];
+
+    List logs = new ArrayList();
+    for (int i = 1; i < args.length; i++)
+    {
+      if (!new File(args[i]).exists())
+      {
+        TchUtils.log("Could not find file " + args[i]);
+      }
+      else
+      {
+        logs.add(args[i]);
+      }
+    }
+    if (logs.isEmpty())
+    {
+      TchUtils.log("Nothing to merge...");
+      TchUtils.log("Giving up.");
+      return;
+    }
+
+    GTLFLogMerger m = new GTLFLogMerger();
+    m.init(outFileName, logs);
+    m.run();
+    TchUtils.log("Done");
+  }
+}

Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFLogMerger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFProperties.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFProperties.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFProperties.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFProperties.java Fri Aug 12 08:12:28 2005
@@ -1,150 +1,150 @@
-package org.apache.beehive.test.tools.tch.util.gtlf;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.beehive.test.tools.tch.util.AntProperties;
-
-public class GTLFProperties extends AntProperties implements GTLFConstants
-{
-  public final static String TCH_PREFIX = "tch.";
-
-  public final static String PARAM_SYSTEM_USER = "user.name";
-
-  public final static String DEFAULT_HARNESSTYPE = "Tch 3";
-
-  private static final Collection testLogAttrsNames = new HashSet();
-  static {
-    testLogAttrsNames.add(appendTch(PARAM_RELEASE));
-    testLogAttrsNames.add(appendTch(PARAM_RUNID));
-    testLogAttrsNames.add(appendTch(PARAM_CHANGE_NO));
-    testLogAttrsNames.add(appendTch(PARAM_LOAD));
-    testLogAttrsNames.add(appendTch(PARAM_BRANCH));
-    testLogAttrsNames.add(appendTch(PARAM_PHASE));
-    testLogAttrsNames.add(appendTch(PARAM_ANALYZER));
-    testLogAttrsNames.add(appendTch(PARAM_HOSTNAME));
-    testLogAttrsNames.add(appendTch(PARAM_TOPTESTFILE));
-    testLogAttrsNames.add(appendTch(PARAM_RUNMODIFIER));
-  }
-
-  private static final Collection headerAttrsNames = new HashSet();
-  static {
-    headerAttrsNames.add(appendTch(PARAM_HEAD_CHKSUM));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_RESULTCOUNT));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_EXECACCOUNT));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_EXECDATE));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_IMPORTERNAME));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_HARNESSTYPE));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_IMPORTINFO));
-    headerAttrsNames.add(appendTch(PARAM_HEAD_TESTRUNTYPE));
-  }
-
-  public static String getExecAccount()
-  {
-    String execAccount =
-      getGlobalProperty(appendTch(PARAM_HEAD_EXECACCOUNT), null);
-    if (execAccount == null)
-    {
-      execAccount = System.getProperty(PARAM_SYSTEM_USER);
-      if (execAccount == null)
-      {
-        throw new GTLFConfigurationRuntimeException(
-          "Cannot determine "
-            + PARAM_HEAD_EXECACCOUNT
-            + " - please set "
-            + appendTch(PARAM_HEAD_EXECACCOUNT)
-            + " on the command line");
-      }
-    }
-    return execAccount;
-  }
-
-  public static String getExecDate()
-  {
-    String execDate =
-      getGlobalProperty(appendTch(PARAM_HEAD_EXECDATE), null);
-    if (execDate == null)
-      execDate = new java.sql.Timestamp(System.currentTimeMillis()).toString();
-    return execDate;
-  }
-
-  public static String getHarnessType()
-  {
-    String harnessType =
-      getGlobalProperty(appendTch(PARAM_HEAD_HARNESSTYPE), null);
-    if (harnessType == null)
-      harnessType = DEFAULT_HARNESSTYPE;
-    return harnessType;
-  }
-
-  public static Map getHeaderAttrsMap()
-  {
-    Map m = new HashMap();
-    
-    // special cases, with defaults
-    m.put(appendTch(PARAM_HEAD_EXECACCOUNT), getExecAccount());
-    m.put(appendTch(PARAM_HEAD_EXECDATE), getExecDate());
-    m.put(appendTch(PARAM_HEAD_HARNESSTYPE), getHarnessType());
-    
-    // now add all remaining ones (only add if we did not add already above)
-    for (Iterator iter = getHeaderAttrsNames().iterator(); iter.hasNext();)
-	{
-	  String key = (String)iter.next();
-	  String value = getGlobalProperty(key, null);
-	  if (!m.containsKey(key) && value != null)
-	    m.put(key, value);
-     }
-    return m;
-  }
-
-  public static Map getTestLogAttrsMap()
-  {
-    Map m = new HashMap();
-    for (Iterator iter = getTestLogAttrsNames().iterator(); iter.hasNext();)
-    {
-      String key = (String)iter.next();
-      String value = getGlobalProperty(key, null);
-      if (value != null)
-        m.put(key, value);
-    }
-    return m;
-  }
-
-  public static Map getEnvironmentMap()
-  {
-    Map envMap = new HashMap();
-    // support both tch.env.* (old) and tch.log.gtlf.env.*
-    String oldEnvPrefix = appendTch(OLD_GTLF_ENV_PREFIX);
-    String envPrefix = appendTch(GTLF_ENV_PREFIX);
-    Iterator i = globalProperties.entrySet().iterator();
-    while (i.hasNext())
-    {
-      Map.Entry entry = (Map.Entry)i.next();
-      String key = (String)entry.getKey();
-      if (key.startsWith(oldEnvPrefix) || key.startsWith(envPrefix))
-        envMap.put(key, entry.getValue());
-    }
-    return envMap;
-  }
-
-  //private stuff
-
-  private static Collection getTestLogAttrsNames()
-  {
-    return testLogAttrsNames;
-  }
-
-  private static Collection getHeaderAttrsNames()
-  {
-    return headerAttrsNames;
-  }
-
-  private static String appendTch(String propName)
-  {
-    return TCH_PREFIX + propName;
-  }
-
-}
+package org.apache.beehive.test.tools.tch.util.gtlf;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.beehive.test.tools.tch.util.AntProperties;
+
+public class GTLFProperties extends AntProperties implements GTLFConstants
+{
+  public final static String TCH_PREFIX = "tch.";
+
+  public final static String PARAM_SYSTEM_USER = "user.name";
+
+  public final static String DEFAULT_HARNESSTYPE = "Tch 3";
+
+  private static final Collection testLogAttrsNames = new HashSet();
+  static {
+    testLogAttrsNames.add(appendTch(PARAM_RELEASE));
+    testLogAttrsNames.add(appendTch(PARAM_RUNID));
+    testLogAttrsNames.add(appendTch(PARAM_CHANGE_NO));
+    testLogAttrsNames.add(appendTch(PARAM_LOAD));
+    testLogAttrsNames.add(appendTch(PARAM_BRANCH));
+    testLogAttrsNames.add(appendTch(PARAM_PHASE));
+    testLogAttrsNames.add(appendTch(PARAM_ANALYZER));
+    testLogAttrsNames.add(appendTch(PARAM_HOSTNAME));
+    testLogAttrsNames.add(appendTch(PARAM_TOPTESTFILE));
+    testLogAttrsNames.add(appendTch(PARAM_RUNMODIFIER));
+  }
+
+  private static final Collection headerAttrsNames = new HashSet();
+  static {
+    headerAttrsNames.add(appendTch(PARAM_HEAD_CHKSUM));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_RESULTCOUNT));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_EXECACCOUNT));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_EXECDATE));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_IMPORTERNAME));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_HARNESSTYPE));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_IMPORTINFO));
+    headerAttrsNames.add(appendTch(PARAM_HEAD_TESTRUNTYPE));
+  }
+
+  public static String getExecAccount()
+  {
+    String execAccount =
+      getGlobalProperty(appendTch(PARAM_HEAD_EXECACCOUNT), null);
+    if (execAccount == null)
+    {
+      execAccount = System.getProperty(PARAM_SYSTEM_USER);
+      if (execAccount == null)
+      {
+        throw new GTLFConfigurationRuntimeException(
+          "Cannot determine "
+            + PARAM_HEAD_EXECACCOUNT
+            + " - please set "
+            + appendTch(PARAM_HEAD_EXECACCOUNT)
+            + " on the command line");
+      }
+    }
+    return execAccount;
+  }
+
+  public static String getExecDate()
+  {
+    String execDate =
+      getGlobalProperty(appendTch(PARAM_HEAD_EXECDATE), null);
+    if (execDate == null)
+      execDate = new java.sql.Timestamp(System.currentTimeMillis()).toString();
+    return execDate;
+  }
+
+  public static String getHarnessType()
+  {
+    String harnessType =
+      getGlobalProperty(appendTch(PARAM_HEAD_HARNESSTYPE), null);
+    if (harnessType == null)
+      harnessType = DEFAULT_HARNESSTYPE;
+    return harnessType;
+  }
+
+  public static Map getHeaderAttrsMap()
+  {
+    Map m = new HashMap();
+    
+    // special cases, with defaults
+    m.put(appendTch(PARAM_HEAD_EXECACCOUNT), getExecAccount());
+    m.put(appendTch(PARAM_HEAD_EXECDATE), getExecDate());
+    m.put(appendTch(PARAM_HEAD_HARNESSTYPE), getHarnessType());
+    
+    // now add all remaining ones (only add if we did not add already above)
+    for (Iterator iter = getHeaderAttrsNames().iterator(); iter.hasNext();)
+	{
+	  String key = (String)iter.next();
+	  String value = getGlobalProperty(key, null);
+	  if (!m.containsKey(key) && value != null)
+	    m.put(key, value);
+     }
+    return m;
+  }
+
+  public static Map getTestLogAttrsMap()
+  {
+    Map m = new HashMap();
+    for (Iterator iter = getTestLogAttrsNames().iterator(); iter.hasNext();)
+    {
+      String key = (String)iter.next();
+      String value = getGlobalProperty(key, null);
+      if (value != null)
+        m.put(key, value);
+    }
+    return m;
+  }
+
+  public static Map getEnvironmentMap()
+  {
+    Map envMap = new HashMap();
+    // support both tch.env.* (old) and tch.log.gtlf.env.*
+    String oldEnvPrefix = appendTch(OLD_GTLF_ENV_PREFIX);
+    String envPrefix = appendTch(GTLF_ENV_PREFIX);
+    Iterator i = globalProperties.entrySet().iterator();
+    while (i.hasNext())
+    {
+      Map.Entry entry = (Map.Entry)i.next();
+      String key = (String)entry.getKey();
+      if (key.startsWith(oldEnvPrefix) || key.startsWith(envPrefix))
+        envMap.put(key, entry.getValue());
+    }
+    return envMap;
+  }
+
+  //private stuff
+
+  private static Collection getTestLogAttrsNames()
+  {
+    return testLogAttrsNames;
+  }
+
+  private static Collection getHeaderAttrsNames()
+  {
+    return headerAttrsNames;
+  }
+
+  private static String appendTch(String propName)
+  {
+    return TCH_PREFIX + propName;
+  }
+
+}

Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFResultStripper.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFResultStripper.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFResultStripper.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFResultStripper.java Fri Aug 12 08:12:28 2005
@@ -1,107 +1,107 @@
-package org.apache.beehive.test.tools.tch.util.gtlf;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.beehive.test.tools.tch.util.AbstractResultProcessor;
-import org.apache.beehive.test.tools.tch.util.TestResult;
-
-/**
- *
- */
-public class GTLFResultStripper
-  extends AbstractResultProcessor
-  implements GTLFConstants
-{
-
-  public TestResult processResult(TestResult inResult)
-  {
-    GTLFTestResultAdapter res = null;
-    if (inResult != null)
-    {
-      res = new GTLFTestResultAdapter();
-      res.clear();
-      res.init(inResult);
-      res.setEnvironment(extractEnvironment(res.getParameters(), true));
-    }
-    return super.processResult(res);
-  }
-
-  public Map processGeneric(Map inMap)
-  {
-    Map m = null;
-    if (inMap != null)
-    {
-      m = new HashMap();
-      String[] params =
-        new String[] {
-          PARAM_RUNID,
-          PARAM_TESTTYPE,
-          PARAM_CHANGE_NO,
-          PARAM_RELEASE,
-          PARAM_LOAD,
-          PARAM_BRANCH,
-          PARAM_PHASE,
-          PARAM_ANALYZER,
-          PARAM_HOSTNAME,
-          PARAM_TOPTESTFILE,
-          PARAM_RUNMODIFIER,
-          PARAM_HEAD_CHKSUM,
-          PARAM_HEAD_RESULTCOUNT,
-          PARAM_HEAD_EXECACCOUNT,
-          PARAM_HEAD_EXECDATE,
-          PARAM_HEAD_IMPORTERNAME,
-          PARAM_HEAD_HARNESSTYPE,
-          PARAM_HEAD_IMPORTINFO,
-          PARAM_HEAD_TESTRUNTYPE };
-
-      for (int i = 0; i < params.length; i++)
-      {
-        if (inMap.get(PARAM_PREFIX + params[i]) != null)
-        {
-          m.put(params[i], inMap.get(PARAM_PREFIX + params[i]));
-        }
-      }
-      m.putAll(extractEnvironment(inMap, false));
-    }
-    return super.processGeneric(m);
-  }
-
-  private Map extractEnvironment(Map inMap, boolean removeFromSourceMap)
-  {
-    // get env values
-    Map envMap = new HashMap();
-    Set keys = new HashSet(inMap.keySet());
-    if (inMap != null)
-    {
-      // support both tch.env.* (old) and tch.log.gtlf.env.*
-      String oldEnvPrefix = PARAM_PREFIX + OLD_GTLF_ENV_PREFIX;
-      String envPrefix = PARAM_PREFIX + GTLF_ENV_PREFIX;
-      Iterator i = keys.iterator();
-      while (i.hasNext())
-      {
-        String key = (String)i.next();
-        if (key.startsWith(envPrefix))
-        {
-          envMap.put(key.substring(envPrefix.length()), inMap.get(key));
-          if (removeFromSourceMap)
-          {
-            inMap.remove(key);
-          }
-        }
-        else if (key.startsWith(oldEnvPrefix))
-        {
-          envMap.put(key.substring(oldEnvPrefix.length()), inMap.get(key));
-          if (removeFromSourceMap)
-          {
-            inMap.remove(key);
-          }
-        }
-      }
-    }
-    return envMap;
-  }
-}
+package org.apache.beehive.test.tools.tch.util.gtlf;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.beehive.test.tools.tch.util.AbstractResultProcessor;
+import org.apache.beehive.test.tools.tch.util.TestResult;
+
+/**
+ *
+ */
+public class GTLFResultStripper
+  extends AbstractResultProcessor
+  implements GTLFConstants
+{
+
+  public TestResult processResult(TestResult inResult)
+  {
+    GTLFTestResultAdapter res = null;
+    if (inResult != null)
+    {
+      res = new GTLFTestResultAdapter();
+      res.clear();
+      res.init(inResult);
+      res.setEnvironment(extractEnvironment(res.getParameters(), true));
+    }
+    return super.processResult(res);
+  }
+
+  public Map processGeneric(Map inMap)
+  {
+    Map m = null;
+    if (inMap != null)
+    {
+      m = new HashMap();
+      String[] params =
+        new String[] {
+          PARAM_RUNID,
+          PARAM_TESTTYPE,
+          PARAM_CHANGE_NO,
+          PARAM_RELEASE,
+          PARAM_LOAD,
+          PARAM_BRANCH,
+          PARAM_PHASE,
+          PARAM_ANALYZER,
+          PARAM_HOSTNAME,
+          PARAM_TOPTESTFILE,
+          PARAM_RUNMODIFIER,
+          PARAM_HEAD_CHKSUM,
+          PARAM_HEAD_RESULTCOUNT,
+          PARAM_HEAD_EXECACCOUNT,
+          PARAM_HEAD_EXECDATE,
+          PARAM_HEAD_IMPORTERNAME,
+          PARAM_HEAD_HARNESSTYPE,
+          PARAM_HEAD_IMPORTINFO,
+          PARAM_HEAD_TESTRUNTYPE };
+
+      for (int i = 0; i < params.length; i++)
+      {
+        if (inMap.get(PARAM_PREFIX + params[i]) != null)
+        {
+          m.put(params[i], inMap.get(PARAM_PREFIX + params[i]));
+        }
+      }
+      m.putAll(extractEnvironment(inMap, false));
+    }
+    return super.processGeneric(m);
+  }
+
+  private Map extractEnvironment(Map inMap, boolean removeFromSourceMap)
+  {
+    // get env values
+    Map envMap = new HashMap();
+    Set keys = new HashSet(inMap.keySet());
+    if (inMap != null)
+    {
+      // support both tch.env.* (old) and tch.log.gtlf.env.*
+      String oldEnvPrefix = PARAM_PREFIX + OLD_GTLF_ENV_PREFIX;
+      String envPrefix = PARAM_PREFIX + GTLF_ENV_PREFIX;
+      Iterator i = keys.iterator();
+      while (i.hasNext())
+      {
+        String key = (String)i.next();
+        if (key.startsWith(envPrefix))
+        {
+          envMap.put(key.substring(envPrefix.length()), inMap.get(key));
+          if (removeFromSourceMap)
+          {
+            inMap.remove(key);
+          }
+        }
+        else if (key.startsWith(oldEnvPrefix))
+        {
+          envMap.put(key.substring(oldEnvPrefix.length()), inMap.get(key));
+          if (removeFromSourceMap)
+          {
+            inMap.remove(key);
+          }
+        }
+      }
+    }
+    return envMap;
+  }
+}

Propchange: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/gtlf/GTLFResultStripper.java
------------------------------------------------------------------------------
    svn:eol-style = native