You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ot...@apache.org on 2003/05/01 03:12:10 UTC
cvs commit: jakarta-lucene/src/test/org/apache/lucene/index TestIndexReader.java
otis 2003/04/30 18:12:10
Modified: src/test/org/apache/lucene/index TestIndexReader.java
Log:
- Added tests for getFieldNames(boolean) method in IndexReader.
Revision Changes Path
1.2 +18 -5 jakarta-lucene/src/test/org/apache/lucene/index/TestIndexReader.java
Index: TestIndexReader.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TestIndexReader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestIndexReader.java 4 Jan 2003 17:13:40 -0000 1.1
+++ TestIndexReader.java 1 May 2003 01:12:10 -0000 1.2
@@ -12,8 +12,8 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
- * reserved.
+ * Copyright (c) 2001, 2002, 2003 The Apache Software Foundation.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -86,12 +86,12 @@
// add more documents
writer = new IndexWriter(d, new StandardAnalyzer(), false);
// want to get some more segments here
- for (int i=0;i<5*writer.mergeFactor;i++)
+ for (int i = 0; i < 5*writer.mergeFactor; i++)
{
addDocumentWithFields(writer);
}
// new fields are in some different segments (we hope)
- for (int i=0;i<5*writer.mergeFactor;i++)
+ for (int i = 0; i < 5*writer.mergeFactor; i++)
{
addDocumentWithDifferentFields(writer);
}
@@ -107,6 +107,20 @@
assertTrue(fieldNames.contains("text2"));
assertTrue(fieldNames.contains("unindexed2"));
assertTrue(fieldNames.contains("unstored2"));
+
+ // verify that only indexed fields were returned
+ Collection indexedFieldNames = reader.getFieldNames(true);
+ assertTrue(fieldNames.contains("keyword"));
+ assertTrue(fieldNames.contains("text"));
+ assertTrue(fieldNames.contains("unstored"));
+ assertTrue(fieldNames.contains("keyword2"));
+ assertTrue(fieldNames.contains("text2"));
+ assertTrue(fieldNames.contains("unindexed2"));
+ assertTrue(fieldNames.contains("unstored2"));
+
+ // verify that only unindexed fields were returned
+ Collection unindexedFieldNames = reader.getFieldNames(false);
+ assertTrue(fieldNames.contains("unindexed"));
}
private void addDocumentWithFields(IndexWriter writer) throws IOException
@@ -129,4 +143,3 @@
writer.addDocument(doc);
}
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org