You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vl...@apache.org on 2002/11/19 10:17:58 UTC

cvs commit: xml-xindice/java/tests/src/org/apache/xindice/client/xmldb ResourceIteratorImplTest.java

vladimir    2002/11/19 01:17:58

  Modified:    java/tests/src/org/apache/xindice UnitTests.java
               java/tests/src/org/apache/xindice/tools XMLToolsTest.java
  Added:       java/tests/src/org/apache/xindice/util
                        ConfigurationTest.java
               java/tests/src/org/apache/xindice/client/xmldb
                        ResourceIteratorImplTest.java
  Log:
  new tests
  
  Revision  Changes    Path
  1.5       +8 -3      xml-xindice/java/tests/src/org/apache/xindice/UnitTests.java
  
  Index: UnitTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/UnitTests.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- UnitTests.java	4 Nov 2002 06:41:34 -0000	1.4
  +++ UnitTests.java	19 Nov 2002 09:17:57 -0000	1.5
  @@ -60,15 +60,16 @@
   package org.apache.xindice;
   
   import org.apache.xindice.client.xmldb.DatabaseImplTest;
  +import org.apache.xindice.client.xmldb.ResourceIteratorImplTest;
   import org.apache.xindice.core.data.KeyTest;
   import org.apache.xindice.core.data.ValueTest;
   import org.apache.xindice.core.filer.BTreeFiler;
   import org.apache.xindice.core.filer.FSFiler;
   import org.apache.xindice.core.filer.FilerTestCase;
   import org.apache.xindice.core.filer.FilerTestSetup;
  -import org.apache.xindice.core.filer.HashFiler;
   import org.apache.xindice.core.filer.MemFiler;
   import org.apache.xindice.tools.XMLToolsTest;
  +import org.apache.xindice.util.ConfigurationTest;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -95,7 +96,11 @@
         suite.addTest(new FilerTestSetup(new TestSuite(FilerTestCase.class), new MemFiler()));
   
         suite.addTest(new TestSuite(DatabaseImplTest.class));
  +      suite.addTest(new TestSuite(ResourceIteratorImplTest.class));
  +
         suite.addTest(new TestSuite(XMLToolsTest.class));
  +
  +      suite.addTest(new TestSuite(ConfigurationTest.class));
   
         return new TestSetup(suite) {
   
  
  
  
  1.1                  xml-xindice/java/tests/src/org/apache/xindice/util/ConfigurationTest.java
  
  Index: ConfigurationTest.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: ConfigurationTest.java,v 1.1 2002/11/19 09:17:58 vladimir Exp $
   */
  
  package org.apache.xindice.util;
  
  import junit.framework.TestCase;
  import org.apache.xindice.xml.dom.DOMParser;
  import org.apache.xindice.server.Xindice;
  import org.w3c.dom.*;
  
  /**
   * @version $Revision: 1.1 $, $Date: 2002/11/19 09:17:58 $
   * @author Vladimir R. Bossicard <vl...@apache.org>
   */
  public class ConfigurationTest
        extends TestCase {
  
     public void testDefaultConfiguration()
           throws Exception {
        Document doc = DOMParser.toDocument(Xindice.DEFAULT_CONFIGURATION);
        Configuration config = new Configuration(doc);
  
        config = config.getChild("root-collection", false);
        assertEquals("root-collection", config.getName());
  
        assertEquals("./db/", config.getAttribute("dbroot"));
        assertEquals("db", config.getAttribute("name"));
  
        /* TODO show how to access the resolver subconfigurations */
     }
  
  
  }
  
  
  
  1.4       +5 -1      xml-xindice/java/tests/src/org/apache/xindice/tools/XMLToolsTest.java
  
  Index: XMLToolsTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/tools/XMLToolsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLToolsTest.java	28 Oct 2002 08:39:20 -0000	1.3
  +++ XMLToolsTest.java	19 Nov 2002 09:17:58 -0000	1.4
  @@ -28,4 +28,8 @@
         tools.parseArguments(new String[]{"ac", "-c", "/db"});
      }
   
  +   public void testParseValidLongDbName() {
  +      tools.parseArguments(new String[]{"ac", "-c", "xmldb:xindice-embed://localhost:8090/db"});
  +   }
  +
   }
  
  
  
  1.1                  xml-xindice/java/tests/src/org/apache/xindice/client/xmldb/ResourceIteratorImplTest.java
  
  Index: ResourceIteratorImplTest.java
  ===================================================================
  package org.apache.xindice.client.xmldb;
  
  import junit.framework.*;
  import org.xmldb.api.base.*;
  import org.xmldb.api.base.Collection;
  import org.xmldb.api.base.XMLDBException;
  
  import java.util.*;
  
  /**
   * @version $Revision: 1.1 $, $Date: 2002/11/19 09:17:58 $
   * @author Vladimir R. Bossicard <vl...@apache.org>
   */
  public class ResourceIteratorImplTest
        extends TestCase {
  
     List vct = new Vector();
  
     public void setUp() {
        for (int i = 0; i < 3; i++) {
           vct.add(new MockResource());
        }
     }
  
     public void testIterate()
           throws Exception {
        ResourceIterator iterator = new ResourceIteratorImpl(vct);
  
        assertEquals(true, iterator.hasMoreResources());
        assertNotNull(iterator.nextResource());
  
        assertEquals(true, iterator.hasMoreResources());
        assertNotNull(iterator.nextResource());
  
        assertEquals(true, iterator.hasMoreResources());
        assertNotNull(iterator.nextResource());
  
        assertEquals(false, iterator.hasMoreResources());
        try {
           iterator.nextResource();
           fail();
        } catch (XMLDBException e) {
           return;
        }
     }
  
     private static class MockResource
           implements Resource {
  
        public Collection getParentCollection()
              throws XMLDBException {
           return null;
        }
  
        public String getId()
              throws XMLDBException {
           return null;
        }
  
        public String getResourceType()
              throws XMLDBException {
           return null;
        }
  
        public Object getContent()
              throws XMLDBException {
           return null;
        }
  
        public void setContent(Object value)
              throws XMLDBException {
        }
     }
  
  }