FileDocCategorySizeDatePackage
TestIndexWriterLockRelease.javaAPI DocApache Lucene 2.2.03121Sat Jun 16 22:20:28 BST 2007org.apache.lucene.index

TestIndexWriterLockRelease

public class TestIndexWriterLockRelease extends TestCase
This tests the patch for issue #LUCENE-715 (IndexWriter does not release its write lock when trying to open an index which does not yet exist).
author
mbogosian
version
$Id$

Fields Summary
private File
__test_dir
Constructors Summary
Methods Summary
public voidsetUp()

        if (this.__test_dir == null) {
            String tmp_dir = System.getProperty("java.io.tmpdir", "tmp");
            this.__test_dir = new File(tmp_dir, "testIndexWriter");

            if (this.__test_dir.exists()) {
                throw new IOException("test directory \"" + this.__test_dir.getPath() + "\" already exists (please remove by hand)");
            }

            if (!this.__test_dir.mkdirs()
                && !this.__test_dir.isDirectory()) {
                throw new IOException("unable to create test directory \"" + this.__test_dir.getPath() + "\"");
            }
        }
    
public voidtearDown()

        if (this.__test_dir != null) {
            File[] files = this.__test_dir.listFiles();

            for (int i = 0;
                i < files.length;
                ++i) {
                if (!files[i].delete()) {
                    throw new IOException("unable to remove file in test directory \"" + this.__test_dir.getPath() + "\" (please remove by hand)");
                }
            }

            if (!this.__test_dir.delete()) {
                throw new IOException("unable to remove test directory \"" + this.__test_dir.getPath() + "\" (please remove by hand)");
            }
        }
    
public voidtestIndexWriterLockRelease()

        IndexModifier im;

        try {
            im = new IndexModifier(this.__test_dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(), false);
        } catch (FileNotFoundException e) {
            try {
                im = new IndexModifier(this.__test_dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(), false);
            } catch (FileNotFoundException e1) {
            }
        }