Modified: 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestRunnerMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestRunnerMojo.java?rev=651325&r1=651324&r2=651325&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestRunnerMojo.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestRunnerMojo.java
 Thu Apr 24 10:49:03 2008
@@ -1,274 +1,274 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.junit.maven;
-
-import org.apache.maven.plugin.AbstractMojo;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-/**
- * TKTestRunnerMojo is a JUnit test runner plugin for Maven 2. It is intended 
to be compatible with the surefire
- * plugin (though not all features of that are yet implemented), with some 
extended capabilities.
- *
- * <p/>This plugin adds the ability to use different JUnit test runners, and 
to pass arbitrary options to them.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * </table>
- *
- * @author Rupert Smith
- *
- * @goal tktest
- * @phase test
- * @requiresDependencyResolution test
- */
-public class TKTestRunnerMojo extends AbstractMojo
-{
-    private static final BitSet UNRESERVED = new BitSet(256);
-
-    /**
-     * Set this to 'true' to bypass unit tests entirely. Its use is NOT 
RECOMMENDED, but quite convenient on occasion.
-     *
-     * @parameter expression="${maven.test.skip}"
-     */
-    private boolean skip;
-
-    /**
-     * The TKTest runner command lines. There are passed directly to the 
TKTestRunner main method.
-     *
-     * @parameter
-     */
-    private Map<String, String> commands = new LinkedHashMap<String, String>();
-
-    /**
-     * The base directory of the project being tested. This can be obtained in 
your unit test by
-     * System.getProperty("basedir").
-     *
-     * @parameter expression="${basedir}"
-     * @required
-     */
-    private File basedir;
-
-    /**
-     * The directory containing generated classes of the project being tested.
-     *
-     * @parameter expression="${project.build.outputDirectory}"
-     * @required
-     */
-    private File classesDirectory;
-
-    /**
-     * The directory containing generated test classes of the project being 
tested.
-     *
-     * @parameter expression="${project.build.testOutputDirectory}"
-     * @required
-     */
-    private File testClassesDirectory;
-
-    /**
-     * The classpath elements of the project being tested.
-     *
-     * @parameter expression="${project.testClasspathElements}"
-     * @required
-     * @readonly
-     */
-    private List classpathElements;
-
-    /**
-     * List of System properties to pass to the tests.
-     *
-     * @parameter
-     */
-    private Properties systemProperties;
-
-    /**
-     * Map of of plugin artifacts.
-     *
-     * @parameter expression="${plugin.artifactMap}"
-     * @required
-     * @readonly
-     */
-    private Map pluginArtifactMap;
-
-    /**
-     * Map of of project artifacts.
-     *
-     * @parameter expression="${project.artifactMap}"
-     * @required
-     * @readonly
-     */
-    private Map projectArtifactMap;
-
-    /**
-     * Option to specify the forking mode. Can be "never" (default), "once" or 
"always".
-     * "none" and "pertest" are also accepted for backwards compatibility.
-     *
-     * @parameter expression="${forkMode}" default-value="once"
-     */
-    private String forkMode;
-
-    /**
-     * Option to specify the jvm (or path to the java executable) to use with
-     * the forking options. For the default we will assume that java is in the 
path.
-     *
-     * @parameter expression="${jvm}"
-     * default-value="java"
-     */
-    private String jvm;
-
-    /**
-     * The test runner to use.
-     *
-     * @parameter
-     */
-    private String testrunner;
-
-    /**
-     * The additional properties to append to the test runner invocation 
command line.
-     *
-     * @parameter
-     */
-    private Properties testrunnerproperties;
-
-    /**
-     * The options to pass to all test runner invocation command lines.
-     *
-     * @parameter
-     */
-    private String[] testrunneroptions;
-
-    /**
-     * Implementation of the tktest goal.
-     */
-    public void execute()
-    {
-        // Skip these tests if test skipping is turned on.
-        if (skip)
-        {
-            getLog().info("Skipping Tests.");
-
-            return;
-        }
-
-        // Log out the classpath if debugging is on.
-        if (getLog().isDebugEnabled())
-        {
-            getLog().info("Test Classpath :");
-
-            for (Object classpathElement1 : classpathElements)
-            {
-                String classpathElement = (String) classpathElement1;
-                getLog().info("  " + classpathElement);
-            }
-        }
-
-        try
-        {
-            // Create a class loader to load the test runner with. This also 
gets set as the context loader for this
-            // thread, so that all subsequent class loading activity by the 
test runner or the test code, has the
-            // test classes available to it. The system loader is set up for 
the maven build, which is why a seperate
-            // loader needs to be created; in order to inject the test 
dependencies into it.
-            ClassLoader runnerClassLoader = 
createClassLoader(classpathElements, ClassLoader.getSystemClassLoader(), true);
-            Thread.currentThread().setContextClassLoader(runnerClassLoader);
-
-            // Load the test runner implementation that will be used to run 
the tests.
-            if ((testrunner == null) || "".equals(testrunner))
-            {
-                testrunner = "org.apache.qpid.junit.extensions.TKTestRunner";
-            }
-
-            Class testRunnerClass = Class.forName(testrunner, false, 
runnerClassLoader);
-            Method run = testRunnerClass.getMethod("main", String[].class);
-
-            // Concatenate all of the options to pass on the command line to 
the test runner.
-            String preOptions = "";
-
-            for (String option : testrunneroptions)
-            {
-                preOptions += option + " ";
-            }
-
-            // Concatenate all of the additional properties as name=value 
pairs on the command line.
-            String nvPairs = "";
-
-            if (testrunnerproperties != null)
-            {
-                for (Object objKey : testrunnerproperties.keySet())
-                {
-                    String key = (String) objKey;
-                    String value = testrunnerproperties.getProperty(key);
-
-                    nvPairs = key + "=" + value + " ";
-                }
-            }
-
-            // Pass each of the test runner command lines in turn to the 
toolkit test runner.
-            // The command line is made up of the options, the command 
specific command line, then the trailing
-            // name=value pairs.
-            for (String testName : commands.keySet())
-            {
-                String commandLine = preOptions + " " + commands.get(testName) 
+ " " + nvPairs;
-                getLog().info("commandLine = " + commandLine);
-
-                // Tokenize the command line on white space, into an array of 
string components.
-                String[] tokenizedCommandLine = commandLine.split("\\s+");
-
-                // Run the tests.
-                run.invoke(testRunnerClass, new Object[] { 
tokenizedCommandLine });
-            }
-        }
-        catch (Exception e)
-        {
-            getLog().error("There was an exception: " + e.getMessage(), e);
-        }
-    }
-
-    private static ClassLoader createClassLoader(List classPathUrls, 
ClassLoader parent, boolean childDelegation)
-        throws MalformedURLException
-    {
-        List urls = new ArrayList();
-
-        for (Iterator i = classPathUrls.iterator(); i.hasNext();)
-        {
-            String url = (String) i.next();
-
-            if (url != null)
-            {
-                File f = new File(url);
-                urls.add(f.toURL());
-            }
-        }
-
-        IsolatedClassLoader classLoader = new IsolatedClassLoader(parent, 
childDelegation);
-
-        for (Iterator iter = urls.iterator(); iter.hasNext();)
-        {
-            URL url = (URL) iter.next();
-            classLoader.addURL(url);
-        }
-
-        return classLoader;
-    }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.junit.maven;
+
+import org.apache.maven.plugin.AbstractMojo;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * TKTestRunnerMojo is a JUnit test runner plugin for Maven 2. It is intended 
to be compatible with the surefire
+ * plugin (though not all features of that are yet implemented), with some 
extended capabilities.
+ *
+ * <p/>This plugin adds the ability to use different JUnit test runners, and 
to pass arbitrary options to them.
+ *
+ * <p><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * </table>
+ *
+ * @author Rupert Smith
+ *
+ * @goal tktest
+ * @phase test
+ * @requiresDependencyResolution test
+ */
+public class TKTestRunnerMojo extends AbstractMojo
+{
+    private static final BitSet UNRESERVED = new BitSet(256);
+
+    /**
+     * Set this to 'true' to bypass unit tests entirely. Its use is NOT 
RECOMMENDED, but quite convenient on occasion.
+     *
+     * @parameter expression="${maven.test.skip}"
+     */
+    private boolean skip;
+
+    /**
+     * The TKTest runner command lines. There are passed directly to the 
TKTestRunner main method.
+     *
+     * @parameter
+     */
+    private Map<String, String> commands = new LinkedHashMap<String, String>();
+
+    /**
+     * The base directory of the project being tested. This can be obtained in 
your unit test by
+     * System.getProperty("basedir").
+     *
+     * @parameter expression="${basedir}"
+     * @required
+     */
+    private File basedir;
+
+    /**
+     * The directory containing generated classes of the project being tested.
+     *
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    private File classesDirectory;
+
+    /**
+     * The directory containing generated test classes of the project being 
tested.
+     *
+     * @parameter expression="${project.build.testOutputDirectory}"
+     * @required
+     */
+    private File testClassesDirectory;
+
+    /**
+     * The classpath elements of the project being tested.
+     *
+     * @parameter expression="${project.testClasspathElements}"
+     * @required
+     * @readonly
+     */
+    private List classpathElements;
+
+    /**
+     * List of System properties to pass to the tests.
+     *
+     * @parameter
+     */
+    private Properties systemProperties;
+
+    /**
+     * Map of of plugin artifacts.
+     *
+     * @parameter expression="${plugin.artifactMap}"
+     * @required
+     * @readonly
+     */
+    private Map pluginArtifactMap;
+
+    /**
+     * Map of of project artifacts.
+     *
+     * @parameter expression="${project.artifactMap}"
+     * @required
+     * @readonly
+     */
+    private Map projectArtifactMap;
+
+    /**
+     * Option to specify the forking mode. Can be "never" (default), "once" or 
"always".
+     * "none" and "pertest" are also accepted for backwards compatibility.
+     *
+     * @parameter expression="${forkMode}" default-value="once"
+     */
+    private String forkMode;
+
+    /**
+     * Option to specify the jvm (or path to the java executable) to use with
+     * the forking options. For the default we will assume that java is in the 
path.
+     *
+     * @parameter expression="${jvm}"
+     * default-value="java"
+     */
+    private String jvm;
+
+    /**
+     * The test runner to use.
+     *
+     * @parameter
+     */
+    private String testrunner;
+
+    /**
+     * The additional properties to append to the test runner invocation 
command line.
+     *
+     * @parameter
+     */
+    private Properties testrunnerproperties;
+
+    /**
+     * The options to pass to all test runner invocation command lines.
+     *
+     * @parameter
+     */
+    private String[] testrunneroptions;
+
+    /**
+     * Implementation of the tktest goal.
+     */
+    public void execute()
+    {
+        // Skip these tests if test skipping is turned on.
+        if (skip)
+        {
+            getLog().info("Skipping Tests.");
+
+            return;
+        }
+
+        // Log out the classpath if debugging is on.
+        if (getLog().isDebugEnabled())
+        {
+            getLog().info("Test Classpath :");
+
+            for (Object classpathElement1 : classpathElements)
+            {
+                String classpathElement = (String) classpathElement1;
+                getLog().info("  " + classpathElement);
+            }
+        }
+
+        try
+        {
+            // Create a class loader to load the test runner with. This also 
gets set as the context loader for this
+            // thread, so that all subsequent class loading activity by the 
test runner or the test code, has the
+            // test classes available to it. The system loader is set up for 
the maven build, which is why a seperate
+            // loader needs to be created; in order to inject the test 
dependencies into it.
+            ClassLoader runnerClassLoader = 
createClassLoader(classpathElements, ClassLoader.getSystemClassLoader(), true);
+            Thread.currentThread().setContextClassLoader(runnerClassLoader);
+
+            // Load the test runner implementation that will be used to run 
the tests.
+            if ((testrunner == null) || "".equals(testrunner))
+            {
+                testrunner = "org.apache.qpid.junit.extensions.TKTestRunner";
+            }
+
+            Class testRunnerClass = Class.forName(testrunner, false, 
runnerClassLoader);
+            Method run = testRunnerClass.getMethod("main", String[].class);
+
+            // Concatenate all of the options to pass on the command line to 
the test runner.
+            String preOptions = "";
+
+            for (String option : testrunneroptions)
+            {
+                preOptions += option + " ";
+            }
+
+            // Concatenate all of the additional properties as name=value 
pairs on the command line.
+            String nvPairs = "";
+
+            if (testrunnerproperties != null)
+            {
+                for (Object objKey : testrunnerproperties.keySet())
+                {
+                    String key = (String) objKey;
+                    String value = testrunnerproperties.getProperty(key);
+
+                    nvPairs = key + "=" + value + " ";
+                }
+            }
+
+            // Pass each of the test runner command lines in turn to the 
toolkit test runner.
+            // The command line is made up of the options, the command 
specific command line, then the trailing
+            // name=value pairs.
+            for (String testName : commands.keySet())
+            {
+                String commandLine = preOptions + " " + commands.get(testName) 
+ " " + nvPairs;
+                getLog().info("commandLine = " + commandLine);
+
+                // Tokenize the command line on white space, into an array of 
string components.
+                String[] tokenizedCommandLine = commandLine.split("\\s+");
+
+                // Run the tests.
+                run.invoke(testRunnerClass, new Object[] { 
tokenizedCommandLine });
+            }
+        }
+        catch (Exception e)
+        {
+            getLog().error("There was an exception: " + e.getMessage(), e);
+        }
+    }
+
+    private static ClassLoader createClassLoader(List classPathUrls, 
ClassLoader parent, boolean childDelegation)
+        throws MalformedURLException
+    {
+        List urls = new ArrayList();
+
+        for (Iterator i = classPathUrls.iterator(); i.hasNext();)
+        {
+            String url = (String) i.next();
+
+            if (url != null)
+            {
+                File f = new File(url);
+                urls.add(f.toURL());
+            }
+        }
+
+        IsolatedClassLoader classLoader = new IsolatedClassLoader(parent, 
childDelegation);
+
+        for (Iterator iter = urls.iterator(); iter.hasNext();)
+        {
+            URL url = (URL) iter.next();
+            classLoader.addURL(url);
+        }
+
+        return classLoader;
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestRunnerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestScriptGenMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestScriptGenMojo.java?rev=651325&r1=651324&r2=651325&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestScriptGenMojo.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestScriptGenMojo.java
 Thu Apr 24 10:49:03 2008
@@ -1,148 +1,148 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.junit.maven;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * </table>
- *
- * @author Rupert Smith
- * @goal tkscriptgen
- * @phase test
- * @execute phase="test"
- * @requiresDependencyResolution test
- */
-public class TKTestScriptGenMojo extends AbstractMojo
-{
-    private static final String _scriptLanguage = "#!/bin/bash\n\n";
-
-    private static final String _javaOptArgParser =
-        "# Parse arguements taking all - prefixed args as JAVA_OPTS\n" + "for 
arg in \"[EMAIL PROTECTED]"; do\n"
-        + "    if [[ $arg == -java:* ]]; then\n" + "        
JAVA_OPTS=\"${JAVA_OPTS}-`echo $arg|cut -d ':' -f 2`  \"\n"
-        + "    else\n" + "        ARGS=\"${ARGS}$arg \"\n" + "    fi\n" + 
"done\n\n";
-
-    /**
-     * Where to write out the scripts.
-     *
-     * @parameter
-     */
-    private String scriptOutDirectory;
-
-    /**
-     * The all-in-one test jar location.
-     *
-     * @parameter
-     */
-    private String testJar;
-
-    /**
-     * The system properties to pass to java runtime.
-     *
-     * @parameter
-     */
-    private Properties systemproperties;
-
-    /**
-     * The TKTest runner command lines. There are passed directly to the 
TKTestRunner main method.
-     *
-     * @parameter
-     */
-    private Map<String, String> commands = new LinkedHashMap<String, String>();
-
-    /**
-     * Implementation of the tkscriptgen goal.
-     *
-     * @throws MojoExecutionException
-     */
-    public void execute() throws MojoExecutionException
-    {
-        // Turn each of the test runner command lines into a script.
-        for (String testName : commands.keySet())
-        {
-            String testOptions = commands.get(testName);
-            String commandLine = "java ";
-
-            String logdir = null;
-
-            for (Object key : systemproperties.keySet())
-            {
-                String keyString = (String) key;
-                String value = systemproperties.getProperty(keyString);
-
-                if (keyString.equals("logdir"))
-                {
-                    logdir = value;
-                }
-                else
-                {
-                    if (keyString.startsWith("-X"))
-                    {
-                        commandLine += keyString + value + " ";
-                    }
-                    else
-                    {
-                        commandLine += "-D" + keyString + "=" + value + " ";
-                    }
-                }
-            }
-
-            commandLine +=
-                "${JAVA_OPTS} -cp " + testJar + " 
org.apache.qpid.junit.extensions.TKTestRunner " + testOptions + " ${ARGS}";
-
-            getLog().info("Generating Script for test: " + testName);
-            getLog().debug(commandLine);
-
-            String fileName = scriptOutDirectory + "/" + testName + ".sh";
-
-            try
-            {
-                File scriptFile = new File(fileName);
-                Writer scriptWriter = new FileWriter(scriptFile);
-                scriptWriter.write(_scriptLanguage);
-                scriptWriter.write(_javaOptArgParser);
-                if (logdir != null)
-                {
-                    scriptWriter.write("mkdir -p " + logdir + "\n");
-                }
-
-                scriptWriter.write(commandLine);
-                scriptWriter.flush();
-                scriptWriter.close();
-            }
-            catch (IOException e)
-            {
-                getLog().error("Failed to write: " + fileName);
-            }
-        }
-    }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.junit.maven;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * <p><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * </table>
+ *
+ * @author Rupert Smith
+ * @goal tkscriptgen
+ * @phase test
+ * @execute phase="test"
+ * @requiresDependencyResolution test
+ */
+public class TKTestScriptGenMojo extends AbstractMojo
+{
+    private static final String _scriptLanguage = "#!/bin/bash\n\n";
+
+    private static final String _javaOptArgParser =
+        "# Parse arguements taking all - prefixed args as JAVA_OPTS\n" + "for 
arg in \"[EMAIL PROTECTED]"; do\n"
+        + "    if [[ $arg == -java:* ]]; then\n" + "        
JAVA_OPTS=\"${JAVA_OPTS}-`echo $arg|cut -d ':' -f 2`  \"\n"
+        + "    else\n" + "        ARGS=\"${ARGS}$arg \"\n" + "    fi\n" + 
"done\n\n";
+
+    /**
+     * Where to write out the scripts.
+     *
+     * @parameter
+     */
+    private String scriptOutDirectory;
+
+    /**
+     * The all-in-one test jar location.
+     *
+     * @parameter
+     */
+    private String testJar;
+
+    /**
+     * The system properties to pass to java runtime.
+     *
+     * @parameter
+     */
+    private Properties systemproperties;
+
+    /**
+     * The TKTest runner command lines. There are passed directly to the 
TKTestRunner main method.
+     *
+     * @parameter
+     */
+    private Map<String, String> commands = new LinkedHashMap<String, String>();
+
+    /**
+     * Implementation of the tkscriptgen goal.
+     *
+     * @throws MojoExecutionException
+     */
+    public void execute() throws MojoExecutionException
+    {
+        // Turn each of the test runner command lines into a script.
+        for (String testName : commands.keySet())
+        {
+            String testOptions = commands.get(testName);
+            String commandLine = "java ";
+
+            String logdir = null;
+
+            for (Object key : systemproperties.keySet())
+            {
+                String keyString = (String) key;
+                String value = systemproperties.getProperty(keyString);
+
+                if (keyString.equals("logdir"))
+                {
+                    logdir = value;
+                }
+                else
+                {
+                    if (keyString.startsWith("-X"))
+                    {
+                        commandLine += keyString + value + " ";
+                    }
+                    else
+                    {
+                        commandLine += "-D" + keyString + "=" + value + " ";
+                    }
+                }
+            }
+
+            commandLine +=
+                "${JAVA_OPTS} -cp " + testJar + " 
org.apache.qpid.junit.extensions.TKTestRunner " + testOptions + " ${ARGS}";
+
+            getLog().info("Generating Script for test: " + testName);
+            getLog().debug(commandLine);
+
+            String fileName = scriptOutDirectory + "/" + testName + ".sh";
+
+            try
+            {
+                File scriptFile = new File(fileName);
+                Writer scriptWriter = new FileWriter(scriptFile);
+                scriptWriter.write(_scriptLanguage);
+                scriptWriter.write(_javaOptArgParser);
+                if (logdir != null)
+                {
+                    scriptWriter.write("mkdir -p " + logdir + "\n");
+                }
+
+                scriptWriter.write(commandLine);
+                scriptWriter.flush();
+                scriptWriter.close();
+            }
+            catch (IOException e)
+            {
+                getLog().error("Failed to write: " + fileName);
+            }
+        }
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/junit-toolkit-maven-plugin/src/main/org/apache/qpid/junit/maven/TKTestScriptGenMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/DefaultThreadFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/DefaultThreadFactory.java?rev=651325&r1=651324&r2=651325&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/DefaultThreadFactory.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/DefaultThreadFactory.java
 Thu Apr 24 10:49:03 2008
@@ -1,48 +1,48 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.junit.concurrency;
-
-import java.util.concurrent.ThreadFactory;
-
-/**
- * Implements a default thread factory.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create default threads with no specialization.
- * </table>
- *
- * @author Rupert Smith
- */
-public class DefaultThreadFactory implements ThreadFactory
-{
-    /**
-     * Constructs a new <tt>Thread</tt>.
-     *
-     * @param r A runnable to be executed by new thread instance.
-     *
-     * @return The constructed thread.
-     */
-    public Thread newThread(Runnable r)
-    {
-        return new Thread(r);
-    }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.junit.concurrency;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * Implements a default thread factory.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Create default threads with no specialization.
+ * </table>
+ *
+ * @author Rupert Smith
+ */
+public class DefaultThreadFactory implements ThreadFactory
+{
+    /**
+     * Constructs a new <tt>Thread</tt>.
+     *
+     * @param r A runnable to be executed by new thread instance.
+     *
+     * @return The constructed thread.
+     */
+    public Thread newThread(Runnable r)
+    {
+        return new Thread(r);
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/DefaultThreadFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/PossibleDeadlockException.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/PossibleDeadlockException.java?rev=651325&r1=651324&r2=651325&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/PossibleDeadlockException.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/PossibleDeadlockException.java
 Thu Apr 24 10:49:03 2008
@@ -1,46 +1,46 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.junit.concurrency;
-
-/**
- * PossibleDeadlockException is used to signal that two test threads being 
executed by a [EMAIL PROTECTED] ThreadTestCoordinator}
- * may be in a state of deadlock because they are mutually blocking each other 
or one is waiting on the other and the
- * other has been blocked elsewhere for longer than a specified timeout.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Signal a possible state of deadlock between coordinated test 
threads.
- * </table>
- *
- * @author Rupert Smith
- */
-public class PossibleDeadlockException extends RuntimeException
-{
-    /**
-     * Create a new possible deadlock execption.
-     *
-     * @param message The exception message.
-     */
-    public PossibleDeadlockException(String message)
-    {
-        super(message);
-    }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.junit.concurrency;
+
+/**
+ * PossibleDeadlockException is used to signal that two test threads being 
executed by a [EMAIL PROTECTED] ThreadTestCoordinator}
+ * may be in a state of deadlock because they are mutually blocking each other 
or one is waiting on the other and the
+ * other has been blocked elsewhere for longer than a specified timeout.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Signal a possible state of deadlock between coordinated test 
threads.
+ * </table>
+ *
+ * @author Rupert Smith
+ */
+public class PossibleDeadlockException extends RuntimeException
+{
+    /**
+     * Create a new possible deadlock execption.
+     *
+     * @param message The exception message.
+     */
+    public PossibleDeadlockException(String message)
+    {
+        super(message);
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/PossibleDeadlockException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/TestRunnable.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/TestRunnable.java?rev=651325&r1=651324&r2=651325&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/TestRunnable.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/TestRunnable.java
 Thu Apr 24 10:49:03 2008
@@ -1,239 +1,239 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.junit.concurrency;
-
-/**
- * TestRunnable is an extension of java.util.Runnable that adds some features 
to make it easier to coordinate the
- * activities of threads in such a way as to expose bugs in multi threaded 
code.
- *
- * <p/>Sometimes several threads will run in a particular order so that a bug 
is not revealed. Other times the ordering
- * of the threads will expose a bug. Such bugs can be hard to replicate as the 
exact execution ordering of threads is not
- * usually controlled. This class adds some methods that allow threads to 
synchronize other threads, either allowing them
- * to run, or waiting for them to allow this thread to run. It also provides 
convenience methods to gather error messages
- * and exceptions from threads, which will often be reported in unit testing 
code.
- *
- * <p/>Coordination between threads is handled by the [EMAIL PROTECTED] 
ThreadTestCoordinator}. It is called through the convenience
- * methods [EMAIL PROTECTED] #allow} and [EMAIL PROTECTED] #waitFor}. Threads 
to be coordinated must be set up with the coordinator and assigned
- * integer ids. It is then possible to call the coordinator with an array of 
thread ids requesting that those threads
- * be allowed to continue, or to wait until one of them allows this thread to 
continue. The otherwise non-deterministic
- * execution order of threads can be controlled into a carefully determined 
sequence using these methods in order
- * to reproduce race conditions, dead locks, live locks, dirty reads, phantom 
reads, non repeatable reads and so on.
- *
- * <p/>When waiting for another thread to give a signal to continue it is 
sometimes the case that the other thread has
- * become blocked by the code under test. For example in testing for a dirty 
read (for example in database code),
- * thread 1 lets thread 2 perform a write but not commit it, then thread 2 
lets thread 1 run and attempt to perform a
- * dirty read on its uncommitted write. Transaction synchronization code being 
tested against the possibility of a dirty
- * write may make use of snapshots in which case both threads should be able 
to read and write without blocking. It may
- * make use of explicit keys in which case thread 2 may become blocked on its 
write attempt because thread 1 holds a
- * read lock and it must wait until thread 1 completes its transaction before 
it can acquire this lock. The
- * [EMAIL PROTECTED] #waitFor} method accepts a boolean parameter to indicate 
that threads being blocked (other than on the
- * coordinator) can be interpreted the same as if the thread explicitly allows 
the thread calling waitFor to continue.
- * Using this technique a dirty read test could be written that works against 
either the snapshot or the locking
- * implementation, allowing both approaches to pass the test yet arranging for 
multiple threads to run against the
- * implementation in such a way that a potential dirty read bug is exposed.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Wait for another thread to allow this one to continue.
- * <tr><td> Allow another thread to continue.
- * <tr><td> Accumulate error messages.
- * <tr><td> Record exceptions from thread run.
- * <tr><td> Maintain link to thread coordinator.
- * <tr><td> Explicitly mark a thread with an integer id.
- * <tr><td> Maintian a flag to indicate whether or not this thread is waiting 
on the coordinator.
- * </table>
- *
- * @todo The allow then waitFor operations are very often used as a pair. So 
create a method allowAndWait that combines
- *       them into a single method call.
- *
- * @author Rupert Smith
- */
-public abstract class TestRunnable implements Runnable
-{
-    /** Holds a reference to the thread coordinator. */
-    private ThreadTestCoordinator coordinator;
-
-    /** Holds the explicit integer id of this thread. */
-    private int id;
-
-    /** Used to indicate that this thread is waiting on the coordinator and 
not elsewhere. */
-    private boolean waitingOnCoordinator = false;
-
-    /** Used to accumulate error messsages. */
-    private String errorMessage = "";
-
-    /** Holds the Java thread object that this is running under. */
-    private Thread thisThread;
-
-    /** Used to hold any exceptions resulting from the run method. */
-    private Exception runException = null;
-
-    /**
-     * Implementations override this to perform coordinated thread sequencing.
-     *
-     * @throws Exception Any exception raised by the implementation will be 
caught by the default [EMAIL PROTECTED] #run()}
-     *                   implementation for later querying by the [EMAIL 
PROTECTED] #getException()} method.
-     */
-    public abstract void runWithExceptions() throws Exception;
-
-    /**
-     * Provides a default implementation of the run method that allows 
exceptions to be thrown and keeps a record
-     * of those exceptions. Defers to the [EMAIL PROTECTED] 
#runWithExceptions()} method to provide the thread body implementation
-     * and catches any exceptions thrown by it.
-     */
-    public void run()
-    {
-        try
-        {
-            runWithExceptions();
-        }
-        catch (Exception e)
-        {
-            this.runException = e;
-        }
-    }
-
-    /**
-     * Attempt to consume an allow event from one of the specified threads and 
blocks until such an event occurrs.
-     *
-     * @param threads          The set of threads that can allow this one to 
continue.
-     * @param otherWaitIsAllow If set to <tt>true</tt> if the threads being 
waited on are blocked other than on
-     *                         the coordinator itself then this is to be 
interpreted as allowing this thread to
-     *                         continue.
-     *
-     * @return If the <tt>otherWaitIsAllow</tt> flag is set, then 
<tt>true</tt> is returned when the thread being waited on is found
-     *         to be blocked outside of the thread test coordinator. 
<tt>false</tt> under all other conditions.
-     */
-    protected boolean waitFor(int[] threads, boolean otherWaitIsAllow)
-    {
-        return coordinator.consumeAllowEvent(threads, otherWaitIsAllow, id, 
this);
-    }
-
-    /**
-     * Produces allow events on each of the specified threads.
-     *
-     * @param threads The set of threads that are to be allowed to continue.
-     */
-    protected void allow(int[] threads)
-    {
-        coordinator.produceAllowEvents(threads, id, this);
-    }
-
-    /**
-     * Keeps the error message for later reporting by the coordinator.
-     *
-     * @param message The error message to keep.
-     */
-    protected void addErrorMessage(String message)
-    {
-        errorMessage += message;
-    }
-
-    /**
-     * Sets the coordinator for this thread.
-     *
-     * @param coordinator The coordinator for this thread.
-     */
-    void setCoordinator(ThreadTestCoordinator coordinator)
-    {
-        this.coordinator = coordinator;
-    }
-
-    /**
-     * Reports whether or not this thread is waiting on the coordinator.
-     *
-     * @return <tt>If this thread is waiting on the coordinator.
-     */
-    boolean isWaitingOnCoordinator()
-    {
-        return waitingOnCoordinator;
-    }
-
-    /**
-     * Sets the value of the waiting on coordinator flag.
-     *
-     * @param waiting The value of the waiting on coordinator flag.
-     */
-    void setWaitingOnCoordinator(boolean waiting)
-    {
-        waitingOnCoordinator = waiting;
-    }
-
-    /**
-     * Sets up the explicit int id for this thread.
-     *
-     * @param id The integer id.
-     */
-    void setId(int id)
-    {
-        this.id = id;
-    }
-
-    /**
-     * Reports any accumulated error messages.
-     *
-     * @return Any accumulated error messages.
-     */
-    String getErrorMessage()
-    {
-        return errorMessage;
-    }
-
-    /**
-     * Reports any exception thrown by the [EMAIL PROTECTED] 
#runWithExceptions} method.
-     *
-     * @return Any exception thrown by the [EMAIL PROTECTED] 
#runWithExceptions} method.
-     */
-    Exception getException()
-    {
-        return runException;
-    }
-
-    /**
-     * Sets the Java thread under which this runs.
-     *
-     * @param thread The Java thread under which this runs.
-     */
-    void setThread(Thread thread)
-    {
-        thisThread = thread;
-    }
-
-    /**
-     * Gets the Java thread under which this runs.
-     *
-     * @return The Java thread under which this runs.
-     */
-    Thread getThread()
-    {
-        return thisThread;
-    }
-
-    /**
-     * Provides a string summary of this test threads status.
-     *
-     * @return Summarizes this threads status.
-     */
-    public String toString()
-    {
-        return "id = " + id + ", waitingOnCoordinator = " + 
waitingOnCoordinator;
-    }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.junit.concurrency;
+
+/**
+ * TestRunnable is an extension of java.util.Runnable that adds some features 
to make it easier to coordinate the
+ * activities of threads in such a way as to expose bugs in multi threaded 
code.
+ *
+ * <p/>Sometimes several threads will run in a particular order so that a bug 
is not revealed. Other times the ordering
+ * of the threads will expose a bug. Such bugs can be hard to replicate as the 
exact execution ordering of threads is not
+ * usually controlled. This class adds some methods that allow threads to 
synchronize other threads, either allowing them
+ * to run, or waiting for them to allow this thread to run. It also provides 
convenience methods to gather error messages
+ * and exceptions from threads, which will often be reported in unit testing 
code.
+ *
+ * <p/>Coordination between threads is handled by the [EMAIL PROTECTED] 
ThreadTestCoordinator}. It is called through the convenience
+ * methods [EMAIL PROTECTED] #allow} and [EMAIL PROTECTED] #waitFor}. Threads 
to be coordinated must be set up with the coordinator and assigned
+ * integer ids. It is then possible to call the coordinator with an array of 
thread ids requesting that those threads
+ * be allowed to continue, or to wait until one of them allows this thread to 
continue. The otherwise non-deterministic
+ * execution order of threads can be controlled into a carefully determined 
sequence using these methods in order
+ * to reproduce race conditions, dead locks, live locks, dirty reads, phantom 
reads, non repeatable reads and so on.
+ *
+ * <p/>When waiting for another thread to give a signal to continue it is 
sometimes the case that the other thread has
+ * become blocked by the code under test. For example in testing for a dirty 
read (for example in database code),
+ * thread 1 lets thread 2 perform a write but not commit it, then thread 2 
lets thread 1 run and attempt to perform a
+ * dirty read on its uncommitted write. Transaction synchronization code being 
tested against the possibility of a dirty
+ * write may make use of snapshots in which case both threads should be able 
to read and write without blocking. It may
+ * make use of explicit keys in which case thread 2 may become blocked on its 
write attempt because thread 1 holds a
+ * read lock and it must wait until thread 1 completes its transaction before 
it can acquire this lock. The
+ * [EMAIL PROTECTED] #waitFor} method accepts a boolean parameter to indicate 
that threads being blocked (other than on the
+ * coordinator) can be interpreted the same as if the thread explicitly allows 
the thread calling waitFor to continue.
+ * Using this technique a dirty read test could be written that works against 
either the snapshot or the locking
+ * implementation, allowing both approaches to pass the test yet arranging for 
multiple threads to run against the
+ * implementation in such a way that a potential dirty read bug is exposed.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Wait for another thread to allow this one to continue.
+ * <tr><td> Allow another thread to continue.
+ * <tr><td> Accumulate error messages.
+ * <tr><td> Record exceptions from thread run.
+ * <tr><td> Maintain link to thread coordinator.
+ * <tr><td> Explicitly mark a thread with an integer id.
+ * <tr><td> Maintian a flag to indicate whether or not this thread is waiting 
on the coordinator.
+ * </table>
+ *
+ * @todo The allow then waitFor operations are very often used as a pair. So 
create a method allowAndWait that combines
+ *       them into a single method call.
+ *
+ * @author Rupert Smith
+ */
+public abstract class TestRunnable implements Runnable
+{
+    /** Holds a reference to the thread coordinator. */
+    private ThreadTestCoordinator coordinator;
+
+    /** Holds the explicit integer id of this thread. */
+    private int id;
+
+    /** Used to indicate that this thread is waiting on the coordinator and 
not elsewhere. */
+    private boolean waitingOnCoordinator = false;
+
+    /** Used to accumulate error messsages. */
+    private String errorMessage = "";
+
+    /** Holds the Java thread object that this is running under. */
+    private Thread thisThread;
+
+    /** Used to hold any exceptions resulting from the run method. */
+    private Exception runException = null;
+
+    /**
+     * Implementations override this to perform coordinated thread sequencing.
+     *
+     * @throws Exception Any exception raised by the implementation will be 
caught by the default [EMAIL PROTECTED] #run()}
+     *                   implementation for later querying by the [EMAIL 
PROTECTED] #getException()} method.
+     */
+    public abstract void runWithExceptions() throws Exception;
+
+    /**
+     * Provides a default implementation of the run method that allows 
exceptions to be thrown and keeps a record
+     * of those exceptions. Defers to the [EMAIL PROTECTED] 
#runWithExceptions()} method to provide the thread body implementation
+     * and catches any exceptions thrown by it.
+     */
+    public void run()
+    {
+        try
+        {
+            runWithExceptions();
+        }
+        catch (Exception e)
+        {
+            this.runException = e;
+        }
+    }
+
+    /**
+     * Attempt to consume an allow event from one of the specified threads and 
blocks until such an event occurrs.
+     *
+     * @param threads          The set of threads that can allow this one to 
continue.
+     * @param otherWaitIsAllow If set to <tt>true</tt> if the threads being 
waited on are blocked other than on
+     *                         the coordinator itself then this is to be 
interpreted as allowing this thread to
+     *                         continue.
+     *
+     * @return If the <tt>otherWaitIsAllow</tt> flag is set, then 
<tt>true</tt> is returned when the thread being waited on is found
+     *         to be blocked outside of the thread test coordinator. 
<tt>false</tt> under all other conditions.
+     */
+    protected boolean waitFor(int[] threads, boolean otherWaitIsAllow)
+    {
+        return coordinator.consumeAllowEvent(threads, otherWaitIsAllow, id, 
this);
+    }
+
+    /**
+     * Produces allow events on each of the specified threads.
+     *
+     * @param threads The set of threads that are to be allowed to continue.
+     */
+    protected void allow(int[] threads)
+    {
+        coordinator.produceAllowEvents(threads, id, this);
+    }
+
+    /**
+     * Keeps the error message for later reporting by the coordinator.
+     *
+     * @param message The error message to keep.
+     */
+    protected void addErrorMessage(String message)
+    {
+        errorMessage += message;
+    }
+
+    /**
+     * Sets the coordinator for this thread.
+     *
+     * @param coordinator The coordinator for this thread.
+     */
+    void setCoordinator(ThreadTestCoordinator coordinator)
+    {
+        this.coordinator = coordinator;
+    }
+
+    /**
+     * Reports whether or not this thread is waiting on the coordinator.
+     *
+     * @return <tt>If this thread is waiting on the coordinator.
+     */
+    boolean isWaitingOnCoordinator()
+    {
+        return waitingOnCoordinator;
+    }
+
+    /**
+     * Sets the value of the waiting on coordinator flag.
+     *
+     * @param waiting The value of the waiting on coordinator flag.
+     */
+    void setWaitingOnCoordinator(boolean waiting)
+    {
+        waitingOnCoordinator = waiting;
+    }
+
+    /**
+     * Sets up the explicit int id for this thread.
+     *
+     * @param id The integer id.
+     */
+    void setId(int id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * Reports any accumulated error messages.
+     *
+     * @return Any accumulated error messages.
+     */
+    String getErrorMessage()
+    {
+        return errorMessage;
+    }
+
+    /**
+     * Reports any exception thrown by the [EMAIL PROTECTED] 
#runWithExceptions} method.
+     *
+     * @return Any exception thrown by the [EMAIL PROTECTED] 
#runWithExceptions} method.
+     */
+    Exception getException()
+    {
+        return runException;
+    }
+
+    /**
+     * Sets the Java thread under which this runs.
+     *
+     * @param thread The Java thread under which this runs.
+     */
+    void setThread(Thread thread)
+    {
+        thisThread = thread;
+    }
+
+    /**
+     * Gets the Java thread under which this runs.
+     *
+     * @return The Java thread under which this runs.
+     */
+    Thread getThread()
+    {
+        return thisThread;
+    }
+
+    /**
+     * Provides a string summary of this test threads status.
+     *
+     * @return Summarizes this threads status.
+     */
+    public String toString()
+    {
+        return "id = " + id + ", waitingOnCoordinator = " + 
waitingOnCoordinator;
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/TestRunnable.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to