From 6d49170509aa9944b12adc9685ecd85e4371f0ca Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 23 Aug 2013 10:15:17 +0200 Subject: [PATCH] Introduce base test classes to share thread scope annotations Currently we run unittests with clusters running in the background that can potentiallly spawn threads causeing the thread leak control to fire off in tests that don't use the test cluster. This commit introduces some base classes for that purpose shadowning lucene test framework classes adding the approriate ThreadScope. --- .../XFastVectorHighlighterTest.java | 4 +-- .../ElasticSearchThreadFilter.java | 29 +++++++++++++++ .../ElasticSearchTokenStreamTestCase.java | 34 ++++++++++++++++++ .../ElasticsearchLuceneTestCase.java | 36 +++++++++++++++++++ .../integration/ElasticsearchTestCase.java | 11 +----- .../suggest/CompletionTokenStreamTest.java | 4 +-- .../unit/common/lucene/uid/VersionsTests.java | 9 ++--- .../index/analysis/CJKFilterFactoryTests.java | 7 ++-- .../unit/index/analysis/CharFilterTests.java | 7 ++-- .../analysis/KeepFilterFactoryTests.java | 7 ++-- .../LimitTokenCountFilterFactoryTests.java | 7 ++-- .../analysis/NGramTokenizerFactoryTests.java | 7 ++-- .../PatternCaptureTokenFilterTests.java | 7 ++-- .../ShingleTokenFilterFactoryTests.java | 4 +-- .../index/analysis/StopAnalyzerTests.java | 7 ++-- .../WordDelimiterTokenFilterFactoryTests.java | 7 ++-- .../CommonGramsTokenFilterFactoryTests.java | 8 ++--- 17 files changed, 126 insertions(+), 69 deletions(-) create mode 100644 src/test/java/org/elasticsearch/test/integration/ElasticSearchThreadFilter.java create mode 100644 src/test/java/org/elasticsearch/test/integration/ElasticSearchTokenStreamTestCase.java create mode 100644 src/test/java/org/elasticsearch/test/integration/ElasticsearchLuceneTestCase.java diff --git a/src/test/java/org/apache/lucene/search/vectorhighlight/XFastVectorHighlighterTest.java b/src/test/java/org/apache/lucene/search/vectorhighlight/XFastVectorHighlighterTest.java index 3ed3b369174..384323d0756 100644 --- a/src/test/java/org/apache/lucene/search/vectorhighlight/XFastVectorHighlighterTest.java +++ b/src/test/java/org/apache/lucene/search/vectorhighlight/XFastVectorHighlighterTest.java @@ -33,13 +33,13 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.LuceneTestCase; +import org.elasticsearch.test.integration.ElasticsearchLuceneTestCase; import org.junit.Test; import java.io.IOException; -public class XFastVectorHighlighterTest extends LuceneTestCase { +public class XFastVectorHighlighterTest extends ElasticsearchLuceneTestCase { @Test public void testLotsOfPhrases() throws IOException { diff --git a/src/test/java/org/elasticsearch/test/integration/ElasticSearchThreadFilter.java b/src/test/java/org/elasticsearch/test/integration/ElasticSearchThreadFilter.java new file mode 100644 index 00000000000..c1702a6daf5 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/integration/ElasticSearchThreadFilter.java @@ -0,0 +1,29 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test.integration; + +import com.carrotsearch.randomizedtesting.ThreadFilter; + +public class ElasticSearchThreadFilter implements ThreadFilter { + @Override + public boolean reject(Thread t) { + return true; + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/ElasticSearchTokenStreamTestCase.java b/src/test/java/org/elasticsearch/test/integration/ElasticSearchTokenStreamTestCase.java new file mode 100644 index 00000000000..4ab2ecb9f32 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/integration/ElasticSearchTokenStreamTestCase.java @@ -0,0 +1,34 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test.integration; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; +import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; +import org.apache.lucene.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.util.TimeUnits; + +@ThreadLeakFilters(defaultFilters = true, filters = {ElasticSearchThreadFilter.class}) +@ThreadLeakScope(Scope.NONE) +@TimeoutSuite(millis = TimeUnits.HOUR) +public class ElasticSearchTokenStreamTestCase extends BaseTokenStreamTestCase { + +} diff --git a/src/test/java/org/elasticsearch/test/integration/ElasticsearchLuceneTestCase.java b/src/test/java/org/elasticsearch/test/integration/ElasticsearchLuceneTestCase.java new file mode 100644 index 00000000000..726d2808b8b --- /dev/null +++ b/src/test/java/org/elasticsearch/test/integration/ElasticsearchLuceneTestCase.java @@ -0,0 +1,36 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.test.integration; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; +import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; +import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.util.TimeUnits; + +@ThreadLeakFilters(defaultFilters = true, filters = {ElasticSearchThreadFilter.class}) +@ThreadLeakScope(Scope.NONE) +@TimeoutSuite(millis = TimeUnits.HOUR) +@SuppressCodecs("Lucene3x") +public class ElasticsearchLuceneTestCase extends LuceneTestCase { + +} diff --git a/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java b/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java index 21f1066b1db..35cc1f7052a 100644 --- a/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java +++ b/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.test.integration; -import com.carrotsearch.randomizedtesting.ThreadFilter; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; @@ -32,7 +31,7 @@ import org.elasticsearch.common.logging.Loggers; import java.util.Random; import java.util.concurrent.TimeUnit; -@ThreadLeakFilters(defaultFilters = true, filters = {ElasticsearchTestCase.ElasticSearchThreadFilter.class}) +@ThreadLeakFilters(defaultFilters = true, filters = {ElasticSearchThreadFilter.class}) @ThreadLeakScope(Scope.NONE) @TimeoutSuite(millis = TimeUnits.HOUR) // timeout the suite after 1h and fail the test. public abstract class ElasticsearchTestCase extends AbstractRandomizedTest { @@ -41,14 +40,6 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest { public static final String CHILD_VM_ID = System.getProperty("junit4.childvm.id", "" + System.currentTimeMillis()); - public static class ElasticSearchThreadFilter implements ThreadFilter { - @Override - public boolean reject(Thread t) { - - return true; - } - } - public void awaitBusy(Predicate breakPredicate) throws InterruptedException { awaitBusy(breakPredicate, 10, TimeUnit.SECONDS); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionTokenStreamTest.java b/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionTokenStreamTest.java index cf7349674a6..ecb8c8380d1 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionTokenStreamTest.java +++ b/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionTokenStreamTest.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.test.integration.search.suggest; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; @@ -36,13 +35,14 @@ import org.apache.lucene.util.CharsRef; import org.apache.lucene.util.IntsRef; import org.elasticsearch.search.suggest.completion.CompletionTokenStream; import org.elasticsearch.search.suggest.completion.CompletionTokenStream.ByteTermAttribute; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Set; -public class CompletionTokenStreamTest extends BaseTokenStreamTestCase { +public class CompletionTokenStreamTest extends ElasticSearchTokenStreamTestCase { final XAnalyzingSuggester suggester = new XAnalyzingSuggester(new SimpleAnalyzer(TEST_VERSION_CURRENT)); diff --git a/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/VersionsTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/VersionsTests.java index fe439572201..ccafc6a70bd 100644 --- a/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/VersionsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/VersionsTests.java @@ -19,8 +19,6 @@ package org.elasticsearch.test.unit.common.lucene.uid; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; import com.google.common.collect.ImmutableMap; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; @@ -33,13 +31,12 @@ import org.apache.lucene.index.*; import org.apache.lucene.index.FieldInfo.IndexOptions; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.merge.policy.IndexUpgraderMergePolicy; +import org.elasticsearch.test.integration.ElasticsearchLuceneTestCase; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -50,9 +47,7 @@ import java.util.Map; import static org.hamcrest.Matchers.*; -@SuppressCodecs("Lucene3x") -@ThreadLeakScope(Scope.NONE) // a thread in this JVM might be from a prev. test -public class VersionsTests extends LuceneTestCase { +public class VersionsTests extends ElasticsearchLuceneTestCase { public static DirectoryReader reopen(DirectoryReader reader) throws IOException { return reopen(reader, true); diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/CJKFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/CJKFilterFactoryTests.java index c6467dff2d4..d19a4796844 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/CJKFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/CJKFilterFactoryTests.java @@ -19,20 +19,17 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.standard.StandardTokenizer; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; import java.io.StringReader; -@ThreadLeakScope(Scope.NONE) -public class CJKFilterFactoryTests extends BaseTokenStreamTestCase{ +public class CJKFilterFactoryTests extends ElasticSearchTokenStreamTestCase { private static final String RESOURCE = "org/elasticsearch/test/unit/index/analysis/cjk_analysis.json"; diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/CharFilterTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/CharFilterTests.java index cf02be2cbdc..5f7817c7e53 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/CharFilterTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/CharFilterTests.java @@ -18,9 +18,6 @@ */ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; @@ -35,14 +32,14 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** */ -@ThreadLeakScope(Scope.NONE) -public class CharFilterTests extends BaseTokenStreamTestCase{ +public class CharFilterTests extends ElasticSearchTokenStreamTestCase { @Test public void testMappingCharFilter() throws Exception { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/KeepFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/KeepFilterFactoryTests.java index c333d5df6be..7f96c9e3ed8 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/KeepFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/KeepFilterFactoryTests.java @@ -19,9 +19,6 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.ElasticSearchIllegalArgumentException; @@ -30,6 +27,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.KeepWordFilterFactory; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Assert; import org.junit.Test; @@ -38,8 +36,7 @@ import java.io.StringReader; import static org.hamcrest.Matchers.instanceOf; -@ThreadLeakScope(Scope.NONE) -public class KeepFilterFactoryTests extends BaseTokenStreamTestCase { +public class KeepFilterFactoryTests extends ElasticSearchTokenStreamTestCase { private static final String RESOURCE = "org/elasticsearch/test/unit/index/analysis/keep_analysis.json"; diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/LimitTokenCountFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/LimitTokenCountFilterFactoryTests.java index 63436e390b3..62875fdda7c 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/LimitTokenCountFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/LimitTokenCountFilterFactoryTests.java @@ -19,22 +19,19 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; import java.io.StringReader; -@ThreadLeakScope(Scope.NONE) -public class LimitTokenCountFilterFactoryTests extends BaseTokenStreamTestCase { +public class LimitTokenCountFilterFactoryTests extends ElasticSearchTokenStreamTestCase { @Test public void testDefault() throws IOException { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/NGramTokenizerFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/NGramTokenizerFactoryTests.java index 7e27ae422ec..1d1eaf08165 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/NGramTokenizerFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/NGramTokenizerFactoryTests.java @@ -19,9 +19,6 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; @@ -37,6 +34,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.analysis.EdgeNGramTokenFilterFactory; import org.elasticsearch.index.analysis.EdgeNGramTokenizerFactory; import org.elasticsearch.index.analysis.NGramTokenizerFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; @@ -50,8 +48,7 @@ import java.util.Random; import static org.hamcrest.Matchers.instanceOf; -@ThreadLeakScope(Scope.NONE) -public class NGramTokenizerFactoryTests extends BaseTokenStreamTestCase { +public class NGramTokenizerFactoryTests extends ElasticSearchTokenStreamTestCase { @Test public void testParseTokenChars() { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/PatternCaptureTokenFilterTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/PatternCaptureTokenFilterTests.java index 7a6e55d5bfd..93fcfc10955 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/PatternCaptureTokenFilterTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/PatternCaptureTokenFilterTests.java @@ -19,9 +19,6 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; @@ -36,12 +33,12 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -@ThreadLeakScope(Scope.NONE) -public class PatternCaptureTokenFilterTests extends BaseTokenStreamTestCase{ +public class PatternCaptureTokenFilterTests extends ElasticSearchTokenStreamTestCase { @Test public void testPatternCaptureTokenFilter() throws Exception { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/ShingleTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/ShingleTokenFilterFactoryTests.java index 6ed9bf21696..9c29a07f756 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/ShingleTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/ShingleTokenFilterFactoryTests.java @@ -21,12 +21,12 @@ package org.elasticsearch.test.unit.index.analysis; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.ShingleTokenFilterFactory; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; @@ -35,7 +35,7 @@ import java.io.StringReader; import static org.hamcrest.Matchers.instanceOf; @ThreadLeakScope(Scope.NONE) -public class ShingleTokenFilterFactoryTests extends BaseTokenStreamTestCase{ +public class ShingleTokenFilterFactoryTests extends ElasticSearchTokenStreamTestCase { private static final String RESOURCE = "org/elasticsearch/test/unit/index/analysis/shingle_analysis.json"; diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/StopAnalyzerTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/StopAnalyzerTests.java index a33f22a839c..9705404f795 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/StopAnalyzerTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/StopAnalyzerTests.java @@ -19,9 +19,6 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; @@ -36,12 +33,12 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -@ThreadLeakScope(Scope.NONE) -public class StopAnalyzerTests extends BaseTokenStreamTestCase { +public class StopAnalyzerTests extends ElasticSearchTokenStreamTestCase { @Test public void testDefaultsCompoundAnalysis() throws Exception { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/WordDelimiterTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/WordDelimiterTokenFilterFactoryTests.java index 0260cccc6a3..2ce40f08f52 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/WordDelimiterTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/WordDelimiterTokenFilterFactoryTests.java @@ -19,13 +19,11 @@ package org.elasticsearch.test.unit.index.analysis; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; @@ -33,8 +31,7 @@ import java.io.StringReader; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -@ThreadLeakScope(Scope.NONE) -public class WordDelimiterTokenFilterFactoryTests extends BaseTokenStreamTestCase { +public class WordDelimiterTokenFilterFactoryTests extends ElasticSearchTokenStreamTestCase { @Test public void testDefault() throws IOException { diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java index afde34b296c..2f8fc28f6ee 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java @@ -19,10 +19,7 @@ package org.elasticsearch.test.unit.index.analysis.commongrams; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.ElasticSearchIllegalArgumentException; @@ -30,6 +27,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.integration.ElasticSearchTokenStreamTestCase; import org.elasticsearch.test.unit.index.analysis.AnalysisTestsHelper; import org.junit.Assert; import org.junit.Test; @@ -38,9 +36,7 @@ import java.io.IOException; import java.io.StringReader; import static org.hamcrest.Matchers.instanceOf; - -@ThreadLeakScope(Scope.NONE) -public class CommonGramsTokenFilterFactoryTests extends BaseTokenStreamTestCase { +public class CommonGramsTokenFilterFactoryTests extends ElasticSearchTokenStreamTestCase { @Test public void testDefault() throws IOException {