Added tests that ensures all version are in the Version#fromId(int) switch statement

This commit is contained in:
Simon Willnauer 2014-01-22 11:25:36 +01:00
parent 994ad77032
commit d49f099fdb
1 changed files with 14 additions and 0 deletions

View File

@ -24,8 +24,10 @@ import org.junit.Test;
import static org.elasticsearch.Version.V_0_20_0;
import static org.elasticsearch.Version.V_0_90_0;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
public class VersionTests extends ElasticsearchTestCase {
@ -48,4 +50,16 @@ public class VersionTests extends ElasticsearchTestCase {
assertThat(V_0_90_0.onOrAfter(V_0_20_0), is(true));
}
@Test
public void testVersionConstantPresent() {
assertThat(Version.CURRENT, sameInstance(Version.fromId(Version.CURRENT.id)));
assertThat(Version.CURRENT.luceneVersion.ordinal(), equalTo(org.apache.lucene.util.Version.LUCENE_CURRENT.ordinal() - 1));
final int iters = atLeast(20);
for (int i = 0; i < iters; i++) {
Version version = randomVersion();
assertThat(version, sameInstance(Version.fromId(version.id)));
assertThat(version.luceneVersion, sameInstance(Version.fromId(version.id).luceneVersion));
}
}
}