Index: src/test/org/apache/lucene/index/TestRemoveFields.java
===================================================================
--- src/test/org/apache/lucene/index/TestRemoveFields.java	(revision 0)
+++ src/test/org/apache/lucene/index/TestRemoveFields.java	(revision 0)
@@ -0,0 +1,103 @@
+package org.apache.lucene.index;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Random;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.lucene.analysis.KeywordAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.FieldOption;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
+public class TestRemoveFields extends TestCase {
+
+  public static final String V1 = "v1";
+  public static final String F1 = "f1";
+  public static final String F2 = "f2";
+  public static final String F3 = "f3";
+
+  public TestRemoveFields (String name) {
+    super (name);
+  }
+
+  protected IndexWriter getWriter(Directory d) throws Exception {
+    IndexWriter writer = new IndexWriter (d, true, new KeywordAnalyzer());
+                                          
+    writer.setMaxBufferedDocs(2);
+    writer.setMergeFactor(100);
+    return writer;
+  }
+
+  public void testRemoveFields() throws Exception {
+    Random rand = new Random(32);
+    RAMDirectory dir = new RAMDirectory ();
+    
+    final int docCount = 1000;
+    IndexWriter w = getWriter(dir);
+
+    for (int i=0; i < docCount; ++i) {
+      Document doc = new Document();
+      doc.add(new Field (F1, V1, Field.Store.YES, Field.Index.TOKENIZED ));
+      doc.add(new Field (F2, "rand" + rand.nextInt(), 
+                         Field.Store.YES, Field.Index.TOKENIZED ));
+      doc.add(new Field (F3, "i" + i, Field.Store.YES, Field.Index.TOKENIZED ));
+                         
+      w.addDocument (doc);
+    }
+    w.close();
+    IndexReader r = IndexReader.open(dir);
+    assertEquals("wrong number of docs", docCount, r.numDocs());
+    assertEquals("wrong docFreq for for (F1,V1)", 1000,
+                 r.docFreq(new Term(F1, V1)));
+    assertEquals("wrong init field count", 3, 
+                 r.getFieldNames(FieldOption.ALL).size());
+    r.close();
+
+    w = getWriter(dir);
+    w.deleteDocuments(new Term(F1,V1));
+
+    w.optimize();
+    w.close(); 
+   
+    r = IndexReader.open(dir);
+    assertEquals("shouldn't be any matches for (F1,V1)", 0,
+                 r.docFreq(new Term(F1, V1)));
+
+    assertEquals("All docs should be gone", 0, r.numDocs());
+    assertEquals("should be no fields left", 0, 
+                 r.getFieldNames(FieldOption.ALL).size());
+
+
+
+  }
+
+}

Property changes on: src/test/org/apache/lucene/index/TestRemoveFields.java
___________________________________________________________________
Name: svn:keywords
   + Date Author Id Revision HeadURL
Name: svn:eol-style
   + native

