[jsword-svn] r2155 - in trunk/jsword/src/test/java/org/crosswire/jsword/book: sword test

dmsmith at crosswire.org dmsmith at crosswire.org
Sat Apr 9 09:15:35 MST 2011


Author: dmsmith
Date: 2011-04-09 09:15:35 -0700 (Sat, 09 Apr 2011)
New Revision: 2155

Added:
   trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/AllTests.java
Modified:
   trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java
Log:
Improve JSword tests

Added: trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/AllTests.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/AllTests.java	                        (rev 0)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/AllTests.java	2011-04-09 16:15:35 UTC (rev 2155)
@@ -0,0 +1,26 @@
+package org.crosswire.jsword.book.sword;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * JUnit Test.
+ * 
+ * @see gnu.lgpl.License for license details.<br>
+ *      The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ */
+public class AllTests {
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for org.crosswire.jsword.book.sword");
+        // $JUnit-BEGIN$
+        suite.addTest(new TestSuite(ConfigEntryTableTest.class));
+        suite.addTest(new TestSuite(GenBookTest.class));
+        suite.addTest(new TestSuite(RawFileBackendTest.class));
+        suite.addTest(new TestSuite(SwordBookDriverTest.class));
+        suite.addTest(new TestSuite(SwordBookMetaDataTest.class));
+        suite.addTest(new TestSuite(SwordBookTest.class));
+        // $JUnit-END$
+        return suite;
+    }
+}

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java	2011-04-09 16:15:12 UTC (rev 2154)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java	2011-04-09 16:15:35 UTC (rev 2155)
@@ -25,6 +25,8 @@
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookData;
 import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.index.search.DefaultSearchModifier;
+import org.crosswire.jsword.index.search.DefaultSearchRequest;
 import org.crosswire.jsword.passage.Key;
 import org.crosswire.jsword.passage.KeyUtil;
 import org.crosswire.jsword.passage.NoSuchKeyException;
@@ -74,19 +76,36 @@
         try {
             start_time = System.currentTimeMillis();
 
-            PassageTally tally;
 
+            DefaultSearchModifier modifier = new DefaultSearchModifier();
+            modifier.setRanked(true);
+
+            // If ranking see if the results are being limited.
+            int rankCount = 35;
+            modifier.setMaxResults(rankCount);
+
             // Part 1, a best match, and doc generate
-            tally = (PassageTally) book.find("\"In the beginning god created the heavens and the earth\"");
-            tally.trimVerses(35);
-            dummyDisplay(tally);
-            tally = null;
+            String param = "\"In the beginning god created the heavens and the earth\"";
+            Key results = book.find(new DefaultSearchRequest(param, modifier));
 
+            // we should get PassageTallys for rank searches
+            if (results instanceof PassageTally) {
+                PassageTally tally = (PassageTally) results;
+                tally.setOrdering(PassageTally.Order.TALLY);
+                tally.trimVerses(rankCount);
+                dummyDisplay(tally);
+                results = null;
+            }
+
             // Part 2, another best match, and doc generate
-            tally = (PassageTally) book.find("\"for god so loves the world that he gave his only begotten son\"");
-            tally.trimVerses(35);
-            dummyDisplay(tally);
-            tally = null;
+            param = "\"for god so loves the world that he gave his only begotten son\"";
+            if (results instanceof PassageTally) {
+                PassageTally tally = (PassageTally) results;
+                tally.setOrdering(PassageTally.Order.TALLY);
+                tally.trimVerses(rankCount);
+                dummyDisplay(tally);
+                results = null;
+            }
 
             // Part 3, a power match, and doc generate
             String nextInput = book.find("aaron & manna").getName();




More information about the jsword-svn mailing list