vgritsenko    2003/08/08 06:48:35

  Modified:    config   system.xml
               java/tests/src/org/apache/xindice/core/meta MetaTest.java
               java/tests/src/org/apache/xindice/integration
                        IntegrationTests.java
  Added:       java/tests/src/org/apache/xindice/integration/client/services
                        MetaTest.java
  Log:
  Enable meta in system.xml
  Add MetaService integration test.
  
  Revision  Changes    Path
  1.12      +13 -11    xml-xindice/config/system.xml
  
  Index: system.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/config/system.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- system.xml        27 Jun 2003 21:20:45 -0000      1.11
  +++ system.xml        8 Aug 2003 13:48:35 -0000       1.12
  @@ -1,17 +1,19 @@
   <?xml version="1.0" encoding="UTF-8"?>
  +
   <!--
     - Version: $Revision$ $Date$
     - Author: Kimbro Staken ([EMAIL PROTECTED])
     -->
  +
   <xindice>
  -     <root-collection dbroot="./db/" name="db" use-metadata="off">
  -             <!-- Set use-metadata to on to enable metadata usage. -->
  -             <queryengine>
  -                     <resolver autoindex="false" 
class="org.apache.xindice.core.query.XPathQueryResolver"/>
  -                     <resolver 
class="org.apache.xindice.core.xupdate.XUpdateQueryResolver"/>
  -             </queryengine>
  -     </root-collection>
  -     <xml-rpc>
  -             <driver name="xerces"/>
  -     </xml-rpc>
  +    <root-collection dbroot="./db/" name="db" use-metadata="on">
  +        <!-- Set use-metadata to on to enable metadata usage. -->
  +        <queryengine>
  +            <resolver autoindex="false" 
class="org.apache.xindice.core.query.XPathQueryResolver"/>
  +            <resolver 
class="org.apache.xindice.core.xupdate.XUpdateQueryResolver"/>
  +        </queryengine>
  +    </root-collection>
  +    <xml-rpc>
  +        <driver name="xerces"/>
  +    </xml-rpc>
   </xindice>
  
  
  
  1.4       +4 -7      
xml-xindice/java/tests/src/org/apache/xindice/core/meta/MetaTest.java
  
  Index: MetaTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/core/meta/MetaTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MetaTest.java     7 Aug 2003 20:13:26 -0000       1.3
  +++ MetaTest.java     8 Aug 2003 13:48:35 -0000       1.4
  @@ -66,13 +66,12 @@
   import org.w3c.dom.*;
   
   /**
  - * @version CVS $Revision$, $Date$
    * @author Dave Viner <[EMAIL PROTECTED]>
  + * @version CVS $Revision$, $Date$
    */
   public class MetaTest extends TestCase {
   
  -
  -   /* make sure we can make 2 metadata objects that are identical */ 
  +   /* make sure we can make 2 metadata objects that are identical */
      public void testMetaSimpleComparison() {
            MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0);
                MetaData m2 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0);
  @@ -95,8 +94,7 @@
                
                s = (String)m1.getAttribute("not there");
                assertNull(s);
  -             
  -     }
  +    }
        
        /* make sure we can get and set custom documents */
        public void testMetaCustomDocument() {
  @@ -118,7 +116,6 @@
                m1.setCustomDocument(doc);
                
                Document doc2 = m1.getCustomDocument();
  -             
                assertEquals(TextWriter.toString(doc), 
TextWriter.toString(doc2));
        }
        
  
  
  
  1.1                  
xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/MetaTest.java
  
  Index: MetaTest.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/>.
   *
   * CVS $Id: MetaTest.java,v 1.1 2003/08/08 13:48:35 vgritsenko Exp $
   */
  
  package org.apache.xindice.integration.client.services;
  
  import org.apache.xindice.client.xmldb.services.MetaService;
  import org.apache.xindice.core.meta.MetaData;
  import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
  
  import org.xmldb.api.base.Collection;
  
  /**
   * Test MetaService
   *
   * @version CVS $Revision: 1.1 $, $Date: 2003/08/08 13:48:35 $
   * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
   */
  public class MetaTest extends AbstractXmlDbClientTest {
  
      public void setUp() throws Exception {
          super.setUp();
  
          String document1 = "<?xml version=\"1.0\"?>" +
                  "<person>" +
                  "<first>John</first>" +
                  "<last>Smith</last>" +
                  "<age>30</age>" +
                  "<phone type=\"work\">555-345-6789</phone>" +
                  "</person>";
  
          this.client.insertDocument(TEST_COLLECTION_PATH, "doc1", document1);
      }
  
      public void tearDown() throws Exception {
          this.client.removeDocument(TEST_COLLECTION_PATH, "doc1");
  
          super.tearDown();
      }
  
      public void testGetMetaData() throws Exception {
          // Get meta service
          Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
          MetaService service = (MetaService) col.getService("MetaService", 
"1.0");
          assertNotNull("MetaService is not found!", service);
  
          // Get meta data
          MetaData data = service.getMetaData("doc1");
          assertNotNull("MetaData is not found for doc1!", data);
          assertTrue("Created time is 0!", data.getCreatedTime() != 0);
          assertTrue("Modified time is 0!", data.getLastModifiedTime() != 0);
          long created0 = data.getCreatedTime();
          long modified0 = data.getLastModifiedTime();
  
          // Sleep and get it again
          Thread.sleep(500);
          data = service.getMetaData("doc1");
          long created1 = data.getCreatedTime();
          long modified1 = data.getLastModifiedTime();
          assertEquals("Created time changed on 2nd get (diff: "+ (created1 - 
created0) +")!", created0, created1);
          assertEquals("Modified time changed on 2nd get (diff: "+ (modified1 - 
modified0) +")!", modified0, modified1);
  
          // Sleep and update the document and get data again
          Thread.sleep(500);
          String document1 = "<?xml version=\"1.0\"?>" +
                  "<person>" +
                  "<first>John</first>" +
                  "<last>Smith</last>" +
                  "<age>31</age>" +
                  "<phone type=\"work\">555-345-6789</phone>" +
                  "</person>";
          this.client.updateDocument(TEST_COLLECTION_PATH, "doc1", document1);
  
          data = service.getMetaData("doc1");
          assertNotNull("MetaData is not found for doc1 after update!", data);
          long created2 = data.getCreatedTime();
          long modified2 = data.getLastModifiedTime();
          assertEquals("Created time changed on update (diff: "+ (created2 - 
created1) +")!", created1, created2);
          assertTrue("Modified time has not changed on update", modified1 != 
modified2);
          System.out.println("End!");
      }
  }
  
  
  
  
  1.4       +4 -4      
xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java
  
  Index: IntegrationTests.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IntegrationTests.java     7 Aug 2003 20:13:26 -0000       1.3
  +++ IntegrationTests.java     8 Aug 2003 13:48:35 -0000       1.4
  @@ -64,6 +64,7 @@
   import org.apache.xindice.integration.client.basic.IndexTest;
   import org.apache.xindice.integration.client.services.XPathQueryTest;
   import org.apache.xindice.integration.client.services.XUpdateQueryTest;
  +import org.apache.xindice.integration.client.services.MetaTest;
   
   import junit.framework.TestSuite;
   
  @@ -80,8 +81,7 @@
           suite.addTestSuite(DocumentTest.class);
           suite.addTestSuite(XUpdateQueryTest.class);
           suite.addTestSuite(XPathQueryTest.class);
  -
  +        suite.addTestSuite(MetaTest.class);
           return suite;
       }
  -
   }
  
  
  

Reply via email to