lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/index TestIndexWriter.java
Date Mon, 15 Sep 2003 12:33:07 GMT
otis        2003/09/15 05:33:07

  Modified:    src/test/org/apache/lucene/index TestIndexWriter.java
  Log:
  - Applied a patch from Christoph Goller.
  - Unified a mix of 2 and 4-space indentations.
  
  Revision  Changes    Path
  1.2       +38 -30    jakarta-lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
  
  Index: TestIndexWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TestIndexWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestIndexWriter.java	10 Sep 2003 12:58:37 -0000	1.1
  +++ TestIndexWriter.java	15 Sep 2003 12:33:07 -0000	1.2
  @@ -14,13 +14,11 @@
   
   
   /**
  - *
    * @author goller
  + * @version $Id$
    */
   public class TestIndexWriter extends TestCase
   {
  -    private int docCount = 0;
  -
       public void testDocCount()
       {
           Directory dir = new RAMDirectory();
  @@ -30,46 +28,56 @@
           int i;
   
           try {
  -          writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
  +            writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
   
  -          // add 100 documents
  -          for (i = 0; i < 100; i++) {
  -              addDoc(writer);
  -          }
  -          assertEquals(100, writer.docCount());
  -          writer.close();
  -
  -          // delete 50 documents
  -          reader = IndexReader.open(dir);
  -          for (i = 0; i < 50; i++) {
  -              reader.delete(i);
  -          }
  -          reader.close();
  -
  -          writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
  -          assertEquals(50, writer.docCount());
  -          writer.optimize();
  -          assertEquals(50, writer.docCount());
  -          writer.close();
  +            // add 100 documents
  +            for (i = 0; i < 100; i++) {
  +                addDoc(writer);
  +            }
  +            assertEquals(100, writer.docCount());
  +            writer.close();
  +
  +            // delete 50 documents
  +            reader = IndexReader.open(dir);
  +            for (i = 0; i < 50; i++) {
  +                reader.delete(i);
  +            }
  +            reader.close();
  +
  +            writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
  +            assertEquals(100, writer.docCount());
  +            writer.close();
  +
  +            reader = IndexReader.open(dir);
  +            assertEquals(100, reader.maxDoc());
  +            assertEquals(50, reader.numDocs());
  +            reader.close();
  +
  +            writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
  +            writer.optimize();
  +            assertEquals(50, writer.docCount());
  +            writer.close();
  +
  +            reader = IndexReader.open(dir);
  +            assertEquals(50, reader.maxDoc());
  +            assertEquals(50, reader.numDocs());
  +            reader.close();
           }
           catch (IOException e) {
  -          e.printStackTrace();
  +            e.printStackTrace();
           }
       }
   
       private void addDoc(IndexWriter writer)
       {
           Document doc = new Document();
  -
  -        doc.add(Field.Keyword("id","id" + docCount));
  -        doc.add(Field.UnStored("content","aaa"));
  +        doc.add(Field.UnStored("content", "aaa"));
   
           try {
  -          writer.addDocument(doc);
  +            writer.addDocument(doc);
           }
           catch (IOException e) {
  -          e.printStackTrace();
  +            e.printStackTrace();
           }
  -        docCount++;
       }
   }
  
  
  

Mime
View raw message