[sword-devel] unti test classes for JSword

Bobby Nations sword-devel@crosswire.org
24 Jan 2002 21:06:35 -0600


All,

Ok, it's almost two weeks since I submitted the three files in this
thread, and I still don't see them in CVS.  What would it take to get
priveledges to the CVS server so that I could continue working on the
JSword port?  It's getting a little old waiting.

Please if anyone else is still working on JSword, let me know because
I'd like to be able to email questions without necessarily going through
the mailing list.  Brainstorming type stuff.

Thanks,

Bobby


On Sun, 2002-01-13 at 05:26, Bobby Nations wrote:
> All,
> 
> I've made some progress on getting the unit test classes up and going on
> the JSword project.  Attached are two test classes along with a new ant
> build containing targets to run all test cases and generate reports on
> their results.  The target names are 'test' and 'results' respectively. 
> In order to run the results target, you'll need two jar files from the
> apache group's xalan xml project, xalan.jar and xerces.jar, to be either
> in your CLASSPATH or in the ANT_HOME/lib directory.  I'm working with
> them to get this requirement removed.
> 
> Cheers,
> 
> Bobby
> 
> P.S. Is anyone else working on JSword?
> 
> 
> ----
> 

> <?xml version="1.0" encoding="iso-8859-1"?>
> <project name="jsword" default="jar" basedir=".">
> 
>     <!-- Set the project wide classpath -->
>     <path id="project.classpath">
>         <pathelement path="${java.class.path}/"/>
>         <pathelement location="./"/>
>         <fileset dir="lib">
>             <include name="**/*.jar"/>
>         </fileset>
>     </path>
> 
>     <target name="init">
>         <tstamp/>
> 	<property name="build.compiler" value="modern" />
> 	<property name="src.dir" value="src" />
> 	<property name="build.dir" value="btree" />
> 	<property name="build.test.dir" value="${build.dir}/tests" />
> 	<property name="dist.dir" value="dist" />
> 	<property name="reports.dir" value="${dist.dir}/reports" />
> 	<property name="reports.results.dir" value="${reports.dir}/results" />
> 	<property name="javadoc.dir" value="${dist.dir}/api" />
>     </target>
> 
>     <target name="prepare" depends="init">
>         <mkdir dir="${build.dir}"/>
> 	<mkdir dir="${build.test.dir}" />
>         <mkdir dir="${dist.dir}"/>
>         <mkdir dir="${reports.dir}"/>
>         <mkdir dir="${reports.results.dir}"/>
>         <mkdir dir="${javadoc.dir}"/>
>     </target>
> 
>     <target name="compile" depends="prepare">
>         <javac srcdir="${src.dir}"
>             destdir="${build.dir}" optimize="on"
>             excludes="**/DisplayConf.java"
>             deprecation="on"
>             classpathref="project.classpath"/>
>     </target>
> 
>     <target name="jar" depends="compile">
>         <jar jarfile="${dist.dir}/sword.jar" basedir="${build.dir}"/>
>     </target>
> 
>     <target name="test" depends="compile">
>         <junit printsummary="on" fork="on">
>             <classpath>
>                 <pathelement location="${build.dir}" />
>             </classpath>
>             <formatter type="xml"/>
>             <batchtest todir="${build.test.dir}" >
>                 <fileset dir="${build.dir}">
>                     <include name="**/*Test.class"/>
>                 </fileset>
>             </batchtest>
>         </junit>
>     </target>
> 
>     <target name="results" depends="test">
>         <junitreport todir="${reports.results.dir}" >
>             <fileset dir="${build.test.dir}">
>                 <include name="TEST-*.xml"/>
>             </fileset>
>             <report format="frames" todir="${reports.results.dir}" />
>         </junitreport>
>         <echo message="Complete results can be found at" />
>         <echo message="${reports.results.dir}" />
>     </target>
> 
>     <target name="javadoc" depends="prepare">
>         <javadoc destdir="${javadoc.dir}"
> 	         sourcepath="${src.dir}/"
>                  private="true"
> 		 packagenames="SwordMod, org.crosswire.*">
>             <classpath refid="project.classpath"/>
>         </javadoc>
>     </target>
> 
>     <target name="modedit" depends="prepare">
>         <javac srcdir="apps/ModEdit/${src.dir}"
>                destdir="${build.dir}" optimize="on"
>                classpathref="project.classpath"/>
>     </target>
> 
>     <target name="clean" depends="init">
>         <delete dir="${build.dir}"/>
>         <delete dir="${dist.dir}"/>
>     </target>
> 
> </project>     
>      
> ----
> 

> // CanonTest.java
> 
> package org.crosswire.sword.keys;
> 
> import junit.framework.TestCase;
> import junit.framework.TestSuite;
> 
> /**
>  * CanonTest    (Copyright 2001 <company>)
>  * 
>  * <p> This class performs unit tests on org.crosswire.sword.keys.Canon </p>
>  * 
>  * @author Bobby Nations <bobby@bobbynations.com>
>  * @date $Date: $
>  * @version $Revision: $
>  * 
>  * @see org.crosswire.sword.keys.Canon
>  * @see some.other.package
>  */
> 
> public class CanonTest extends TestCase
> {
>     /**
>      * Constructor (needed for JTest)
>      * @param name    Name of Object
>      */
>     public CanonTest(String name) {
>         super(name);
>     }
> 
>     /**
>      * Used by JUnit (called before each test method)
>      */
>     protected void setUp() {
>         canon = new Canon();
>     }
> 
>     /**
>      * Used by JUnit (called after each test method)
>      */
>     protected void tearDown() {
>         canon = null;
>     }
> 
>     /**
>      * Test the constructor: Canon()
>      */
>     public void testCanon() {
>     }
> 
>     /**
>      * Test the old testament books array #1
>      */
>     public void testOTBooks1() {
>         assertTrue( "Genesis" == canon.otbooks[0].name );
>         assertTrue( 50 == canon.otbooks[0].chapmax );
>     }
> 
>     /**
>      * Test the old testament books array #2
>      */
>     public void testOTBooks2() {
>         assertTrue( "Psalms" == canon.otbooks[18].name );
>         assertTrue( 150 == canon.otbooks[18].chapmax );
>     }
> 
>     /**
>      * Test the old testament books array #3
>      */
>     public void testOTBooks3() {
>         assertTrue( "Malachi" == canon.otbooks[38].name );
>         assertTrue( 4 == canon.otbooks[38].chapmax );
>     }
> 
>     /**
>      * Test the new testament books array length
>      */
>     public void testOTBooksLength() {
>         assertTrue( 39  == canon.otbooks.length );
>     }
> 
>     /**
>      * Test the new testament books array #1
>      */
>     public void testNTBooks1() {
>         assertTrue( "Matthew" == canon.ntbooks[0].name );
>         assertTrue( 28 == canon.ntbooks[0].chapmax );
>     }
> 
>     /**
>      * Test the new testament books array #2
>      */
>     public void testNTBooks2() {
>         assertTrue( "Titus" == canon.ntbooks[16].name );
>         assertTrue( 3 == canon.ntbooks[16].chapmax );
>     }
> 
>     /**
>      * Test the new testament books array #3
>      */
>     public void testNTBooks3() {
>         assertTrue( "Revelation of John" == canon.ntbooks[26].name );
>         assertTrue( 22 == canon.ntbooks[26].chapmax );
>     }
> 
>     /**
>      * Test the new testament books array length
>      */
>     public void testNTBooksLength() {
>         assertTrue( 27  == canon.ntbooks.length );
>     }
> 
>     /**
>      * Test the abbreviations for all books array #1
>      */
>     public void testAbbrevs1() {
>         assertTrue( "1 C" == canon.builtin_abbrevs[0].ab );
>         assertTrue( 46 == canon.builtin_abbrevs[0].book );
>     }
> 
>     /**
>      * Test the abbreviations for all books array #2
>      */
>     public void testAbbrevs2() {
>         assertTrue( "PSALMS" == canon.builtin_abbrevs[170].ab );
>         assertTrue( 19 == canon.builtin_abbrevs[170].book );
>     }
> 
>     /**
>      * Test the abbreviations for all books array #3
>      */
>     public void testAbbrevs3() {
>         int n =  canon.builtin_abbrevs.length;
>         assertTrue( "" == canon.builtin_abbrevs[n-1].ab );
>         assertTrue( -1 == canon.builtin_abbrevs[n-1].book );
>     }
> 
>     /**
>      * Test the abbreviations for all books array #4
>      */
>     public void testAbbrevsLength() {
>         assertTrue( 184  == canon.builtin_abbrevs.length );
>     }
> 
> 
>     /**
>      * Main method needed to make a self runnable class
>      * 
>      * @param args This is required for main method
>      */
>     public static void main(String[] args) {
>         junit.textui.TestRunner.run( new TestSuite(CanonTest.class) );
>     }
> 
>     private Canon canon;
> }
> ----
> 

> // SWKeyTest.java
> 
> package org.crosswire.sword.keys;
> 
> import junit.framework.TestCase;
> import junit.framework.TestSuite;
> 
> /**
>  * SWKeyTest    (Copyright 2001 <company>)
>  * 
>  * <p> This class performs unit tests on org.crosswire.sword.keys.SWKey </p>
>  * 
>  * <p> Explanation about the tested class and its responsibilities </p>
>  * 
>  * <p> Relations:
>  *     SWKey extends java.lang.Object <br>
>  *     SWKey implements java.lang.Cloneable, java.lang.Comparable </p>
>  * 
>  * @author <Your Name> <e-mail> - <company>
>  * @date $Date: $
>  * @version $Revision: $
>  * 
>  * @see org.crosswire.sword.keys.SWKey
>  * @see some.other.package
>  */
> 
> public class SWKeyTest extends TestCase
> {
> 
>   /**
>    * Constructor (needed for JTest)
>    * @param name    Name of Object
>    */
>   public SWKeyTest(String name) {
>     super(name);
>   }
> 
>   /**
>    * Used by JUnit (called before each test method)
>    */
>   protected void setUp() {
>     //swkey = new SWKey();
>   }
> 
>   /**
>    * Used by JUnit (called after each test method)
>    */
>   protected void tearDown() {
>     swkey = null;
>   }
> 
>   /**
>    * Test the constructor: SWKey()
>    */
>   public void testSWKey() {
> 
>   }
> 
>   /**
>    * Test the constructor: SWKey(String)
>    */
>   public void testSWKey_1() {
>     //Must test for the following parameters!
>     String str [] = {null, "\u0000", " "};
> 
>   }
> 
>   /**
>    * Test the constructor: SWKey(SWKey)
>    */
>   public void testSWKey_2() {
>     //Must test for the following parameters!
>     //SWKey;
> 
>   }
> 
>   /**
>    * Test method: int compareTo(Object)
>    */
>   public void testCompareTo() {
>     //Must test for the following parameters!
>     Object oValues [] = { null };
> 
>   }
> 
>   /**
>    * Test method: java.lang.Object clone()
>    */
>   public void testClone() {
> 
>   }
> 
>   /**
>    * Test method: String toString()
>    */
>   public void testToString() {
> 
>   }
> 
>   /**
>    * Test method: void set(SWKey)
>    */
>   public void testSet() {
>     //Must test for the following parameters!
>     //SWKey;
> 
>   }
> 
>   /**
>    * Test method: void next(int)
>    */
>   public void testNext_1() {
>     //Must test for the following parameters!
>     int intValues [] = {-1, 0, 1, Integer.MAX_VALUE, Integer.MIN_VALUE};
> 
>   }
> 
>   /**
>    * Test method: void next()
>    */
>   public void testNext() {
> 
>   }
> 
>   /**
>    * Test method: void previous(int)
>    */
>   public void testPrevious_1() {
>     //Must test for the following parameters!
>     int intValues [] = {-1, 0, 1, Integer.MAX_VALUE, Integer.MIN_VALUE};
> 
>   }
> 
>   /**
>    * Test method: void previous()
>    */
>   public void testPrevious() {
> 
>   }
> 
>   /**
>    * Test method: String getText()
>    */
>   public void testGetText() {
> 
>   }
> 
>   /**
>    * Test method: int getError()
>    */
>   public void testGetError() {
> 
>   }
> 
>   /**
>    * Test method: void position(int)
>    */
>   public void testPosition() {
>     //Must test for the following parameters!
>     int intValues [] = {-1, 0, 1, Integer.MAX_VALUE, Integer.MIN_VALUE};
> 
>   }
> 
>   /**
>    * Test method: boolean isPersist()
>    */
>   public void testIsPersist() {
> 
>   }
> 
>   /**
>    * Test method: void setPersist(boolean)
>    */
>   public void testSetPersist() {
>     //Must test for the following parameters!
>     boolean BValues [] = { true, false };
> 
>   }
> 
>   /**
>    * Test method: boolean traversable()
>    */
>   public void testTraversable() {
> 
>   }
> 
>   /**
>    * Test method: void setText(String)
>    */
>   public void testSetText() {
>     //Must test for the following parameters!
>     String str [] = {null, "\u0000", " "};
> 
>   }
> 
>   /**
>    * Main method needed to make a self runnable class
>    * 
>    * @param args This is required for main method
>    */
>   public static void main(String[] args) {
>     junit.textui.TestRunner.run( new TestSuite(SWKeyTest.class) );
>   }
>   private SWKey swkey;
> }