Methods Summary |
---|
private static java.lang.String | openIndexWriter()Open an IndexWriter
Catch any (expected) IOException
Close the IndexWriter
IndexWriter iw = null;
String ret = null;
try {
iw = new IndexWriter(TEST_INDEX_DIR, new StandardAnalyzer(), true);
} catch (IOException e) {
ret = e.toString();
e.printStackTrace();
} catch (NullPointerException e) {
ret = e.toString();
e.printStackTrace();
} finally {
if (iw != null) {
try {
iw.close();
} catch (IOException ioe) {
// ignore this
}
}
}
return ret;
|
private static void | rmDir(java.io.File dirName)
if (dirName.exists()) {
if (dirName.isDirectory()) {
File[] contents = dirName.listFiles();
for (int i = 0; i < contents.length; i++)
rmDir(contents[i]);
dirName.delete();
} else {
dirName.delete();
}
}
|
public void | tearDown()
if (orgApacheLuceneLockDir != null)
System.setProperty("org.apache.lucene.lockDir",
orgApacheLuceneLockDir);
if (shouldBeADirectory != null && shouldBeADirectory.exists()) {
try {
shouldBeADirectory.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
File deletableIndex = new File(TEST_INDEX_DIR);
if (deletableIndex.exists())
try {
rmDir(deletableIndex);
} catch (Exception e) {
e.printStackTrace();
}
|
public void | testNonExistentTmpDir()What happens if the Lucene lockDir doesn't exist?
orgApacheLuceneLockDir = System.setProperty(
"org.apache.lucene.lockDir", NON_EXISTENT_DIRECTORY);
String exceptionClassName = openIndexWriter();
if (exceptionClassName == null
|| exceptionClassName.equals("java.io.IOException"))
assertTrue(true);
else
fail("Caught an unexpected Exception");
|
public void | testTmpDirIsPlainFile()What happens if the Lucene lockDir is a regular file instead of a
directory?
shouldBeADirectory = new File(NON_EXISTENT_DIRECTORY);
shouldBeADirectory.createNewFile();
String exceptionClassName = openIndexWriter();
if (exceptionClassName == null
|| exceptionClassName.equals("java.io.IOException"))
assertTrue(true);
else
fail("Caught an unexpected Exception");
|