vgritsenko    2003/12/11 17:38:12

  Modified:    java/tests/src/org/apache/xindice/integration/client/services
                        IndexedSearchTest.java
  Log:
  Reduce expected indexed query speedup on 4 tests from 10 to 7-8
  
  Revision  Changes    Path
  1.2       +394 -441  
xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
  
  Index: IndexedSearchTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IndexedSearchTest.java    6 Dec 2003 22:44:36 -0000       1.1
  +++ IndexedSearchTest.java    12 Dec 2003 01:38:12 -0000      1.2
  @@ -59,34 +59,27 @@
   
   package org.apache.xindice.integration.client.services;
   
  -import org.custommonkey.xmlunit.XMLAssert;
  -
  -import org.xml.sax.InputSource;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
  +import org.apache.xindice.integration.client.XmlDbClientSetup;
  +import org.apache.xindice.xml.TextWriter;
   
  +import org.custommonkey.xmlunit.XMLAssert;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
  -
  +import org.xml.sax.InputSource;
   import org.xmldb.api.base.Collection;
   import org.xmldb.api.base.ResourceSet;
  -import org.xmldb.api.base.XMLDBException;
   import org.xmldb.api.modules.XMLResource;
   import org.xmldb.api.modules.XPathQueryService;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -
  -import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
  -import org.apache.xindice.integration.client.XmlDbClientSetup;
  -import org.apache.xindice.util.XindiceException;
  -import org.apache.xindice.xml.TextWriter;
  -
  -import java.io.StringReader;
  -import java.util.Arrays;
  -import java.util.Vector;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   
  +import java.io.StringReader;
  +
   /**
    * Implements test cases for testing functionality of
    * indexed xpath searching.
  @@ -101,100 +94,87 @@
        */
       public static String PARENT_COLLECTION_PATH = 
XmlDbClientSetup.INSTANCE_NAME + "/" + XmlDbClientSetup.TEST_COLLECTION_NAME;
       public static String SUBCOLLECTION_NAME = "indexedsearch";
  -    public static String INDEXED_SEARCH_TEST_COLLECTION_PATH = 
PARENT_COLLECTION_PATH + "/" +  SUBCOLLECTION_NAME;
  +    public static String INDEXED_SEARCH_TEST_COLLECTION_PATH = 
PARENT_COLLECTION_PATH + "/" + SUBCOLLECTION_NAME;
       private static boolean docsCreated = false;
       private static boolean aCollectionCreated = false;
       public final static String TEST_DOCUMENT_PREFIX = "indexedsearchtestdoc";
       private final static DocumentBuilderFactory itsDocumentBuilderFactory = 
DocumentBuilderFactory.newInstance();
       private static final Log itsLog = 
LogFactory.getLog(IndexedSearchTest.class);
  -    
  +
       /**
        * Performs setup for each test case.
        */
       public void setUp() throws Exception {
  -
           super.setUp();
   
  -        if(!aCollectionCreated)
  -        {
  -            try
  -            {
  +        if (!aCollectionCreated) {
  +            try {
                   this.client.dropCollection(PARENT_COLLECTION_PATH, 
SUBCOLLECTION_NAME);
  -            }
  -            catch(Exception anException)
  -            {
  +            } catch (Exception anException) {
                   /**
                    * ignore problems during drop collection above...
                    **/
  -            }
  -            finally
  -            {
  +            } finally {
                   this.client.createCollection(PARENT_COLLECTION_PATH, 
SUBCOLLECTION_NAME);
                   aCollectionCreated = true;
               }
           }
   
  -        if(!docsCreated) {
  +        if (!docsCreated) {
               createTestDocs();
               docsCreated = true;
           }
       }
  -    
  +
       /**
        * Creates 104 test documents and inserts them into the test Collection.
        */
       private void createTestDocs() throws Exception {
  -        for(int anIndex = 0; anIndex < 100; ++anIndex) {
  +        for (int anIndex = 0; anIndex < 100; ++anIndex) {
               String aNumber = String.valueOf(anIndex);
               String aDocument = "<?xml version='1.0'?>" +
  -            "<person number='" + aNumber + "'>" +
  -            "<first>Sally</first>" +
  -            "<last>Jones" + aNumber + "</last>" +
  -            "<phone type='home'>555-345-6789</phone>" +
  -            "</person>";
  +                    "<person number='" + aNumber + "'>" +
  +                    "<first>Sally</first>" +
  +                    "<last>Jones" + aNumber + "</last>" +
  +                    "<phone type='home'>555-345-6789</phone>" +
  +                    "</person>";
               this.client.insertDocument(INDEXED_SEARCH_TEST_COLLECTION_PATH, 
"doc" + String.valueOf(anIndex), aDocument);
           }
       }
  -    
  -    private class IndexerTestDefinition
  -    {
  -        public class Result
  -        {
  +
  +    private class IndexerTestDefinition {
  +        public class Result {
               private ResourceSet itsResourceSet;
               private long itsElapsedTime;
  -            
  +
               /**
                * Creates a new object.
                */
  -            public Result(
  -                ResourceSet theResourceSet,
  -                long theElapsedTime)
  -            {
  +            public Result(ResourceSet theResourceSet,
  +                          long theElapsedTime) {
                   itsResourceSet = theResourceSet;
                   itsElapsedTime = theElapsedTime;
               }
  -            
  +
               /**
                * Provides this Result's ResourceSet.
                *
                * @return the ResourceSet of this result
                */
  -            public ResourceSet getResourceSet()
  -            {
  +            public ResourceSet getResourceSet() {
                   return itsResourceSet;
               }
  -            
  +
               /**
                * Provides this Result's elapsed time (how long the query took).
                *
                * @return the elapsed time in milliseconds
                */
  -            public long getElapsedTime()
  -            {
  +            public long getElapsedTime() {
                   return itsElapsedTime;
               }
           }
  -        
  +
           private String itsTestQuery;
           private String itsTestIndexName;
           private String itsTestIndexType;
  @@ -221,17 +201,15 @@
            *        any resources provided will be checked against the query 
results in order provided;
            *        if null will not be checked)
            */
  -        public IndexerTestDefinition(
  -            String theDescription,
  -            String theTestQuery,
  -            String theTestIndexName,
  -            String theTestIndexType,
  -            String theTestIndexPattern,
  -            int theIndexSpeedupFactor,
  -            String[] theTestDocuments,
  -            long theExpectedResourceCount,
  -            Object[] theExpectedResources)
  -        {
  +        public IndexerTestDefinition(String theDescription,
  +                                     String theTestQuery,
  +                                     String theTestIndexName,
  +                                     String theTestIndexType,
  +                                     String theTestIndexPattern,
  +                                     int theIndexSpeedupFactor,
  +                                     String[] theTestDocuments,
  +                                     long theExpectedResourceCount,
  +                                     Object[] theExpectedResources) {
               itsDescription = theDescription;
               itsTestQuery = theTestQuery;
               itsTestIndexName = theTestIndexName;
  @@ -242,103 +220,97 @@
               itsExpectedResourceCount = theExpectedResourceCount;
               itsExpectedResources = theExpectedResources;
           }
  -        
  +
           /**
            * Runs the test. If any test failure occurs, a JUnit exception is 
thrown.
            */
  -        public void runTest() throws Exception
  -        {
  -            try
  -            {
  +        public void runTest() throws Exception {
  +            try {
  +                Result aResult;
                   addTestDocuments();
  -                Result aResult = runNonIndexed();
  +
  +                aResult = runNonIndexed();
                   checkResult(aResult);
                   long aNonIndexedTime = aResult.getElapsedTime();
                   aResult = runIndexed();
  +                checkResult(aResult);
                   long anIndexedTime = aResult.getElapsedTime();
  -                itsLog.info(itsDescription + ": Non-indexed time = " + 
aNonIndexedTime + "  Indexed time = " + anIndexedTime +
  -                    "  Index speedup:" +
  -                    (anIndexedTime > 0 ? " " + aNonIndexedTime/anIndexedTime 
+ "X" :
  -                        anIndexedTime == 0 ? " >" + aNonIndexedTime + "X" : 
" (Indexed query not run)"));
  -                if(anIndexedTime * itsIndexSpeedupFactor > aNonIndexedTime) {
  +                itsLog.info(itsDescription +
  +                            ": Non-indexed time = " + aNonIndexedTime +
  +                            "  Indexed time = " + anIndexedTime +
  +                            "  Index speedup:" + (anIndexedTime > 0 ? " " + 
aNonIndexedTime / anIndexedTime + "X" :
  +                            anIndexedTime == 0 ? " >" + aNonIndexedTime + 
"X" : " (Indexed query not run)"));
  +                if (anIndexedTime * itsIndexSpeedupFactor > aNonIndexedTime) 
{
                       fail("Query apparently did not use index" +
  -                    " Non-indexed time = " + aNonIndexedTime + " Indexed 
time = " + anIndexedTime);
  +                         " Non-indexed time = " + aNonIndexedTime + " 
Indexed time = " + anIndexedTime);
                   }
  -            }
  -            finally
  -            {
  +            } finally {
                   removeTestDocuments();
                   dropIndex();
               }
           }
  -        
  +
           /**
            * Runs the test query without an index.
            *
            * @return a Result containing the query result (ResourceSet) and 
elapsed time
            */
  -        public Result runNonIndexed() throws Exception
  -        {
  -            runIndexed();
  +        public Result runNonIndexed() throws Exception {
               return runQuery();
           }
  -        
  +
           /**
            * Runs the test query with an index.
            *
            * @return a Result containing the query result (ResourceSet) and 
elapsed time
            */
  -        public Result runIndexed() throws Exception
  -        {
  +        public Result runIndexed() throws Exception {
               createIndex();
  -            Result aResult = runQuery();
  -            dropIndex();
  -            return aResult;
  +            try {
  +                return runQuery();
  +            } finally {
  +                dropIndex();
  +            }
           }
  -        
  +
           /**
            * Runs the test query.
            *
            * @return a Result containing the query result (ResourceSet) and 
elapsed time
            */
  -        public Result runQuery() throws Exception
  -        {
  +        public Result runQuery() throws Exception {
               Collection col = 
IndexedSearchTest.this.client.getCollection(IndexedSearchTest.INDEXED_SEARCH_TEST_COLLECTION_PATH);
               XPathQueryService xpathservice = (XPathQueryService) 
col.getService("XPathQueryService", "1.0");
  -          
  +
               org.apache.xindice.Stopwatch aStopwatch = new 
org.apache.xindice.Stopwatch("Non-indexed starts-with query", true);
               ResourceSet resultSet = xpathservice.query(itsTestQuery);
               aStopwatch.stop();
  -            return new Result(resultSet, aStopwatch.elapsed());           
  +            return new Result(resultSet, aStopwatch.elapsed());
           }
  -        
  +
           /**
            * Checks the result of a test. Throws an assertion exception
            * if any check fails.
            *
            * @param theResult Result to check
            */
  -        public void checkResult(Result theResult) throws Exception
  -        {
  +        public void checkResult(Result theResult) throws Exception {
               assertNotNull("Parameter theResult is null", theResult);
               ResourceSet aResourceSet = theResult.getResourceSet();
               assertNotNull("theResult contains a null ResourceSet", 
aResourceSet);
  -            if(itsExpectedResourceCount >= 0)
  -            {
  +            if (itsExpectedResourceCount >= 0) {
                   assertEquals("Result did not contain expected number of 
resources",
  -                    itsExpectedResourceCount, aResourceSet.getSize());
  +                             itsExpectedResourceCount, 
aResourceSet.getSize());
               }
  -            
  -            if(itsExpectedResources != null && itsExpectedResources.length > 
1)
  -            {
  -                for(int anIndex = 0; anIndex < itsExpectedResources.length / 
2; anIndex += 2)
  -                {
  +
  +            if (itsExpectedResources != null && itsExpectedResources.length 
> 1) {
  +                for (int anIndex = 0; anIndex < itsExpectedResources.length 
/ 2; anIndex += 2) {
                       XMLResource aResource = (XMLResource) 
aResourceSet.getResource(anIndex);
                       Node aNode = aResource.getContentAsDOM();
  -                    int anExpectedSourceDocumentIndex = 
((Integer)itsExpectedResources[anIndex]).intValue();
  -                    String anExpected = "<?xml version=\"1.0\"?>\n" + 
addSource((String)itsExpectedResources[anIndex + 1],
  -                        TEST_DOCUMENT_PREFIX + anIndex,
  -                        
IndexedSearchTest.INDEXED_SEARCH_TEST_COLLECTION_PATH);
  +                    int anExpectedSourceDocumentIndex = ((Integer) 
itsExpectedResources[anIndex]).intValue();
  +                    String anExpected = "<?xml version=\"1.0\"?>\n" + 
addSource((String) itsExpectedResources[anIndex + 1],
  +                                                                             
   TEST_DOCUMENT_PREFIX + anIndex,
  +                                                                             
   IndexedSearchTest.INDEXED_SEARCH_TEST_COLLECTION_PATH);
                       String anActual = TextWriter.toString(aNode);
                       //itsLog.info(itsDescription);
                       //itsLog.info("Expected resource " + (anIndex / 2) + 
":");
  @@ -347,34 +319,32 @@
                       //itsLog.info("Actual:");
                       //itsLog.info(anActual);
                       XMLAssert.assertXMLEqual("While checking target Resource 
" + anIndex / 2,
  -                        anExpected, anActual);
  +                                             anExpected, anActual);
                   }
               }
           }
  -        
  +
           /**
            * Adds the xindice source document/collection information to the
            * root of the specified XML and rreturns the XML as a string.
            *
            * @param theXML XML to add source to
            * @param theKey document key to add
  -         * @param theCollection source collection to add
  +         * @param theCollectionName source collection to add
            */
  -        public String addSource(String theXML, String theKey, String 
theCollectionName) throws Exception
  -        {
  +        public String addSource(String theXML, String theKey, String 
theCollectionName) throws Exception {
               DocumentBuilder aBuilder = 
itsDocumentBuilderFactory.newDocumentBuilder();
               Document aDocument = aBuilder.parse(
  -                new InputSource(new StringReader(theXML)));
  +                    new InputSource(new StringReader(theXML)));
               Element aRootElement = aDocument.getDocumentElement();
               org.xmldb.api.base.Collection aCollection = 
IndexedSearchTest.this.client.getCollection(
  -                theCollectionName);
  +                    theCollectionName);
   
               final String aPrefix = "src";
  -
               
aRootElement.setAttribute(org.apache.xindice.xml.dom.NodeImpl.XMLNS_PREFIX + 
":" + aPrefix,
  -                org.apache.xindice.xml.NodeSource.SOURCE_NS);
  +                                      
org.apache.xindice.xml.NodeSource.SOURCE_NS);
               aRootElement.setAttribute(aPrefix + ":" + 
org.apache.xindice.xml.NodeSource.SOURCE_COL,
  -                "/" + INDEXED_SEARCH_TEST_COLLECTION_PATH);
  +                                      "/" + 
INDEXED_SEARCH_TEST_COLLECTION_PATH);
               aRootElement.setAttribute(aPrefix + ":" + 
org.apache.xindice.xml.NodeSource.SOURCE_KEY, theKey);
               return TextWriter.toString(aRootElement);
           }
  @@ -382,46 +352,39 @@
           /**
            * Creates the index used by this test.
            */
  -        public void createIndex() throws Exception
  -        {
  -            if(!itsIndexCreated)
  -            {
  +        public void createIndex() throws Exception {
  +            if (!itsIndexCreated) {
                   
IndexedSearchTest.this.client.createIndexer(INDEXED_SEARCH_TEST_COLLECTION_PATH,
 itsTestIndexName,
  -                "<?xml version='1.0'?><index name='" + itsTestIndexName + "' 
" +
  -                "class='org.apache.xindice.core.indexer." + itsTestIndexType 
+ "Indexer' " +
  -                "pattern='" + itsTestIndexPattern + "' />");
  +                                                            "<?xml 
version='1.0'?><index name='" + itsTestIndexName + "' " +
  +                                                            
"class='org.apache.xindice.core.indexer." + itsTestIndexType + "Indexer' " +
  +                                                            "pattern='" + 
itsTestIndexPattern + "' />");
                   itsIndexCreated = true;
  -            
  -                // wait for the indexer to do the background indexing
  -                Thread.sleep(1000);
  +
  +                // Wait for the indexer to do the background indexing
  +                Thread.sleep(1250);
               }
           }
  -        
  +
           /**
            * Drops the index used by this test.
            */
  -        public void dropIndex() throws Exception
  -        {
  -            if(itsIndexCreated)
  -            {
  +        public void dropIndex() throws Exception {
  +            if (itsIndexCreated) {
                   
IndexedSearchTest.this.client.dropIndexer(INDEXED_SEARCH_TEST_COLLECTION_PATH, 
itsTestIndexName);
                   itsIndexCreated = false;
               }
           }
  -        
  +
           /**
            * Adds all test-specific documents supplied for this test to the 
test collection.
            */
  -        public void addTestDocuments() throws Exception
  -        {
  -            if(!itsTestDocumentsAdded && itsTestDocuments != null)
  -            {
  -                for(int anIndex = 0; anIndex < itsTestDocuments.length; 
++anIndex)
  -                {
  +        public void addTestDocuments() throws Exception {
  +            if (!itsTestDocumentsAdded && itsTestDocuments != null) {
  +                for (int anIndex = 0; anIndex < itsTestDocuments.length; 
++anIndex) {
                       String aDocumentName = TEST_DOCUMENT_PREFIX + anIndex;
                       IndexedSearchTest.this.client.insertDocument(
  -                        INDEXED_SEARCH_TEST_COLLECTION_PATH,
  -                        aDocumentName, itsTestDocuments[anIndex]);
  +                            INDEXED_SEARCH_TEST_COLLECTION_PATH,
  +                            aDocumentName, itsTestDocuments[anIndex]);
                   }
                   itsTestDocumentsAdded = true;
               }
  @@ -430,24 +393,19 @@
           /**
            * Removes all test-specific documents supplied for this test from 
the test collection.
            */
  -        public void removeTestDocuments() throws Exception
  -        {
  -            if(itsTestDocumentsAdded && itsTestDocuments != null)
  -            {
  -                for(int anIndex = 0; anIndex < itsTestDocuments.length; 
++anIndex)
  -                {
  +        public void removeTestDocuments() throws Exception {
  +            if (itsTestDocumentsAdded && itsTestDocuments != null) {
  +                for (int anIndex = 0; anIndex < itsTestDocuments.length; 
++anIndex) {
                       String aDocumentName = TEST_DOCUMENT_PREFIX + anIndex;
                       IndexedSearchTest.this.client.removeDocument(
  -                        INDEXED_SEARCH_TEST_COLLECTION_PATH,
  -                        aDocumentName);
  +                            INDEXED_SEARCH_TEST_COLLECTION_PATH,
  +                            aDocumentName);
                   }
                   itsTestDocumentsAdded = false;
               }
           }
  -
  -
       }
  -    
  +
       /**
        * Tests the functionality of indexed searches on a Collection
        * with a name index that has a pattern specifying a specific Element
  @@ -455,34 +413,34 @@
        */
       public void testSpecificElementNoAttributeNameIndexer() throws Exception 
{
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testSpecificElementNoAttributeNameIndexer",  // description
  -            "/person/address",          // query
  -            "SENA",                     // index name
  -            "Name",                     // index type
  -            "address",                  // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  +                "testSpecificElementNoAttributeNameIndexer", // description
  +                "/person/address",        // query
  +                "SENA",                   // index name
  +                "Name",                   // index type
  +                "address",                // index pattern
  +                8,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                1,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1),
                       "<address> " +
                           "<street>" +
  -                            "<number given='no' />"+
  +                            "<number given='no' />" +
                           "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            1,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1),
  -                "<address> " +
  -                    "<street>" +
  -                        "<number given='no' />"+
  -                    "</street>" +
  -                "</address>"
  -            } );
  +                    "</address>"
  +                });
   
           aTest.runTest();
       }
  @@ -494,35 +452,35 @@
        */
       public void testSpecificElementNoAttributeNameIndexer2() throws 
Exception {
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testSpecificElementNoAttributeNameIndexer2",  // description
  -            "/person/[EMAIL PROTECTED]",    // query
  -            "SENA",                     // index name
  -            "Name",                     // index type
  -            "second",                    // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<second surname='no' given='yes'>Wally</second>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            1,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1),
  -                "<second surname='no' given='yes'>Wally</second>"
  -            } );
  -                
  +                "testSpecificElementNoAttributeNameIndexer2", // description
  +                "/person/[EMAIL PROTECTED]", // query
  +                "SENA",                   // index name
  +                "Name",                   // index type
  +                "second",                 // index pattern
  +                10,                       // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<second surname='no' given='yes'>Wally</second>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                1,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1),
  +                    "<second surname='no' given='yes'>Wally</second>"
  +                });
  +
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests the functionality of indexed searches on a Collection
        * with a name index that has a pattern specifying both an Element
  @@ -531,34 +489,34 @@
       public void testSpecificElementSpecificAttributeNameIndexer() throws 
Exception {
           // select all phone records having a call attribute
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testSpecificElementSpecificAttributeNameIndexer",  // 
description
  -            "/person/[EMAIL PROTECTED]",     // query
  -            "SESA",                     // index name
  -            "Name",                     // index type
  -            "[EMAIL PROTECTED]",               // index pattern
  -            8,                          // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            1,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1),
  -                "<phone call='no' type='work'>555-345-6789</phone>"
  -            } );
  -                
  +                "testSpecificElementSpecificAttributeNameIndexer", // 
description
  +                "/person/[EMAIL PROTECTED]",   // query
  +                "SESA",                   // index name
  +                "Name",                   // index type
  +                "[EMAIL PROTECTED]",             // index pattern
  +                8,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                1,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1),
  +                    "<phone call='no' type='work'>555-345-6789</phone>"
  +                });
  +
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests the functionality of indexed searches on a Collection
        * with a name index that has a pattern specifying a specific Element
  @@ -567,35 +525,35 @@
       public void testSpecificElementWildAttributeNameIndexer() throws 
Exception {
           // select resources having a "first" element containing a "surname" 
attribute that is a child of a "person" element
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testSpecificElementWildAttributeNameIndexer",  // description
  -            "/person/[EMAIL PROTECTED]",  // query
  -            "SEWA",                     // index name
  -            "Name",                     // index type
  -            "[EMAIL PROTECTED]",                    // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<second surname='no' given='yes'>Wally</second>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            1,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1),
  +                "testSpecificElementWildAttributeNameIndexer", // description
  +                "/person/[EMAIL PROTECTED]", // query
  +                "SEWA",                   // index name
  +                "Name",                   // index type
  +                "[EMAIL PROTECTED]",               // index pattern
  +                10,                       // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<second surname='no' given='yes'>Wally</second>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                1,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1),
                       "<second surname='no' given='yes'>Wally</second>",
  -            } );
  -                
  +                });
  +
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests the functionality of indexed searches on a Collection
        * with a name index that has a pattern specifying a wildcard Element
  @@ -604,42 +562,41 @@
       public void testWildElementSpecificAttributeNameIndexer() throws 
Exception {
           // select resources having any element containing a "surname" 
attribute that is a child of a "person" element
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testWildElementSpecificAttributeNameIndexer",  // description
  -            "//[EMAIL PROTECTED]",               // query
  -            "WESA",                     // index name
  -            "Name",                     // index type
  -            "[EMAIL PROTECTED]",                  // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  +                "testWildElementSpecificAttributeNameIndexer", // description
  +                "//[EMAIL PROTECTED]",            // query
  +                "WESA",                   // index name
  +                "Name",                   // index type
  +                "[EMAIL PROTECTED]",                // index pattern
  +                10,                       // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                2,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1),
  +                    "<first surname='no' given='yes'>Sally</first>",
  +
  +                    new Integer(1),
                       "<address> " +
                           "<street>" +
  -                            "<number given='no' />"+
  +                            "<number given='no' />" +
                           "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            2,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                
  -                new Integer(1),
  -                "<first surname='no' given='yes'>Sally</first>",
  -                
  -                new Integer(1),
  -                "<address> " +
  -                    "<street>" +
  -                        "<number given='no' />"+
  -                    "</street>" +
  -                "</address>"
  -            } );
  -                
  +                    "</address>"
  +                });
  +
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests the functionality of indexed searches on a Collection
        * with a name index that has a pattern specifying a wildcard Element
  @@ -649,137 +606,133 @@
       public void testWildElementWildAttributeNameIndexer() throws Exception {
           // select nodes with an attribute named 'given'
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testWildElementWildAttributeNameIndexer",  // description
  -            "//[EMAIL PROTECTED]",              // query
  -            "WEWA",                     // index name
  -            "Name",                     // index type
  -            "[EMAIL PROTECTED]",                      // index pattern
  -            0,                          // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            2,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1), "<first surname='no' 
given='yes'>Sally</first>",
  -                new Integer(1), "<number given='no' />"
  -            } );
  -                
  +                "testWildElementWildAttributeNameIndexer", // description
  +                "//[EMAIL PROTECTED]",            // query
  +                "WEWA",                   // index name
  +                "Name",                   // index type
  +                "[EMAIL PROTECTED]",                    // index pattern
  +                0,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                2,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1), "<first surname='no' 
given='yes'>Sally</first>",
  +                    new Integer(1), "<number given='no' />"
  +                });
  +
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests a starts-with search query for an Element value that should be 
resolvable using indexed searching
        * on a value index. (index pattern like "last")
        */
       public void testSpecificElementNoAttributeValueIndexedStartsWithSearch()
  -        throws Exception {
  +            throws Exception {
           // search all records whose last name begins with 'Smi'
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testSpecificElementNoAttributeValueIndexedStartsWithSearch",  
// description
  -            "//person[starts-with(last, 'Smi')]",               // query
  -            "SENA",                     // index name
  -            "Value",                    // index type
  -            "last",                     // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>Smith</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>",
  -                
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>Smithers</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -
  -            },
  -            2,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1), "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>Smith</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>",
  -
  -                new Integer(2), "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>Smithers</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  +                
"testSpecificElementNoAttributeValueIndexedStartsWithSearch", // description
  +                "//person[starts-with(last, 'Smi')]", // query
  +                "SENA",                   // index name
  +                "Value",                  // index type
  +                "last",                   // index pattern
  +                8,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>Smith</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>",
  +
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>Smithers</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                2,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1), "<person number3='yes'>" +
  +                                        "<first surname='no' 
given='yes'>Sally</first>" +
  +                                        "<last surname='yes'>Smith</last>" +
  +                                        "<phone call='no' 
type='work'>555-345-6789</phone>" +
  +                                        "<address> " +
  +                                            "<street>" +
  +                                                "<number given='no' />" +
  +                                            "</street>" +
  +                                        "</address>" +
  +                                    "</person>",
  +
  +                    new Integer(2), "<person number3='yes'>" +
  +                                        "<first surname='no' 
given='yes'>Sally</first>" +
  +                                        "<last 
surname='yes'>Smithers</last>" +
  +                                        "<phone call='no' 
type='work'>555-345-6789</phone>" +
  +                                        "<address> " +
  +                                            "<street>" +
  +                                                "<number given='no' />" +
  +                                            "</street>" +
  +                                        "</address>" +
  +                                    "</person>"
  +                });
   
  -            } );
  -                
           aTest.runTest();
       }
  -    
  +
       /**
        * Tests a starts-with search query for an attribute value that should 
be resolvable using indexed searching
        * on a value index. (index pattern like "[EMAIL PROTECTED]")
        */
       public void 
testSpecificElementSpecificAttributeValueIndexedStartsWithSearch()
  -        throws Exception {
  +            throws Exception {
           // search all records whose last name begins with 'Smi'
  -        String query = "//phone[starts-with(@call, 'n')]";
  -            
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            
"testSpecificElementSpecificAttributeValueIndexedStartsWithSearch",  // 
description
  -            "//phone[starts-with(@call, 'n')]",               // query
  -            "SESA",                     // index name
  -            "Value",                    // index type
  -            "[EMAIL PROTECTED]",               // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            1,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1), "<phone call='no' 
type='work'>555-345-6789</phone>"
  -            } );
  -                
  +                
"testSpecificElementSpecificAttributeValueIndexedStartsWithSearch", // 
description
  +                "//phone[starts-with(@call, 'n')]", // query
  +                "SESA",                   // index name
  +                "Value",                  // index type
  +                "[EMAIL PROTECTED]",             // index pattern
  +                8,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                1,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1), "<phone call='no' 
type='work'>555-345-6789</phone>"
  +                });
  +
           aTest.runTest();
       }
   
  @@ -788,46 +741,46 @@
        * on a value index. (index pattern like "[EMAIL PROTECTED]")
        */
       public void 
testWildElementSpecificAttributeValueIndexedStartsWithSearch()
  -        throws Exception {
  +            throws Exception {
           // search all records whose last name begins with 'Smi'
           IndexerTestDefinition aTest = new IndexerTestDefinition(
  -            "testWildElementSpecificAttributeValueIndexedStartsWithSearch",  
// description
  -            "//phone[starts-with(@call, 'n')]",               // query
  -            "SENA",                     // index name
  -            "Value",                     // index type
  -            "[EMAIL PROTECTED]",                    // index pattern
  -            10,                         // indexed query speedup expected 
(conservative)
  -            new String[] {              // test docs specifically for this 
test
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>555-345-6789</phone>" +
  -                    "<address call='no'> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>",
  +                
"testWildElementSpecificAttributeValueIndexedStartsWithSearch", // description
  +                "//phone[starts-with(@call, 'n')]", // query
  +                "SENA",                   // index name
  +                "Value",                  // index type
  +                "[EMAIL PROTECTED]",                 // index pattern
  +                7,                        // indexed query speedup expected 
(conservative)
  +                new String[] {            // test docs specifically for this 
test
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>555-345-6789</phone>" +
  +                        "<address call='no'> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>",
  +
  +                    "<?xml version='1.0'?>" +
  +                    "<person number3='yes'>" +
  +                        "<first surname='no' given='yes'>Sally</first>" +
  +                        "<last surname='yes'>aSm</last>" +
  +                        "<phone call='no' type='work'>525-345-6789</phone>" +
  +                        "<address call='no'> " +
  +                            "<street>" +
  +                                "<number given='no' />" +
  +                            "</street>" +
  +                        "</address>" +
  +                    "</person>"
  +                },
  +                2,                        // expected result count
  +                new Object[] {            // expected resources to check for 
(can be empty or partial set)
  +                    new Integer(1), "<phone call='no' 
type='work'>555-345-6789</phone>",
  +                    new Integer(1), "<phone call='no' 
type='work'>525-345-6789</phone>"
  +                });
   
  -                "<?xml version='1.0'?>" +
  -                "<person number3='yes'>" +
  -                    "<first surname='no' given='yes'>Sally</first>" +
  -                    "<last surname='yes'>aSm</last>" +
  -                    "<phone call='no' type='work'>525-345-6789</phone>" +
  -                    "<address call='no'> " +
  -                        "<street>" +
  -                            "<number given='no' />"+
  -                        "</street>" +
  -                    "</address>" +
  -                "</person>"
  -            },
  -            2,                          // expected result count
  -            new Object[] {              // expected resources to check for 
(can be empty or partial set)
  -                new Integer(1), "<phone call='no' 
type='work'>555-345-6789</phone>",
  -                new Integer(1), "<phone call='no' 
type='work'>525-345-6789</phone>"
  -            } );
  -                
           aTest.runTest();
       }
   }
  
  
  

Reply via email to