Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/search SearchResultItem.java SelfTest.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/search SearchResultItem.java SelfTest.java

Author stack
Full name Michael Stack
Date 2000-11-02 11:33:48 PST
Message User: stack
  Date: 00/11/02 11:33:48

  Modified: java/org/joist/search SearchResultItem.java SelfTest.java
  Log:
  New jUnit tests to exercises changes in API. Flushed bugs. Fixes
  
  Revision Changes Path
  1.7 +10 -6 joist/java/org/joist​/search/SearchResult​Item.java
  
  Index: SearchResultItem.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/search/SearchR​esultItem.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SearchResultItem.java 2000/11/02 02:20:34 1.6
  +++ SearchResultItem.java 2000/11/02 19:33:48 1.7
  @@ -51,14 +51,14 @@
   * «Immutable -- Read-Only.»
   *
   * @author <a href="mailto:stack@c​ollab.net">St.Ack​</a>
  -* @version $Id: SearchResultItem.java,v 1.6 2000/11/02 02:20:34 stack Exp $
  +* @version $Id: SearchResultItem.java,v 1.7 2000/11/02 19:33:48 stack Exp $
   */
   public class SearchResultItem
   {
       /** Class version string
       */
       public static final String versionID
  - = "$Id: SearchResultItem.java,v 1.6 2000/11/02 02:20:34 stack Exp $";
  + = "$Id: SearchResultItem.java,v 1.7 2000/11/02 19:33:48 stack Exp $";
   
   
       /** Search engine ranking.
  @@ -174,11 +174,15 @@
               throw new NullPointerException( "inDomain is null" );
           domain = inDomain.trim( );
           
  - port = inPort.trim( );
  - protocol = inProtocol.trim( );
  + if( inPort != null )
  + port = inPort.trim( );
  + if( inProtocol != null )
  + protocol = inProtocol.trim( );
  + if( inTitle != null )
  + title = inTitle.trim( );
  +
           ranking = inRanking;
           size = inSize;
  - title = inTitle.trim( );
       }
   
   
  @@ -337,7 +341,7 @@
           strBuffer.append( "." );
           strBuffer.append( domain );
           if( port != null
  - || port.equals( DEFAULT_PORT_80 ) )
  + && !port.equals( DEFAULT_PORT_80 ) )
           {
               strBuffer.append( ":" );
               strBuffer.append( port );
  
  
  
  1.3 +141 -38 joist/java/org/joist​/search/SelfTest.jav​a
  
  Index: SelfTest.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/search/SelfTes​t.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelfTest.java 2000/11/02 02:20:34 1.2
  +++ SelfTest.java 2000/11/02 19:33:48 1.3
  @@ -52,10 +52,13 @@
   * Uses junit. Doc. is a bit flakey.
   * <p>Here's how to run it:
   * <pre>
  -* % javac -d classes org/tigris/helm/search/*.java
  -* % java -classpath ${CLASSPATH}:./classes -nojit -Dquery="sandbox" -Dindex="${SANDBOX}​/search/swish.idx" junit.textui.TestRunner org.tigris.helm.sear​ch.SearchTestjava -Dquery="sandbox" -classpath ${CLASSPATH}:./classes -nojit junit.textui.TestRunner org.tigris.helm.sear​ch.SearchTest
  +* % java -classpath ${CLASSPATH}:../dest/class -Dquery="sandbox" -Dindex="${SANDBOX}​/search/swish.idx" -Dhtdoc=${SANDBOX}/​data/helm/htdoc -Ddomain=wireopen.org junit.textui.TestRunner org.joist.search.SelfTest
   * </pre>
  -* <p>Here is a note from <a hef="mailto:dlr@coll​ab.net">Daniell Rall</a>
  +* or, w/ passing more args:
  +* <pre>
  +* % java -classpath ${CLASSPATH}:../dest/class -Dquery="sandbox" -Dindex="${SANDBOX}​/search/swish.idx" -Dhtdoc=${SANDBOX}/​data/helm/htdoc -Ddomain=wireopen.org -Dport=1234 -Dprotocol=https junit.textui.TestRunner org.joist.search.SelfTest
  +* </pre>
  +<p>Here is a note from <a hef="mailto:dlr@coll​ab.net">Daniell Rall</a>
   * on JUnit:
   * <pre>
   * Subject: Re: Heyup boss..
  @@ -81,20 +84,16 @@
   *
   * @see <a href="http://www.junit.org">JUnit Site</a>
   * @author <a href="mailto:stack@c​ollab.net">St.Ack​</a>
  -* @version $Id: SelfTest.java,v 1.2 2000/11/02 02:20:34 stack Exp $
  +* @version $Id: SelfTest.java,v 1.3 2000/11/02 19:33:48 stack Exp $
   */
   public class SelfTest
       extends junit.framework.TestCase
  + implements SearchServletConstants
   {
       /** Class version string
       */
       public static final String versionID
  - = "$Id: SelfTest.java,v 1.2 2000/11/02 02:20:34 stack Exp $";
  -
  -
  - /** Use this key to pull query from system properties.
  - */
  - protected static final String QUERY_PARAM_KEY = "query";
  + = "$Id: SelfTest.java,v 1.3 2000/11/02 19:33:48 stack Exp $";
       
       
       /** Use this key to pull query from system properties.
  @@ -126,8 +125,53 @@
       */
       private static final String PATH_TO_BINARY
           = "/usr/bin/swish-e";
  +
  +
  + /** Key to pull domain from myProperties.
  + */
  + public static final String DOMAIN_PARAM_KEY
  + = "domain";
  +
  +
  + /** Domain to use.
  + */
  + private String domain = null;
  +
       
       
  + /** Key to pull port from myProperties.
  + */
  + public static final String PORT_PARAM_KEY
  + = "port";
  +
  +
  + /** Port to use.
  + */
  + private String port = null;
  +
  +
  + /** Key to pull protocol from myProperties.
  + */
  + public static final String PROTOCOL_PARAM_KEY
  + = "protocol";
  +
  +
  + /** Protocol to use.
  + */
  + private String protocol = null;
  +
  +
  + /** Key to pull htdoc from myProperties.
  + */
  + public static final String HTDOC_PARAM_KEY
  + = "htdoc";
  +
  +
  + /** Htdoc path to use.
  + */
  + private String htdoc = null;
  +
  +
       /** Constructor
       * @param inString Call super constructor w/ this string
       */
  @@ -141,8 +185,12 @@
       */
       protected void setUp( )
       {
  - strQuery = System.getProperty( QUERY_PARAM_KEY );
  + strQuery = System.getProperty( QUERY_KEY );
           index = System.getProperty( INDEX_PARAM_KEY );
  + domain = System.getProperty( DOMAIN_PARAM_KEY );
  + port = System.getProperty( PORT_PARAM_KEY );
  + protocol = System.getProperty( PROTOCOL_PARAM_KEY );
  + htdoc = System.getProperty( HTDOC_PARAM_KEY );
       }
       
       
  @@ -153,7 +201,7 @@
           assertNotNull( "The 'query' system property is "
                           + "null. Set it on command-line "
                           + "w/ -D"
  - + QUERY_PARAM_KEY
  + + QUERY_KEY
                           + "=\"QUERY\"",
                           strQuery );
       }
  @@ -169,6 +217,21 @@
                           + INDEX_PARAM_KEY
                           + "=\"INDEX\"",
                           index );
  + }
  +
  +
  + /** Test htdoc is non-null
  + */
  + public void testHtdocNull( )
  + {
  + assertNotNull( "The "
  + + HTDOC_PARAM_KEY
  + + " system property is "
  + + "null. Set it on command-line "
  + + "w/ -D"
  + + HTDOC_PARAM_KEY
  + + "=\"INDEX\"",
  + htdoc );
       }
       
       
  @@ -178,20 +241,42 @@
       {
          try
          {
  - SearchSwishe swishe
  - = new SearchSwishe( PATH_TO_BINARY,
  - "/home/stack/cvsroot​/sandbox/data/helm/h​tdoc",
  - "marx.collab.net",
  - "8500",
  - "http" );
  + SearchSwishe swishe = null;
  +
  + try
  + {
  + swishe
  + = new SearchSwishe( PATH_TO_BINARY,
  + htdoc,
  + domain,
  + port,
  + protocol );
  + }
  +
  + catch( Exception exception )
  + {
  + exception.printStackTrace( );
  + }
  +
               assertNotNull( "Swishe object is null", swishe );
               Query query
                   = new Query( strQuery,
                       index,
                       PAGES_PER_QUERY );
               assertNotNull( "Query object is null", query );
  - SearchResult searchresult
  - = swishe.search( query );
  +
  + SearchResult searchresult = null;
  + try
  + {
  + searchresult
  + = swishe.search( query );
  + }
  +
  + catch( Exception exception )
  + {
  + exception.printStackTrace( );
  + }
  +
               assertNotNull( "SearchResult object is null", searchresult );
               com.sun.java.util.co​llections.List items
                   = searchresult.getSear​chResultItems( );
  @@ -200,13 +285,26 @@
                   assertNotNull( "SearchResultItems is null", items );
                   SearchResultItem item = null;
                   java.net.URL url = null;
  - for( int i = 0; i < items.size( ); i++ )
  + String scastFormat = null;
  + try
                   {
  - item = ( SearchResultItem )items.get( i );
  - assertNotNull( "A SearchResultItem is null", item );
  - url = item.getUrl( );
  - assertNotNull( "A SearchResultItem url is null", url );
  + for( int i = 0; i < items.size( ); i++ )
  + {
  + item = ( SearchResultItem )items.get( i );
  + assertNotNull( "A SearchResultItem is null", item );
  + url = item.getUrl( );
  + assertNotNull( "A SearchResultItem url is null", url );
  + scastFormat = item.getSourceCastURL( );
  + assertNotNull( "A SearchResultItem scastFormat is null",
  + scastFormat );
  + // System.out.println( "scastFormat: " + scastFormat );
  + }
                   }
  +
  + catch( Exception exception )
  + {
  + exception.printStackTrace( );
  + }
               }
          }
           
  @@ -222,11 +320,12 @@
       {
          try
          {
  - SearchSwishe swishe = new SearchSwishe( PATH_TO_BINARY,
  - "/home/stack/cvsroot​/sandbox/data/helm/h​tdoc",
  - "marx.collab.net",
  - "8500",
  - "http" );
  + SearchSwishe swishe
  + = new SearchSwishe( PATH_TO_BINARY,
  + htdoc,
  + domain,
  + port,
  + protocol );
               assertNotNull( "Swishe object is null", swishe );
               Query query
                   = new Query( "BAD_QUERY_BAD_QUERY",
  @@ -254,10 +353,10 @@
          {
               SearchSwishe swishe
                   = new SearchSwishe( PATH_TO_BINARY,
  - "/home/stack/cvsroot​/sandbox/data/helm/h​tdoc",
  - "marx.collab.net",
  - "8500",
  - "http" );
  + htdoc,
  + domain,
  + port,
  + protocol );
               assertNotNull( "Swishe object is null", swishe );
               Query query
                   = new Query( strQuery,
  @@ -285,10 +384,10 @@
          {
               SearchSwishe swishe
                   = new SearchSwishe( PATH_TO_BINARY,
  - "/home/stack/cvsroot​/sandbox/data/helm/h​tdoc",
  - "marx.collab.net",
  - "8500",
  - "http" );
  + htdoc,
  + domain,
  + port,
  + protocol );
               assertNotNull( "Swishe object is null", swishe );
               Query query
                   = new Query( strQuery,
  @@ -330,6 +429,7 @@
               = new junit.framework.TestSuite( );
           suite.addTest( new SelfTest( "testStrQueryNull" ) );
           suite.addTest( new SelfTest( "testIndexNull" ) );
  + suite.addTest( new SelfTest( "testHtdocNull" ) );
           suite.addTest( new SelfTest( "testQuery" ) );
           suite.addTest( new SelfTest( "testBadQuery" ) );
           suite.addTest( new SelfTest( "testBadIndex" ) );
  @@ -340,6 +440,9 @@
       
       
       /** Call test suite myself directly bypassing JUnit.
  + * DON'T DO THIS USUALLY. USE JUNIT. I just put this
  + * here while i was trying to figure how junit works.
  + * <p>
       * Pass at least a 'TEST' using
       * the '-Dkey=value' facility.
       * <p> Here's an example:

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/search SearchResultItem.java SelfTest.java stack Michael Stack 2000-11-02 11:33:48 PST
Messages per page: