mirror of https://github.com/apache/lucene.git
Add extra test for new TokenStream API backwards layer
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@799359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1073d29a53
commit
be85ca650a
|
@ -268,6 +268,23 @@ public class TestTokenStreamBWComp extends LuceneTestCase {
|
||||||
assertTrue("TypeAttribute is implemented by TypeAttributeImpl",
|
assertTrue("TypeAttribute is implemented by TypeAttributeImpl",
|
||||||
stream.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
|
stream.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
|
||||||
|
|
||||||
|
// try to call old API, this should fail
|
||||||
|
try {
|
||||||
|
stream.reset();
|
||||||
|
Token reusableToken = new Token();
|
||||||
|
while ((reusableToken = stream.next(reusableToken)) != null);
|
||||||
|
fail("If only the new API is allowed, this should fail with an UOE");
|
||||||
|
} catch (UnsupportedOperationException uoe) {
|
||||||
|
assertTrue("This TokenStream only supports the new Attributes API.".equals(uoe.getMessage()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
stream.reset();
|
||||||
|
while (stream.next() != null);
|
||||||
|
fail("If only the new API is allowed, this should fail with an UOE");
|
||||||
|
} catch (UnsupportedOperationException uoe) {
|
||||||
|
assertTrue("This TokenStream only supports the new Attributes API.".equals(uoe.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
// Test if the wrapper API (onlyUseNewAPI==false) uses TokenWrapper
|
// Test if the wrapper API (onlyUseNewAPI==false) uses TokenWrapper
|
||||||
// as attribute instance.
|
// as attribute instance.
|
||||||
// TokenWrapper encapsulates a Token instance that can be exchanged
|
// TokenWrapper encapsulates a Token instance that can be exchanged
|
||||||
|
|
Loading…
Reference in New Issue