lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r821380 - in /lucene/java/branches/lucene_2_9_back_compat_tests: ./ src/test/org/apache/lucene/index/ src/test/org/apache/lucene/search/ src/test/org/apache/lucene/store/
Date Sat, 03 Oct 2009 18:05:13 GMT
Author: uschindler
Date: Sat Oct  3 18:05:12 2009
New Revision: 821380

URL: http://svn.apache.org/viewvc?rev=821380&view=rev
Log:
Further test updates in BW branch

Modified:
    lucene/java/branches/lucene_2_9_back_compat_tests/   (props changed)
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestFieldsReader.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReader.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/CheckHits.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestScorerPerf.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestLockFactory.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestRAMDirectory.java

Propchange: lucene/java/branches/lucene_2_9_back_compat_tests/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct  3 18:05:12 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4:748824
+/lucene/java/trunk:821379

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestFieldsReader.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestFieldsReader.java
Sat Oct  3 18:05:12 2009
@@ -320,9 +320,6 @@
     public IndexInput openInput(String name) throws IOException {
       return new FaultyIndexInput(fsDir.openInput(name));
     }
-    public String[] list() throws IOException {
-      return fsDir.list();
-    }
     public String[] listAll() throws IOException {
       return fsDir.listAll();
     }
@@ -338,9 +335,6 @@
     public void deleteFile(String name) throws IOException {
       fsDir.deleteFile(name);
     }
-    public void renameFile(String name, String newName) throws IOException {
-      fsDir.renameFile(name, newName);
-    }
     public long fileLength(String name) throws IOException {
       return fsDir.fileLength(name);
     }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReader.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReader.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReader.java
Sat Oct  3 18:05:12 2009
@@ -552,24 +552,24 @@
         reader.setNorm(0, "content", (float) 2.0);
 
         // we should be holding the write lock now:
-        assertTrue("locked", IndexReader.isLocked(dir));
+        assertTrue("locked", IndexWriter.isLocked(dir));
 
         reader.commit();
 
         // we should not be holding the write lock now:
-        assertTrue("not locked", !IndexReader.isLocked(dir));
+        assertTrue("not locked", !IndexWriter.isLocked(dir));
 
         // open a 2nd reader:
         IndexReader reader2 = IndexReader.open(dir, false);
 
         // set norm again for doc 0
         reader.setNorm(0, "content", (float) 3.0);
-        assertTrue("locked", IndexReader.isLocked(dir));
+        assertTrue("locked", IndexWriter.isLocked(dir));
 
         reader.close();
 
         // we should not be holding the write lock now:
-        assertTrue("not locked", !IndexReader.isLocked(dir));
+        assertTrue("not locked", !IndexWriter.isLocked(dir));
 
         reader2.close();
         dir.close();
@@ -752,7 +752,6 @@
     }
 
     public void testLastModified() throws Exception {
-      assertFalse(IndexReader.indexExists("there_is_no_such_index"));
       final File fileDir = new File(System.getProperty("tempDir"), "testIndex");
       for(int i=0;i<2;i++) {
         try {
@@ -764,14 +763,14 @@
           assertFalse(IndexReader.indexExists(dir));
           IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
           addDocumentWithFields(writer);
-          assertTrue(IndexReader.isLocked(dir));		// writer open, so dir is locked
+          assertTrue(IndexWriter.isLocked(dir));		// writer open, so dir is locked
           writer.close();
           assertTrue(IndexReader.indexExists(dir));
           IndexReader reader = IndexReader.open(dir, false);
-          assertFalse(IndexReader.isLocked(dir));		// reader only, no lock
+          assertFalse(IndexWriter.isLocked(dir));		// reader only, no lock
           long version = IndexReader.lastModified(dir);
           if (i == 1) {
-            long version2 = IndexReader.lastModified(fileDir);
+            long version2 = IndexReader.lastModified(dir);
             assertEquals(version, version2);
           }
           reader.close();
@@ -794,16 +793,15 @@
     }
 
     public void testVersion() throws IOException {
-      assertFalse(IndexReader.indexExists("there_is_no_such_index"));
       Directory dir = new MockRAMDirectory();
       assertFalse(IndexReader.indexExists(dir));
       IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
       addDocumentWithFields(writer);
-      assertTrue(IndexReader.isLocked(dir));		// writer open, so dir is locked
+      assertTrue(IndexWriter.isLocked(dir));		// writer open, so dir is locked
       writer.close();
       assertTrue(IndexReader.indexExists(dir));
       IndexReader reader = IndexReader.open(dir, false);
-      assertFalse(IndexReader.isLocked(dir));		// reader only, no lock
+      assertFalse(IndexWriter.isLocked(dir));		// reader only, no lock
       long version = IndexReader.getCurrentVersion(dir);
       reader.close();
       // modify index and check version has been
@@ -830,7 +828,7 @@
       } catch(IOException e) {
         // expected exception
       }
-      IndexReader.unlock(dir);		// this should not be done in the real world! 
+      IndexWriter.unlock(dir);		// this should not be done in the real world! 
       reader.deleteDocument(0);
       reader.close();
       writer.close();
@@ -1153,7 +1151,7 @@
         // expected
       }
       reader.close();
-      if (IndexReader.isLocked(dir)) {
+      if (IndexWriter.isLocked(dir)) {
         fail("write lock is still held after close");
       }
 
@@ -1165,7 +1163,7 @@
         // expected
       }
       reader.close();
-      if (IndexReader.isLocked(dir)) {
+      if (IndexWriter.isLocked(dir)) {
         fail("write lock is still held after close");
       }
       dir.close();

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
Sat Oct  3 18:05:12 2009
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.FSDirectory;
 
 /**
  * This tests the patch for issue #LUCENE-715 (IndexWriter does not
@@ -72,14 +73,16 @@
 
     public void testIndexWriterLockRelease() throws IOException {
         IndexWriter im;
-
+        FSDirectory dir = FSDirectory.open(this.__test_dir);
         try {
-            im = new IndexWriter(this.__test_dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(),
false, IndexWriter.MaxFieldLength.LIMITED);
+            im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(),
false, IndexWriter.MaxFieldLength.LIMITED);
         } catch (FileNotFoundException e) {
             try {
-                im = new IndexWriter(this.__test_dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(),
false, IndexWriter.MaxFieldLength.LIMITED);
+                im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(),
false, IndexWriter.MaxFieldLength.LIMITED);
             } catch (FileNotFoundException e1) {
             }
+        } finally {
+          dir.close();
         }
     }
 }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/CheckHits.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/CheckHits.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/CheckHits.java
Sat Oct  3 18:05:12 2009
@@ -402,7 +402,7 @@
    */
   public static class ExplanationAssertingSearcher extends IndexSearcher {
     public ExplanationAssertingSearcher(Directory d) throws IOException {
-      super(d);
+      super(d, true);
     }
     public ExplanationAssertingSearcher(IndexReader r) throws IOException {
       super(r);

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
Sat Oct  3 18:05:12 2009
@@ -222,7 +222,7 @@
          * @throws IOException
          */
         public CustomSearcher(Directory directory, int switcher) throws IOException {
-            super(directory);
+            super(directory, true);
             this.switcher = switcher;
         }
         /**
@@ -232,14 +232,6 @@
             super(r);
             this.switcher = switcher;
         }
-        /**
-         * @param path
-         * @throws IOException
-         */
-        public CustomSearcher(String path, int switcher) throws IOException {
-            super(path);
-            this.switcher = switcher;
-        }
         /* (non-Javadoc)
          * @see org.apache.lucene.search.Searchable#search(org.apache.lucene.search.Query,
org.apache.lucene.search.Filter, int, org.apache.lucene.search.Sort)
          */

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
Sat Oct  3 18:05:12 2009
@@ -74,7 +74,7 @@
     writer.optimize ();
     writer.close ();
 
-    searcher = new IndexSearcher (directory);
+    searcher = new IndexSearcher (directory, true);
     query = new TermQuery (new Term ("field", "three"));
     filter = newStaticFilterB();
   }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestScorerPerf.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestScorerPerf.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestScorerPerf.java
Sat Oct  3 18:05:12 2009
@@ -52,7 +52,7 @@
     IndexWriter iw = new IndexWriter(rd,new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     iw.addDocument(new Document());
     iw.close();
-    s = new IndexSearcher(rd);
+    s = new IndexSearcher(rd, true);
   }
 
   public void createRandomTerms(int nDocs, int nTerms, double power, Directory dir) throws
Exception {
@@ -359,7 +359,7 @@
     RAMDirectory dir = new RAMDirectory();
     System.out.println("Creating index");
     createRandomTerms(100000,25,.5, dir);
-    s = new IndexSearcher(dir);
+    s = new IndexSearcher(dir, true);
     System.out.println("Starting performance test");
     for (int i=0; i<bigIter; i++) {
       long start = System.currentTimeMillis();
@@ -376,7 +376,7 @@
     RAMDirectory dir = new RAMDirectory();
     System.out.println("Creating index");
     createRandomTerms(100000,25,.2, dir);
-    s = new IndexSearcher(dir);
+    s = new IndexSearcher(dir, true);
     System.out.println("Starting performance test");
     for (int i=0; i<bigIter; i++) {
       long start = System.currentTimeMillis();
@@ -394,7 +394,7 @@
     RAMDirectory dir = new RAMDirectory();
     System.out.println("Creating index");
     createRandomTerms(100000,25,2,dir);
-    s = new IndexSearcher(dir);
+    s = new IndexSearcher(dir, true);
     System.out.println("Starting performance test");
     for (int i=0; i<bigIter; i++) {
       long start = System.currentTimeMillis();

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
Sat Oct  3 18:05:12 2009
@@ -128,7 +128,7 @@
     }
     //writer.optimize ();
     writer.close ();
-    IndexSearcher s = new IndexSearcher (indexStore);
+    IndexSearcher s = new IndexSearcher (indexStore, true);
     s.setDefaultFieldSortScoring(true, true);
     return s;
   }
@@ -160,7 +160,7 @@
     //writer.optimize ();
     //System.out.println(writer.getSegmentCount());
     writer.close ();
-    return new IndexSearcher (indexStore);
+    return new IndexSearcher (indexStore, true);
   }
   
   public String getRandomNumberString(int num, int low, int high) {

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
Sat Oct  3 18:05:12 2009
@@ -96,13 +96,13 @@
                                                 inputBufferSize, 10), inputBufferSize, r);
     // run test with chunk size of 100 MB - default
     runReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile,
-                                                inputBufferSize), inputBufferSize, r);
+                                                inputBufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE),
inputBufferSize, r);
     // run test with chunk size of 10 bytes
     runReadBytesAndClose(new NIOFSIndexInput(tmpInputFile,
                                              inputBufferSize, 10), inputBufferSize, r);
     // run test with chunk size of 100 MB - default
     runReadBytesAndClose(new NIOFSIndexInput(tmpInputFile,
-                                             inputBufferSize), inputBufferSize, r);
+                                             inputBufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE),
inputBufferSize, r);
   }
 
   private void runReadBytesAndClose(IndexInput input, int bufferSize, Random r)
@@ -352,11 +352,6 @@
       {
         return dir.fileExists(name);
       }
-      public String[] list()
-        throws IOException
-      {
-        return dir.list();
-      }
       public String[] listAll()
         throws IOException
       {
@@ -366,11 +361,6 @@
       public long fileLength(String name) throws IOException {
         return dir.fileLength(name);
       }
-      public void renameFile(String from, String to)
-        throws IOException
-      {
-        dir.renameFile(from, to);
-      }
 
 
     }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestLockFactory.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestLockFactory.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestLockFactory.java
Sat Oct  3 18:05:12 2009
@@ -128,175 +128,12 @@
             writer2.close();
         }
     }
-
-    // Verify: SimpleFSLockFactory is the default for FSDirectory
-    // Verify: FSDirectory does basic locking correctly
-    public void testDefaultFSDirectory() throws IOException {
-        File indexDirName = _TestUtil.getTempDir("index.TestLockFactory1");
-
-        IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                             IndexWriter.MaxFieldLength.LIMITED);
-
-        assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                   SimpleFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory())
||
-                   NativeFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-
-        IndexWriter writer2 = null;
-
-        // Create a 2nd IndexWriter.  This should fail:
-        try {
-            writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), false,
-                                      IndexWriter.MaxFieldLength.LIMITED);
-            fail("Should have hit an IOException with two IndexWriters on default SimpleFSLockFactory");
-        } catch (IOException e) {
-        }
-
-        writer.close();
-        if (writer2 != null) {
-            writer2.close();
-        }
-
-        // Cleanup
-        _TestUtil.rmDir(indexDirName);
-    }
-
-    // Verify: FSDirectory's default lockFactory clears all locks correctly
-    public void testFSDirectoryTwoCreates() throws IOException {
-        File indexDirName = _TestUtil.getTempDir("index.TestLockFactory2");
-
-        IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                             IndexWriter.MaxFieldLength.LIMITED);
-
-        assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                   SimpleFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory())
||
-                   NativeFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-
-        // Intentionally do not close the first writer here.
-        // The goal is to "simulate" a crashed writer and
-        // ensure the second writer, with create=true, is
-        // able to remove the lock files.  This works OK
-        // with SimpleFSLockFactory as the locking
-        // implementation.  Note, however, that this test
-        // will not work on WIN32 when we switch to
-        // NativeFSLockFactory as the default locking for
-        // FSDirectory because the second IndexWriter cannot
-        // remove those lock files since they are held open
-        // by the first writer.  This is because leaving the
-        // first IndexWriter open is not really a good way
-        // to simulate a crashed writer.
-        
-        // Create a 2nd IndexWriter.  This should not fail:
-        IndexWriter writer2 = null;
-        try {
-            writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                      IndexWriter.MaxFieldLength.LIMITED);
-        } catch (IOException e) {
-            e.printStackTrace(System.out);
-            fail("Should not have hit an IOException with two IndexWriters with create=true,
on default SimpleFSLockFactory");
-        }
-
-        writer.close();
-        if (writer2 != null) {
-          try {
-            writer2.close();
-            // expected
-          } catch (LockReleaseFailedException e) {
-            fail("writer2.close() should not have hit LockReleaseFailedException");
-          }
-        }
-
-        // Cleanup
-        _TestUtil.rmDir(indexDirName);
-    }
-    
-
-    // Verify: setting custom lock factory class (as system property) works:
-    // Verify: all 4 builtin LockFactory implementations are
-    //         settable this way 
-    // Verify: FSDirectory does basic locking correctly
-    public void testLockClassProperty() throws IOException {
-        File indexDirName = _TestUtil.getTempDir("index.TestLockFactory3");
-        String prpName = "org.apache.lucene.store.FSDirectoryLockFactoryClass";
-
-        try {
-
-          // NoLockFactory:
-          System.setProperty(prpName, "org.apache.lucene.store.NoLockFactory");
-          IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                               IndexWriter.MaxFieldLength.LIMITED);
-          assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                     NoLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-          writer.close();
-
-          // SingleInstanceLockFactory:
-          System.setProperty(prpName, "org.apache.lucene.store.SingleInstanceLockFactory");
-          writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                   IndexWriter.MaxFieldLength.LIMITED);
-          assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                     SingleInstanceLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-          writer.close();
-
-          // NativeFSLockFactory:
-          System.setProperty(prpName, "org.apache.lucene.store.NativeFSLockFactory");
-          writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                   IndexWriter.MaxFieldLength.LIMITED);
-          assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                     NativeFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-          writer.close();
-
-          // SimpleFSLockFactory:
-          System.setProperty(prpName, "org.apache.lucene.store.SimpleFSLockFactory");
-          writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                   IndexWriter.MaxFieldLength.LIMITED);
-          assertTrue("FSDirectory did not use correct LockFactory: got " + writer.getDirectory().getLockFactory(),
-                     SimpleFSLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-          writer.close();
-        } finally {
-          // Put back to the correct default for subsequent tests:
-          System.setProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass", "");
-        }
-
-        // Cleanup
-        _TestUtil.rmDir(indexDirName);
-    }
     
     public void testSimpleFSLockFactory() throws IOException {
       // test string file instantiation
       new SimpleFSLockFactory("test");
     }
 
-    // Verify: setDisableLocks works
-    public void testDisableLocks() throws IOException {
-        File indexDirName = _TestUtil.getTempDir("index.TestLockFactory4");
-        
-        assertTrue("Locks are already disabled", !FSDirectory.getDisableLocks());
-        FSDirectory.setDisableLocks(true);
-
-        IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true,
-                                             IndexWriter.MaxFieldLength.LIMITED);
-
-        assertTrue("FSDirectory did not use correct default LockFactory: got " + writer.getDirectory().getLockFactory(),
-                   NoLockFactory.class.isInstance(writer.getDirectory().getLockFactory()));
-
-        // Should be no error since locking is disabled:
-        IndexWriter writer2 = null;
-        try {
-            writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), false,
-                                      IndexWriter.MaxFieldLength.LIMITED);
-        } catch (IOException e) {
-            e.printStackTrace(System.out);
-            fail("Should not have hit an IOException with locking disabled");
-        }
-
-        FSDirectory.setDisableLocks(false);
-        writer.close();
-        if (writer2 != null) {
-            writer2.close();
-        }
-        // Cleanup
-        _TestUtil.rmDir(indexDirName);
-    }
-
     // Verify: do stress test, by opening IndexReaders and
     // IndexWriters over & over in 2 threads and making sure
     // no unexpected exceptions are raised:

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=821380&r1=821379&r2=821380&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestRAMDirectory.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestRAMDirectory.java
Sat Oct  3 18:05:12 2009
@@ -56,7 +56,8 @@
       throw new IOException("java.io.tmpdir undefined, cannot run test");
     indexDir = new File(tempDir, "RAMDirIndex");
     
-    IndexWriter writer  = new IndexWriter(indexDir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+    Directory dir = FSDirectory.open(indexDir);
+    IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     // add some documents
     Document doc = null;
     for (int i = 0; i < docsToAdd; i++) {
@@ -66,6 +67,7 @@
     }
     assertEquals(docsToAdd, writer.docCount());
     writer.close();
+    dir.close();
   }
   
   public void testRAMDirectory () throws IOException {



Mime
View raw message