diff --git a/src/test/java/org/elasticsearch/VersionTests.java b/src/test/java/org/elasticsearch/VersionTests.java index de377aa3532..5ed9143ce2e 100644 --- a/src/test/java/org/elasticsearch/VersionTests.java +++ b/src/test/java/org/elasticsearch/VersionTests.java @@ -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)); + } + } + } \ No newline at end of file