mirror of https://github.com/apache/lucene.git
Improve test for deprecated Version enum constants
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1455179 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1600711a61
commit
c724083016
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.lucene.util;
|
package org.apache.lucene.util;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
public class TestVersion extends LuceneTestCase {
|
public class TestVersion extends LuceneTestCase {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
@ -36,9 +38,17 @@ public class TestVersion extends LuceneTestCase {
|
||||||
public void testDeprecations() throws Exception {
|
public void testDeprecations() throws Exception {
|
||||||
Version values[] = Version.values();
|
Version values[] = Version.values();
|
||||||
// all but the latest version should be deprecated
|
// all but the latest version should be deprecated
|
||||||
for (int i = 0; i < values.length-2; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
assertNotNull(values[i].name() + " should be deprecated",
|
if (i + 1 == values.length) {
|
||||||
Version.class.getField(values[i].name()).getAnnotation(Deprecated.class));
|
assertSame("Last constant must be LUCENE_CURRENT", Version.LUCENE_CURRENT, values[i]);
|
||||||
|
}
|
||||||
|
// TODO: Use isAnnotationPresent once bug in Java 8 is fixed (LUCENE-4808)
|
||||||
|
final Annotation ann = Version.class.getField(values[i].name()).getAnnotation(Deprecated.class);
|
||||||
|
if (i + 2 != values.length) {
|
||||||
|
assertNotNull(values[i].name() + " should be deprecated", ann);
|
||||||
|
} else {
|
||||||
|
assertNull(values[i].name() + " should not be deprecated", ann);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue