From 3f773d6699d384243e28e647cbcb57cef3726e23 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Thu, 10 Apr 2014 13:52:25 +0000 Subject: [PATCH] Fix test that fails on Windows if it gets a FSDirectory (it intentionally does not close IW/IR). The new cleanup code then complains about inability to delete the index dir git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1586301 13f79535-47bb-0310-9956-ffa450edef68 --- .../util/junitcompat/TestFailOnFieldCacheInsanity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java b/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java index 354e145aab7..20d57a6d27c 100644 --- a/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java +++ b/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java @@ -24,6 +24,8 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.FieldCache; import org.apache.lucene.store.Directory; +import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.store.RAMDirectory; import org.junit.Assert; import org.junit.Test; import org.junit.runner.JUnitCore; @@ -41,8 +43,10 @@ public class TestFailOnFieldCacheInsanity extends WithNestedTests { private AtomicReader subR; private void makeIndex() throws Exception { - d = newDirectory(); - RandomIndexWriter w = new RandomIndexWriter(random(), d); + // we use RAMDirectory here, because we dont want to stay on open files on Windows: + d = new MockDirectoryWrapper(random(), new RAMDirectory()); + @SuppressWarnings("resource") RandomIndexWriter w = + new RandomIndexWriter(random(), d); Document doc = new Document(); doc.add(newField("ints", "1", StringField.TYPE_NOT_STORED)); w.addDocument(doc);