org.cdlib.xtf.dynaXML.test
Class CDLSearchTest

Object
  extended by SearchTest
      extended by CDLSearchTest

public class CDLSearchTest
extends SearchTest

CDL-specific test: searches for every chunk of every document in an index.

Author:
Martin Haye

Field Summary
private  String debugDoc
           
private  int debugNum
           
private  String searchTerm
           
private static String server
           
private  boolean skipping
           
private  String skipToDoc
           
private  int totalUrls
           
private static String urlPrefix
           
private  int urlsDone
           
 
Fields inherited from class SearchTest
baseDir, dynaXML
 
Constructor Summary
CDLSearchTest(String baseDir)
          Default constructor
 
Method Summary
private  String docIdFromPath(String path)
          Parses out the document ID given a document's path.
private  String[] getDocs(String indexPath, String sourcePath)
          Scans an index for all the documents present in it, and returns their paths.
static void main(String[] args)
          Runs the test.
private  String normalizeResult(String result)
          Transforms parts of the text that are okay to mismatch into matching text.
private  void pushUrl(HashSet processedUrls, String url, LinkedList urlStack)
          If the URL hasn't been processed yet, it is added to the LinkedList.
private  void pushUrls(HashSet processedUrls, String htmlResult, LinkedList urlStack)
          Scans the HTML result and adds all relevant URLs that haven't already been processed to the urlStack.
 void runTest(String indexPath, String sourcePath)
          Actual controlling routine that manages the test through its various stages.
private  boolean sameResults(String result1, String result2)
          Compares two strings for equality.
(package private)  String[] slurp(String str)
          Breaks up a string by newlines into an array of strings, one per line.
private  void testDoc(String docPath)
          Runs the test for a single document.
 
Methods inherited from class SearchTest
randomizeArray, runDynaXML
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

private static final String server
See Also:
Constant Field Values

urlPrefix

private static final String urlPrefix
See Also:
Constant Field Values

totalUrls

private int totalUrls

urlsDone

private int urlsDone

searchTerm

private final String searchTerm
See Also:
Constant Field Values

skipToDoc

private String skipToDoc

skipping

private boolean skipping

debugDoc

private String debugDoc

debugNum

private int debugNum
Constructor Detail

CDLSearchTest

public CDLSearchTest(String baseDir)
              throws ServletException
Default constructor

Parameters:
baseDir - The normal base directory used for DynaXML
Throws:
ServletException
Method Detail

docIdFromPath

private String docIdFromPath(String path)
Parses out the document ID given a document's path. Very CDL-specific.

Parameters:
path - Path to the document
Returns:
9-digit ID (letters and numbers)

getDocs

private String[] getDocs(String indexPath,
                         String sourcePath)
                  throws IOException
Scans an index for all the documents present in it, and returns their paths.

Returns:
Array of all the document paths
Throws:
IOException

pushUrl

private void pushUrl(HashSet processedUrls,
                     String url,
                     LinkedList urlStack)
If the URL hasn't been processed yet, it is added to the LinkedList.

Parameters:
processedUrls - Set of all processed URLs so far
url - URL to push
urlStack - LinkedList to add to

pushUrls

private void pushUrls(HashSet processedUrls,
                      String htmlResult,
                      LinkedList urlStack)
Scans the HTML result and adds all relevant URLs that haven't already been processed to the urlStack.

Parameters:
processedUrls - Set of URLs which have already been processed
htmlResult - HTML to scan
urlStack - LinkedList to add to

normalizeResult

private String normalizeResult(String result)
Transforms parts of the text that are okay to mismatch into matching text.


slurp

String[] slurp(String str)
Breaks up a string by newlines into an array of strings, one per line.

Parameters:
str - String to break up
Returns:
Array of the lines

sameResults

private boolean sameResults(String result1,
                            String result2)
Compares two strings for equality. If not equal, a message is printed.

Parameters:
result1 - First string
result2 - Second string
Returns:
true if equal, false if not (and message printed.)

testDoc

private void testDoc(String docPath)
              throws Exception
Runs the test for a single document. First, examines the document to find all the chunk IDs, then does a chunk test for each one.

Parameters:
docPath - File path of the document to test
Throws:
Exception

runTest

public void runTest(String indexPath,
                    String sourcePath)
             throws Exception
Actual controlling routine that manages the test through its various stages.

Throws:
Exception

main

public static void main(String[] args)
Runs the test.