lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r416475 - in /lucene/java/trunk/src/test/org/apache/lucene/index: DocHelper.java TestFieldsReader.java TestParallelReader.java TestSegmentReader.java
Date Thu, 22 Jun 2006 21:12:08 GMT
Author: dnaber
Date: Thu Jun 22 14:12:07 2006
New Revision: 416475

URL: http://svn.apache.org/viewvc?rev=416475&view=rev
Log:
use the new non-deprecated getFields() method, clean up some imports

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java?rev=416475&r1=416474&r2=416475&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java Thu Jun 22 14:12:07
2006
@@ -16,17 +16,18 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-import org.apache.lucene.document.*;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.store.Directory;
-
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Enumeration;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.search.Similarity;
+import org.apache.lucene.store.Directory;
 
 class DocHelper {
   public static final String FIELD_1_TEXT = "field one text";
@@ -257,13 +258,6 @@
   }
 
   public static int numFields(Document doc) {
-    Enumeration fields = doc.fields();
-    int result = 0;
-    while (fields.hasMoreElements()) {
-      String name = fields.nextElement().toString();
-      name += "";   // avoid compiler warning
-      result++;
-    }
-    return result;
+    return doc.getFields().size();
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=416475&r1=416474&r2=416475&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java Thu Jun 22 14:12:07
2006
@@ -16,19 +16,25 @@
  * limitations under the License.
  */
 
-import junit.framework.TestCase;
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-import org.apache.lucene.document.*;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.store.FSDirectory;
-import org.apache.lucene.store.RAMDirectory;
-
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
-import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.document.LoadFirstFieldSelector;
+import org.apache.lucene.document.SetBasedFieldSelector;
+import org.apache.lucene.search.Similarity;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.RAMDirectory;
 
 public class TestFieldsReader extends TestCase {
   private RAMDirectory dir = new RAMDirectory();
@@ -137,9 +143,9 @@
     Document doc = reader.doc(0, fieldSelector);
     assertTrue("doc is null and it shouldn't be", doc != null);
     int count = 0;
-    Enumeration enumeration = doc.fields();
-    while (enumeration.hasMoreElements()) {
-      Field field = (Field) enumeration.nextElement();
+    List l = doc.getFields();
+    for (Iterator iter = l.iterator(); iter.hasNext();) {
+      Field field = (Field) iter.next();
       assertTrue("field is null and it shouldn't be", field != null);
       String sv = field.stringValue();
       assertTrue("sv is null and it shouldn't be", sv != null);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java?rev=416475&r1=416474&r2=416475&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java Thu Jun 22
14:12:07 2006
@@ -16,26 +16,26 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
 import junit.framework.TestCase;
+
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.MapFieldSelector;
-import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;  
+import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-
 public class TestParallelReader extends TestCase {
 
   private Searcher parallel;
@@ -87,22 +87,14 @@
     Document doc24 = pr.document(1, new MapFieldSelector(Arrays.asList(new String[] {"f4"})));
     Document doc223 = pr.document(1, new MapFieldSelector(new String[] {"f2", "f3"}));
     
-    assertEquals(1, numFields(doc11));
-    assertEquals(1, numFields(doc24));
-    assertEquals(2, numFields(doc223));
+    assertEquals(1, doc11.getFields().size());
+    assertEquals(1, doc24.getFields().size());
+    assertEquals(2, doc223.getFields().size());
     
     assertEquals("v1", doc11.get("f1"));
     assertEquals("v2", doc24.get("f4"));
     assertEquals("v2", doc223.get("f2"));
     assertEquals("v2", doc223.get("f3"));
-  }
-  
-  private int numFields(Document doc) {
-    int num;
-    Enumeration e = doc.fields();
-    for (num=0; e.hasMoreElements(); num++)
-      e.nextElement();
-    return num;
   }
   
   public void testIncompatibleIndexes() throws IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=416475&r1=416474&r2=416475&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java Thu Jun 22 14:12:07
2006
@@ -16,16 +16,17 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
 import junit.framework.TestCase;
-import org.apache.lucene.store.RAMDirectory;
+
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.search.DefaultSimilarity;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Enumeration;
+import org.apache.lucene.store.RAMDirectory;
 
 public class TestSegmentReader extends TestCase {
   private RAMDirectory dir = new RAMDirectory();
@@ -62,9 +63,9 @@
     //There are 2 unstored fields on the document that are not preserved across writing
     assertTrue(DocHelper.numFields(result) == DocHelper.numFields(testDoc) - DocHelper.unstored.size());
     
-    Enumeration fields = result.fields();
-    while (fields.hasMoreElements()) {
-      Fieldable field = (Fieldable) fields.nextElement();
+    List fields = result.getFields();
+    for (Iterator iter = fields.iterator(); iter.hasNext();) {
+      Fieldable field = (Fieldable) iter.next();
       assertTrue(field != null);
       assertTrue(DocHelper.nameValues.containsKey(field.name()));
     }



Mime
View raw message