Author: natalia
Date: Tue Jul 24 18:26:38 2007
New Revision: 559271

URL: http://svn.apache.org/viewvc?view=rev&rev=559271
Log:
Additional tests for empty elements/attributes

Modified:
    
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/indexer/ValueIndexerTest.java

Modified: 
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/indexer/ValueIndexerTest.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/core/indexer/ValueIndexerTest.java?view=diff&rev=559271&r1=559270&r2=559271
==============================================================================
--- 
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/indexer/ValueIndexerTest.java
 (original)
+++ 
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/indexer/ValueIndexerTest.java
 Tue Jul 24 18:26:38 2007
@@ -94,11 +94,49 @@
         document = DOMParser.toDocument("<test value='aac'/>");
         collection.insertDocument("key", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "ab", 
IndexQuery.SW);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "ab", 
IndexQuery.SW);
 
         assertEquals(2, match.length);
     }
 
+    public void testElementEmptyStringIndex() throws Exception {
+        Indexer ind = createIndex("StrIndex", "test", "string");
+
+        Document document = DOMParser.toDocument("<test value=''>text</test>");
+        collection.insertDocument("key1", document);
+
+        document = DOMParser.toDocument("<test value='abe'/>");
+        collection.insertDocument("key2", document);
+
+        document = DOMParser.toDocument("<test value='bcd'/>");
+        collection.insertDocument("key3", document);
+
+        document = DOMParser.toDocument("<test value='aac'/>");
+        collection.insertDocument("key4", document);
+
+        IndexMatch[] match = query(ind, "test", "", IndexQuery.EQ);
+        assertEquals(3, match.length);
+    }
+
+    public void testAttributeEmptyStringIndex() throws Exception {
+        Indexer ind = createIndex("StrIndex", "[EMAIL PROTECTED]", "string");
+
+        Document document = DOMParser.toDocument("<test value=''>text</test>");
+        collection.insertDocument("key1", document);
+
+        document = DOMParser.toDocument("<test value='abe'/>");
+        collection.insertDocument("key2", document);
+
+        document = DOMParser.toDocument("<test value='bcd'/>");
+        collection.insertDocument("key3", document);
+
+        document = DOMParser.toDocument("<test value='aac'/>");
+        collection.insertDocument("key4", document);
+
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "", 
IndexQuery.EQ);
+        assertEquals(1, match.length);
+    }
+
     public void testLongIntIndex() throws Exception {
         Indexer ind = createIndex("IntIndex", "[EMAIL PROTECTED]", "long");
 
@@ -111,7 +149,7 @@
         document = DOMParser.toDocument("<test value='-1050687000291'/>");
         collection.insertDocument("key3", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "1049903940000", 
IndexQuery.GT);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "1049903940000", 
IndexQuery.GT);
 
         assertEquals(1, match.length);
     }
@@ -143,7 +181,7 @@
         document = DOMParser.toDocument("<test value='" + 
Double.POSITIVE_INFINITY + "'/>");
         collection.insertDocument("key8", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "71.48941", 
IndexQuery.LT);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "71.48941", 
IndexQuery.LT);
         assertEquals(6, match.length);
 
         match = query(ind, "[EMAIL PROTECTED]", "-211.499539", IndexQuery.LT);
@@ -159,7 +197,7 @@
         document = DOMParser.toDocument("<test value='-112'/>");
         collection.insertDocument("key2", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "-112", 
IndexQuery.GT);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "-112", 
IndexQuery.GT);
 
         assertEquals(1, match.length);
     }
@@ -173,7 +211,7 @@
         document = DOMParser.toDocument("<test value='\u00FF'/>");
         collection.insertDocument("key2", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "z", 
IndexQuery.EQ);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "z", 
IndexQuery.EQ);
 
         assertEquals(1, match.length);
     }
@@ -187,7 +225,7 @@
         document = DOMParser.toDocument("<test value='true'/>");
         collection.insertDocument("key2", document);
 
-        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "false", 
IndexQuery.EQ);
+        IndexMatch[] match = query(ind, "[EMAIL PROTECTED]", "false", 
IndexQuery.EQ);
 
         assertEquals(1, match.length);
     }


Reply via email to