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 [78/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/tool/GTLFMerger.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/GTLFMerger.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/GTLFMerger.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/GTLFMerger.java Fri Aug 12 08:12:28 2005
@@ -1,131 +1,131 @@
-package org.apache.beehive.test.tools.tch.tool;
-
-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.gtlf.GTLFDocument;
-import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
-
-/**
- * Merges any number of GTLF files.
- * 
- * @version 1.0, Feb 20, 2001
- */
-public class GTLFMerger {
-
-  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.tool.GTLFMerger <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.getClass().getName() + ": " + e.getMessage());
-      }
-    }
-    // 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");
-      e.printStackTrace();
-    }
-  }
-
-  // ======================= 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 GTLFMerger");
-
-    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;
-    } 
-    
-    GTLFMerger m = new GTLFMerger();
-    m.init(outFileName, logs); 
-    m.run();
-    TchUtils.log("Done");
-  }
-}
-
+package org.apache.beehive.test.tools.tch.tool;
+
+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.gtlf.GTLFDocument;
+import org.apache.beehive.test.tools.tch.util.xml.DomUtils;
+
+/**
+ * Merges any number of GTLF files.
+ * 
+ * @version 1.0, Feb 20, 2001
+ */
+public class GTLFMerger {
+
+  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.tool.GTLFMerger <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.getClass().getName() + ": " + e.getMessage());
+      }
+    }
+    // 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");
+      e.printStackTrace();
+    }
+  }
+
+  // ======================= 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 GTLFMerger");
+
+    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;
+    } 
+    
+    GTLFMerger m = new GTLFMerger();
+    m.init(outFileName, logs); 
+    m.run();
+    TchUtils.log("Done");
+  }
+}
+

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/MarkerLogMerger.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/MarkerLogMerger.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/MarkerLogMerger.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/MarkerLogMerger.java Fri Aug 12 08:12:28 2005
@@ -1,288 +1,288 @@
-package org.apache.beehive.test.tools.tch.tool;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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.NestedRuntimeException;
-import org.apache.beehive.test.tools.tch.util.StringUtils;
-
-public class MarkerLogMerger
-{
-  private static final String sep = System.getProperty("line.separator");
-
-  private static final String COMPOSITE_LOG_INPUT_SYS_PROP = "merger.complog";
-
-  private static final String OUTPUT_FILE_SYS_PROP = "merger.output";
-  private static final String OUTPUT_FILE_DEFAULT = "merged.cout";
-
-  private static final String PLACEHOLDER_START = "<!--@";
-  private static final String PLACEHOLDER_END = "@-->";
-
-  private static final String BEGIN_WRAPPER = "<xmp>" + sep;
-  private static final String END_WRAPPER = "</xmp>" + sep;
-  
-
-  private List lines = null;
-
-  public static void main(String[] args) throws Exception
-  {
-    if (args.length == 0)
-    {
-      System.out.println(
-        "\njava "
-          + "-D"
-          + COMPOSITE_LOG_INPUT_SYS_PROP
-          + "=<composite log> "
-          + "[-D"
-          + OUTPUT_FILE_SYS_PROP
-          + "=<output file>] "
-          + "org.apache.beehive.test.tools.tch.tool.MarkerLogMerger "
-          + "name1=log1 name2=log2 nameN=logN\n");
-      return;
-    }
-
-    if (System.getProperty(COMPOSITE_LOG_INPUT_SYS_PROP) == null)
-    {
-      System.out.println(
-        "You must specify which composite log to use, setting -D"
-          + COMPOSITE_LOG_INPUT_SYS_PROP
-          + "=<composite log>");
-      return;
-    }
-
-    MarkerLogMerger m = new MarkerLogMerger();
-
-    //create server logs 
-    //could be made pluggable to take other kinds of logs
-
-    AssociatedLog[] logs = new AssociatedLog[args.length];
-    // split by '='
-    for (int i = 0; i < args.length; i++)
-    {
-      int index = args[i].indexOf('=');
-      if (index == -1 || index == args[i].length() - 1)
-        throw new RuntimeException(
-          args[i] + " must have an '=' followed by a filename");
-      String name = args[i].substring(0, index);
-      String fileName = args[i].substring(index + 1);
-      logs[i] = m.new ServerLog(new File(fileName), name);
-    }
-
-    m.run(
-      new File(System.getProperty(COMPOSITE_LOG_INPUT_SYS_PROP)),
-      new File(System.getProperty(OUTPUT_FILE_SYS_PROP, OUTPUT_FILE_DEFAULT)),
-      logs,
-      System.out);
-  }
-
-  public void run(
-    File compositeLog,
-    File outputFile,
-    AssociatedLog[] externalLogs,
-    PrintStream log)
-  {
-    lines =
-      StringUtils.splitByNewline(
-        TchUtils.getContentsAsString(compositeLog),
-        true);
-    List tmp = new ArrayList();
-    // iterate over lines, and find special marker comments of the form
-    // <!-...@-->
-    for (Iterator iter = lines.iterator(); iter.hasNext();)
-    {
-      String line = (String)iter.next();
-      String trimmedLine = line.trim();
-      if (trimmedLine.startsWith(PLACEHOLDER_START)
-        && trimmedLine.endsWith(PLACEHOLDER_END))
-      {
-        String testName = getTestName(trimmedLine);
-        // now, for each logical test name, get the relevant output 
-        // from the associated logs
-        for (int i = 0; i < externalLogs.length; i++)
-        {
-          List logPart = externalLogs[i].getAssociatedLogOutput(testName);
-          if (!logPart.isEmpty())
-          {
-          	tmp.add(BEGIN_WRAPPER);
-            tmp.add(externalLogs[i].getName());
-            tmp.add(sep);
-            tmp.addAll(logPart);
-            tmp.add(sep);
-            tmp.add(sep);
-            tmp.add(END_WRAPPER);
-          }
-        }
-      }
-      else
-      {
-        tmp.add(line);
-      }
-    }
-
-    log.println("Writing output to " + outputFile.getAbsolutePath());
-    try
-    {
-      PrintWriter pw = new PrintWriter(new FileOutputStream(outputFile));
-      // write everything out
-      for (Iterator iter = tmp.iterator(); iter.hasNext();)
-      {
-        pw.print(iter.next());
-      }
-      pw.flush();
-      pw.close();
-    }
-    catch (FileNotFoundException ex)
-    {
-      throw new NestedRuntimeException(ex);
-    }
-  }
-
-  private String getTestName(String line)
-  {
-    return line.substring(line.indexOf('@') + 1, line.lastIndexOf("@-->"));
-  }
-
-  private class MarkerLog
-  {
-    private List lines = null;
-
-    public MarkerLog(File f) throws FileNotFoundException
-    {
-      if (!f.exists() || !f.isFile())
-        throw new FileNotFoundException(
-          "Cannot find log at " + f.getAbsolutePath());
-
-      lines =
-        StringUtils.splitByNewline(TchUtils.getContentsAsString(f), true);
-    }
-
-    public List getLogPart(String startMarker, String endMarker)
-    {
-      return getLogPart(startMarker, endMarker, false);
-    }
-
-    public List getLogPart(
-      String startMarker,
-      String endMarker,
-      boolean includeMarkerLine)
-    {
-      return getLogPart(startMarker, endMarker, includeMarkerLine, 0);
-    }
-
-    public List getLogPart(
-      String startMarker,
-      String endMarker,
-      boolean includeMarkerLine,
-      int startLine)
-    {
-      List rtn = new ArrayList();
-      boolean foundStartMarker = false;
-
-      // FIXME, instead of iterating over the content every time, 
-      // we should sore this in a map
-      for (int i = startLine; i < lines.size(); i++)
-      {
-        String line = (String)lines.get(i);
-        if (foundStartMarker)
-        {
-          if (line.indexOf(endMarker) > -1)
-          {
-            if (includeMarkerLine)
-              rtn.add(line);
-            return rtn;
-          }
-          rtn.add(line);
-        }
-        else if (!foundStartMarker && line.indexOf(startMarker) > -1)
-        {
-          foundStartMarker = true;
-          if (includeMarkerLine)
-          {
-            rtn.add(line);
-            // also include carriage return, if we have it
-            if ((i + 1) < lines.size())
-              rtn.add(lines.get(i + 1));
-          }
-          i += 2;
-        }
-      }
-      return rtn;
-    }
-  }
-
-  private interface AssociatedLog
-  {
-    /**
-     * @return the name of this associated log
-     */
-    public String getName();
-
-    /**
-     * @param testName
-     * @return output for the test passed in
-     */
-    public List getAssociatedLogOutput(String testName);
-  }
-
-  /**
-   * A server log knows what kind of marker to look for.
-   * 
-   */
-  private class ServerLog implements AssociatedLog
-  {
-    private MarkerLog markerLog = null;
-    private String name = null;
-
-    public ServerLog(File f, String inName) throws FileNotFoundException
-    {
-      markerLog = new MarkerLog(f);
-      name = inName;
-    }
-
-    public String getName()
-    {
-      return name;
-    }
-
-    public List getAssociatedLogOutput(String testName)
-    {
-      String startMarker =
-        TchConstants.SERVERSIDE_START_TEST_MARKER
-          + getTestNameWithoutSubtest(testName);
-      String endMarker = TchUtils.SERVERSIDE_TEST_RESULT_MARKER + testName;
-      return markerLog.getLogPart(startMarker, endMarker, true);
-    }
-    
-    private String getTestNameWithoutSubtest(String testName)
-    {
-      if (getNumDots(testName) == 2)
-      {
-        // has a subtest name
-        return testName.substring(0, testName.lastIndexOf('.'));
-      }
-      return testName;
-    }
-    
-    // assumes '.' is a reserved character
-    // (as it currently for BH test names)
-    private int getNumDots(String testName)
-    {
-      int rtn = 0;
-      for (int i = testName.length() - 1; i > 0; i--)
-      {
-        if (testName.charAt(i) == '.')
-          rtn++;
-      }
-      return rtn;
-    }
-    
-  }
-}
+package org.apache.beehive.test.tools.tch.tool;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+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.NestedRuntimeException;
+import org.apache.beehive.test.tools.tch.util.StringUtils;
+
+public class MarkerLogMerger
+{
+  private static final String sep = System.getProperty("line.separator");
+
+  private static final String COMPOSITE_LOG_INPUT_SYS_PROP = "merger.complog";
+
+  private static final String OUTPUT_FILE_SYS_PROP = "merger.output";
+  private static final String OUTPUT_FILE_DEFAULT = "merged.cout";
+
+  private static final String PLACEHOLDER_START = "<!--@";
+  private static final String PLACEHOLDER_END = "@-->";
+
+  private static final String BEGIN_WRAPPER = "<xmp>" + sep;
+  private static final String END_WRAPPER = "</xmp>" + sep;
+  
+
+  private List lines = null;
+
+  public static void main(String[] args) throws Exception
+  {
+    if (args.length == 0)
+    {
+      System.out.println(
+        "\njava "
+          + "-D"
+          + COMPOSITE_LOG_INPUT_SYS_PROP
+          + "=<composite log> "
+          + "[-D"
+          + OUTPUT_FILE_SYS_PROP
+          + "=<output file>] "
+          + "org.apache.beehive.test.tools.tch.tool.MarkerLogMerger "
+          + "name1=log1 name2=log2 nameN=logN\n");
+      return;
+    }
+
+    if (System.getProperty(COMPOSITE_LOG_INPUT_SYS_PROP) == null)
+    {
+      System.out.println(
+        "You must specify which composite log to use, setting -D"
+          + COMPOSITE_LOG_INPUT_SYS_PROP
+          + "=<composite log>");
+      return;
+    }
+
+    MarkerLogMerger m = new MarkerLogMerger();
+
+    //create server logs 
+    //could be made pluggable to take other kinds of logs
+
+    AssociatedLog[] logs = new AssociatedLog[args.length];
+    // split by '='
+    for (int i = 0; i < args.length; i++)
+    {
+      int index = args[i].indexOf('=');
+      if (index == -1 || index == args[i].length() - 1)
+        throw new RuntimeException(
+          args[i] + " must have an '=' followed by a filename");
+      String name = args[i].substring(0, index);
+      String fileName = args[i].substring(index + 1);
+      logs[i] = m.new ServerLog(new File(fileName), name);
+    }
+
+    m.run(
+      new File(System.getProperty(COMPOSITE_LOG_INPUT_SYS_PROP)),
+      new File(System.getProperty(OUTPUT_FILE_SYS_PROP, OUTPUT_FILE_DEFAULT)),
+      logs,
+      System.out);
+  }
+
+  public void run(
+    File compositeLog,
+    File outputFile,
+    AssociatedLog[] externalLogs,
+    PrintStream log)
+  {
+    lines =
+      StringUtils.splitByNewline(
+        TchUtils.getContentsAsString(compositeLog),
+        true);
+    List tmp = new ArrayList();
+    // iterate over lines, and find special marker comments of the form
+    // <!-...@-->
+    for (Iterator iter = lines.iterator(); iter.hasNext();)
+    {
+      String line = (String)iter.next();
+      String trimmedLine = line.trim();
+      if (trimmedLine.startsWith(PLACEHOLDER_START)
+        && trimmedLine.endsWith(PLACEHOLDER_END))
+      {
+        String testName = getTestName(trimmedLine);
+        // now, for each logical test name, get the relevant output 
+        // from the associated logs
+        for (int i = 0; i < externalLogs.length; i++)
+        {
+          List logPart = externalLogs[i].getAssociatedLogOutput(testName);
+          if (!logPart.isEmpty())
+          {
+          	tmp.add(BEGIN_WRAPPER);
+            tmp.add(externalLogs[i].getName());
+            tmp.add(sep);
+            tmp.addAll(logPart);
+            tmp.add(sep);
+            tmp.add(sep);
+            tmp.add(END_WRAPPER);
+          }
+        }
+      }
+      else
+      {
+        tmp.add(line);
+      }
+    }
+
+    log.println("Writing output to " + outputFile.getAbsolutePath());
+    try
+    {
+      PrintWriter pw = new PrintWriter(new FileOutputStream(outputFile));
+      // write everything out
+      for (Iterator iter = tmp.iterator(); iter.hasNext();)
+      {
+        pw.print(iter.next());
+      }
+      pw.flush();
+      pw.close();
+    }
+    catch (FileNotFoundException ex)
+    {
+      throw new NestedRuntimeException(ex);
+    }
+  }
+
+  private String getTestName(String line)
+  {
+    return line.substring(line.indexOf('@') + 1, line.lastIndexOf("@-->"));
+  }
+
+  private class MarkerLog
+  {
+    private List lines = null;
+
+    public MarkerLog(File f) throws FileNotFoundException
+    {
+      if (!f.exists() || !f.isFile())
+        throw new FileNotFoundException(
+          "Cannot find log at " + f.getAbsolutePath());
+
+      lines =
+        StringUtils.splitByNewline(TchUtils.getContentsAsString(f), true);
+    }
+
+    public List getLogPart(String startMarker, String endMarker)
+    {
+      return getLogPart(startMarker, endMarker, false);
+    }
+
+    public List getLogPart(
+      String startMarker,
+      String endMarker,
+      boolean includeMarkerLine)
+    {
+      return getLogPart(startMarker, endMarker, includeMarkerLine, 0);
+    }
+
+    public List getLogPart(
+      String startMarker,
+      String endMarker,
+      boolean includeMarkerLine,
+      int startLine)
+    {
+      List rtn = new ArrayList();
+      boolean foundStartMarker = false;
+
+      // FIXME, instead of iterating over the content every time, 
+      // we should sore this in a map
+      for (int i = startLine; i < lines.size(); i++)
+      {
+        String line = (String)lines.get(i);
+        if (foundStartMarker)
+        {
+          if (line.indexOf(endMarker) > -1)
+          {
+            if (includeMarkerLine)
+              rtn.add(line);
+            return rtn;
+          }
+          rtn.add(line);
+        }
+        else if (!foundStartMarker && line.indexOf(startMarker) > -1)
+        {
+          foundStartMarker = true;
+          if (includeMarkerLine)
+          {
+            rtn.add(line);
+            // also include carriage return, if we have it
+            if ((i + 1) < lines.size())
+              rtn.add(lines.get(i + 1));
+          }
+          i += 2;
+        }
+      }
+      return rtn;
+    }
+  }
+
+  private interface AssociatedLog
+  {
+    /**
+     * @return the name of this associated log
+     */
+    public String getName();
+
+    /**
+     * @param testName
+     * @return output for the test passed in
+     */
+    public List getAssociatedLogOutput(String testName);
+  }
+
+  /**
+   * A server log knows what kind of marker to look for.
+   * 
+   */
+  private class ServerLog implements AssociatedLog
+  {
+    private MarkerLog markerLog = null;
+    private String name = null;
+
+    public ServerLog(File f, String inName) throws FileNotFoundException
+    {
+      markerLog = new MarkerLog(f);
+      name = inName;
+    }
+
+    public String getName()
+    {
+      return name;
+    }
+
+    public List getAssociatedLogOutput(String testName)
+    {
+      String startMarker =
+        TchConstants.SERVERSIDE_START_TEST_MARKER
+          + getTestNameWithoutSubtest(testName);
+      String endMarker = TchUtils.SERVERSIDE_TEST_RESULT_MARKER + testName;
+      return markerLog.getLogPart(startMarker, endMarker, true);
+    }
+    
+    private String getTestNameWithoutSubtest(String testName)
+    {
+      if (getNumDots(testName) == 2)
+      {
+        // has a subtest name
+        return testName.substring(0, testName.lastIndexOf('.'));
+      }
+      return testName;
+    }
+    
+    // assumes '.' is a reserved character
+    // (as it currently for BH test names)
+    private int getNumDots(String testName)
+    {
+      int rtn = 0;
+      for (int i = testName.length() - 1; i > 0; i--)
+      {
+        if (testName.charAt(i) == '.')
+          rtn++;
+      }
+      return rtn;
+    }
+    
+  }
+}

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumper.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumper.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumper.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumper.java Fri Aug 12 08:12:28 2005
@@ -1,13 +1,13 @@
-package org.apache.beehive.test.tools.tch.tool;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface ThreadDumper
-  extends Remote  {
-
-  public void registerVM(String name, String port) throws RemoteException;
-  public String getThreaddump() throws RemoteException;
-  public void shutdown() throws RemoteException;
-
-}
+package org.apache.beehive.test.tools.tch.tool;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface ThreadDumper
+  extends Remote  {
+
+  public void registerVM(String name, String port) throws RemoteException;
+  public String getThreaddump() throws RemoteException;
+  public void shutdown() throws RemoteException;
+
+}

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumperImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumperImpl.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumperImpl.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/ThreadDumperImpl.java Fri Aug 12 08:12:28 2005
@@ -1,153 +1,153 @@
-package org.apache.beehive.test.tools.tch.tool;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-
-public class ThreadDumperImpl 
-   extends UnicastRemoteObject 
-   implements ThreadDumper {
-
-  public static String sep = System.getProperty("line.separator");
-
-  List VMs = Collections.synchronizedList(new ArrayList());
-
-  public ThreadDumperImpl() throws RemoteException {}
-
-  public void registerVM(String name, String port) throws RemoteException {
-    TchUtils.log("Registering VM: " + name + " at port: " + port);
-    VMHolder vm = new VMHolder(name, port);
-    VMs.add(vm);
-  }
-
-  public void disconnect() {
-    Iterator i = VMs.iterator();
-    while (i.hasNext()) {
-      ((VMHolder)i.next()).disconnect();
-    }
-  }
-
-   public void shutdown() throws RemoteException {
-     TchUtils.log("Shutdown sequence initiated");
-     disconnect();
-     System.exit(0);
-   }
-
-  public String getThreaddump() throws RemoteException {
-    StringBuffer dump = new StringBuffer();
-    Iterator i = VMs.iterator();
-    while (i.hasNext()) {
-      dump.append(((VMHolder)i.next()).getThreaddump());
-    }
-    return dump.toString();
-  }
-
-  public void bind(int rmiPort, String lookupName) {
-    String url = "";
-    String host = "";
-    try {
-      host = InetAddress.getLocalHost().getHostName();
-    } catch (UnknownHostException uhe) {
-      host = "localhost";
-    }
-    try {
-      Registry reg = LocateRegistry.createRegistry(rmiPort);
-      reg.rebind (lookupName, this);
-      url = "rmi://" + host + ":" + rmiPort + "/" + lookupName;
-      TchUtils.log("Bound to: " + url);
-      TchUtils.log("Use above url to lookup");
-    } catch (RemoteException re) {
-      re.printStackTrace();
-    }
-  }
-
-
-  public String toString() {
-    StringBuffer out = new StringBuffer();
-    Iterator i = VMs.iterator();
-    while (i.hasNext()) {
-      out.append(((VMHolder)i.next()).toString());
-    }
-    return out.toString();
-  }
-
-
-  public static void main(String[] args) throws Exception {
-    System.out.println("");
-    // just because I like stdout to look nice.
-    Runtime.getRuntime().addShutdownHook(new Thread () {
-      public void run () {
-        System.out.println("");
-      }
-    });
-
-    boolean bind = false;
-    int cmdOffset = 0;
-
-    if (args.length == 0) {
-      System.out.println(getHelp());
-      return;
-    }
-  
-    if (args.length > 1) {
-      if (args[0].equalsIgnoreCase("bind")) {
-        bind = true;
-        cmdOffset = 3;
-      }
-    }
-    
-    ThreadDumperImpl dumper = new ThreadDumperImpl();
-    Properties cmd =
-      CommandLineArgs.getCommandLineArgs(args, cmdOffset, false, false);
-    Iterator i = cmd.keySet().iterator();
-    while (i.hasNext()) {
-      String name = (String)i.next();
-      String port = cmd.getProperty(name);
-      dumper.registerVM(name, port);
-    }
-
-    TchUtils.log(dumper.toString());
-
-    // when binding into rmi reg, need to provide lookup name and port
-    if (bind) {
-      int port = 0;
-      String lookupName = null;
-
-      try { port = Integer.parseInt (args[1]); }
-      catch (Exception exc) { }
-   
-      lookupName = args[2].trim();
-      
-      dumper.bind(port, lookupName);
-    }
-    
-    else {
-      TchUtils.log(dumper.getThreaddump());
-      dumper.shutdown();
-    }
-  }
-
-  public static String getHelp() {
-    StringBuffer help = new StringBuffer();
-    help.append("Start target VM(s) with:").append(sep)
-      .append("  -Xrunjdwp:transport=dt_socket,server=y,address=<jdi_port>")
-      .append(",suspend=n -Xdebug -Xnoagent -Djava.compiler=NONE").append(sep)
-      .append(sep)
-      .append("Then run ThreadDumperImpl with (multiple) <some-name>=<jdi_port>")
-      .append(" arguments.").append(sep).append(sep)
-      .append("For example:").append(sep)
-      .append("  java tch.utils.ThreadDumperImpl server1=1234 server2=5678")
-      .append(sep);
-    return help.toString();
-  }
-}
+package org.apache.beehive.test.tools.tch.tool;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+
+public class ThreadDumperImpl 
+   extends UnicastRemoteObject 
+   implements ThreadDumper {
+
+  public static String sep = System.getProperty("line.separator");
+
+  List VMs = Collections.synchronizedList(new ArrayList());
+
+  public ThreadDumperImpl() throws RemoteException {}
+
+  public void registerVM(String name, String port) throws RemoteException {
+    TchUtils.log("Registering VM: " + name + " at port: " + port);
+    VMHolder vm = new VMHolder(name, port);
+    VMs.add(vm);
+  }
+
+  public void disconnect() {
+    Iterator i = VMs.iterator();
+    while (i.hasNext()) {
+      ((VMHolder)i.next()).disconnect();
+    }
+  }
+
+   public void shutdown() throws RemoteException {
+     TchUtils.log("Shutdown sequence initiated");
+     disconnect();
+     System.exit(0);
+   }
+
+  public String getThreaddump() throws RemoteException {
+    StringBuffer dump = new StringBuffer();
+    Iterator i = VMs.iterator();
+    while (i.hasNext()) {
+      dump.append(((VMHolder)i.next()).getThreaddump());
+    }
+    return dump.toString();
+  }
+
+  public void bind(int rmiPort, String lookupName) {
+    String url = "";
+    String host = "";
+    try {
+      host = InetAddress.getLocalHost().getHostName();
+    } catch (UnknownHostException uhe) {
+      host = "localhost";
+    }
+    try {
+      Registry reg = LocateRegistry.createRegistry(rmiPort);
+      reg.rebind (lookupName, this);
+      url = "rmi://" + host + ":" + rmiPort + "/" + lookupName;
+      TchUtils.log("Bound to: " + url);
+      TchUtils.log("Use above url to lookup");
+    } catch (RemoteException re) {
+      re.printStackTrace();
+    }
+  }
+
+
+  public String toString() {
+    StringBuffer out = new StringBuffer();
+    Iterator i = VMs.iterator();
+    while (i.hasNext()) {
+      out.append(((VMHolder)i.next()).toString());
+    }
+    return out.toString();
+  }
+
+
+  public static void main(String[] args) throws Exception {
+    System.out.println("");
+    // just because I like stdout to look nice.
+    Runtime.getRuntime().addShutdownHook(new Thread () {
+      public void run () {
+        System.out.println("");
+      }
+    });
+
+    boolean bind = false;
+    int cmdOffset = 0;
+
+    if (args.length == 0) {
+      System.out.println(getHelp());
+      return;
+    }
+  
+    if (args.length > 1) {
+      if (args[0].equalsIgnoreCase("bind")) {
+        bind = true;
+        cmdOffset = 3;
+      }
+    }
+    
+    ThreadDumperImpl dumper = new ThreadDumperImpl();
+    Properties cmd =
+      CommandLineArgs.getCommandLineArgs(args, cmdOffset, false, false);
+    Iterator i = cmd.keySet().iterator();
+    while (i.hasNext()) {
+      String name = (String)i.next();
+      String port = cmd.getProperty(name);
+      dumper.registerVM(name, port);
+    }
+
+    TchUtils.log(dumper.toString());
+
+    // when binding into rmi reg, need to provide lookup name and port
+    if (bind) {
+      int port = 0;
+      String lookupName = null;
+
+      try { port = Integer.parseInt (args[1]); }
+      catch (Exception exc) { }
+   
+      lookupName = args[2].trim();
+      
+      dumper.bind(port, lookupName);
+    }
+    
+    else {
+      TchUtils.log(dumper.getThreaddump());
+      dumper.shutdown();
+    }
+  }
+
+  public static String getHelp() {
+    StringBuffer help = new StringBuffer();
+    help.append("Start target VM(s) with:").append(sep)
+      .append("  -Xrunjdwp:transport=dt_socket,server=y,address=<jdi_port>")
+      .append(",suspend=n -Xdebug -Xnoagent -Djava.compiler=NONE").append(sep)
+      .append(sep)
+      .append("Then run ThreadDumperImpl with (multiple) <some-name>=<jdi_port>")
+      .append(" arguments.").append(sep).append(sep)
+      .append("For example:").append(sep)
+      .append("  java tch.utils.ThreadDumperImpl server1=1234 server2=5678")
+      .append(sep);
+    return help.toString();
+  }
+}

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/VMHolder.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/VMHolder.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/VMHolder.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/tool/VMHolder.java Fri Aug 12 08:12:28 2005
@@ -1,228 +1,228 @@
-package org.apache.beehive.test.tools.tch.tool;
-
-import java.io.IOException;
-import java.net.ConnectException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.beehive.test.tools.tch.util.TchUtils;
-
-import com.sun.jdi.AbsentInformationException;
-import com.sun.jdi.Bootstrap;
-import com.sun.jdi.IncompatibleThreadStateException;
-import com.sun.jdi.InvalidStackFrameException;
-import com.sun.jdi.LocalVariable;
-import com.sun.jdi.Location;
-import com.sun.jdi.Method;
-import com.sun.jdi.NativeMethodException;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.StackFrame;
-import com.sun.jdi.ThreadGroupReference;
-import com.sun.jdi.ThreadReference;
-import com.sun.jdi.VMDisconnectedException;
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.VirtualMachineManager;
-import com.sun.jdi.connect.AttachingConnector;
-import com.sun.jdi.connect.Connector;
-import com.sun.jdi.connect.IllegalConnectorArgumentsException;
-
-/*package*/ class VMHolder {
-
-  private static boolean SHOW_LOCAL_VARIABLES = false;
-  public static String sep = System.getProperty("line.separator"); 
-  private VirtualMachine vm;
-  boolean connected = false;
-  String port = "-1";
-  String name = "<no name>";
-
-  public VMHolder(String inName, String inPort) {
-    name = inName;
-    port = inPort;
-  }
-
-  public String getThreaddump() {
-    String s = null;
-    if (!connected) {
-      TchUtils.log("Calling connect for " + name + " " + port);
-      connect();
-    }
-    if (connected) {
-      TchUtils.log("Calling getThreads for " + name + " " + port);
-      s = getThreadReport();
-    }
-    else {
-      TchUtils.log(name + " is not connected");
-      s = "=============> No VM image for " + name + " <==============" + sep;
-    }
-    return s;
-  }
-
-  public void disconnect() {
-    if (vm != null) {
-      TchUtils.log("disconnecting: " + name);
-      vm.dispose();
-    }
-  }
-
-  private void connect() {
-    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
-    Iterator i = vmm.attachingConnectors().iterator();
-    Connector connector = null;
-    while(i.hasNext()) {
-      connector = (Connector) i.next();
-      if(connector.transport().name().equals("dt_socket")) break;
-    }
-    AttachingConnector ac = (AttachingConnector) connector;
-    Map arguments = ac.defaultArguments();
-    Connector.Argument hostArg = 
-      (Connector.Argument) arguments.get("hostname");
-    hostArg.setValue("localhost");
-    Connector.Argument portArg = (Connector.Argument) arguments.get("port");
-    portArg.setValue(port);
-    
-    try {
-      vm = ac.attach(arguments);
-      if (vm != null) {
-        connected = true;
-	// in case vm is waiting
-        vm.resume();
-      }
-    } catch (ConnectException ce) {
-      TchUtils.log(name + " is not listening at port " + port);
-    } catch (IOException ioe) {
-      TchUtils.log(ioe);
-    } catch (IllegalConnectorArgumentsException icae) {
-      TchUtils.log(icae);
-    }
-  }
-
-  private String getThreadReport() {
-    StringBuffer buf = new StringBuffer();
-    try {
-      buf.append("=============> Begin ").append(name)
-        .append(" <==============").append(sep);
-      vm.suspend(); 
-      List threads = vm.allThreads();
-      Iterator threadsIter = threads.iterator();
-
-      while (threadsIter.hasNext()) {
-	ThreadReference tr = (ThreadReference)threadsIter.next();
-	ThreadGroupReference tgr = tr.threadGroup();
-        // don't care about system threads, like gc
-	if (tgr.name().equals("system")) {
-	  continue;
-	}
-
-	// mention name of thread and threadgroup this thread is in
-	buf.append(sep).append("start thread: ")
-          .append(tr.name()).append(" ThreadGroup: ").append(tgr.name())
-	  .append(sep);
-
-	// print list of monitors this thread owns
-        if (vm.canGetOwnedMonitorInfo()) {
-	  List monitors = tr.ownedMonitors();
-	  Iterator monitorsIter = monitors.iterator();
-	  if (monitorsIter.hasNext()) {
-	    buf.append("Monitors owned: ").append(sep);
-	  }
-	  while (monitorsIter.hasNext()) {
-	    ObjectReference objref = (ObjectReference)monitorsIter.next();
-	    buf.append("  ").append(objref).append(sep);
-	  }
-	} 
-        else {
-          buf.append("VM does not support retrieval of owned monitors")
-            .append(sep);
-	}
-
-        // print which monitor this thread is waiting for
-        if (vm.canGetCurrentContendedMonitor()) {
-          ObjectReference contendedMonitor = tr.currentContendedMonitor();
-          if (contendedMonitor != null) {
-            buf.append("Waiting for monitor: ").append(contendedMonitor)
-              .append(sep);
-	  }
-	} 
-        else {
-          buf.append("VM does not support retrieval of monitor this thread ")
-            .append("is waiting for").append(sep);
-	}
-
-	List frames = tr.frames();
-	Iterator framesIter = frames.iterator();
-	// print all stack frames for this thread
-	if (framesIter.hasNext()) {
-	  buf.append(sep);
-	  while (framesIter.hasNext()) {
-	    StackFrame sf = (StackFrame)framesIter.next();
-            Location loc = sf.location();
-            List vars = new ArrayList();
-            boolean gotVars = false;
-            if (SHOW_LOCAL_VARIABLES) {
-	      try {
-		vars = sf.visibleVariables();
-		gotVars = true;
-	      } catch (AbsentInformationException aie) {}
-    	        catch (InvalidStackFrameException isfe) {}
-                catch (NativeMethodException nme) {}
-	    }
-	    // looks like just calling loc.lineNumber() is enough to enhance
-	    // the result of sf.toString(). Calling that method dynamically 
-	    // modifies the string representation of the StackFrame. I don't 
-	    // know if we can always rely on that happening, so just in case
-	    // I also explicitly print line numbers.
-            int line = loc.lineNumber(); 
-            Method method = loc.method();
-	    buf.append(sf.toString());
-            buf.append(" inside method: ")
-              .append(String.valueOf(method.name()));
-            if (line > -1) {
-              buf.append(" at line: ").append(String.valueOf(line));
-	    }
-            if (gotVars) {
-              buf.append(sep).append("Local Variables for above StackFrame:")
-              .append(sep).append("[");
-              Iterator varIter = vars.iterator();
-              while (varIter.hasNext()) {
-                LocalVariable v = (LocalVariable)varIter.next();
-                buf.append(v.typeName()).append(" ").append(v.name())
-                  .append("=").append(sf.getValue(v)).append(sep);
-	      }
-              buf.append("]");
-	    }
-            buf.append(sep);
-	  }
-	}
-	buf.append(sep).append("end: ").append(tr.name())
-	  .append(sep);
-      }
-    } catch (IncompatibleThreadStateException itse) {
-      buf.append("Threads messed up")
-        .append(TchUtils.throwable2StackTrace(itse)).append(sep);
-      connected = false;
-    } catch (VMDisconnectedException mvde) {
-      buf.append(name).append(" disconnected while processing")
-        .append(TchUtils.throwable2StackTrace(mvde)).append(sep);
-      connected = false;
-    } catch (Throwable th) {
-      buf.append("Caught unexpected Throwable: ")
-        .append(TchUtils.throwable2StackTrace(th)).append(sep);
-      connected = false;
-    } finally {
-      vm.resume();
-      buf.append("=============> End ").append(name).append(" <==============")
-        .append(sep);
-    }
-    return buf.toString();
-  }
-
-  public String toString() {
-    StringBuffer out = new StringBuffer();
-    out.append("name:").append(name).append(" port:").append(port)
-      .append(" connected? ").append(connected).append(" ");
-    return out.toString();
-  }
-}
-
+package org.apache.beehive.test.tools.tch.tool;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.beehive.test.tools.tch.util.TchUtils;
+
+import com.sun.jdi.AbsentInformationException;
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InvalidStackFrameException;
+import com.sun.jdi.LocalVariable;
+import com.sun.jdi.Location;
+import com.sun.jdi.Method;
+import com.sun.jdi.NativeMethodException;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.StackFrame;
+import com.sun.jdi.ThreadGroupReference;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.VMDisconnectedException;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.VirtualMachineManager;
+import com.sun.jdi.connect.AttachingConnector;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
+
+/*package*/ class VMHolder {
+
+  private static boolean SHOW_LOCAL_VARIABLES = false;
+  public static String sep = System.getProperty("line.separator"); 
+  private VirtualMachine vm;
+  boolean connected = false;
+  String port = "-1";
+  String name = "<no name>";
+
+  public VMHolder(String inName, String inPort) {
+    name = inName;
+    port = inPort;
+  }
+
+  public String getThreaddump() {
+    String s = null;
+    if (!connected) {
+      TchUtils.log("Calling connect for " + name + " " + port);
+      connect();
+    }
+    if (connected) {
+      TchUtils.log("Calling getThreads for " + name + " " + port);
+      s = getThreadReport();
+    }
+    else {
+      TchUtils.log(name + " is not connected");
+      s = "=============> No VM image for " + name + " <==============" + sep;
+    }
+    return s;
+  }
+
+  public void disconnect() {
+    if (vm != null) {
+      TchUtils.log("disconnecting: " + name);
+      vm.dispose();
+    }
+  }
+
+  private void connect() {
+    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
+    Iterator i = vmm.attachingConnectors().iterator();
+    Connector connector = null;
+    while(i.hasNext()) {
+      connector = (Connector) i.next();
+      if(connector.transport().name().equals("dt_socket")) break;
+    }
+    AttachingConnector ac = (AttachingConnector) connector;
+    Map arguments = ac.defaultArguments();
+    Connector.Argument hostArg = 
+      (Connector.Argument) arguments.get("hostname");
+    hostArg.setValue("localhost");
+    Connector.Argument portArg = (Connector.Argument) arguments.get("port");
+    portArg.setValue(port);
+    
+    try {
+      vm = ac.attach(arguments);
+      if (vm != null) {
+        connected = true;
+	// in case vm is waiting
+        vm.resume();
+      }
+    } catch (ConnectException ce) {
+      TchUtils.log(name + " is not listening at port " + port);
+    } catch (IOException ioe) {
+      TchUtils.log(ioe);
+    } catch (IllegalConnectorArgumentsException icae) {
+      TchUtils.log(icae);
+    }
+  }
+
+  private String getThreadReport() {
+    StringBuffer buf = new StringBuffer();
+    try {
+      buf.append("=============> Begin ").append(name)
+        .append(" <==============").append(sep);
+      vm.suspend(); 
+      List threads = vm.allThreads();
+      Iterator threadsIter = threads.iterator();
+
+      while (threadsIter.hasNext()) {
+	ThreadReference tr = (ThreadReference)threadsIter.next();
+	ThreadGroupReference tgr = tr.threadGroup();
+        // don't care about system threads, like gc
+	if (tgr.name().equals("system")) {
+	  continue;
+	}
+
+	// mention name of thread and threadgroup this thread is in
+	buf.append(sep).append("start thread: ")
+          .append(tr.name()).append(" ThreadGroup: ").append(tgr.name())
+	  .append(sep);
+
+	// print list of monitors this thread owns
+        if (vm.canGetOwnedMonitorInfo()) {
+	  List monitors = tr.ownedMonitors();
+	  Iterator monitorsIter = monitors.iterator();
+	  if (monitorsIter.hasNext()) {
+	    buf.append("Monitors owned: ").append(sep);
+	  }
+	  while (monitorsIter.hasNext()) {
+	    ObjectReference objref = (ObjectReference)monitorsIter.next();
+	    buf.append("  ").append(objref).append(sep);
+	  }
+	} 
+        else {
+          buf.append("VM does not support retrieval of owned monitors")
+            .append(sep);
+	}
+
+        // print which monitor this thread is waiting for
+        if (vm.canGetCurrentContendedMonitor()) {
+          ObjectReference contendedMonitor = tr.currentContendedMonitor();
+          if (contendedMonitor != null) {
+            buf.append("Waiting for monitor: ").append(contendedMonitor)
+              .append(sep);
+	  }
+	} 
+        else {
+          buf.append("VM does not support retrieval of monitor this thread ")
+            .append("is waiting for").append(sep);
+	}
+
+	List frames = tr.frames();
+	Iterator framesIter = frames.iterator();
+	// print all stack frames for this thread
+	if (framesIter.hasNext()) {
+	  buf.append(sep);
+	  while (framesIter.hasNext()) {
+	    StackFrame sf = (StackFrame)framesIter.next();
+            Location loc = sf.location();
+            List vars = new ArrayList();
+            boolean gotVars = false;
+            if (SHOW_LOCAL_VARIABLES) {
+	      try {
+		vars = sf.visibleVariables();
+		gotVars = true;
+	      } catch (AbsentInformationException aie) {}
+    	        catch (InvalidStackFrameException isfe) {}
+                catch (NativeMethodException nme) {}
+	    }
+	    // looks like just calling loc.lineNumber() is enough to enhance
+	    // the result of sf.toString(). Calling that method dynamically 
+	    // modifies the string representation of the StackFrame. I don't 
+	    // know if we can always rely on that happening, so just in case
+	    // I also explicitly print line numbers.
+            int line = loc.lineNumber(); 
+            Method method = loc.method();
+	    buf.append(sf.toString());
+            buf.append(" inside method: ")
+              .append(String.valueOf(method.name()));
+            if (line > -1) {
+              buf.append(" at line: ").append(String.valueOf(line));
+	    }
+            if (gotVars) {
+              buf.append(sep).append("Local Variables for above StackFrame:")
+              .append(sep).append("[");
+              Iterator varIter = vars.iterator();
+              while (varIter.hasNext()) {
+                LocalVariable v = (LocalVariable)varIter.next();
+                buf.append(v.typeName()).append(" ").append(v.name())
+                  .append("=").append(sf.getValue(v)).append(sep);
+	      }
+              buf.append("]");
+	    }
+            buf.append(sep);
+	  }
+	}
+	buf.append(sep).append("end: ").append(tr.name())
+	  .append(sep);
+      }
+    } catch (IncompatibleThreadStateException itse) {
+      buf.append("Threads messed up")
+        .append(TchUtils.throwable2StackTrace(itse)).append(sep);
+      connected = false;
+    } catch (VMDisconnectedException mvde) {
+      buf.append(name).append(" disconnected while processing")
+        .append(TchUtils.throwable2StackTrace(mvde)).append(sep);
+      connected = false;
+    } catch (Throwable th) {
+      buf.append("Caught unexpected Throwable: ")
+        .append(TchUtils.throwable2StackTrace(th)).append(sep);
+      connected = false;
+    } finally {
+      vm.resume();
+      buf.append("=============> End ").append(name).append(" <==============")
+        .append(sep);
+    }
+    return buf.toString();
+  }
+
+  public String toString() {
+    StringBuffer out = new StringBuffer();
+    out.append("name:").append(name).append(" port:").append(port)
+      .append(" connected? ").append(connected).append(" ");
+    return out.toString();
+  }
+}
+

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AbstractResultProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AbstractResultProcessor.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AbstractResultProcessor.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AbstractResultProcessor.java Fri Aug 12 08:12:28 2005
@@ -1,81 +1,81 @@
-package org.apache.beehive.test.tools.tch.util;
-
-import java.util.Map;
-
-/**
- *
- */
-public abstract class AbstractResultProcessor
-  implements ResultProcessor {
-
-  private ResultProcessor innerProcessor = null;
-  protected Exception ex = null;
- 
-  public ResultProcessor appendResultProcessor(ResultProcessor inProcessor) {
-    if (innerProcessor == null) {
-      innerProcessor = inProcessor;
-    }
-    else {
-      innerProcessor.appendResultProcessor(inProcessor);  
-    }
-    return this;
-  }
-
-  public TestResult processResult(TestResult inResult) {
-    if (innerProcessor == null) {
-      return inResult;
-    }
-    else {
-      return innerProcessor.processResult(inResult);     
-    }
-  }
-
-  public Map processGeneric(Map inMap) {
-    if (innerProcessor == null) {
-      return inMap;
-    }
-    else {
-      return innerProcessor.processGeneric(inMap);     
-    }
-  }
-
-  public boolean errorWhileProcessing() {
-    return (getException() != null);
-  }
-
-  public Exception getException() {
-    if (ex != null) {
-      return ex;
-    }
-    if (innerProcessor != null) {
-      return innerProcessor.getException();
-    }
-    return null;
-  }
-
-  public void resetError() {
-    ex = null;
-    if (innerProcessor != null) {
-      innerProcessor.resetError();
-    }
-  }
-
-  public int size() {
-    AbstractResultProcessor p = this;
-    int numProcessors = 1;
-    while (p.getNext() != null) {
-      numProcessors++;
-      p = p.getNext();
-    }
-    return numProcessors;
-  }
-
-  private AbstractResultProcessor getNext() {
-    if (innerProcessor != null) {
-      return (AbstractResultProcessor)innerProcessor;
-    } 
-    return null;
-  }
-
-}
-
+package org.apache.beehive.test.tools.tch.util;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public abstract class AbstractResultProcessor
+  implements ResultProcessor {
+
+  private ResultProcessor innerProcessor = null;
+  protected Exception ex = null;
+ 
+  public ResultProcessor appendResultProcessor(ResultProcessor inProcessor) {
+    if (innerProcessor == null) {
+      innerProcessor = inProcessor;
+    }
+    else {
+      innerProcessor.appendResultProcessor(inProcessor);  
+    }
+    return this;
+  }
+
+  public TestResult processResult(TestResult inResult) {
+    if (innerProcessor == null) {
+      return inResult;
+    }
+    else {
+      return innerProcessor.processResult(inResult);     
+    }
+  }
+
+  public Map processGeneric(Map inMap) {
+    if (innerProcessor == null) {
+      return inMap;
+    }
+    else {
+      return innerProcessor.processGeneric(inMap);     
+    }
+  }
+
+  public boolean errorWhileProcessing() {
+    return (getException() != null);
+  }
+
+  public Exception getException() {
+    if (ex != null) {
+      return ex;
+    }
+    if (innerProcessor != null) {
+      return innerProcessor.getException();
+    }
+    return null;
+  }
+
+  public void resetError() {
+    ex = null;
+    if (innerProcessor != null) {
+      innerProcessor.resetError();
+    }
+  }
+
+  public int size() {
+    AbstractResultProcessor p = this;
+    int numProcessors = 1;
+    while (p.getNext() != null) {
+      numProcessors++;
+      p = p.getNext();
+    }
+    return numProcessors;
+  }
+
+  private AbstractResultProcessor getNext() {
+    if (innerProcessor != null) {
+      return (AbstractResultProcessor)innerProcessor;
+    } 
+    return null;
+  }
+
+}
+

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntProperties.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntProperties.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntProperties.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntProperties.java Fri Aug 12 08:12:28 2005
@@ -1,160 +1,160 @@
-package org.apache.beehive.test.tools.tch.util;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.apache.tools.ant.Project;
-
-/**
- * Responsible for referring to the global Hashtable for the Ant run
- * Initialized with a reference to the Project
- */
-
-public class AntProperties
-{
-  // These are the properties at init-time, which 
-  // should represent the properties set at the
-  // command line and in the very top level buildfile
-  // which is controlled by us, not by the user
-  protected static Hashtable globalProperties = null;
-
-  private static Project proj = null;
-
-  private static boolean isInitialized = false;
-
-  public static void init(Project project)
-  {
-    proj = project;
-    init(project.getProperties());
-  }
-  
-  public static void init(Hashtable props)
-  {
-    globalProperties = props;
-    isInitialized = true;
-  }
-
-  public static String getGlobalProperty(String propName)
-  {
-    return getGlobalProperty(propName, null);
-  }
-
-  public static String getGlobalProperty(String propName, String defaultValue)
-  {
-    if (!isInitialized)
-      throw new AntPropertiesNotInitializedException();
-    return getTheProperty(propName, defaultValue, globalProperties);
-  }
-
-  public static String getLiveGlobalProperty(
-    String propName,
-    String defaultValue)
-  {
-    if (!isInitialized)
-      throw new AntPropertiesNotInitializedException();
-    return getTheLiveProperty(propName, defaultValue);
-  }
-
-  public static void setProperty(String name, String value)
-  {
-    proj.setProperty(name, value);
-    globalProperties.put(name, value);
-  }
-
-  public static boolean getGlobalBoolean(String propName, String defaultValue)
-  {
-    return GeneralUtil.parseBoolean(getGlobalProperty(propName, defaultValue));
-  }
-
-  public static boolean getLiveGlobalBoolean(
-    String propName,
-    String defaultValue)
-  {
-    return GeneralUtil.parseBoolean(
-      getLiveGlobalProperty(propName, defaultValue));
-  }
-
-  public static long getGlobalLong(String propName, String defaultValue)
-  {
-    return Long.parseLong(getGlobalProperty(propName, defaultValue));
-  }
-
-  public static int getGlobalInt(String propName, String defaultValue)
-  {
-    return Integer.parseInt(getGlobalProperty(propName, defaultValue));
-  }
-
-  protected static String getTheProperty(
-    String propName,
-    String defaultValue,
-    Hashtable props)
-  {
-    String rtn = (String)props.get(propName);
-    if (rtn == null)
-      rtn = defaultValue;
-    return rtn;
-  }
-
-  protected static String getTheLiveProperty(
-    String propName,
-    String defaultValue)
-  {
-    String rtn = proj.getProperty(propName);
-    if (rtn == null)
-      rtn = defaultValue;
-    return rtn;
-  }
-
-  private static final String ANT_VERSION_SUBSTRING = "version";
-  public static String getAntVersion()
-  {
-    String versionString = getGlobalProperty(".ant.version", null);
-    if (versionString == null)
-      versionString = getGlobalProperty("ant.version", "");
-    versionString = versionString.toLowerCase();
-    // try something somewhat smart
-    int versionIndex = versionString.indexOf(ANT_VERSION_SUBSTRING);
-    if (versionIndex > -1)
-    {
-      int versionNumberIndex = versionIndex + ANT_VERSION_SUBSTRING.length() + 1; // for extra space
-      String firstCut = versionString.substring(versionNumberIndex); 
-      int nextSpace = firstCut.indexOf(" ");
-      if (nextSpace == -1)
-        nextSpace = firstCut.length();
-      return firstCut.substring(0, nextSpace);
-    }
-    else
-    {
-    // does not work, try somethign stupid 
-      if (versionString.indexOf("1.5") != -1)
-        return "1.5";
-      else
-        if (versionString.indexOf("1.4.1") != -1)
-          return "1.4.1";
-        else
-          return "unknown";
-    }
-  }
-
-  protected static Map getGlobalProperties()
-  {
-    return globalProperties;
-  }
-
-  private static class AntPropertiesNotInitializedException
-    extends RuntimeException
-  {
-    public AntPropertiesNotInitializedException()
-    {
-      super("Global properties not intialized!");
-    }
-  }
-
-  public static class AntPropertiesException extends NestedException
-  {
-    public AntPropertiesException(String message)
-    {
-      super(message);
-    }
-  }
-}
+package org.apache.beehive.test.tools.tch.util;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.tools.ant.Project;
+
+/**
+ * Responsible for referring to the global Hashtable for the Ant run
+ * Initialized with a reference to the Project
+ */
+
+public class AntProperties
+{
+  // These are the properties at init-time, which 
+  // should represent the properties set at the
+  // command line and in the very top level buildfile
+  // which is controlled by us, not by the user
+  protected static Hashtable globalProperties = null;
+
+  private static Project proj = null;
+
+  private static boolean isInitialized = false;
+
+  public static void init(Project project)
+  {
+    proj = project;
+    init(project.getProperties());
+  }
+  
+  public static void init(Hashtable props)
+  {
+    globalProperties = props;
+    isInitialized = true;
+  }
+
+  public static String getGlobalProperty(String propName)
+  {
+    return getGlobalProperty(propName, null);
+  }
+
+  public static String getGlobalProperty(String propName, String defaultValue)
+  {
+    if (!isInitialized)
+      throw new AntPropertiesNotInitializedException();
+    return getTheProperty(propName, defaultValue, globalProperties);
+  }
+
+  public static String getLiveGlobalProperty(
+    String propName,
+    String defaultValue)
+  {
+    if (!isInitialized)
+      throw new AntPropertiesNotInitializedException();
+    return getTheLiveProperty(propName, defaultValue);
+  }
+
+  public static void setProperty(String name, String value)
+  {
+    proj.setProperty(name, value);
+    globalProperties.put(name, value);
+  }
+
+  public static boolean getGlobalBoolean(String propName, String defaultValue)
+  {
+    return GeneralUtil.parseBoolean(getGlobalProperty(propName, defaultValue));
+  }
+
+  public static boolean getLiveGlobalBoolean(
+    String propName,
+    String defaultValue)
+  {
+    return GeneralUtil.parseBoolean(
+      getLiveGlobalProperty(propName, defaultValue));
+  }
+
+  public static long getGlobalLong(String propName, String defaultValue)
+  {
+    return Long.parseLong(getGlobalProperty(propName, defaultValue));
+  }
+
+  public static int getGlobalInt(String propName, String defaultValue)
+  {
+    return Integer.parseInt(getGlobalProperty(propName, defaultValue));
+  }
+
+  protected static String getTheProperty(
+    String propName,
+    String defaultValue,
+    Hashtable props)
+  {
+    String rtn = (String)props.get(propName);
+    if (rtn == null)
+      rtn = defaultValue;
+    return rtn;
+  }
+
+  protected static String getTheLiveProperty(
+    String propName,
+    String defaultValue)
+  {
+    String rtn = proj.getProperty(propName);
+    if (rtn == null)
+      rtn = defaultValue;
+    return rtn;
+  }
+
+  private static final String ANT_VERSION_SUBSTRING = "version";
+  public static String getAntVersion()
+  {
+    String versionString = getGlobalProperty(".ant.version", null);
+    if (versionString == null)
+      versionString = getGlobalProperty("ant.version", "");
+    versionString = versionString.toLowerCase();
+    // try something somewhat smart
+    int versionIndex = versionString.indexOf(ANT_VERSION_SUBSTRING);
+    if (versionIndex > -1)
+    {
+      int versionNumberIndex = versionIndex + ANT_VERSION_SUBSTRING.length() + 1; // for extra space
+      String firstCut = versionString.substring(versionNumberIndex); 
+      int nextSpace = firstCut.indexOf(" ");
+      if (nextSpace == -1)
+        nextSpace = firstCut.length();
+      return firstCut.substring(0, nextSpace);
+    }
+    else
+    {
+    // does not work, try somethign stupid 
+      if (versionString.indexOf("1.5") != -1)
+        return "1.5";
+      else
+        if (versionString.indexOf("1.4.1") != -1)
+          return "1.4.1";
+        else
+          return "unknown";
+    }
+  }
+
+  protected static Map getGlobalProperties()
+  {
+    return globalProperties;
+  }
+
+  private static class AntPropertiesNotInitializedException
+    extends RuntimeException
+  {
+    public AntPropertiesNotInitializedException()
+    {
+      super("Global properties not intialized!");
+    }
+  }
+
+  public static class AntPropertiesException extends NestedException
+  {
+    public AntPropertiesException(String message)
+    {
+      super(message);
+    }
+  }
+}

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntUtils.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntUtils.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AntUtils.java Fri Aug 12 08:12:28 2005
@@ -1,227 +1,227 @@
-package org.apache.beehive.test.tools.tch.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Location;
-import org.apache.tools.ant.Task;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class AntUtils
-{
-  public static final String ANT_PROP_PREFIX = "-D",
-    ANT_EQUALS = "=",
-    LOCATION_DELIMITER = ":";
-
-  /**
-   * Calls perform() on input Collection of Tasks
-   */
-  public static void perform(Collection tasks)
-  {
-    for (Iterator iter = tasks.iterator(); iter.hasNext();)
-    {
-      Task t = (Task)iter.next();
-      //System.out.println("ANTUTILS:  Calling perform on task:  "+t.getClass().getName());
-      t.perform();
-    }
-  }
-
-  public static String getSourcePath(Location location)
-  {
-    String path = location.toString().trim();
-    if (path.endsWith(":"))
-      path = path.substring(0, path.length() - 1);
-    return path;
-  }
-
-  public static String getLineNumber(Location location)
-  {
-    String path = location.toString().trim();
-    int afterNumColumnIndex = path.lastIndexOf(":");
-    int beforeNumColumnIndex = path.lastIndexOf(":", afterNumColumnIndex - 1);
-    return path.substring(beforeNumColumnIndex + 1, afterNumColumnIndex);
-  }
-
-  public static String getBuildfileName(Location location)
-  {
-    // Must hack this, parse the toString of the Location
-    String[] arr =
-      TchUtils.parseString(location.toString(), LOCATION_DELIMITER);
-
-    //System.out.println(TchUtils.arrayToString(arr," | "));
-
-    if (AntProperties.getAntVersion().startsWith("1.5"))
-    {
-      if (arr.length == 4)
-        return arr[1]; //if on unix, no drive letter
-      else
-        //First one is drive letter, include the next
-        return arr[1] + LOCATION_DELIMITER + arr[2];
-    }
-    else
-    {
-      if (arr.length == 3)
-        return arr[0]; //if on unix, no drive letter
-      else
-        //First one is drive letter, include the next
-        return arr[0] + LOCATION_DELIMITER + arr[1];
-    }
-  }
-
-  public static void cloneTaskData(Task oldTask, Task newTask)
-  {
-    newTask.setProject(oldTask.getProject());
-    newTask.setOwningTarget(oldTask.getOwningTarget());
-    newTask.setLocation(oldTask.getLocation());
-    newTask.setRuntimeConfigurableWrapper(
-      oldTask.getRuntimeConfigurableWrapper());
-  }
-
-  public static void appendProperty(StringBuffer sb, String name, String value)
-  {
-    appendProperty(sb, name, value, new ArrayList());
-  }
-
-  public static void appendProperty(
-    StringBuffer sb,
-    String name,
-    String value,
-    Collection excludedPropNames)
-  {
-    if (!excludedPropNames.contains(name))
-    {
-      // the ordering of these ugly string replacements is important.
-      // first, convert all '\' to '/' to stuff runs fine on mks.
-      value = TchUtils.searchAndReplace(value, "\\", "/");
-      // second if value has '"', need to escape it
-	  value = TchUtils.searchAndReplace(value, "\"", "\\\"");
-      sb
-        .append(" ")
-        .append(ANT_PROP_PREFIX)
-        .append(name)
-        .append(ANT_EQUALS)
-        .append("\"")
-        // if value has '"', need to escape it
-        .append(value)
-        .append("\"");
-    }
-  }
-
-  public static Throwable unwrapBuildExceptions(Throwable t)
-  {
-    if (t instanceof BuildException)
-    {
-      BuildException be = (BuildException)t;
-      if (be.getException() != null)
-        return unwrapBuildExceptions(be.getException());
-      else
-        return t;
-    }
-    else
-      return t;
-  }
-
-  public static String appendProperty(String s, String name, String value)
-  {
-    StringBuffer sb = new StringBuffer(s);
-    appendProperty(sb, name, value);
-    return sb.toString();
-  }
-
-  public static void appendProperties(StringBuffer sb, Map properties)
-  {
-    appendProperties(sb, properties, new ArrayList());
-  }
-
-  public static void appendProperties(
-    StringBuffer sb,
-    Map properties,
-    Collection excludedPropNames)
-  {
-    for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();)
-    {
-      Map.Entry me = (Map.Entry)iter.next();
-      appendProperty(
-        sb,
-        (String)me.getKey(),
-        (String)me.getValue(),
-        excludedPropNames);
-    }
-  }
-
-  // returns Element -> name (String)
-  // same as getAllPropertyElementsByName, but inverse mapping
-  public static Map getAllPropertyElements(Document document)
-  {
-    Map ret = new OrderedMap();
-    NodeList nl = document.getDocumentElement().getChildNodes();
-    int length = nl.getLength();
-    for (int i = 0; i < length; i++)
-    {
-      Node node = nl.item(i);
-      if (node instanceof Element)
-      {
-        Element e = (Element)node;
-        if (e.getNodeName().equals("property"))
-        {
-          NamedNodeMap attrs = e.getAttributes();
-          Attr nameAttr = (Attr)attrs.getNamedItem("name");
-          if (nameAttr != null)
-          {
-            ret.put(e, nameAttr.getValue());
-          }
-        }
-      }
-    }
-    return ret;
-  }
-
-  // returns name (String) -> Element
-  //same as getAllPropertyElements, but inverse mapping
-  public static Map getAllPropertyElementsByName(Document document)
-  {
-    Map ret = new OrderedMap();
-    NodeList nl = document.getDocumentElement().getChildNodes();
-    int length = nl.getLength();
-    for (int i = 0; i < length; i++)
-    {
-      Node node = nl.item(i);
-      if (node instanceof Element)
-      {
-        Element e = (Element)node;
-        if (e.getNodeName().equals("property"))
-        {
-          NamedNodeMap attrs = e.getAttributes();
-          Attr nameAttr = (Attr)attrs.getNamedItem("name");
-          if (nameAttr != null)
-          {
-            ret.put(nameAttr.getValue(), e);
-          }
-        }
-      }
-    }
-    return ret;
-  }
-  
-  public static boolean buildListenerIsSupported()
-  {
-  	// we NPE in ant code if ant version < 1.5.2
-  	String version = AntProperties.getAntVersion();
-    if (version.startsWith("1.5"))
-      if (version.equals("1.5") || version.equals("1.5.1"))
-        return false;
-      else
-        return true;
-    else
-      return false;
-  }
-
-}
+package org.apache.beehive.test.tools.tch.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Task;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class AntUtils
+{
+  public static final String ANT_PROP_PREFIX = "-D",
+    ANT_EQUALS = "=",
+    LOCATION_DELIMITER = ":";
+
+  /**
+   * Calls perform() on input Collection of Tasks
+   */
+  public static void perform(Collection tasks)
+  {
+    for (Iterator iter = tasks.iterator(); iter.hasNext();)
+    {
+      Task t = (Task)iter.next();
+      //System.out.println("ANTUTILS:  Calling perform on task:  "+t.getClass().getName());
+      t.perform();
+    }
+  }
+
+  public static String getSourcePath(Location location)
+  {
+    String path = location.toString().trim();
+    if (path.endsWith(":"))
+      path = path.substring(0, path.length() - 1);
+    return path;
+  }
+
+  public static String getLineNumber(Location location)
+  {
+    String path = location.toString().trim();
+    int afterNumColumnIndex = path.lastIndexOf(":");
+    int beforeNumColumnIndex = path.lastIndexOf(":", afterNumColumnIndex - 1);
+    return path.substring(beforeNumColumnIndex + 1, afterNumColumnIndex);
+  }
+
+  public static String getBuildfileName(Location location)
+  {
+    // Must hack this, parse the toString of the Location
+    String[] arr =
+      TchUtils.parseString(location.toString(), LOCATION_DELIMITER);
+
+    //System.out.println(TchUtils.arrayToString(arr," | "));
+
+    if (AntProperties.getAntVersion().startsWith("1.5"))
+    {
+      if (arr.length == 4)
+        return arr[1]; //if on unix, no drive letter
+      else
+        //First one is drive letter, include the next
+        return arr[1] + LOCATION_DELIMITER + arr[2];
+    }
+    else
+    {
+      if (arr.length == 3)
+        return arr[0]; //if on unix, no drive letter
+      else
+        //First one is drive letter, include the next
+        return arr[0] + LOCATION_DELIMITER + arr[1];
+    }
+  }
+
+  public static void cloneTaskData(Task oldTask, Task newTask)
+  {
+    newTask.setProject(oldTask.getProject());
+    newTask.setOwningTarget(oldTask.getOwningTarget());
+    newTask.setLocation(oldTask.getLocation());
+    newTask.setRuntimeConfigurableWrapper(
+      oldTask.getRuntimeConfigurableWrapper());
+  }
+
+  public static void appendProperty(StringBuffer sb, String name, String value)
+  {
+    appendProperty(sb, name, value, new ArrayList());
+  }
+
+  public static void appendProperty(
+    StringBuffer sb,
+    String name,
+    String value,
+    Collection excludedPropNames)
+  {
+    if (!excludedPropNames.contains(name))
+    {
+      // the ordering of these ugly string replacements is important.
+      // first, convert all '\' to '/' to stuff runs fine on mks.
+      value = TchUtils.searchAndReplace(value, "\\", "/");
+      // second if value has '"', need to escape it
+	  value = TchUtils.searchAndReplace(value, "\"", "\\\"");
+      sb
+        .append(" ")
+        .append(ANT_PROP_PREFIX)
+        .append(name)
+        .append(ANT_EQUALS)
+        .append("\"")
+        // if value has '"', need to escape it
+        .append(value)
+        .append("\"");
+    }
+  }
+
+  public static Throwable unwrapBuildExceptions(Throwable t)
+  {
+    if (t instanceof BuildException)
+    {
+      BuildException be = (BuildException)t;
+      if (be.getException() != null)
+        return unwrapBuildExceptions(be.getException());
+      else
+        return t;
+    }
+    else
+      return t;
+  }
+
+  public static String appendProperty(String s, String name, String value)
+  {
+    StringBuffer sb = new StringBuffer(s);
+    appendProperty(sb, name, value);
+    return sb.toString();
+  }
+
+  public static void appendProperties(StringBuffer sb, Map properties)
+  {
+    appendProperties(sb, properties, new ArrayList());
+  }
+
+  public static void appendProperties(
+    StringBuffer sb,
+    Map properties,
+    Collection excludedPropNames)
+  {
+    for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();)
+    {
+      Map.Entry me = (Map.Entry)iter.next();
+      appendProperty(
+        sb,
+        (String)me.getKey(),
+        (String)me.getValue(),
+        excludedPropNames);
+    }
+  }
+
+  // returns Element -> name (String)
+  // same as getAllPropertyElementsByName, but inverse mapping
+  public static Map getAllPropertyElements(Document document)
+  {
+    Map ret = new OrderedMap();
+    NodeList nl = document.getDocumentElement().getChildNodes();
+    int length = nl.getLength();
+    for (int i = 0; i < length; i++)
+    {
+      Node node = nl.item(i);
+      if (node instanceof Element)
+      {
+        Element e = (Element)node;
+        if (e.getNodeName().equals("property"))
+        {
+          NamedNodeMap attrs = e.getAttributes();
+          Attr nameAttr = (Attr)attrs.getNamedItem("name");
+          if (nameAttr != null)
+          {
+            ret.put(e, nameAttr.getValue());
+          }
+        }
+      }
+    }
+    return ret;
+  }
+
+  // returns name (String) -> Element
+  //same as getAllPropertyElements, but inverse mapping
+  public static Map getAllPropertyElementsByName(Document document)
+  {
+    Map ret = new OrderedMap();
+    NodeList nl = document.getDocumentElement().getChildNodes();
+    int length = nl.getLength();
+    for (int i = 0; i < length; i++)
+    {
+      Node node = nl.item(i);
+      if (node instanceof Element)
+      {
+        Element e = (Element)node;
+        if (e.getNodeName().equals("property"))
+        {
+          NamedNodeMap attrs = e.getAttributes();
+          Attr nameAttr = (Attr)attrs.getNamedItem("name");
+          if (nameAttr != null)
+          {
+            ret.put(nameAttr.getValue(), e);
+          }
+        }
+      }
+    }
+    return ret;
+  }
+  
+  public static boolean buildListenerIsSupported()
+  {
+  	// we NPE in ant code if ant version < 1.5.2
+  	String version = AntProperties.getAntVersion();
+    if (version.startsWith("1.5"))
+      if (version.equals("1.5") || version.equals("1.5.1"))
+        return false;
+      else
+        return true;
+    else
+      return false;
+  }
+
+}

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

Modified: beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AssertionError.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AssertionError.java?rev=232310&r1=232309&r2=232310&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AssertionError.java (original)
+++ beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/util/AssertionError.java Fri Aug 12 08:12:28 2005
@@ -1,77 +1,77 @@
-package org.apache.beehive.test.tools.tch.util;
-
-/**
- * Class for assertion errors -- this error should be thrown to
- * indicate an internal error; i.e. the code went down a path that we
- * believed to be impossible. It should <b>never</b> be caught!
- *
- */
-public class AssertionError extends NestedError
-{
-  /**
-   * Set this to true if you want the first AssertionError constructed
-   * to dump stack and System.exit().
-   */
-  private final static boolean makeFatal = false;
-
-  /**
-   * The default message -- used if there is no message given to the
-   * constructor or prepended if there is. Designed to be loud and
-   * obnoxious.
-   */
-  private final static String DEFAULT_MSG = "***** ASSERTION FAILED *****";
-
-  /**
-   * Create a new AssertionError with the default message of:
-   *  "***** ASSERTION FAILED *****"
-   */
-  public AssertionError()
-  {
-    super(DEFAULT_MSG);
-    printStackTrace();
-    if (makeFatal)
-      exit();
-  }
-
-  /**
-   * Create a new AssertionError with the default message and the
-   * given msg appended.
-   */
-  public AssertionError(String msg)
-  {
-    super(DEFAULT_MSG + "[ " + msg + " ]");
-    printStackTrace();
-    if (makeFatal)
-      exit();
-  }
-
-  /**
-   * Create a new AssertionError with the default message and with the
-   * given Throwable nested inside.
-   */
-  public AssertionError(Throwable nested)
-  {
-    super(DEFAULT_MSG, nested);
-    printStackTrace();
-    if (makeFatal)
-      exit();
-  }
-
-  /**
-   * Create a new AssertionError with the default message and the
-   * given msg appended and with the given Throwable nested inside.
-   */
-  public AssertionError(String msg, Throwable nested)
-  {
-    super(DEFAULT_MSG + "[ " + msg + " ]", nested);
-    printStackTrace();
-    if (makeFatal)
-      exit();
-  }
-
-  private void exit()
-  {
-    System.err.println("Exiting because AssertionError.makeFatal == true.");
-    System.exit(-1);
-  }
-}
+package org.apache.beehive.test.tools.tch.util;
+
+/**
+ * Class for assertion errors -- this error should be thrown to
+ * indicate an internal error; i.e. the code went down a path that we
+ * believed to be impossible. It should <b>never</b> be caught!
+ *
+ */
+public class AssertionError extends NestedError
+{
+  /**
+   * Set this to true if you want the first AssertionError constructed
+   * to dump stack and System.exit().
+   */
+  private final static boolean makeFatal = false;
+
+  /**
+   * The default message -- used if there is no message given to the
+   * constructor or prepended if there is. Designed to be loud and
+   * obnoxious.
+   */
+  private final static String DEFAULT_MSG = "***** ASSERTION FAILED *****";
+
+  /**
+   * Create a new AssertionError with the default message of:
+   *  "***** ASSERTION FAILED *****"
+   */
+  public AssertionError()
+  {
+    super(DEFAULT_MSG);
+    printStackTrace();
+    if (makeFatal)
+      exit();
+  }
+
+  /**
+   * Create a new AssertionError with the default message and the
+   * given msg appended.
+   */
+  public AssertionError(String msg)
+  {
+    super(DEFAULT_MSG + "[ " + msg + " ]");
+    printStackTrace();
+    if (makeFatal)
+      exit();
+  }
+
+  /**
+   * Create a new AssertionError with the default message and with the
+   * given Throwable nested inside.
+   */
+  public AssertionError(Throwable nested)
+  {
+    super(DEFAULT_MSG, nested);
+    printStackTrace();
+    if (makeFatal)
+      exit();
+  }
+
+  /**
+   * Create a new AssertionError with the default message and the
+   * given msg appended and with the given Throwable nested inside.
+   */
+  public AssertionError(String msg, Throwable nested)
+  {
+    super(DEFAULT_MSG + "[ " + msg + " ]", nested);
+    printStackTrace();
+    if (makeFatal)
+      exit();
+  }
+
+  private void exit()
+  {
+    System.err.println("Exiting because AssertionError.makeFatal == true.");
+    System.exit(-1);
+  }
+}

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