commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit folder.gif file.gif JUnitTestAdapter.html JUnitEventReporter.html index.html
Date Mon, 01 Apr 2002 05:42:13 GMT
dion        02/03/31 21:42:13

  Added:       docs/latka/xref/java/org/apache/commons/latka/junit
                        folder.gif file.gif JUnitTestAdapter.html
                        JUnitEventReporter.html index.html
  Log:
  New Maven generated site
  
  Revision  Changes    Path
  1.1                  jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit/folder.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit/file.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit/JUnitTestAdapter.html
  
  Index: JUnitTestAdapter.html
  ===================================================================
  <html>
  <body bgcolor="white">
  <pre>
  <table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/junit/JUnitTestAdapter.html">View Javadoc</a></table>
  <a name="1" href="#1">1</a>   <font color="#329900"><i>/*</font></i>
  <a name="2" href="#2">2</a>   <font color="#329900"><i> * ====================================================================</font></i>
  <a name="3" href="#3">3</a>   <font color="#329900"><i> *</font></i>
  <a name="4" href="#4">4</a>   <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
  <a name="5" href="#5">5</a>   <font color="#329900"><i> *</font></i>
  <a name="6" href="#6">6</a>   <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation.  All rights </font></i>
  <a name="7" href="#7">7</a>   <font color="#329900"><i> * reserved.</font></i>
  <a name="8" href="#8">8</a>   <font color="#329900"><i> *</font></i>
  <a name="9" href="#9">9</a>   <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
  <a name="10" href="#10">10</a>  <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
  <a name="11" href="#11">11</a>  <font color="#329900"><i> * are met:</font></i>
  <a name="12" href="#12">12</a>  <font color="#329900"><i> *</font></i>
  <a name="13" href="#13">13</a>  <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
  <a name="14" href="#14">14</a>  <font color="#329900"><i> *    notice, this list of conditions and the following disclaimer. </font></i>
  <a name="15" href="#15">15</a>  <font color="#329900"><i> *</font></i>
  <a name="16" href="#16">16</a>  <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
  <a name="17" href="#17">17</a>  <font color="#329900"><i> *    notice, this list of conditions and the following disclaimer in</font></i>
  <a name="18" href="#18">18</a>  <font color="#329900"><i> *    the documentation and/or other materials provided with the</font></i>
  <a name="19" href="#19">19</a>  <font color="#329900"><i> *    distribution.</font></i>
  <a name="20" href="#20">20</a>  <font color="#329900"><i> *</font></i>
  <a name="21" href="#21">21</a>  <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
  <a name="22" href="#22">22</a>  <font color="#329900"><i> *    any, must include the following acknowlegement:  </font></i>
  <a name="23" href="#23">23</a>  <font color="#329900"><i> *       "This product includes software developed by the </font></i>
  <a name="24" href="#24">24</a>  <font color="#329900"><i> *        Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
  <a name="25" href="#25">25</a>  <font color="#329900"><i> *    Alternately, this acknowlegement may appear in the software itself,</font></i>
  <a name="26" href="#26">26</a>  <font color="#329900"><i> *    if and wherever such third-party acknowlegements normally appear.</font></i>
  <a name="27" href="#27">27</a>  <font color="#329900"><i> *</font></i>
  <a name="28" href="#28">28</a>  <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
  <a name="29" href="#29">29</a>  <font color="#329900"><i> *    Foundation" must not be used to endorse or promote products derived</font></i>
  <a name="30" href="#30">30</a>  <font color="#329900"><i> *    from this software without prior written permission. For written </font></i>
  <a name="31" href="#31">31</a>  <font color="#329900"><i> *    permission, please contact apache@apache.org.</font></i>
  <a name="32" href="#32">32</a>  <font color="#329900"><i> *</font></i>
  <a name="33" href="#33">33</a>  <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
  <a name="34" href="#34">34</a>  <font color="#329900"><i> *    nor may "Apache" appear in their names without prior written</font></i>
  <a name="35" href="#35">35</a>  <font color="#329900"><i> *    permission of the Apache Group.</font></i>
  <a name="36" href="#36">36</a>  <font color="#329900"><i> *</font></i>
  <a name="37" href="#37">37</a>  <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
  <a name="38" href="#38">38</a>  <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
  <a name="39" href="#39">39</a>  <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
  <a name="40" href="#40">40</a>  <font color="#329900"><i> * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
  <a name="41" href="#41">41</a>  <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
  <a name="42" href="#42">42</a>  <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
  <a name="43" href="#43">43</a>  <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
  <a name="44" href="#44">44</a>  <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
  <a name="45" href="#45">45</a>  <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
  <a name="46" href="#46">46</a>  <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
  <a name="47" href="#47">47</a>  <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
  <a name="48" href="#48">48</a>  <font color="#329900"><i> * SUCH DAMAGE.</font></i>
  <a name="49" href="#49">49</a>  <font color="#329900"><i> * ====================================================================</font></i>
  <a name="50" href="#50">50</a>  <font color="#329900"><i> *</font></i>
  <a name="51" href="#51">51</a>  <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
  <a name="52" href="#52">52</a>  <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation.  For more</font></i>
  <a name="53" href="#53">53</a>  <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
  <a name="54" href="#54">54</a>  <font color="#329900"><i> * &lt;<a href="http://www.apache.org/&gt" target="alexandria_uri">http://www.apache.org/&gt</a>;.</font></i>
  <a name="55" href="#55">55</a>  <font color="#329900"><i> *</font></i>
  <a name="56" href="#56">56</a>  <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
  <a name="57" href="#57">57</a>  <font color="#329900"><i> *</font></i>
  <a name="58" href="#58">58</a>  <font color="#329900"><i> */</font></i>   
  <a name="59" href="#59">59</a>  
  <a name="60" href="#60">60</a>  <b>package</b> <a href="../../../../../org/apache/commons/latka/junit/index.html">org.apache.commons.latka.junit</a>;
  <a name="61" href="#61">61</a>  
  <a name="62" href="#62">62</a>  <font color="#329900"><i>// java imports</font></i>
  <a name="63" href="#63">63</a>  <b>import</b> java.io.File;
  <a name="64" href="#64">64</a>  <b>import</b> java.io.IOException;
  <a name="65" href="#65">65</a>  <b>import</b> java.net.MalformedURLException;
  <a name="66" href="#66">66</a>  <b>import</b> java.net.URL;
  <a name="67" href="#67">67</a>  <font color="#329900"><i>// jaxp imports</font></i>
  <a name="68" href="#68">68</a>  <b>import</b> javax.xml.parsers.FactoryConfigurationError;
  <a name="69" href="#69">69</a>  <b>import</b> javax.xml.parsers.ParserConfigurationException;
  <a name="70" href="#70">70</a>  <b>import</b> javax.xml.parsers.SAXParser;
  <a name="71" href="#71">71</a>  <b>import</b> javax.xml.parsers.SAXParserFactory;
  <a name="72" href="#72">72</a>  <font color="#329900"><i>// latka imports</font></i>
  <a name="73" href="#73">73</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Latka.html">Latka</a>;
  <a name="74" href="#74">74</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/LatkaException.html">LatkaException</a>;
  <a name="75" href="#75">75</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Suite.html">Suite</a>;
  <a name="76" href="#76">76</a>  <font color="#329900"><i>// log4j imports</font></i>
  <a name="77" href="#77">77</a>  <b>import</b> org.apache.log4j.Category;
  <a name="78" href="#78">78</a>  <font color="#329900"><i>// sax imports</font></i>
  <a name="79" href="#79">79</a>  <b>import</b> org.xml.sax.Attributes;
  <a name="80" href="#80">80</a>  <b>import</b> org.xml.sax.InputSource;
  <a name="81" href="#81">81</a>  <b>import</b> org.xml.sax.SAXException;
  <a name="82" href="#82">82</a>  <b>import</b> org.xml.sax.XMLReader;
  <a name="83" href="#83">83</a>  <b>import</b> org.xml.sax.helpers.DefaultHandler;
  <a name="84" href="#84">84</a>  <font color="#329900"><i>// junit imports</font></i>
  <a name="85" href="#85">85</a>  <b>import</b> junit.framework.Test;
  <a name="86" href="#86">86</a>  <b>import</b> junit.framework.TestResult;
  <a name="87" href="#87">87</a>  
  <a name="88" href="#88">88</a>  <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="89" href="#89">89</a>  <font color="#AA0000"><i> * A JUnit {@link junit.framework.Test Test} which is created by</font></i>
  <a name="90" href="#90">90</a>  <font color="#AA0000"><i> * wrapping a Latka {@link org.apache.commons.latka.Suite Suite}</font></i>
  <a name="91" href="#91">91</a>  <font color="#AA0000"><i> *</font></i>
  <a name="92" href="#92">92</a>  <font color="#AA0000"><i> * @author Chuck Burdick</font></i>
  <a name="93" href="#93">93</a>  <font color="#AA0000"><i> * @author dIon Gillard</font></i>
  <a name="94" href="#94">94</a>  <font color="#AA0000"><i> * @version $Id: JUnitTestAdapter.html,v 1.1 2002/04/01 05:42:12 dion Exp $</font></i>
  <a name="95" href="#95">95</a>  <font color="#AA0000"><i> */</font></i>
  <a name="96" href="#96">96</a>  <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitTestAdapter.html">JUnitTestAdapter</a> implements Test {
  <a name="97" href="#97">97</a>      <font color="#AA0000"><i>/**<font color="#AA0000"><i>* log4j category that output is logged to */</font></i></font></i>
  <a name="98" href="#98">98</a>      <b>private</b> <b>static</b> <b>final</b> Category _log = Category.getInstance(JUnitTestAdapter.<b>class</b>);
  <a name="99" href="#99">99</a>  
  <a name="100" href="#100">100</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>* The latka {@link org.apache.commons.latka.Suite Suite} to be run*/</font></i></font></i>
  <a name="101" href="#101">101</a>     <b>private</b> <a href="../../../../../org/apache/commons/latka/Suite.html">Suite</a> _latkaSuite = <b>null</b>;
  <a name="102" href="#102">102</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>* the number of tests in the suite */</font></i></font></i>
  <a name="103" href="#103">103</a>     <b>private</b> <b>int</b> _testCount = 0;
  <a name="104" href="#104">104</a> 
  <a name="105" href="#105">105</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="106" href="#106">106</a> <font color="#AA0000"><i>     * Create a Test from a Latka suite and a number of tests</font></i>
  <a name="107" href="#107">107</a> <font color="#AA0000"><i>     *</font></i>
  <a name="108" href="#108">108</a> <font color="#AA0000"><i>     * @param suite The Latka {@link org.apache.commons.latka.Suite}</font></i>
  <a name="109" href="#109">109</a> <font color="#AA0000"><i>     * to be run as a JUnit Test</font></i>
  <a name="110" href="#110">110</a> <font color="#AA0000"><i>     * @param testCount The number of 'request's in the Latka suite</font></i>
  <a name="111" href="#111">111</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="112" href="#112">112</a>     <b>protected</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitTestAdapter.html">JUnitTestAdapter</a>(<a href="../../../../../org/apache/commons/latka/Suite.html">Suite</a> suite, <b>int</b> testCount) {
  <a name="113" href="#113">113</a>         _latkaSuite = suite;
  <a name="114" href="#114">114</a>         _testCount = testCount;
  <a name="115" href="#115">115</a>     }
  <a name="116" href="#116">116</a> 
  <a name="117" href="#117">117</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="118" href="#118">118</a> <font color="#AA0000"><i>     * Create a Test from a Latka file</font></i>
  <a name="119" href="#119">119</a> <font color="#AA0000"><i>     * @param fileName The name of a readable file in Latka's XML format</font></i>
  <a name="120" href="#120">120</a> <font color="#AA0000"><i>     * @return a JUnit Test, ready to run</font></i>
  <a name="121" href="#121">121</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="122" href="#122">122</a>     <b>public</b> <b>static</b> Test createTestFromFile(String fileName) {
  <a name="123" href="#123">123</a>         Test result = <b>null</b>;
  <a name="124" href="#124">124</a>         File file = <b>new</b> File(fileName);
  <a name="125" href="#125">125</a>         <b>if</b> (file.exists()) {
  <a name="126" href="#126">126</a>             result = createTestFromFile(file);
  <a name="127" href="#127">127</a>         } <b>else</b> {
  <a name="128" href="#128">128</a>             _log.error(<font color="#000099">"Input file "</font> + file.getAbsolutePath() +
  <a name="129" href="#129">129</a>                        <font color="#000099">" does not exist"</font>);
  <a name="130" href="#130">130</a>         }
  <a name="131" href="#131">131</a>         <b>return</b> result;
  <a name="132" href="#132">132</a>     }
  <a name="133" href="#133">133</a> 
  <a name="134" href="#134">134</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="135" href="#135">135</a> <font color="#AA0000"><i>     * Create a Test from a {@link java.io.File Java file}</font></i>
  <a name="136" href="#136">136</a> <font color="#AA0000"><i>     * @param file A readable java file containing Latka's XML format </font></i>
  <a name="137" href="#137">137</a> <font color="#AA0000"><i>     * @return a JUnit Test, ready to run</font></i>
  <a name="138" href="#138">138</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="139" href="#139">139</a>     <b>public</b> <b>static</b> Test createTestFromFile(File file) {
  <a name="140" href="#140">140</a>         Test result = <b>null</b>;
  <a name="141" href="#141">141</a>         <b>try</b> {
  <a name="142" href="#142">142</a>             result = createTestFromURL(file.toURL());
  <a name="143" href="#143">143</a>         } <b>catch</b> (MalformedURLException e) {
  <a name="144" href="#144">144</a>             _log.error(<font color="#000099">"Could not access input file"</font>, e);
  <a name="145" href="#145">145</a>         }
  <a name="146" href="#146">146</a>         <b>return</b> result;
  <a name="147" href="#147">147</a>     }
  <a name="148" href="#148">148</a> 
  <a name="149" href="#149">149</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="150" href="#150">150</a> <font color="#AA0000"><i>     * Create a Test from a resource accessible via</font></i>
  <a name="151" href="#151">151</a> <font color="#AA0000"><i>     * the {@link java.lang.ClassLoader#getResource(String) class loader}</font></i>
  <a name="152" href="#152">152</a> <font color="#AA0000"><i>     * @param resourceName A resource accessible by the class loader in Latka's XML format</font></i>
  <a name="153" href="#153">153</a> <font color="#AA0000"><i>     * @return a JUnit Test, ready to run</font></i>
  <a name="154" href="#154">154</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="155" href="#155">155</a>     <b>public</b> <b>static</b> Test createTestFromResource(String resourceName) {
  <a name="156" href="#156">156</a>         Test result = <b>null</b>;
  <a name="157" href="#157">157</a>         ClassLoader loader = JUnitTestAdapter.<b>class</b>.getClassLoader();
  <a name="158" href="#158">158</a>         URL resource = loader.getResource(resourceName);
  <a name="159" href="#159">159</a>         <b>if</b> (resource != <b>null</b>) {
  <a name="160" href="#160">160</a>             result = createTestFromURL(resource);
  <a name="161" href="#161">161</a>         }
  <a name="162" href="#162">162</a>         <b>return</b> result;
  <a name="163" href="#163">163</a>     }
  <a name="164" href="#164">164</a> 
  <a name="165" href="#165">165</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="166" href="#166">166</a> <font color="#AA0000"><i>     * Create a Test from a String containing a URL whose</font></i>
  <a name="167" href="#167">167</a> <font color="#AA0000"><i>     * contents are in Latka's XML format</font></i>
  <a name="168" href="#168">168</a> <font color="#AA0000"><i>     * @param url the {@link java.net.URL URL} to fetch</font></i>
  <a name="169" href="#169">169</a> <font color="#AA0000"><i>     * @return a JUnit Test, ready to run</font></i>
  <a name="170" href="#170">170</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="171" href="#171">171</a>     <b>public</b> <b>static</b> Test createTestFromURL(String url) {
  <a name="172" href="#172">172</a>         Test result = <b>null</b>;
  <a name="173" href="#173">173</a>         <b>try</b> {
  <a name="174" href="#174">174</a>             result = createTestFromURL(<b>new</b> URL(url));
  <a name="175" href="#175">175</a>         } <b>catch</b> (MalformedURLException e) {
  <a name="176" href="#176">176</a>             _log.error(<font color="#000099">"Unable to create URL "</font> + url, e);
  <a name="177" href="#177">177</a>         }
  <a name="178" href="#178">178</a>         <b>return</b> result;
  <a name="179" href="#179">179</a>     }
  <a name="180" href="#180">180</a> 
  <a name="181" href="#181">181</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="182" href="#182">182</a> <font color="#AA0000"><i>     * Create a Test from a URL whose contents are in Latka's XML format</font></i>
  <a name="183" href="#183">183</a> <font color="#AA0000"><i>     * @param url the {@link java.net.URL URL} to fetch</font></i>
  <a name="184" href="#184">184</a> <font color="#AA0000"><i>     * @return a JUnit Test, ready to run</font></i>
  <a name="185" href="#185">185</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="186" href="#186">186</a>     <b>public</b> <b>static</b> Test createTestFromURL(URL url) {
  <a name="187" href="#187">187</a>         Test result = <b>null</b>;
  <a name="188" href="#188">188</a>         <b>try</b> {
  <a name="189" href="#189">189</a>             InputSource source = <b>new</b> InputSource(url.toString());
  <a name="190" href="#190">190</a>             <a href="../../../../../org/apache/commons/latka/Suite.html">Suite</a> suite = <b>new</b> <a href="../../../../../org/apache/commons/latka/Suite.html">Suite</a>(url);
  <a name="191" href="#191">191</a>             result = <b>new</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitTestAdapter.html">JUnitTestAdapter</a>(suite, parse(source));
  <a name="192" href="#192">192</a>         } <b>catch</b> (IOException ioe) {
  <a name="193" href="#193">193</a>             _log.error(<font color="#000099">"IOException obtaining xml from URL "</font> + url, ioe);
  <a name="194" href="#194">194</a>         } <b>catch</b> (SAXException se) {
  <a name="195" href="#195">195</a>             _log.error(<font color="#000099">"Problem parsing URL "</font> + url, se);
  <a name="196" href="#196">196</a>         } <b>catch</b> (ParserConfigurationException pce) {
  <a name="197" href="#197">197</a>             _log.error(<font color="#000099">"Problem determining parser"</font>, pce);
  <a name="198" href="#198">198</a>         }
  <a name="199" href="#199">199</a>         <b>return</b> result;
  <a name="200" href="#200">200</a>     }
  <a name="201" href="#201">201</a> 
  <a name="202" href="#202">202</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="203" href="#203">203</a> <font color="#AA0000"><i>     * Parse the Latka XML document to count the requests</font></i>
  <a name="204" href="#204">204</a> <font color="#AA0000"><i>     * @param xml The inputsource to parse</font></i>
  <a name="205" href="#205">205</a> <font color="#AA0000"><i>     * @throws IOException When an IO occurs reading the document</font></i>
  <a name="206" href="#206">206</a> <font color="#AA0000"><i>     * @throws SAXException When the document is invalid XML </font></i>
  <a name="207" href="#207">207</a> <font color="#AA0000"><i>     * @throws FactoryConfigurationError When the SAX Parser factory can't be configured correctly</font></i>
  <a name="208" href="#208">208</a> <font color="#AA0000"><i>     * @throws ParserConfigurationException When the SAX Parser can't be configured correctly</font></i>
  <a name="209" href="#209">209</a> <font color="#AA0000"><i>     * @return the number of tests in the Latka suite</font></i>
  <a name="210" href="#210">210</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="211" href="#211">211</a>     <b>protected</b> <b>static</b> <b>int</b> parse(InputSource xml) throws IOException, SAXException,
  <a name="212" href="#212">212</a>                      FactoryConfigurationError, ParserConfigurationException {
  <a name="213" href="#213">213</a>         <b>int</b> result = 0;
  <a name="214" href="#214">214</a>         XMLReader reader = <b>null</b>;
  <a name="215" href="#215">215</a>         SAXParserFactory factory = SAXParserFactory.newInstance();
  <a name="216" href="#216">216</a>         factory.setValidating(false);   
  <a name="217" href="#217">217</a>         SAXParser parser = factory.newSAXParser();
  <a name="218" href="#218">218</a>         reader = parser.getXMLReader();
  <a name="219" href="#219">219</a>         TestCounter handler = <b>new</b> TestCounter();
  <a name="220" href="#220">220</a>         reader.setContentHandler(handler);
  <a name="221" href="#221">221</a>         reader.parse(xml);
  <a name="222" href="#222">222</a>         result = handler.getCount();
  <a name="223" href="#223">223</a>         <b>return</b> result;
  <a name="224" href="#224">224</a>     }
  <a name="225" href="#225">225</a> 
  <a name="226" href="#226">226</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="227" href="#227">227</a> <font color="#AA0000"><i>     * A SAX Handler to count the number of request tags in the document</font></i>
  <a name="228" href="#228">228</a> <font color="#AA0000"><i>     *</font></i>
  <a name="229" href="#229">229</a> <font color="#AA0000"><i>     * @author Chuck Burdick</font></i>
  <a name="230" href="#230">230</a> <font color="#AA0000"><i>     * @author dIon Gillard</font></i>
  <a name="231" href="#231">231</a> <font color="#AA0000"><i>     * @version $Id: JUnitTestAdapter.html,v 1.1 2002/04/01 05:42:12 dion Exp $</font></i>
  <a name="232" href="#232">232</a> <font color="#AA0000"><i>     */</font></i>
  <a name="233" href="#233">233</a>     <b>private</b> <b>static</b> <b>class</b> TestCounter <b>extends</b> DefaultHandler {
  <a name="234" href="#234">234</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>* number of requests (ie junit tests) */</font></i></font></i>
  <a name="235" href="#235">235</a>         <b>private</b> <b>int</b> _count = 0;
  <a name="236" href="#236">236</a>       
  <a name="237" href="#237">237</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="238" href="#238">238</a> <font color="#AA0000"><i>         * Create a DefaultHandler to count request elements</font></i>
  <a name="239" href="#239">239</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="240" href="#240">240</a>         <b>public</b> TestCounter() {
  <a name="241" href="#241">241</a>             _count = 0;
  <a name="242" href="#242">242</a>         }
  <a name="243" href="#243">243</a>       
  <a name="244" href="#244">244</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="245" href="#245">245</a> <font color="#AA0000"><i>         * process the start of an xml element</font></i>
  <a name="246" href="#246">246</a> <font color="#AA0000"><i>         * @param uri uri</font></i>
  <a name="247" href="#247">247</a> <font color="#AA0000"><i>         * @param localName localName</font></i>
  <a name="248" href="#248">248</a> <font color="#AA0000"><i>         * @param qName qName</font></i>
  <a name="249" href="#249">249</a> <font color="#AA0000"><i>         * @param atts atts</font></i>
  <a name="250" href="#250">250</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="251" href="#251">251</a>         <b>public</b> <b>void</b> startElement(String uri, String localName, String qName, 
  <a name="252" href="#252">252</a>                                  Attributes atts) {
  <a name="253" href="#253">253</a>             <b>if</b> (qName.equals(<font color="#000099">"request"</font>)) {
  <a name="254" href="#254">254</a>                 _count++;
  <a name="255" href="#255">255</a>             }
  <a name="256" href="#256">256</a>         }
  <a name="257" href="#257">257</a>         
  <a name="258" href="#258">258</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="259" href="#259">259</a> <font color="#AA0000"><i>         * Provides the number of &lt;request&gt; tags</font></i>
  <a name="260" href="#260">260</a> <font color="#AA0000"><i>         * @return the count of request elements found</font></i>
  <a name="261" href="#261">261</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="262" href="#262">262</a>         <b>public</b> <b>int</b> getCount() {
  <a name="263" href="#263">263</a>             <b>return</b> _count;
  <a name="264" href="#264">264</a>         }
  <a name="265" href="#265">265</a>     }
  <a name="266" href="#266">266</a> 
  <a name="267" href="#267">267</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="268" href="#268">268</a> <font color="#AA0000"><i>     * Provides access, post-parsing, of the number of</font></i>
  <a name="269" href="#269">269</a> <font color="#AA0000"><i>     * request elements in the Latka Suite </font></i>
  <a name="270" href="#270">270</a> <font color="#AA0000"><i>     * @return the number of test cases in the Latka suite</font></i>
  <a name="271" href="#271">271</a> <font color="#AA0000"><i>     */</font></i>
  <a name="272" href="#272">272</a>     <b>public</b> <b>int</b> countTestCases() {
  <a name="273" href="#273">273</a>         <b>return</b> _testCount;
  <a name="274" href="#274">274</a>     }
  <a name="275" href="#275">275</a> 
  <a name="276" href="#276">276</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="277" href="#277">277</a> <font color="#AA0000"><i>     * Run the test, adding results to the provided {@link junit.framework.TestResult TestResult}</font></i>
  <a name="278" href="#278">278</a> <font color="#AA0000"><i>     * @param r TestResult to accumulate</font></i>
  <a name="279" href="#279">279</a> <font color="#AA0000"><i>     */</font></i>      
  <a name="280" href="#280">280</a>     <b>public</b> <b>void</b> run(TestResult r) {
  <a name="281" href="#281">281</a>         _log.debug(<font color="#000099">"Attempting to perform latka tests"</font>);
  <a name="282" href="#282">282</a>         <a href="../../../../../org/apache/commons/latka/Latka.html">Latka</a> latka = <b>new</b> <a href="../../../../../org/apache/commons/latka/Latka.html">Latka</a>();
  <a name="283" href="#283">283</a>         <b>try</b> {
  <a name="284" href="#284">284</a>             latka.runTests(_latkaSuite, <b>new</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitEventReporter.html">JUnitEventReporter</a>(r));
  <a name="285" href="#285">285</a>         } <b>catch</b> (LatkaException e) {
  <a name="286" href="#286">286</a>             _log.error(<font color="#000099">"Unable to execute latka tests"</font>, e);
  <a name="287" href="#287">287</a>         }
  <a name="288" href="#288">288</a>     }
  <a name="289" href="#289">289</a> }
  </pre>
  <hr><center>This page automatically generated by Maven</center></body>
  </html>
  
  
  
  
  1.1                  jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit/JUnitEventReporter.html
  
  Index: JUnitEventReporter.html
  ===================================================================
  <html>
  <body bgcolor="white">
  <pre>
  <table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/junit/JUnitEventReporter.html">View Javadoc</a></table>
  <a name="1" href="#1">1</a>   <font color="#329900"><i>/*</font></i>
  <a name="2" href="#2">2</a>   <font color="#329900"><i> * ====================================================================</font></i>
  <a name="3" href="#3">3</a>   <font color="#329900"><i> *</font></i>
  <a name="4" href="#4">4</a>   <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
  <a name="5" href="#5">5</a>   <font color="#329900"><i> *</font></i>
  <a name="6" href="#6">6</a>   <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation.  All rights </font></i>
  <a name="7" href="#7">7</a>   <font color="#329900"><i> * reserved.</font></i>
  <a name="8" href="#8">8</a>   <font color="#329900"><i> *</font></i>
  <a name="9" href="#9">9</a>   <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
  <a name="10" href="#10">10</a>  <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
  <a name="11" href="#11">11</a>  <font color="#329900"><i> * are met:</font></i>
  <a name="12" href="#12">12</a>  <font color="#329900"><i> *</font></i>
  <a name="13" href="#13">13</a>  <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
  <a name="14" href="#14">14</a>  <font color="#329900"><i> *    notice, this list of conditions and the following disclaimer. </font></i>
  <a name="15" href="#15">15</a>  <font color="#329900"><i> *</font></i>
  <a name="16" href="#16">16</a>  <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
  <a name="17" href="#17">17</a>  <font color="#329900"><i> *    notice, this list of conditions and the following disclaimer in</font></i>
  <a name="18" href="#18">18</a>  <font color="#329900"><i> *    the documentation and/or other materials provided with the</font></i>
  <a name="19" href="#19">19</a>  <font color="#329900"><i> *    distribution.</font></i>
  <a name="20" href="#20">20</a>  <font color="#329900"><i> *</font></i>
  <a name="21" href="#21">21</a>  <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
  <a name="22" href="#22">22</a>  <font color="#329900"><i> *    any, must include the following acknowlegement:  </font></i>
  <a name="23" href="#23">23</a>  <font color="#329900"><i> *       "This product includes software developed by the </font></i>
  <a name="24" href="#24">24</a>  <font color="#329900"><i> *        Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
  <a name="25" href="#25">25</a>  <font color="#329900"><i> *    Alternately, this acknowlegement may appear in the software itself,</font></i>
  <a name="26" href="#26">26</a>  <font color="#329900"><i> *    if and wherever such third-party acknowlegements normally appear.</font></i>
  <a name="27" href="#27">27</a>  <font color="#329900"><i> *</font></i>
  <a name="28" href="#28">28</a>  <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
  <a name="29" href="#29">29</a>  <font color="#329900"><i> *    Foundation" must not be used to endorse or promote products derived</font></i>
  <a name="30" href="#30">30</a>  <font color="#329900"><i> *    from this software without prior written permission. For written </font></i>
  <a name="31" href="#31">31</a>  <font color="#329900"><i> *    permission, please contact apache@apache.org.</font></i>
  <a name="32" href="#32">32</a>  <font color="#329900"><i> *</font></i>
  <a name="33" href="#33">33</a>  <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
  <a name="34" href="#34">34</a>  <font color="#329900"><i> *    nor may "Apache" appear in their names without prior written</font></i>
  <a name="35" href="#35">35</a>  <font color="#329900"><i> *    permission of the Apache Group.</font></i>
  <a name="36" href="#36">36</a>  <font color="#329900"><i> *</font></i>
  <a name="37" href="#37">37</a>  <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
  <a name="38" href="#38">38</a>  <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
  <a name="39" href="#39">39</a>  <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
  <a name="40" href="#40">40</a>  <font color="#329900"><i> * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
  <a name="41" href="#41">41</a>  <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
  <a name="42" href="#42">42</a>  <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
  <a name="43" href="#43">43</a>  <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
  <a name="44" href="#44">44</a>  <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
  <a name="45" href="#45">45</a>  <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
  <a name="46" href="#46">46</a>  <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
  <a name="47" href="#47">47</a>  <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
  <a name="48" href="#48">48</a>  <font color="#329900"><i> * SUCH DAMAGE.</font></i>
  <a name="49" href="#49">49</a>  <font color="#329900"><i> * ====================================================================</font></i>
  <a name="50" href="#50">50</a>  <font color="#329900"><i> *</font></i>
  <a name="51" href="#51">51</a>  <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
  <a name="52" href="#52">52</a>  <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation.  For more</font></i>
  <a name="53" href="#53">53</a>  <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
  <a name="54" href="#54">54</a>  <font color="#329900"><i> * &lt;<a href="http://www.apache.org/&gt" target="alexandria_uri">http://www.apache.org/&gt</a>;.</font></i>
  <a name="55" href="#55">55</a>  <font color="#329900"><i> *</font></i>
  <a name="56" href="#56">56</a>  <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
  <a name="57" href="#57">57</a>  <font color="#329900"><i> *</font></i>
  <a name="58" href="#58">58</a>  <font color="#329900"><i> */</font></i>   
  <a name="59" href="#59">59</a>  
  <a name="60" href="#60">60</a>  <b>package</b> <a href="../../../../../org/apache/commons/latka/junit/index.html">org.apache.commons.latka.junit</a>;
  <a name="61" href="#61">61</a>  
  <a name="62" href="#62">62</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/AbstractReporter.html">AbstractReporter</a>;
  <a name="63" href="#63">63</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
  <a name="64" href="#64">64</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/event/index.html">org.apache.commons.latka.event</a>.<a href="../../../../../org/apache/commons/latka/event/RequestErrorEvent.html">RequestErrorEvent</a>;
  <a name="65" href="#65">65</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/event/index.html">org.apache.commons.latka.event</a>.<a href="../../../../../org/apache/commons/latka/event/RequestEvent.html">RequestEvent</a>;
  <a name="66" href="#66">66</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/event/index.html">org.apache.commons.latka.event</a>.<a href="../../../../../org/apache/commons/latka/event/RequestFailedEvent.html">RequestFailedEvent</a>;
  <a name="67" href="#67">67</a>  <b>import</b> <a href="../../../../../org/apache/commons/latka/event/index.html">org.apache.commons.latka.event</a>.<a href="../../../../../org/apache/commons/latka/event/SuiteEvent.html">SuiteEvent</a>;
  <a name="68" href="#68">68</a>  
  <a name="69" href="#69">69</a>  <b>import</b> org.apache.log4j.Category;
  <a name="70" href="#70">70</a>  
  <a name="71" href="#71">71</a>  <b>import</b> junit.framework.AssertionFailedError;
  <a name="72" href="#72">72</a>  <b>import</b> junit.framework.Test;
  <a name="73" href="#73">73</a>  <b>import</b> junit.framework.TestResult;
  <a name="74" href="#74">74</a>  
  <a name="75" href="#75">75</a>  <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="76" href="#76">76</a>  <font color="#AA0000"><i> * A Latka reporter that takes the various latka events and adapts them into</font></i>
  <a name="77" href="#77">77</a>  <font color="#AA0000"><i> * JUnit Tests.</font></i>
  <a name="78" href="#78">78</a>  <font color="#AA0000"><i> *</font></i>
  <a name="79" href="#79">79</a>  <font color="#AA0000"><i> * In particular this class handles the request error, failed, skipped and</font></i>
  <a name="80" href="#80">80</a>  <font color="#AA0000"><i> * succeeded events</font></i>
  <a name="81" href="#81">81</a>  <font color="#AA0000"><i> *</font></i>
  <a name="82" href="#82">82</a>  <font color="#AA0000"><i> * @author Chuck Burdick</font></i>
  <a name="83" href="#83">83</a>  <font color="#AA0000"><i> * @author dIon Gillard</font></i>
  <a name="84" href="#84">84</a>  <font color="#AA0000"><i> * @version $Id: JUnitEventReporter.html,v 1.1 2002/04/01 05:42:12 dion Exp $</font></i>
  <a name="85" href="#85">85</a>  <font color="#AA0000"><i> */</font></i>
  <a name="86" href="#86">86</a>  <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitEventReporter.html">JUnitEventReporter</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/AbstractReporter.html">AbstractReporter</a> {
  <a name="87" href="#87">87</a>      <b>private</b> <b>static</b> <b>final</b> Category _log = Category.getInstance(JUnitEventReporter.<b>class</b>);
  <a name="88" href="#88">88</a>  
  <a name="89" href="#89">89</a>      <b>private</b> TestResult _testResult = <b>null</b>;
  <a name="90" href="#90">90</a>  
  <a name="91" href="#91">91</a>      <font color="#AA0000"><i>/**<font color="#AA0000"><i>* </font></i></font></i>
  <a name="92" href="#92">92</a>  <font color="#AA0000"><i>     * Create a JUnitEventReporter, storing the</font></i>
  <a name="93" href="#93">93</a>  <font color="#AA0000"><i>     * JUnit Test results in the provided object</font></i>
  <a name="94" href="#94">94</a>  <font color="#AA0000"><i>     * @param result the JUnit TestResult to add failures and errors to</font></i>
  <a name="95" href="#95">95</a>  <font color="#AA0000"><i>     */</font></i>   
  <a name="96" href="#96">96</a>      <b>protected</b> <a href="../../../../../org/apache/commons/latka/junit/JUnitEventReporter.html">JUnitEventReporter</a>(TestResult result) {
  <a name="97" href="#97">97</a>          _testResult = result;
  <a name="98" href="#98">98</a>      }
  <a name="99" href="#99">99</a>  
  <a name="100" href="#100">100</a>     <b>private</b> <b>class</b> EventTestAdapter implements Test {
  <a name="101" href="#101">101</a>         <b>private</b> AssertionFailedError _failed = <b>null</b>;
  <a name="102" href="#102">102</a>         <b>private</b> Throwable _error = <b>null</b>;
  <a name="103" href="#103">103</a> 
  <a name="104" href="#104">104</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>* </font></i></font></i>
  <a name="105" href="#105">105</a> <font color="#AA0000"><i>         * A JUnit Test class accumulates test results when run</font></i>
  <a name="106" href="#106">106</a> <font color="#AA0000"><i>         * based on the constructor that was called</font></i>
  <a name="107" href="#107">107</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="108" href="#108">108</a>         <b>public</b> EventTestAdapter() {
  <a name="109" href="#109">109</a>         }
  <a name="110" href="#110">110</a>       
  <a name="111" href="#111">111</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>* </font></i></font></i>
  <a name="112" href="#112">112</a> <font color="#AA0000"><i>         * Create an instance with a JUnit</font></i>
  <a name="113" href="#113">113</a> <font color="#AA0000"><i>         * {@link junit.framework.AssertionFailedError AssertionFailedError} </font></i>
  <a name="114" href="#114">114</a> <font color="#AA0000"><i>         * that can be added to the results in the</font></i>
  <a name="115" href="#115">115</a> <font color="#AA0000"><i>         * {@link #run(junit.framework.TestResult) run} method</font></i>
  <a name="116" href="#116">116</a> <font color="#AA0000"><i>         *</font></i>
  <a name="117" href="#117">117</a> <font color="#AA0000"><i>         * @param t The AssertionFailedError that will be stored for</font></i>
  <a name="118" href="#118">118</a> <font color="#AA0000"><i>         * later addition to results</font></i>
  <a name="119" href="#119">119</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="120" href="#120">120</a>         <b>public</b> EventTestAdapter(AssertionFailedError t) {
  <a name="121" href="#121">121</a>             _failed = t;
  <a name="122" href="#122">122</a>         }
  <a name="123" href="#123">123</a>       
  <a name="124" href="#124">124</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="125" href="#125">125</a> <font color="#AA0000"><i>         * Create an instance with a JUnit {@link java.lang.Throwable Throble} that</font></i>
  <a name="126" href="#126">126</a> <font color="#AA0000"><i>         * can be added to the results in the </font></i>
  <a name="127" href="#127">127</a> <font color="#AA0000"><i>         * {@link #run(junit.framework.TestResult) run} method</font></i>
  <a name="128" href="#128">128</a> <font color="#AA0000"><i>         * </font></i>
  <a name="129" href="#129">129</a> <font color="#AA0000"><i>         * @param t The Throwable that will be stored for later addition to results</font></i>
  <a name="130" href="#130">130</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="131" href="#131">131</a>         <b>public</b> EventTestAdapter(Throwable t) {
  <a name="132" href="#132">132</a>             _error = t;
  <a name="133" href="#133">133</a>         }
  <a name="134" href="#134">134</a>       
  <a name="135" href="#135">135</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="136" href="#136">136</a> <font color="#AA0000"><i>         * The number of test cases this test contains</font></i>
  <a name="137" href="#137">137</a> <font color="#AA0000"><i>         * </font></i>
  <a name="138" href="#138">138</a> <font color="#AA0000"><i>         * @return Currently hard coded to one test cases</font></i>
  <a name="139" href="#139">139</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="140" href="#140">140</a>         <b>public</b> <b>int</b> countTestCases() {
  <a name="141" href="#141">141</a>             <b>return</b> 1;
  <a name="142" href="#142">142</a>         }
  <a name="143" href="#143">143</a>       
  <a name="144" href="#144">144</a>         <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="145" href="#145">145</a> <font color="#AA0000"><i>         * Run this test.</font></i>
  <a name="146" href="#146">146</a> <font color="#AA0000"><i>         * Since Latka has already executed the request we simply check if there </font></i>
  <a name="147" href="#147">147</a> <font color="#AA0000"><i>         * has been a failure or error stored and add it to the test results</font></i>
  <a name="148" href="#148">148</a> <font color="#AA0000"><i>         *</font></i>
  <a name="149" href="#149">149</a> <font color="#AA0000"><i>         * @param result The {@link junit.framework.TestResult TestResult} to </font></i>
  <a name="150" href="#150">150</a> <font color="#AA0000"><i>         * store failures or errors in</font></i>
  <a name="151" href="#151">151</a> <font color="#AA0000"><i>         */</font></i>      
  <a name="152" href="#152">152</a>         <b>public</b> <b>void</b> run(TestResult result) {
  <a name="153" href="#153">153</a>             result.startTest(<b>this</b>);
  <a name="154" href="#154">154</a>             <b>if</b> (_error != <b>null</b>) {
  <a name="155" href="#155">155</a>                 result.addError(<b>this</b>, _error);
  <a name="156" href="#156">156</a>             } <b>else</b> <b>if</b> (_failed != <b>null</b>) {
  <a name="157" href="#157">157</a>                 result.addFailure(<b>this</b>, _failed);
  <a name="158" href="#158">158</a>             }
  <a name="159" href="#159">159</a>             result.endTest(<b>this</b>);
  <a name="160" href="#160">160</a>         }
  <a name="161" href="#161">161</a>     }
  <a name="162" href="#162">162</a> 
  <a name="163" href="#163">163</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="164" href="#164">164</a> <font color="#AA0000"><i>     * Process a Latka request error</font></i>
  <a name="165" href="#165">165</a> <font color="#AA0000"><i>     * @param event the latka request event that is in error</font></i>
  <a name="166" href="#166">166</a> <font color="#AA0000"><i>     */</font></i>
  <a name="167" href="#167">167</a>     <b>public</b> <b>void</b> requestError(<a href="../../../../../org/apache/commons/latka/event/RequestEvent.html">RequestEvent</a> event) {
  <a name="168" href="#168">168</a>         _log.debug(<font color="#000099">"Received latka RequestErrorEvent"</font>);
  <a name="169" href="#169">169</a>         <b>super</b>.requestError(event);
  <a name="170" href="#170">170</a>         Throwable error = ((RequestErrorEvent)event).getError();
  <a name="171" href="#171">171</a>         Test test = <b>new</b> EventTestAdapter(error);
  <a name="172" href="#172">172</a>         test.run(_testResult);
  <a name="173" href="#173">173</a>     }
  <a name="174" href="#174">174</a> 
  <a name="175" href="#175">175</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="176" href="#176">176</a> <font color="#AA0000"><i>     * Process a Latka request failure</font></i>
  <a name="177" href="#177">177</a> <font color="#AA0000"><i>     * @param event The event describing the request that has failed</font></i>
  <a name="178" href="#178">178</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="179" href="#179">179</a>     <b>public</b>  <b>void</b> requestFailed(RequestEvent event) {
  <a name="180" href="#180">180</a>         _log.debug(<font color="#000099">"Received latka RequestFailedEvent"</font>);
  <a name="181" href="#181">181</a>         <b>super</b>.requestFailed(event);
  <a name="182" href="#182">182</a>         <a href="../../../../../org/apache/commons/latka/event/RequestFailedEvent.html">RequestFailedEvent</a> fe = (RequestFailedEvent)event;
  <a name="183" href="#183">183</a>         <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> ve = (ValidationException)fe.getValidationException();
  <a name="184" href="#184">184</a>         String requestUrl = event.getRequest().getURL().toString();
  <a name="185" href="#185">185</a>         String requestLabel = event.getRequest().getLabel();
  <a name="186" href="#186">186</a>         String message = requestUrl + <font color="#000099">" -- "</font> + requestLabel + <font color="#000099">": "</font> +
  <a name="187" href="#187">187</a>                          ve.getReason();
  <a name="188" href="#188">188</a>         AssertionFailedError failure = <b>new</b> AssertionFailedError(message);
  <a name="189" href="#189">189</a>         Test test = <b>new</b> EventTestAdapter(failure);
  <a name="190" href="#190">190</a>         test.run(_testResult);
  <a name="191" href="#191">191</a>     }
  <a name="192" href="#192">192</a> 
  <a name="193" href="#193">193</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="194" href="#194">194</a> <font color="#AA0000"><i>     * Process a Latka event being skipped</font></i>
  <a name="195" href="#195">195</a> <font color="#AA0000"><i>     * @param event The event describing the request that has been skipped</font></i>
  <a name="196" href="#196">196</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="197" href="#197">197</a>     <b>public</b> <b>void</b> requestSkipped(<a href="../../../../../org/apache/commons/latka/event/RequestEvent.html">RequestEvent</a> event) {
  <a name="198" href="#198">198</a>         _log.debug(<font color="#000099">"Received latka RequestSkippedEvent"</font>);
  <a name="199" href="#199">199</a>         <b>super</b>.requestSkipped(event);
  <a name="200" href="#200">200</a>         AssertionFailedError failure = <b>new</b> AssertionFailedError(
  <a name="201" href="#201">201</a>                                         <font color="#000099">"Skipped due to earlier error"</font>);
  <a name="202" href="#202">202</a>         Test test = <b>new</b> EventTestAdapter(failure);
  <a name="203" href="#203">203</a>         test.run(_testResult);
  <a name="204" href="#204">204</a>     }
  <a name="205" href="#205">205</a> 
  <a name="206" href="#206">206</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="207" href="#207">207</a> <font color="#AA0000"><i>     * Process a Latka request success event</font></i>
  <a name="208" href="#208">208</a> <font color="#AA0000"><i>     * @param event The event describing the request that has succeeded</font></i>
  <a name="209" href="#209">209</a> <font color="#AA0000"><i>     */</font></i>   
  <a name="210" href="#210">210</a>     <b>public</b> <b>void</b> requestSucceeded(<a href="../../../../../org/apache/commons/latka/event/RequestEvent.html">RequestEvent</a> event) {
  <a name="211" href="#211">211</a>         _log.debug(<font color="#000099">"Received latka RequestSucceededEvent"</font>);
  <a name="212" href="#212">212</a>         <b>super</b>.requestSucceeded(event);
  <a name="213" href="#213">213</a>         Test test = <b>new</b> EventTestAdapter();
  <a name="214" href="#214">214</a>         test.run(_testResult);
  <a name="215" href="#215">215</a>     }
  <a name="216" href="#216">216</a> 
  <a name="217" href="#217">217</a>     <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
  <a name="218" href="#218">218</a> <font color="#AA0000"><i>     * Process a Latka suite completion event</font></i>
  <a name="219" href="#219">219</a> <font color="#AA0000"><i>     * @param event The event describing the suite that has completed</font></i>
  <a name="220" href="#220">220</a> <font color="#AA0000"><i>     */</font></i>      
  <a name="221" href="#221">221</a>     <b>public</b> <b>void</b> suiteCompleted(<a href="../../../../../org/apache/commons/latka/event/SuiteEvent.html">SuiteEvent</a> event) {
  <a name="222" href="#222">222</a>     }
  <a name="223" href="#223">223</a> }
  </pre>
  <hr><center>This page automatically generated by Maven</center></body>
  </html>
  
  
  
  
  1.1                  jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/junit/index.html
  
  Index: index.html
  ===================================================================
  <html>
  <body bgcolor="white">
  <a href="../">[parent]</a>
  <hr>
  <table width="100%">
  <tr>
  <td><b>Name</b></td>
  <td><b>Size</b></td>
  <td><b>Last Modified</b></td>
  </tr>
  <tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0">&nbsp;<a href="JUnitEventReporter.html">JUnitEventReporter.java</a></td><td valign="middle" NOWRAP>23870 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
  <tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0">&nbsp;<a href="JUnitTestAdapter.html">JUnitTestAdapter.java</a></td><td valign="middle" NOWRAP>29139 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
  </table>
  <hr>
  <center>This page automatically generated by Maven</center>
  </body>
  </html>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message