add test for runtime exceptions

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150470 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2004-08-30 21:03:40 +00:00
parent 713c199bbd
commit 8f99bfef89
1 changed files with 19 additions and 0 deletions

View File

@ -70,6 +70,25 @@ public class TestDocument extends TestCase
assertEquals(0, doc.fields.size());
}
public void testConstructorExceptions()
{
new Field("name", "value", Field.Store.YES, Field.Index.NO); // okay
new Field("name", "value", Field.Store.NO, Field.Index.UN_TOKENIZED); // okay
try {
new Field("name", "value", Field.Store.NO, Field.Index.NO);
fail();
} catch(IllegalArgumentException e) {
// expected exception
}
new Field("name", "value", Field.Store.YES, Field.Index.NO, Field.TermVector.NO); // okay
try {
new Field("name", "value", Field.Store.YES, Field.Index.NO, Field.TermVector.YES);
fail();
} catch(IllegalArgumentException e) {
// expected exception
}
}
/**
* Tests {@link Document#getValues(String)} method for a brand new Document
* that has not been indexed yet.