r4529 - trunk/docs/dev

daigle at ecoinformatics.org daigle at ecoinformatics.org
Thu Nov 6 14:27:26 PST 2008


Author: daigle
Date: 2008-11-06 14:27:26 -0800 (Thu, 06 Nov 2008)
New Revision: 4529

Removed:
   trunk/docs/dev/testmetacat.html
Log:
renamed to testing-metacat.html

Deleted: trunk/docs/dev/testmetacat.html
===================================================================
--- trunk/docs/dev/testmetacat.html	2008-11-06 22:27:07 UTC (rev 4528)
+++ trunk/docs/dev/testmetacat.html	2008-11-06 22:27:26 UTC (rev 4529)
@@ -1,195 +0,0 @@
-<!--
-  * sitemaps.html
-  *
-  *      Authors: Michael Daigle
-  *    Copyright: 2008 Regents of the University of California and the
-  *               National Center for Ecological Analysis and Synthesis
-  *  For Details: http://www.nceas.ucsb.edu/
-  *      Created: 2008 November 4
-  *      Version: 
-  *    File Info: '$ '
-  * 
-  * 
--->
-<HTML>
-<HEAD>
-<TITLE>Testing Metacat</TITLE>
-<link rel="stylesheet" type="text/css" href="../common/common.css">
-<link rel="stylesheet" type="text/css" href="./default.css">
-</HEAD> 
-<BODY>
-  <table width="100%">
-    <tr>
-      <td class="tablehead" colspan="2"><p class="label">Testing Metacat</p></td>
-      <td class="tablehead" colspan="2" align="right">
-        <a href="./pagedreturn.html">Back</a> | <a href="./metacattour.html">Home</a> | 
-        <a href="./unimplem.html">Next</a>
-      </td>
-    </tr>
-  </table>
-      
-  <div class="header1">Table of Contents</div>
-  <div class="toc">
-    <div class="toc1"><a href="#Intro">About Metacat Testing</a></div>
-      <div class="toc2"><a href="#Overview">Overview</a></div>
-      <div class="toc2"><a href="#MetacatImplementation">JUnit Implementation in Metacat</a></div>
-    <div class="toc1"><a href="#WritingTestCase">Writing a Test Case</a></div>
-      <div class="toc2"><a href="#Basics">Basics</a></div>
-      <div class="toc2"><a href="#MCTestCase">MCTestCase Base Class</a></div>           
-      <div class="toc2"><a href="#BestPractices">Best Practices</a></div>
-    <div class="toc1"><a href="#RunTests">Running Test Cases</a></div>
-      <div class="toc2"><a href="#AntTask">Ant task</a></div>
-      <div class="toc2"><a href="#ConfigureMetacat">Configure Metacat For Testing</a></div>
-      <div class="toc2"><a href="#RunAllTests">Run All Tests</a></div>
-      <div class="toc2"><a href="#RunOneTest">Run One Test</a></div>
-      <div class="toc2"><a href="#ViewingOutput">Viewing Test Output</a></div>
-  </div>  
-  
-  <a name="Intro"></a><div class="header1">About Metacat Testing</div>
-  <a name="Overview"></a><div class="header2">Overview</div>
-  <p>Metacat uses JUnit tests to test its core functionality.  These tests are
-  good for testing the internal workings of an application, but don't test the 
-  layout and appearance.  JUnit tests are meant to be one tool in the developer's 
-  test arsinal. If you are not familiar with JUnit, you should search out some 
-  tutorial documentation online.  One such tutorial is at 
-  <a href="http://clarkware.com/articles/JUnitPrimer.html"> The Clarkware JUnit primer</a></p>
-  
-  <p>Metacat test cases will need to be run on the same server as the Metacat
-  instance that you want to test.  Since Metacat and its test cases share the same
-  configuration files, there is no way to run the tests remotely.</p>
-
-  <a name="MetacatImplementation"></a><div class="header2">JUnit Implementation in Metacat</div>
-  <p>Metacat test cases are located in the code at:
-  <div class="code">&lt;workspace&gt;/metacat/test/edu/ucsb/nceas/metacat*/</div>  
-  There you will find several java files that define JUnit tests.</p>
-  
-  <p> Test cases are run via an ant task, and output from the tests appears in 
-  a build directory.  More on this to follow.</p>
-
-  <a name="WritingTestCase"></a><div class="header1">Writing a Test Case</div>
-  <a name="Basics"></a><div class="header2">Basics</div>
-  <p>All you need to do to get your JUnit test included into the Metacat test 
-  suite is to create it in one of the &lt;workspace&gt;/test/edu/ucsb/nceas/metacat*/
-  directories.  The ant test tasks will know that it should be run. </p>
-  
-  <p> The following methods are required in a test case class:
-  <ul>
-    <li>public &lt;Constructor&gt;(String name) - The constructor for the test class. </li>
-	<li>public void setUp() - Set up any dependencies for the tests.  This is run before each test case.</li> 
-	<li>public void tearDown() - Release an resources used by the test.</li> 
-	<li>public static Test suite() - define the test methods that need to be run.</li>
-	<li>public void initialize() - define any global initializations that need to be done.</li>
-  </ul>
-  
-  You will test for failure using the many assertion methods available.</p>
-  
-  <a name="MCTestCase"></a><div class="header2">MCTestCase Base Class</div>
-  <p>Metacat test cases extend the MCTestCase base class, which holds common 
-  methods and variables.  Some of these include:
-  <ul>
-    <li>SUCCESS/FALURE - boolean variables holding the values for success and failure. </li>
-	<li>metacatUrl, username, password - connection variables used for LDAP connectivity</li> 
-	<li>readDocumentIdWhichEqualsDoc() - method to read a document from Metacat server.</li> 
-	<li>debug() - method to display debug output to standard error.</li>
-  </ul>
-  These are just a few examples to give you an idea of what is in MCTestCase.
-  </p>
-  
-  <a name="BestPractices"></a><div class="header2">Best Practices</div>
-  <p>The following are a few best practices when writing test cases:
-  <ul>
-    <li>Extend MCTestCase - Although strictly speaking, it is possible to bypass MCTestCase
-    and just extend the JUnit TestCase class, you should not do so.   You should always
-    extend the MCTestCase class.</li>
-    <li>Extend Multiple Test Methods - Try to strike a balance between the number of test 
-    methods and the size of each test.  If a test method starts to get huge, you might see
-    if you can break it down into mulitple tests based on functionality.  If the number of
-    tests in the test suite starts to get large, you might see if it makes sense to 
-    separate them out into different test classes.</li>
-	<li>Use assertion message - Most assertion methods have an alternate implementation that 
-	includes a message parameter.  This message will be shown if the assertion fails.  You
-	should use this version of the assertion method.</li> 
-	<li>debug() - You should use the debug() method available in the MCTestCase class to
-	display debug output as opposed to System.err.println().  The test configuration will
-	allow you to turn off debug output when you use the debug() method.</li>
-  </ul>
-
-  <a name="RunTests"></a><div class="header1">Running Test Cases</div>
-  <a name="AntTask"></a><div class="header2">Ant task</div>
-  <p>As we discussed earlier, the test cases run from within ant tasks.  There is a 
-  task to run all tests and a task to run individual tests. </p>
-  <p>You will need to have ant installed on your system.  For downloads and instructions,
-  visit the <a href="http://ant.apache.org/">Apache Ant site</a>.
-  </p>
-  <a name="ConfigureMetacat"></a><div class="header2">Configure Metacat For Testing</div>
-  <p>The test cases will look at the server's metacat properties file for configuration, 
-  so there are two places that need to be configured.</p>
-  <p>First, you need to edit the configuration file at:
-  <div class="code">&lt;workspace&gt;/metacat/test/test.properties</div>
-  This should only hold one property: metacat.contextDir.  This should point to 
-  the context directory for the metacat server you are testing.  For example:
-  <div class="code">metacat.contextDir=/usr/share/tomcat5.5/webapps/knb</div>
-  The test classes will use this to determine where to look for the server
-  metacat.properties file.</p>
-  
-  <p>the remainder of the configuration needs to happen in the actual server's 
-  metacat.properties file located at:
-  <div class="code">&lt;workspace&gt;/metacat/lib/metacat.properties</div>
-  You will need to verify that all test.* properties are set correctly:
-  <ul>
-    <li>test.printdebug - true if you want debug output, false otherwise </li>
-    <li>test.metacatUrl - the url for the metacat servlet (i.e. http://localhost:8080/knb/metacat)</li>
-    <li>test.contextUrl - the url for the metacat web service (i.e. http://localhost:8080/knb)</li>
-    <li>test.metacatDeployDir - the directory where metacat is physically deployed (i.e. /usr/local/tomcat/webapps/knb)</li>
-    <li>test.mcUser - the first metacat test user ("uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org" should be fine)</li>
-    <li>test.mcPassword - the first metacat test password ("kepler" should be fine)</li>
-    <li>test.mcAnotherUser - the second metacat test user.  This user must be a member of the knb-usr 
-        group in ldap. ("uid=test,o=NCEAS,dc=ecoinformatics,dc=org" should be fine)</li>
-    <li>test.mcAnotherPassword - the second metacat test password ("test" should be fine)</li>
-    <li>test.piscoUser - the pisco test user ("uid=piscotest,o=PISCO,dc=ecoinformatics,dc=org" should be fine)</li>
-    <li>test.piscoPassword - the pisco test password ("testPW" should be fine)</li>
-    <li>test.lterUser - the lter test user ("uid=tmonkey,o=LTER,dc=ecoinformatics,dc=org" should be fine)</li>
-    <li>test.lterPassword - the lter test password ("T3$tusr" should be fine)</li>
-    <li>test.testProperty - a property to verify that we can read properties (leave as "testing")</li>
-  </ul>
-  </p>
-  
-  <p>Note that none of the test users should also be administrative users.  This will mess up 
-  the access tests since some document modifications will succeed when we expect them to fail.</p>
-  
-  <p>Once this is done, you will need to rebuild and redeploy the Metacat server.  Note that
-  changing these properties does nothing to change the way the Metacat server runs.  Rebuilding
-  and redeploying merely makes the test properties available to the JUnit tests.</p>
-  
-  <a name="RunAllTests"></a><div class="header2">Run All Tests</div>
-  <p>To run all tests, go to the &lt;workspace&gt;/metacat directory and type</p>
-  <div class="code">ant clean test</div>
-  You will see a line to standard output summarizing each test result.
-  </p>
-  
-  <a name="RunOneTest"></a><div class="header2">Run One Test</div>
-  <p>To run one test, go to the &lt;workspace&gt;/metacat directory and type</p>
-  <div class="code">ant clean runonetest -Dtesttorun=&lt;test_name&gt;</div>
-  Where &lt;test_name&gt; is the name of the JUnit test class (without .java on 
-  the end).  You will see debug information print to standard error.
-  </p>
-  
-  <a name="ViewingOutput"></a><div class="header2">Viewing Test Output</div>
-  <p>Regardless of whether you ran one test or all tests, you will see output in
-  the Metacat build directory in your code at:
-  <div class="code">&lt;workspace&gt;/metacat/build</div>
-  There will be one output file for each test class.  The files will look like 
-  <div class="code">TEST-edu.ucsb.nceas.&lt;test_dir&gt;.&lt;test_name&gt;.txt</div>
-  where &lt;test_dir&gt; is the metacat* directory where the test lives and 
-  &lt;test_name&gt; is the name of the JUnit test class. These output files will have
-  all standard error and standard out output as well as information on assertion 
-  failures in the event of a failed test.
-  </p>
-    
-  <br>
-  <a href="./pagedreturn.html">Back</a> | <a href="./metacattour.html">Home</a> | 
-  <a href="./unimplem.html">Next</a>
-  </ul>
-
-</BODY>
-</HTML>



More information about the Metacat-cvs mailing list