You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2012/11/21 20:45:09 UTC
svn commit: r1412252 -
/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
Author: shaie
Date: Wed Nov 21 19:45:08 2012
New Revision: 1412252
URL: http://svn.apache.org/viewvc?rev=1412252&view=rev
Log:
LUCENE-3441: add another test that reproduced a bug on a wrong assert
Modified:
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java?rev=1412252&r1=1412251&r2=1412252&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java Wed Nov 21 19:45:08 2012
@@ -289,6 +289,51 @@ public class TestDirectoryTaxonomyReader
}
@Test
+ public void testOpenIfChangedNoChangesButSegmentMerges() throws Exception {
+ // test openIfChanged() when the taxonomy hasn't really changed, but segments
+ // were merged. The NRT reader will be reopened, and ParentArray used to assert
+ // that the new reader contains more ordinals than were given from the old
+ // TaxReader version
+ Directory dir = newDirectory();
+
+ // hold onto IW to forceMerge
+ // note how we don't close it, since DTW will close it.
+ final IndexWriter iw = new IndexWriter(dir,
+ new IndexWriterConfig(TEST_VERSION_CURRENT, new KeywordAnalyzer())
+ .setMergePolicy(new LogByteSizeMergePolicy()));
+ DirectoryTaxonomyWriter writer = new DirectoryTaxonomyWriter(dir) {
+ @Override
+ protected IndexWriter openIndexWriter(Directory directory,
+ IndexWriterConfig config) throws IOException {
+ return iw;
+ }
+ };
+
+ // add a category so that the following DTR open will cause a flush and
+ // a new segment will be created
+ writer.addCategory(new CategoryPath("a"));
+
+ TaxonomyReader reader = new DirectoryTaxonomyReader(writer);
+ assertEquals(2, reader.getSize());
+ assertEquals(2, reader.getParentArray().length);
+
+ // merge all the segments so that NRT reader thinks there's a change
+ iw.forceMerge(1);
+
+ // now calling openIfChanged should trip on the wrong assert in ParetArray's ctor
+ TaxonomyReader newtr = TaxonomyReader.openIfChanged(reader);
+ assertNotNull(newtr);
+ reader.close();
+ reader = newtr;
+ assertEquals(2, reader.getSize());
+ assertEquals(2, reader.getParentArray().length);
+
+ reader.close();
+ writer.close();
+ dir.close();
+ }
+
+ @Test
public void testOpenIfChangedReuseAfterRecreate() throws Exception {
// tests that if the taxonomy is recreated, no data is reused from the previous taxonomy
Directory dir = newDirectory();