kward       02/05/01 20:58:05

  Added:       java/scratchpad/tests/src CollectionManagerTest.java
  Log:
  initial XMLRPC API tests
  
  Revision  Changes    Path
  1.1                  
xml-xindice/java/scratchpad/tests/src/CollectionManagerTest.java
  
  Index: CollectionManagerTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * 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 $
   */
  
  import java.util.*;
  
  import junit.framework.*;
  
  public class CollectionManagerTest extends XMLRPCAPITestCase {
  
     public CollectionManagerTest(String name) {
        super(name);
     }
  
     public static junit.framework.Test suite() {
        System.out.println("In CollectionManagerTest.suite() ");
        return new junit.framework.TestSuite(CollectionManagerTest.class);
     }
  
  
     public void testCreateCollection() throws Exception {
  
        createCollection("child1");
  
        Hashtable message = new Hashtable();
        message.put("message", "ListCollections");
        message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME);
  
        Vector params = new Vector();
        params.addElement(message);
  
        Hashtable result = (Hashtable) client.execute("run", params);
  
        Vector list = (Vector) result.get("result");
        Enumeration enum = list.elements();
        while ( enum.hasMoreElements() ) {
           assert(((String) enum.nextElement()).equals("child1"));
        }
  
        dropCollection("child1");
     }
  
     public void testDropCollection() throws Exception {
  
        createCollection("coltodrop");
  
        Hashtable message = new Hashtable();
        message.put("message", "ListCollections");
        message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME);
  
        Vector params = new Vector();
        params.addElement(message);
  
        Hashtable result = (Hashtable) client.execute("run", params);
  
        Vector list = (Vector) result.get("result");
        Enumeration enum = list.elements();
        while ( enum.hasMoreElements() ) {
           assert(((String) enum.nextElement()).equals("coltodrop"));
        }
  
        dropCollection("coltodrop");
  
        // Try dropping the collection we just dropped
  
        try {
        dropCollection("coltodrop");
        } catch(Exception e) {
  
        }
  
     }
  
  
     public void testCreateIndexer() throws Exception {
  
     }
  
  
     public void testListIndexers() {
  
     }
  
  
     public void testdropIndexer() {
  
     }
  
  
     // Utility functions
  
  
     protected void createCollection(String collection) throws Exception {
        Hashtable message = new Hashtable();
  
        message.put("message", "CreateCollection");
        message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME );
        message.put("name", collection);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        client.execute("run", params);
     }
  
     protected void dropCollection(String collection) throws Exception {
        Hashtable message = new Hashtable();
  
        message.put("message", "RemoveCollection");
        message.put("collection", "/" + INSTANCE_NAME + "/" + 
TEST_COLLECTION_NAME + "/" + collection);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        Hashtable result = (Hashtable) client.execute("run", params);
  
      }
  
      protected void createIndexer(String name, String pattern) throws 
Exception {
        Hashtable message = new Hashtable();
  
        message.put("message", "CreateIndexer");
        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);
  
      }
     
  }
  
  
  
  
  

Reply via email to