From 00edc8bc87289014f24c218dbc884f719a3d2443 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 7 Jan 2016 21:22:20 -0500 Subject: [PATCH] Remove -Xlint:-deprecated from test/framwork There were a few uses of deprecation I couldn't clear up quickly so I filed issues for them and suppressed the warnings. --- test/framework/build.gradle | 2 +- .../elasticsearch/common/io/PathUtilsForTesting.java | 11 ++++++----- .../org/elasticsearch/test/InternalTestCluster.java | 4 +++- .../test/disruption/LongGCDisruption.java | 2 ++ .../test/hamcrest/ElasticsearchAssertions.java | 6 +++--- .../test/store/MockFSDirectoryService.java | 2 ++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/test/framework/build.gradle b/test/framework/build.gradle index 5c607e1aa61..46728d06283 100644 --- a/test/framework/build.gradle +++ b/test/framework/build.gradle @@ -33,7 +33,7 @@ dependencies { compile 'org.elasticsearch:securemock:1.2' } -compileJava.options.compilerArgs << '-Xlint:-cast,-deprecation,-rawtypes,-serial,-try,-unchecked' +compileJava.options.compilerArgs << '-Xlint:-cast,-rawtypes,-serial,-try,-unchecked' compileTestJava.options.compilerArgs << '-Xlint:-rawtypes' // the main files are actually test files, so use the appopriate forbidden api sigs diff --git a/test/framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java b/test/framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java index fee053eed45..36f766b8067 100644 --- a/test/framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java +++ b/test/framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java @@ -23,21 +23,22 @@ import org.apache.lucene.util.LuceneTestCase; import java.nio.file.FileSystem; -/** - * Exposes some package private stuff in PathUtils for framework purposes only! +/** + * Exposes some package private stuff in PathUtils for framework purposes only! */ public class PathUtilsForTesting { - + /** Sets a new default filesystem for testing */ + @SuppressWarnings("deprecation") // https://github.com/elastic/elasticsearch/issues/15845 public static void setup() { installMock(LuceneTestCase.getBaseTempDirForTestClass().getFileSystem()); } - + /** Installs a mock filesystem for testing */ public static void installMock(FileSystem mock) { PathUtils.DEFAULT = mock; } - + /** Resets filesystem back to the real system default */ public static void teardown() { PathUtils.DEFAULT = PathUtils.ACTUAL_DEFAULT; diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index ea2796aad84..81dbc387a14 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -24,6 +24,7 @@ import com.carrotsearch.randomizedtesting.SysGlobals; import com.carrotsearch.randomizedtesting.generators.RandomInts; import com.carrotsearch.randomizedtesting.generators.RandomPicks; import com.carrotsearch.randomizedtesting.generators.RandomStrings; + import org.apache.lucene.store.StoreRateLimiting; import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; @@ -117,7 +118,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -import static junit.framework.Assert.fail; import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY; import static org.apache.lucene.util.LuceneTestCase.rarely; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -127,6 +127,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; /** * InternalTestCluster manages a set of JVM private nodes and allows convenient access to them. @@ -1045,6 +1046,7 @@ public final class InternalTestCluster extends TestCluster { } } + @SuppressWarnings("deprecation") // https://github.com/elastic/elasticsearch/issues/15844 private void randomlyResetClients() throws IOException { // only reset the clients on nightly tests, it causes heavy load... if (RandomizedTest.isNightly() && rarely(random)) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java b/test/framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java index 1e8dcb10db7..591540e72b9 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java +++ b/test/framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java @@ -75,6 +75,7 @@ public class LongGCDisruption extends SingleNodeDisruption { return TimeValue.timeValueMillis(0); } + @SuppressWarnings("deprecation") // stops/resumes threads intentionally @SuppressForbidden(reason = "stops/resumes threads intentionally") protected boolean stopNodeThreads(String node, Set nodeThreads) { Thread[] allThreads = null; @@ -118,6 +119,7 @@ public class LongGCDisruption extends SingleNodeDisruption { return stopped; } + @SuppressWarnings("deprecation") // stops/resumes threads intentionally @SuppressForbidden(reason = "stops/resumes threads intentionally") protected void resumeThreads(Set threads) { for (Thread thread : threads) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index 9d8ad7f7dcf..61755f7ecb4 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -513,9 +513,9 @@ public class ElasticsearchAssertions { public static T assertBooleanSubQuery(Query query, Class subqueryType, int i) { assertThat(query, instanceOf(BooleanQuery.class)); BooleanQuery q = (BooleanQuery) query; - assertThat(q.getClauses().length, greaterThan(i)); - assertThat(q.getClauses()[i].getQuery(), instanceOf(subqueryType)); - return (T) q.getClauses()[i].getQuery(); + assertThat(q.clauses().size(), greaterThan(i)); + assertThat(q.clauses().get(i).getQuery(), instanceOf(subqueryType)); + return subqueryType.cast(q.clauses().get(i).getQuery()); } /** diff --git a/test/framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java b/test/framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java index 58a72789f65..a5fb865238e 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java +++ b/test/framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java @@ -21,6 +21,7 @@ package org.elasticsearch.test.store; import com.carrotsearch.randomizedtesting.SeedUtils; import com.carrotsearch.randomizedtesting.generators.RandomPicks; + import org.apache.lucene.index.CheckIndex; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.BaseDirectoryWrapper; @@ -105,6 +106,7 @@ public class MockFSDirectoryService extends FsDirectoryService { throw new UnsupportedOperationException(); } + @SuppressWarnings("deprecation") // https://github.com/elastic/elasticsearch/issues/15846 public static void checkIndex(ESLogger logger, Store store, ShardId shardId) { if (store.tryIncRef()) { logger.info("start check index");