Skip to content

Apache Lucene open-source search software

LUCENE-2088: add extra test

Uwe Schindler2e244caa1707
diff --git a/src/test/org/apache/lucene/util/TestAttributeSource.java b/src/test/org/apache/lucene/util/TestAttributeSource.java
index 709a835749e..d76cce57381 100644
--- a/src/test/org/apache/lucene/util/TestAttributeSource.java
+++ b/src/test/org/apache/lucene/util/TestAttributeSource.java
@@ -142,6 +142,7 @@ public class TestAttributeSource extends LuceneTestCase {
src.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
}
+ @SuppressWarnings("unchecked")
public void testInvalidArguments() throws Exception {
try {
AttributeSource src = new AttributeSource();
@@ -154,5 +155,12 @@ public class TestAttributeSource extends LuceneTestCase {
src.addAttribute(Token.class);
fail("Should throw IllegalArgumentException");
} catch (IllegalArgumentException iae) {}
+
+ try {
+ AttributeSource src = new AttributeSource();
+ // break this by unsafe cast
+ src.addAttribute((Class) Iterator.class);
+ fail("Should throw IllegalArgumentException");
+ } catch (IllegalArgumentException iae) {}
}
}