xml-xindice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ksta...@apache.org
Subject cvs commit: xml-xindice/java/tests/src AllTests.java CollectionManagerTest.java CollectionTest.java FilerTestCase.java XMLRPCAPITestCase.java XMLRPCAPITestSuite.java XindiceTestSuite.java
Date Wed, 14 Aug 2002 04:07:19 GMT
kstaken     2002/08/13 21:07:19

  Added:       java/tests/src AllTests.java CollectionManagerTest.java
                        CollectionTest.java FilerTestCase.java
                        XMLRPCAPITestCase.java XMLRPCAPITestSuite.java
                        XindiceTestSuite.java
  Log:
  Adding XML-RPC and the start of some filer tests.
  
  Revision  Changes    Path
  1.3       +77 -87    xml-xindice/java/tests/src/AllTests.java
  
  
  
  
  1.3       +280 -590  xml-xindice/java/tests/src/CollectionManagerTest.java
  
  
  
  
  1.3       +244 -546  xml-xindice/java/tests/src/CollectionTest.java
  
  
  
  
  1.1                  xml-xindice/java/tests/src/FilerTestCase.java
  
  Index: FilerTestCase.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 apache@apache.org.
   *
   * 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: FilerTestCase.java,v 1.1 2002/08/14 04:07:19 kstaken Exp $
   */
  
  import java.io.*;
  import java.util.*;
  
  import junit.framework.*;
  import org.apache.xmlrpc.*;
  
  import org.apache.xindice.core.filer.*;
  import org.apache.xindice.core.data.*;
  import org.apache.xindice.util.*;
  import org.apache.xindice.xml.dom.*;
  
  public class FilerTestCase extends TestCase {
  
     static public final String TEST_COLLECTION_NAME = "tests";
     static public final Value TEST_VALUE = new Value("<test><test></test><test>Just
a test</test></test>");
     static public final Key TEST_KEY = new Key("test.xml");
     
     Filer filer;
     
     public FilerTestCase(String name) {
        super(name);
     }
  
     public static junit.framework.Test suite() {
        System.out.println("In FilerTestCase.suite() ");
        return new junit.framework.TestSuite(FilerTestCase.class);
     }
     
     public void setUp() throws Exception {
        filer = new BTreeFiler();
  
        // Create the directory to hold the tests.
        File root = new File(TEST_COLLECTION_NAME);
        root.mkdir();
  
        filer.setLocation(root, TEST_COLLECTION_NAME);
        filer.setConfig(new Configuration(DOMParser.toDocument("<filer location=\"tests\"/>")));
        if ( !filer.exists() ) {
           filer.create();
        }
           
        filer.open();
     }
  
     public void tearDown() throws Exception {
        filer.close();
        File root = new File(TEST_COLLECTION_NAME);
        String [] files = root.list();
        for (int i = 0; i < files.length; i++) {
           File child = new File(root, files[i]);
           child.delete();
        }
        root.delete();
     }
  
     public void testWriteRecord() throws Exception {
        filer.writeRecord(TEST_KEY, TEST_VALUE);
        Record result = filer.readRecord(TEST_KEY);
        assertTrue(result.getValue().toString().equals(TEST_VALUE.toString()));
  
        filer.deleteRecord(TEST_KEY);
        result = filer.readRecord(TEST_KEY);
        assertTrue(result == null);
  
        try {
           filer.writeRecord(null, TEST_VALUE);
           fail("Expecting BTreeException");
        }
        catch (BTreeException e) {
           // Expected result
        }
  
        try {
           filer.writeRecord(TEST_KEY, null);
           fail("Expecting BTreeException");
        }
        catch (BTreeException e) {
           // Expected result
        }
  
        try {
           filer.writeRecord(null, null);
           fail("Expecting BTreeException");
        }
        catch (BTreeException e) {
           // Expected result
        }      
     }
  
     public void testReadRecord() throws Exception {
     }
  
     public void testDeleteRecord() throws Exception {
     }
  
     public void testGetRecordCount() throws Exception {
     }
  
     public void testGetRecordSet() throws Exception {
     }
     
     public void testMultipleActions() throws Exception {
        for (int i = 0, j = 100; i < 100; i++, j--) {
           if (i % 2 == 0) {
              filer.writeRecord(new Key("" + j + i), new Value("test" + j + i));
              Record result = filer.readRecord(new Key("" + j + i));
              assertTrue(result.getValue().toString().equals("test" + j + i));           

           }
           else {
              filer.writeRecord(new Key("" + i + j), new Value("test" + i + j));
              Record result = filer.readRecord(new Key("" + i + j));
              assertTrue(result.getValue().toString().equals("test" + i + j));
           }         
        }
  
        for (int i = 0, j = 100; i < 100; i++, j--) {
           if (i % 2 == 0) {       
              filer.deleteRecord(new Key("" + j + i));
           }
           else {
              filer.deleteRecord(new Key("" + i + j));
           }
        }
  
        assertTrue(filer.getRecordCount() == 0);
     }
  }
  
  
  
  1.1                  xml-xindice/java/tests/src/XMLRPCAPITestCase.java
  
  Index: XMLRPCAPITestCase.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 apache@apache.org.
   *
   * 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: XMLRPCAPITestCase.java,v 1.1 2002/08/14 04:07:19 kstaken Exp $
   */
  
  import java.io.*;
  import java.util.*;
  
  import junit.framework.*;
  import org.apache.xmlrpc.*;
  
  
  public class XMLRPCAPITestCase extends TestCase {
  
     static public final String TEST_COLLECTION_NAME = "tests";
     static public final String INSTANCE_NAME = "db";
  
  
     protected XmlRpcClient client = null;
  
     public XMLRPCAPITestCase(String name) {
        super(name);
     }
  
     public void setUp() throws Exception {
        XmlRpc.setEncoding("UTF8");
        XmlRpc.setDriver("xerces");
        client = new XmlRpcClient("http://localhost:8080/Xindice");
  
        Hashtable message = new Hashtable();
  
        message.put("message", "CreateCollection");
        message.put("collection", "/" + INSTANCE_NAME );
        message.put("name", TEST_COLLECTION_NAME);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        try {
           client.execute("run", params);
        } catch( Exception e ) {
           fail( e.getMessage() );
        }
     }
  
     public void tearDown() throws Exception {
  
        Hashtable message = new Hashtable();
  
        message.put("message", "RemoveCollection");
        message.put("collection", "/" + INSTANCE_NAME );
        message.put("name", TEST_COLLECTION_NAME);
        
        Vector params = new Vector();
  
        params.addElement(message);
  
        try {
           client.execute("run", params);
        } catch( Exception e ) {
           fail( e.getMessage() );
        }
  
     }
  
  
     // Utility functions
     protected String createCollection(String collection) throws Exception {
        Hashtable result = new Hashtable();
        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);
  
        result = (Hashtable) client.execute("run", params);
        return (String) result.get("result");
     }
  
     protected void dropCollection(String collection) throws Exception {
        Hashtable message = new Hashtable();
  
        message.put("message", "RemoveCollection");
        message.put("collection", "/" + INSTANCE_NAME + "/" + TEST_COLLECTION_NAME);
        message.put("name", collection);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        client.execute("run", params);
  
      }
  
      protected String createIndexer(String name, String pattern) throws Exception {
        Hashtable result = new Hashtable();
        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);
  
        result = (Hashtable) client.execute("run", params);
        return (String) result.get("result");
  
      }
  
      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();
  
        params.addElement(message);
  
        client.execute("run", params);
  
      }
  
      protected String insertDocument(String name, String doc) throws Exception {
        Hashtable result = new Hashtable();
        Hashtable message = new Hashtable();
  
        message.put("message", "InsertDocument");
        message.put("collection", "/" + INSTANCE_NAME + "/" + TEST_COLLECTION_NAME );
        message.put("name", name);
        message.put("document", doc);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        result = (Hashtable) client.execute("run", params);
        return (String) result.get("result");
  
      }
  
      protected void removeDocument(String name) throws Exception {
        Hashtable message = new Hashtable();
  
        message.put("message", "RemoveDocument");
        message.put("collection", "/" + INSTANCE_NAME + "/" + TEST_COLLECTION_NAME );
        message.put("name", name);
  
        Vector params = new Vector();
  
        params.addElement(message);
  
        client.execute("run", params);
        
      }
  
   }
  
  
  
  1.1                  xml-xindice/java/tests/src/XMLRPCAPITestSuite.java
  
  Index: XMLRPCAPITestSuite.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 apache@apache.org.
   *
   * 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: XMLRPCAPITestSuite.java,v 1.1 2002/08/14 04:07:19 kstaken Exp $
   */
  
  import junit.framework.*;
  import junit.textui.TestRunner;
  
  public class XMLRPCAPITestSuite   {
      
     public static void main( String args[] ) throws Exception {
        TestRunner.run(suite());
     }
     
     public static junit.framework.Test suite() {
        junit.framework.TestSuite suite = new TestSuite("All XML-RPC API Tests");
        suite.addTest((junit.framework.Test) CollectionManagerTest.suite());
        suite.addTest((junit.framework.Test) CollectionTest.suite());
        System.out.println("Running " + suite.countTestCases() + " Tests");
        return suite;
     }
  }
  
  
  
  
  1.1                  xml-xindice/java/tests/src/XindiceTestSuite.java
  
  Index: XindiceTestSuite.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 apache@apache.org.
   *
   * 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: XindiceTestSuite.java,v 1.1 2002/08/14 04:07:19 kstaken Exp $
   */
  
  import junit.framework.*;
  import junit.textui.TestRunner;
  
  public class XindiceTestSuite   {
      
     public static void main( String args[] ) throws Exception {
        TestRunner.run(suite());
     }
     
     public static junit.framework.Test suite() {
        junit.framework.TestSuite suite = new TestSuite("All Xindice Tests except XML-RPC");
        suite.addTest((junit.framework.Test) FilerTestCase.suite());
        System.out.println("Running " + suite.countTestCases() + " Tests");
        return suite;
     }
  }
  
  
  
  

Mime
View raw message