kward       2002/06/09 19:10:28

  Modified:    java/scratchpad/tests/src CollectionManagerTest.java
  Log:
  completed CollectionManagerTest
  
  Revision  Changes    Path
  1.2       +111 -8    
xml-xindice/java/scratchpad/tests/src/CollectionManagerTest.java
  
  Index: CollectionManagerTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/scratchpad/tests/src/CollectionManagerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CollectionManagerTest.java        2 May 2002 03:58:05 -0000       1.1
  +++ CollectionManagerTest.java        10 Jun 2002 02:10:28 -0000      1.2
  @@ -54,7 +54,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: CollectionManagerTest.java,v 1.1 2002/05/02 03:58:05 kward Exp $
  + * $Id: CollectionManagerTest.java,v 1.2 2002/06/10 02:10:28 kward Exp $
    */
   
   import java.util.*;
  @@ -63,6 +63,8 @@
   
   public class CollectionManagerTest extends XMLRPCAPITestCase {
   
  +   private boolean exceptioncaught = false ;
  +
      public CollectionManagerTest(String name) {
         super(name);
      }
  @@ -75,7 +77,11 @@
   
      public void testCreateCollection() throws Exception {
   
  -      createCollection("child1");
  +      try {
  +         createCollection("child1");
  +      } catch(Exception e) {
  +         fail( e.getMessage() );
  +      }
   
         Hashtable message = new Hashtable();
         message.put("message", "ListCollections");
  @@ -93,6 +99,8 @@
         }
   
         dropCollection("child1");
  +
  +
      }
   
      public void testDropCollection() throws Exception {
  @@ -114,14 +122,41 @@
            assert(((String) enum.nextElement()).equals("coltodrop"));
         }
   
  -      dropCollection("coltodrop");
  +      try {
  +         dropCollection("coltodrop");
  +      } catch( Exception e ) {
  +         fail(e.getMessage());
  +      }
   
         // Try dropping the collection we just dropped
   
         try {
  -      dropCollection("coltodrop");
  +         exceptioncaught = false;
  +         dropCollection("coltodrop");
         } catch(Exception e) {
  +         exceptioncaught = true ;
  +      } finally {
  +         assertTrue( exceptioncaught );
  +      }
  +
  +      // Try dropping a collection with an empty name
  +
  +      exceptioncaught = false;
  +      Hashtable badmessage = new Hashtable();
  +
  +      badmessage.put("message", "RemoveCollection");
  +      badmessage.put("collection", "");
  +
  +      Vector badparams = new Vector();
   
  +      badparams.addElement(badmessage);
  +
  +      try {
  +         client.execute("run", badparams);
  +      } catch(Exception e) {
  +         exceptioncaught = true;
  +      } finally {
  +         assertTrue( exceptioncaught );
         }
   
      }
  @@ -129,15 +164,68 @@
   
      public void testCreateIndexer() throws Exception {
   
  -   }
  +      // try a normal indexer
  +      try {
  +         createIndexer( "goodindexer", "goodindexer" );
  +      } catch( Exception e ) {
  +         fail( e.getMessage() );
  +      }
   
  +      // try adding the same indexer, should result in duplicate error
  +      try {
  +         exceptioncaught = false;
  +         createIndexer( "goodindexer", "goodindexer" );
  +      } catch( Exception e ) {
  +         exceptioncaught = true;
  +      } finally {
  +         assertTrue( exceptioncaught );
  +      }
  +
  +      // try adding a nameless indexer
  +      try {
  +         exceptioncaught = false;
  +         createIndexer( "", "nonamepattern" );
  +      } catch( Exception e ) {
  +         exceptioncaught = true;
  +      } finally {
  +         assertTrue( exceptioncaught );
  +      }
   
  -   public void testListIndexers() {
  +      dropIndexer("goodindexer");
   
      }
   
   
  -   public void testdropIndexer() {
  +   public void testdropIndexer() throws Exception {
  +
  +      createIndexer("index2drop", "pattern1");
  +
  +      try {
  +         dropIndexer("index2drop");
  +      } catch (Exception e) {
  +         fail( e.getMessage() );
  +      }
  +
  +      exceptioncaught = false ;
  +
  +      try {
  +         dropIndexer("index2drop");
  +      } catch (Exception e) {
  +         exceptioncaught = true;
  +      } finally {
  +         assert( exceptioncaught );
  +      }
  +
  +      exceptioncaught = false ;
  +
  +      try {                
  +         dropIndexer("");
  +      } catch (Exception e) {
  +         exceptioncaught = true;
  +      } finally {
  +         assert( exceptioncaught );
  +      }
  +
   
      }
   
  @@ -169,7 +257,7 @@
   
         params.addElement(message);
   
  -      Hashtable result = (Hashtable) client.execute("run", params);
  +      client.execute("run", params);
   
       }
   
  @@ -180,6 +268,21 @@
         message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME );
         message.put("name", name);
         message.put("pattern", pattern);
  +
  +      Vector params = new Vector();
  +
  +      params.addElement(message);
  +
  +      client.execute("run", params);
  +
  +    }
  +
  +    protected void dropIndexer(String name) throws Exception {
  +      Hashtable message = new Hashtable();
  +
  +      message.put("message", "RemoveIndexer");
  +      message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME );
  +      message.put("name", name);
   
         Vector params = new Vector();
   
  
  
  

Reply via email to