summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNik Everett <nik9000@gmail.com>2015-10-09 13:15:22 -0400
committerNik Everett <nik9000@gmail.com>2015-10-20 17:37:36 -0400
commit2cc97a0d3ed2a9276378e2a6462942deab04a1fb (patch)
tree9d08d186506e85f1ff3dd7a7abffbe2e45081365
parent2eff0633417702ec893b683ee8a7b8ac36e7461c (diff)
Remove and ban @Test
There are three ways `@Test` was used. Way one: ```java @Test public void flubTheBlort() { ``` This way was always replaced with: ```java public void testFlubTheBlort() { ``` Or, maybe with a better method name if I was feeling generous. Way two: ```java @Test(throws=IllegalArgumentException.class) public void testFoo() { methodThatThrows(); } ``` This way of using `@Test` is actually pretty OK, but to get the tools to ban `@Test` entirely it can't be used. Instead: ```java public void testFoo() { try { methodThatThrows(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e ) { assertThat(e.getMessage(), containsString("something")); } } ``` This is longer but tests more than the old ways and is much more precise. Compare: ```java @Test(throws=IllegalArgumentException.class) public void testFoo() { some(); copy(); and(); pasted(); methodThatThrows(); code(); // <---- This was left here by mistake and is never called } ``` to: ```java @Test(throws=IllegalArgumentException.class) public void testFoo() { some(); copy(); and(); pasted(); try { methodThatThrows(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e ) { assertThat(e.getMessage(), containsString("something")); } } ``` The final use of test is: ```java @Test(timeout=1000) public void testFoo() { methodThatWasSlow(); } ``` This is the most insidious use of `@Test` because its tempting but tragically flawed. Its flaws are: 1. Hard and fast timeouts can look like they are asserting that something is faster and even do an ok job of it when you compare the timings on the same machine but as soon as you take them to another machine they start to be invalid. On a slow VM both the new and old methods fail. On a super-fast machine the slower and faster ways succeed. 2. Tests often contain slow `assert` calls so the performance of tests isn't sure to predict the performance of non-test code. 3. These timeouts are rude to debuggers because the test just drops out from under it after the timeout. Confusingly, timeouts are useful in tests because it'd be rude for a broken test to cause CI to abort the whole build after it hits a global timeout. But those timeouts should be very very long "backstop" timeouts and aren't useful assertions about speed. For all its flaws `@Test(timeout=1000)` doesn't have a good replacement __in__ __tests__. Nightly benchmarks like http://benchmarks.elasticsearch.org/ are useful here because they run on the same machine but they aren't quick to check and it takes lots of time to figure out the regressions. Sometimes its useful to compare dueling implementations but that requires keeping both implementations around. All and all we don't have a satisfactory answer to the question "what do you replace `@Test(timeout=1000)`" with. So we handle each occurrence on a case by case basis. For files with `@Test` this also: 1. Removes excess blank lines. They don't help anything. 2. Removes underscores from method names. Those would fail any code style checks we ever care to run and don't add to readability. Since I did this manually I didn't do it consistently. 3. Make sure all test method names start with `test`. Some used to end in `Test` or start with `verify` or `check` and they were picked up using the annotation. Without the annotation they always need to start with `test`. 4. Organizes imports using the rules we generate for Eclipse. For the most part this just removes `*` imports which is a win all on its own. It was "required" to quickly remove `@Test`. 5. Removes unneeded casts. This is just a setting I have enabled in Eclipse and forgot to turn off before I did this work. It probably isn't hurting anything. 6. Removes trailing whitespace. Again, another Eclipse setting I forgot to turn off that doesn't hurt anything. Hopefully. 7. Swaps some tests override superclass tests to make them empty with `assumeTrue` so that the reasoning for the skips is logged in the test run and it doesn't "look like" that thing is being tested when it isn't. 8. Adds an oxford comma to an error message. The total test count doesn't change. I know. I counted. ```bash git checkout master && mvn clean && mvn install | tee with_test git no_test_annotation master && mvn clean && mvn install | tee not_test grep 'Tests summary' with_test > with_test_summary grep 'Tests summary' not_test > not_test_summary diff with_test_summary not_test_summary ``` These differ somewhat because some tests are skipped based on the random seed. The total shouldn't differ. But it does! ``` 1c1 < [INFO] Tests summary: 564 suites (1 ignored), 3171 tests, 31 ignored (31 assumptions) --- > [INFO] Tests summary: 564 suites (1 ignored), 3167 tests, 17 ignored (17 assumptions) ``` These are the core unit tests. So we dig further: ```bash cat with_test | perl -pe 's/\n// if /^Suite/;s/.*\n// if /IGNOR/;s/.*\n// if /Assumption #/;s/.*\n// if /HEARTBEAT/;s/Completed .+?,//' | grep Suite > with_test_suites cat not_test | perl -pe 's/\n// if /^Suite/;s/.*\n// if /IGNOR/;s/.*\n// if /Assumption #/;s/.*\n// if /HEARTBEAT/;s/Completed .+?,//' | grep Suite > not_test_suites diff <(sort with_test_suites) <(sort not_test_suites) ``` The four tests with lower test numbers are all extend `AbstractQueryTestCase` and all have a method that looks like this: ```java @Override public void testToQuery() throws IOException { assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0); super.testToQuery(); } ``` It looks like this method was being double counted on master and isn't anymore. Closes #14028
-rw-r--r--core/src/main/java/org/elasticsearch/Version.java2
-rw-r--r--core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java2
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java6
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java1
-rw-r--r--core/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java5
-rw-r--r--core/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java5
-rw-r--r--core/src/test/java/org/apache/lucene/queries/BlendedTermQueryTests.java27
-rw-r--r--core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPassageFormatterTests.java5
-rw-r--r--core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPostingsHighlighterTests.java17
-rw-r--r--core/src/test/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIteratorTests.java8
-rw-r--r--core/src/test/java/org/apache/lucene/util/SloppyMathTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/ESExceptionTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/NamingConventionTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/VersionTests.java35
-rw-r--r--core/src/test/java/org/elasticsearch/action/ListenerActionIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/RejectionActionIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponsesTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/repositories/RepositoryBlocksIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexBlocksIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/flush/FlushBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexIT.java32
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/optimize/OptimizeBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/refresh/RefreshBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequestTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java24
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsBlocksIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/index/IndexRequestBuilderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequestTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java23
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java33
-rw-r--r--core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java112
-rw-r--r--core/src/test/java/org/elasticsearch/blocks/SimpleBlocksIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/bootstrap/JNANativesTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/bootstrap/JavaVersionTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java41
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/GetIndexBackwardsCompatibilityIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/TransportClientBackwardsCompatibilityIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java4
-rw-r--r--core/src/test/java/org/elasticsearch/client/node/NodeClientIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ClusterHealthIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java27
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java1
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java30
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java28
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/SimpleDataNodesIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java30
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java26
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java46
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java112
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java24
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/WildcardExpressionResolverTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeFiltersTests.java47
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/AllocationIdTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/RoutingServiceTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java30
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/CatAllocationTestCase.java23
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java35
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferLocalPrimariesToRelocatingPrimariesTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingNodesIntegrityTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/StartedShardsRoutingTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java21
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/serialization/ClusterStateToStringTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/serialization/DiffableTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java28
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/settings/SettingsValidatorTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/common/Base64Tests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/BooleansTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/common/ChannelsTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/common/ParseFieldTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/PidFileTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/common/TableTests.java68
-rw-r--r--core/src/test/java/org/elasticsearch/common/UUIDTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/common/cli/CliToolTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/common/cli/TerminalTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/geo/GeoDistanceTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/common/geo/GeoHashTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java64
-rw-r--r--core/src/test/java/org/elasticsearch/common/geo/ShapeRelationTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/common/geo/SpatialStrategyTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/hash/MessageDigestsTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/common/io/StreamsTests.java22
-rw-r--r--core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java31
-rw-r--r--core/src/test/java/org/elasticsearch/common/joda/DateMathParserTests.java45
-rw-r--r--core/src/test/java/org/elasticsearch/common/logging/jdk/JDKESLoggerTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java22
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInputTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/math/MathUtilsTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/property/PropertyPlaceholderTests.java30
-rw-r--r--core/src/test/java/org/elasticsearch/common/regex/RegexTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/common/rounding/RoundingTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java49
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/ArrayUtilsTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/LongHashTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/URIPatternTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/iterable/IterablesTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/XContentFactoryTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/cbor/CborXContentParserTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/cbor/JsonVsCborTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/support/XContentHelperTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java28
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/AbstractFilteringJsonGeneratorTestCase.java26
-rw-r--r--core/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java45
-rw-r--r--core/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java39
-rw-r--r--core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java70
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java36
-rw-r--r--core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/document/ShardInfoIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/env/EnvironmentTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/exists/SimpleExistsIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java17
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/DanglingIndicesStateTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java12
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/MetaStateServiceTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java28
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/get/GetActionIT.java54
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java25
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningEnabledIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/http/netty/pipelining/HttpPipeliningHandlerTests.java29
-rw-r--r--core/src/test/java/org/elasticsearch/index/IndexRequestBuilderIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/index/IndexServiceTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/index/TransportIndexFailuresIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/VersionTypeTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactoryTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/AnalysisTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/KeepTypesFilterFactoryTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java31
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactoryTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactoryTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/cache/bitset/BitSetFilterCacheTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/codec/CodecTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/InternalEngineIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java41
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java24
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/AbstractNumericFieldDataTestCase.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java11
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java17
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/ParentChildFieldDataTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/ordinals/SingleOrdinalsTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/UidTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java37
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperIntegrationIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapperTests.java37
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/geo/GeohashMappingGeoPointTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java28
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java63
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java36
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java34
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java59
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/BoostingQueryBuilderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/DisMaxQueryBuilderTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java84
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java90
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java47
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java38
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java40
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/HasChildQueryParserTests.java39
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/IndicesQueryBuilderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/MissingQueryBuilderTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java21
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/MultiMatchQueryBuilderTests.java20
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java91
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/QueryFilterBuilderTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java38
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java29
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java51
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanContainingQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanFirstQueryBuilderTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanNearQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanNotQueryBuilderTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanOrQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/SpanWithinQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TemplateQueryIT.java34
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java42
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/TypeQueryBuilderTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java49
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java41
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java41
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java227
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java45
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/MergePolicySettingsTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java22
-rw-r--r--core/src/test/java/org/elasticsearch/index/similarity/SimilarityTests.java21
-rw-r--r--core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/DirectoryUtilsTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/StoreTests.java20
-rw-r--r--core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java46
-rw-r--r--core/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java48
-rw-r--r--core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java40
-rw-r--r--core/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/indices/cache/query/terms/TermsLookupTests.java22
-rw-r--r--core/src/test/java/org/elasticsearch/indices/exists/indices/IndicesExistsIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java17
-rw-r--r--core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java68
-rw-r--r--core/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerUnitTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java24
-rw-r--r--core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/settings/GetSettingsBlocksIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java31
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java91
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java40
-rw-r--r--core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java30
-rw-r--r--core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java26
-rw-r--r--core/src/test/java/org/elasticsearch/indices/warmer/GatewayIndicesWarmerIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/indices/warmer/IndicesWarmerBlocksIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerIT.java28
-rw-r--r--core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/jvm/JvmStatsTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsEnabledIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java25
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/PercolatorBackwardsCompatibilityIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java102
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/PluggableTransportModuleIT.java17
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/PluginManagerCliTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/RecoveriesCollectionTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/RecoverySettingsTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/RelocationIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/rest/CorsRegexDefaultIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/rest/HeadersAndContextCopyClientTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/rest/RestRequestTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/rest/action/support/RestTableTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/script/NativeScriptTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptContextTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptModesTests.java15
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java239
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTests.java23
-rw-r--r--core/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/search/StressSearchServiceReaperIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/AggregationsBinaryIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/ParsingIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/BooleanTermsIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java34
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java27
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java27
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java44
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java46
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java29
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java56
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsBackwardCompatibilityIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java81
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java139
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java26
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java35
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java27
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java41
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java24
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java25
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java91
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java45
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffIT.java25
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/support/PathTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java68
-rw-r--r--core/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/fetch/FieldDataFieldsTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/fetch/innerhits/NestedChildrenFilterTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java47
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/geo/GeoPolygonIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java12
-rw-r--r--core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java113
-rw-r--r--core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java26
-rw-r--r--core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java30
-rw-r--r--core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java37
-rw-r--r--core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java12
-rw-r--r--core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java37
-rw-r--r--core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java26
-rw-r--r--core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java45
-rw-r--r--core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/search/sort/SortParserTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/source/SourceFetchingIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/stats/SearchStatsUnitTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java101
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTests.java37
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearchIT.java61
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java69
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/context/GeoLocationContextMappingTests.java25
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java71
-rw-r--r--core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java53
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java109
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/SnapshotRequestsTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java40
-rw-r--r--core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java11
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java33
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java24
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java22
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java19
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java34
-rw-r--r--core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java24
-rw-r--r--core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java31
-rw-r--r--core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java27
-rw-r--r--core/src/test/java/org/elasticsearch/transport/ActionNamesIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/transport/TransportMessageTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/NettyTransportIT.java7
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java13
-rw-r--r--core/src/test/java/org/elasticsearch/tribe/TribeIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateIT.java35
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/validate/RenderSearchTemplateIT.java27
-rw-r--r--core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java43
-rw-r--r--core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java24
-rw-r--r--core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/watcher/ResourceWatcherServiceTests.java9
-rw-r--r--dev-tools/src/main/resources/forbidden/test-signatures.txt2
-rw-r--r--plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java3
-rw-r--r--plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuCollationTokenFilterTests.java24
-rw-r--r--plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuNormalizerCharFilterTests.java8
-rw-r--r--plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java12
-rw-r--r--plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java3
-rw-r--r--plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java5
-rw-r--r--plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java5
-rw-r--r--plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java3
-rw-r--r--plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java7
-rw-r--r--plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryActionTests.java28
-rw-r--r--plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java29
-rw-r--r--plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java6
-rw-r--r--plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java13
-rw-r--r--plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java9
-rw-r--r--plugins/discovery-ec2/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java4
-rw-r--r--plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java34
-rw-r--r--plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java4
-rw-r--r--plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java26
-rw-r--r--plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java38
-rw-r--r--plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java20
-rw-r--r--plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/RetryHttpInitializerWrapperTests.java3
-rw-r--r--plugins/discovery-multicast/src/test/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPingTests.java5
-rw-r--r--plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/IndexedExpressionTests.java3
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java43
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketScriptTests.java37
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java47
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java54
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java59
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java13
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java105
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java65
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java136
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java46
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java7
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java15
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java61
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java59
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java81
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java73
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java15
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java12
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java62
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java135
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java51
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java52
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java68
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptIndexSettingsTests.java18
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java7
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java49
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java20
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java8
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchTimeoutTests.java6
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SignificantTermsSignificanceScoreTests.java11
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java62
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java46
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java153
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java46
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java60
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java68
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java12
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ValueCountTests.java34
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptTests.java12
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovySecurityTests.java5
-rw-r--r--plugins/lang-groovy/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java98
-rw-r--r--plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java10
-rw-r--r--plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTests.java6
-rw-r--r--plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java9
-rw-r--r--plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTests.java6
-rw-r--r--plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreServiceTests.java3
-rw-r--r--plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTests.java13
-rw-r--r--plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java4
-rw-r--r--plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTests.java16
-rw-r--r--plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java62
-rw-r--r--plugins/store-smb/src/test/java/org/elasticsearch/index/store/AbstractAzureFsTestCase.java3
-rw-r--r--qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/SmokeTestClientIT.java4
735 files changed, 4915 insertions, 8226 deletions
diff --git a/core/src/main/java/org/elasticsearch/Version.java b/core/src/main/java/org/elasticsearch/Version.java
index 8ce6becf80..e4239037f9 100644
--- a/core/src/main/java/org/elasticsearch/Version.java
+++ b/core/src/main/java/org/elasticsearch/Version.java
@@ -549,7 +549,7 @@ public class Version {
}
String[] parts = version.split("\\.|\\-");
if (parts.length < 3 || parts.length > 4) {
- throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build: " + version);
+ throw new IllegalArgumentException("the version needs to contain major, minor, and revision, and optionally the build: " + version);
}
try {
diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
index 4b56027e2a..93da5ac8f0 100644
--- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
+++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
@@ -602,7 +602,7 @@ public abstract class StreamInput extends InputStream {
* Use {@link FilterInputStream} instead which wraps a stream and supports a {@link NamedWriteableRegistry} too.
*/
<C> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass) throws IOException {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("can't read named writeable from StreamInput");
}
/**
diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java
index ee3d8bcf75..55f3a985d9 100644
--- a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java
@@ -177,7 +177,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
public GeoDistanceRangeQueryBuilder optimizeBbox(String optimizeBbox) {
if (optimizeBbox == null) {
- throw new IllegalArgumentException("optimizeBox must not be null");
+ throw new IllegalArgumentException("optimizeBbox must not be null");
}
switch (optimizeBbox) {
case "none":
@@ -200,7 +200,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
this.validationMethod = method;
return this;
}
-
+
/** Returns validation method for coordinates. */
public GeoValidationMethod getValidationMethod() {
return this.validationMethod;
@@ -305,7 +305,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
@Override
protected boolean doEquals(GeoDistanceRangeQueryBuilder other) {
- return ((Objects.equals(fieldName, other.fieldName)) &&
+ return ((Objects.equals(fieldName, other.fieldName)) &&
(Objects.equals(point, other.point)) &&
(Objects.equals(from, other.from)) &&
(Objects.equals(to, other.to)) &&
diff --git a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java
index 3f8cc5d7e2..a93c60ec14 100644
--- a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java
@@ -121,6 +121,7 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
/** Add several fields to run the query against with a specific boost. */
public SimpleQueryStringBuilder fields(Map<String, Float> fields) {
+ Objects.requireNonNull(fields, "fields cannot be null");
this.fieldsAndWeights.putAll(fields);
return this;
}
diff --git a/core/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java b/core/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java
index 6a563afc00..3c77142221 100644
--- a/core/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java
+++ b/core/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java
@@ -25,7 +25,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -34,9 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
*/
public class TruncateTokenFilterTests extends ESTestCase {
-
- @Test
- public void simpleTest() throws IOException {
+ public void testSimple() throws IOException {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {
diff --git a/core/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java b/core/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java
index 25c4a688fe..7756933a78 100644
--- a/core/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java
+++ b/core/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java
@@ -25,7 +25,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -34,9 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class UniqueTokenFilterTests extends ESTestCase {
-
- @Test
- public void simpleTest() throws IOException {
+ public void testSimple() throws IOException {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {
diff --git a/core/src/test/java/org/apache/lucene/queries/BlendedTermQueryTests.java b/core/src/test/java/org/apache/lucene/queries/BlendedTermQueryTests.java
index 91eaeb2607..0f29ed5a2f 100644
--- a/core/src/test/java/org/apache/lucene/queries/BlendedTermQueryTests.java
+++ b/core/src/test/java/org/apache/lucene/queries/BlendedTermQueryTests.java
@@ -23,18 +23,32 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.QueryUtils;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.similarities.BM25Similarity;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
@@ -42,8 +56,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class BlendedTermQueryTests extends ESTestCase {
-
- @Test
public void testBooleanQuery() throws IOException {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
@@ -97,7 +109,6 @@ public class BlendedTermQueryTests extends ESTestCase {
}
- @Test
public void testDismaxQuery() throws IOException {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
@@ -171,7 +182,6 @@ public class BlendedTermQueryTests extends ESTestCase {
dir.close();
}
- @Test
public void testBasics() {
final int iters = scaledRandomIntBetween(5, 25);
for (int j = 0; j < iters; j++) {
@@ -209,7 +219,6 @@ public class BlendedTermQueryTests extends ESTestCase {
return searcher;
}
- @Test
public void testExtractTerms() throws IOException {
Set<Term> terms = new HashSet<>();
int num = scaledRandomIntBetween(1, 10);
diff --git a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPassageFormatterTests.java b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPassageFormatterTests.java
index dc176ae562..fcddc58f77 100644
--- a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPassageFormatterTests.java
+++ b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPassageFormatterTests.java
@@ -23,16 +23,12 @@ import org.apache.lucene.search.highlight.DefaultEncoder;
import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
public class CustomPassageFormatterTests extends ESTestCase {
-
- @Test
public void testSimpleFormat() {
String content = "This is a really cool highlighter. Postings highlighter gives nice snippets back. No matches here.";
@@ -74,7 +70,6 @@ public class CustomPassageFormatterTests extends ESTestCase {
assertThat(fragments[2].isHighlighted(), equalTo(false));
}
- @Test
public void testHtmlEncodeFormat() {
String content = "<b>This is a really cool highlighter.</b> Postings highlighter gives nice snippets back.";
diff --git a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPostingsHighlighterTests.java b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPostingsHighlighterTests.java
index 58728d8e25..737b3df41a 100644
--- a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPostingsHighlighterTests.java
+++ b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomPostingsHighlighterTests.java
@@ -24,21 +24,25 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.highlight.DefaultEncoder;
import org.apache.lucene.store.Directory;
import org.elasticsearch.search.highlight.HighlightUtils;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
public class CustomPostingsHighlighterTests extends ESTestCase {
-
- @Test
public void testCustomPostingsHighlighter() throws Exception {
-
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
@@ -106,7 +110,6 @@ public class CustomPostingsHighlighterTests extends ESTestCase {
dir.close();
}
- @Test
public void testNoMatchSize() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
diff --git a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIteratorTests.java b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIteratorTests.java
index 1be578f100..ac3a24346a 100644
--- a/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIteratorTests.java
+++ b/core/src/test/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIteratorTests.java
@@ -21,7 +21,6 @@ package org.apache.lucene.search.postingshighlight;
import org.elasticsearch.search.highlight.HighlightUtils;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.text.BreakIterator;
import java.text.CharacterIterator;
@@ -31,8 +30,6 @@ import java.util.Locale;
import static org.hamcrest.CoreMatchers.equalTo;
public class CustomSeparatorBreakIteratorTests extends ESTestCase {
-
- @Test
public void testBreakOnCustomSeparator() throws Exception {
Character separator = randomSeparator();
BreakIterator bi = new CustomSeparatorBreakIterator(separator);
@@ -69,7 +66,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertThat(source.substring(0, bi.next(3)), equalTo("this" + separator + "is" + separator + "the" + separator));
}
- @Test
public void testSingleSentences() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@@ -79,7 +75,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("", expected, actual);
}
- @Test
public void testSliceEnd() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@@ -89,7 +84,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("000", 0, 0, expected, actual);
}
- @Test
public void testSliceStart() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@@ -99,7 +93,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("000", 3, 0, expected, actual);
}
- @Test
public void testSliceMiddle() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@@ -110,7 +103,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
}
/** the current position must be ignored, initial position is always first() */
- @Test
public void testFirstPosition() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
diff --git a/core/src/test/java/org/apache/lucene/util/SloppyMathTests.java b/core/src/test/java/org/apache/lucene/util/SloppyMathTests.java
index f7d43fd130..abfc7c005e 100644
--- a/core/src/test/java/org/apache/lucene/util/SloppyMathTests.java
+++ b/core/src/test/java/org/apache/lucene/util/SloppyMathTests.java
@@ -22,13 +22,10 @@ package org.apache.lucene.util;
import org.elasticsearch.common.geo.GeoDistance;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.number.IsCloseTo.closeTo;
public class SloppyMathTests extends ESTestCase {
-
- @Test
public void testAccuracy() {
for (double lat1 = -89; lat1 <= 89; lat1+=1) {
final double lon1 = randomLongitude();
@@ -42,7 +39,6 @@ public class SloppyMathTests extends ESTestCase {
}
}
- @Test
public void testSloppyMath() {
testSloppyMath(DistanceUnit.METERS, 0.01, 5, 45, 90);
testSloppyMath(DistanceUnit.KILOMETERS, 0.01, 5, 45, 90);
@@ -53,7 +49,7 @@ public class SloppyMathTests extends ESTestCase {
private static double maxError(double distance) {
return distance / 1000.0;
}
-
+
private void testSloppyMath(DistanceUnit unit, double...deltaDeg) {
final double lat1 = randomLatitude();
final double lon1 = randomLongitude();
@@ -68,12 +64,12 @@ public class SloppyMathTests extends ESTestCase {
final double accurate = GeoDistance.ARC.calculate(lat1, lon1, lat2, lon2, unit);
final double dist = GeoDistance.SLOPPY_ARC.calculate(lat1, lon1, lat2, lon2, unit);
-
+
assertThat("distance between("+lat1+", "+lon1+") and ("+lat2+", "+lon2+"))", dist, closeTo(accurate, maxError(accurate)));
}
}
}
-
+
private static void assertAccurate(double lat1, double lon1, double lat2, double lon2) {
double accurate = GeoDistance.ARC.calculate(lat1, lon1, lat2, lon2, DistanceUnit.METERS);
double sloppy = GeoDistance.SLOPPY_ARC.calculate(lat1, lon1, lat2, lon2, DistanceUnit.METERS);
diff --git a/core/src/test/java/org/elasticsearch/ESExceptionTests.java b/core/src/test/java/org/elasticsearch/ESExceptionTests.java
index 5bb3bf4c13..4d81b3488c 100644
--- a/core/src/test/java/org/elasticsearch/ESExceptionTests.java
+++ b/core/src/test/java/org/elasticsearch/ESExceptionTests.java
@@ -37,7 +37,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentLocation;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNotFoundException;
-import org.elasticsearch.index.query.*;
+import org.elasticsearch.index.query.QueryShardException;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.SearchShardTarget;
@@ -47,7 +47,6 @@ import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.elasticsearch.transport.RemoteTransportException;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.EOFException;
import java.io.FileNotFoundException;
@@ -59,7 +58,6 @@ import static org.hamcrest.Matchers.equalTo;
public class ESExceptionTests extends ESTestCase {
private static final ToXContent.Params PARAMS = ToXContent.EMPTY_PARAMS;
- @Test
public void testStatus() {
ElasticsearchException exception = new ElasticsearchException("test");
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
diff --git a/core/src/test/java/org/elasticsearch/NamingConventionTests.java b/core/src/test/java/org/elasticsearch/NamingConventionTests.java
index 40868fc281..912f8922b0 100644
--- a/core/src/test/java/org/elasticsearch/NamingConventionTests.java
+++ b/core/src/test/java/org/elasticsearch/NamingConventionTests.java
@@ -19,15 +19,14 @@
package org.elasticsearch;
import junit.framework.TestCase;
+
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.nio.file.FileVisitResult;
@@ -91,7 +90,7 @@ public class NamingConventionTests extends ESTestCase {
} else if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) {
if (isTestCase(clazz)) {
missingSuffix.add(clazz);
- } else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) {
+ } else if (junit.framework.Test.class.isAssignableFrom(clazz)) {
pureUnitTest.add(clazz);
}
}
@@ -102,16 +101,6 @@ public class NamingConventionTests extends ESTestCase {
return FileVisitResult.CONTINUE;
}
- private boolean hasTestAnnotation(Class<?> clazz) {
- for (Method method : clazz.getDeclaredMethods()) {
- if (method.getAnnotation(Test.class) != null) {
- return true;
- }
- }
- return false;
-
- }
-
private boolean isTestCase(Class<?> clazz) {
return LuceneTestCase.class.isAssignableFrom(clazz);
}
@@ -145,7 +134,6 @@ public class NamingConventionTests extends ESTestCase {
assertTrue(innerClasses.remove(InnerTests.class));
assertTrue(notImplementing.remove(NotImplementingTests.class));
assertTrue(pureUnitTest.remove(PlainUnit.class));
- assertTrue(pureUnitTest.remove(PlainUnitTheSecond.class));
String classesToSubclass = String.join(
",",
@@ -187,11 +175,4 @@ public class NamingConventionTests extends ESTestCase {
public static final class WrongNameTheSecond extends ESTestCase {}
public static final class PlainUnit extends TestCase {}
-
- public static final class PlainUnitTheSecond {
- @Test
- public void foo() {
- }
- }
-
}
diff --git a/core/src/test/java/org/elasticsearch/VersionTests.java b/core/src/test/java/org/elasticsearch/VersionTests.java
index 3adb6d98c0..d79d1ee092 100644
--- a/core/src/test/java/org/elasticsearch/VersionTests.java
+++ b/core/src/test/java/org/elasticsearch/VersionTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.lang.reflect.Modifier;
import java.util.HashMap;
@@ -36,6 +35,7 @@ import static org.elasticsearch.Version.V_0_20_0;
import static org.elasticsearch.Version.V_0_90_0;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
@@ -102,24 +102,41 @@ public class VersionTests extends ESTestCase {
}
}
- @Test(expected = IllegalArgumentException.class)
public void testTooLongVersionFromString() {
- Version.fromString("1.0.0.1.3");
+ try {
+ Version.fromString("1.0.0.1.3");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testTooShortVersionFromString() {
- Version.fromString("1.0");
+ try {
+ Version.fromString("1.0");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
+ }
+
}
- @Test(expected = IllegalArgumentException.class)
public void testWrongVersionFromString() {
- Version.fromString("WRONG.VERSION");
+ try {
+ Version.fromString("WRONG.VERSION");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
+ }
}
- @Test(expected = IllegalStateException.class)
public void testVersionNoPresentInSettings() {
- Version.indexCreated(Settings.builder().build());
+ try {
+ Version.indexCreated(Settings.builder().build());
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("[index.version.created] is not present"));
+ }
}
public void testIndexCreatedVersion() {
diff --git a/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java b/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
index 7d52c6c77c..f68cb76c95 100644
--- a/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
+++ b/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
@@ -33,10 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
/**
*/
public class ListenerActionIT extends ESIntegTestCase {
-
- @Test
- public void verifyThreadedListeners() throws Throwable {
-
+ public void testThreadedListeners() throws Throwable {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> failure = new AtomicReference<>();
final AtomicReference<String> threadName = new AtomicReference<>();
diff --git a/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java b/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java
index becdb93386..a19905c99d 100644
--- a/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java
+++ b/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -36,7 +35,6 @@ public class OriginalIndicesTests extends ESTestCase {
IndicesOptions.lenientExpandOpen() , IndicesOptions.strictExpand(), IndicesOptions.strictExpandOpen(),
IndicesOptions.strictExpandOpenAndForbidClosed(), IndicesOptions.strictSingleIndexNoExpandForbidClosed()};
- @Test
public void testOriginalIndicesSerialization() throws IOException {
int iterations = iterations(10, 30);
for (int i = 0; i < iterations; i++) {
diff --git a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
index 3c59f677f5..fb0283db48 100644
--- a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
+++ b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -56,8 +55,7 @@ public class RejectionActionIT extends ESIntegTestCase {
}
- @Test
- public void simulateSearchRejectionLoad() throws Throwable {
+ public void testSimulatedSearchRejectionLoad() throws Throwable {
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "1").get();
}
diff --git a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
index 47fcdff277..a6217d7ea6 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsReq
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -41,8 +40,6 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.Matchers.lessThan;
public class HotThreadsIT extends ESIntegTestCase {
-
- @Test
public void testHotThreadsDontFail() throws ExecutionException, InterruptedException {
/**
* This test just checks if nothing crashes or gets stuck etc.
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponsesTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponsesTests.java
index ec05023205..ba3b10e3db 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponsesTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponsesTests.java
@@ -41,7 +41,6 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
@@ -165,7 +164,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
return builder.build();
}
- @Test
public void testClusterIndexHealth() {
int numberOfShards = randomInt(3) + 1;
int numberOfReplicas = randomInt(4);
@@ -200,7 +198,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
}
}
- @Test
public void testClusterHealth() throws IOException {
ShardCounter counter = new ShardCounter();
RoutingTable.Builder routingTable = RoutingTable.builder();
@@ -239,7 +236,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
return clusterHealth;
}
- @Test
public void testValidations() throws IOException {
IndexMetaData indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(2).build();
ShardCounter counter = new ShardCounter();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/repositories/RepositoryBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/repositories/RepositoryBlocksIT.java
index caa88ddfb7..9c554da781 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/repositories/RepositoryBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/repositories/RepositoryBlocksIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
@@ -39,8 +38,6 @@ import static org.hamcrest.Matchers.hasSize;
*/
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class RepositoryBlocksIT extends ESIntegTestCase {
-
- @Test
public void testPutRepositoryWithBlocks() {
logger.info("--> registering a repository is blocked when the cluster is read only");
try {
@@ -60,7 +57,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath())));
}
- @Test
public void testVerifyRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")
@@ -77,7 +73,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testDeleteRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")
@@ -96,7 +91,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().prepareDeleteRepository("test-repo-blocks"));
}
- @Test
public void testGetRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
index 2516310c7a..f3a23be919 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
@@ -30,10 +30,9 @@ import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Before;
-import org.junit.Test;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@@ -85,7 +84,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
public void testCreateSnapshotWithBlocks() {
logger.info("--> creating a snapshot is allowed when the cluster is read only");
try {
@@ -102,7 +100,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
assertThat(response.status(), equalTo(RestStatus.OK));
}
- @Test
public void testCreateSnapshotWithIndexBlocks() {
logger.info("--> creating a snapshot is not blocked when an index is read only");
try {
@@ -123,7 +120,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testDeleteSnapshotWithBlocks() {
logger.info("--> deleting a snapshot is allowed when the cluster is read only");
try {
@@ -134,7 +130,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testRestoreSnapshotWithBlocks() {
assertAcked(client().admin().indices().prepareDelete(INDEX_NAME, OTHER_INDEX_NAME));
assertFalse(client().admin().indices().prepareExists(INDEX_NAME, OTHER_INDEX_NAME).get().isExists());
@@ -156,7 +151,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
assertTrue(client().admin().indices().prepareExists(OTHER_INDEX_NAME).get().isExists());
}
- @Test
public void testGetSnapshotWithBlocks() {
// This test checks that the Get Snapshot operation is never blocked, even if the cluster is read only.
try {
@@ -169,7 +163,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testSnapshotStatusWithBlocks() {
// This test checks that the Snapshot Status operation is never blocked, even if the cluster is read only.
try {
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java
index 5c0627555a..a2d838bc3f 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java
@@ -21,11 +21,10 @@ package org.elasticsearch.action.admin.cluster.state;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
+import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -33,8 +32,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
* Unit tests for the {@link ClusterStateRequest}.
*/
public class ClusterStateRequestTests extends ESTestCase {
-
- @Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
index 2be808ebef..e23ce27035 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
@@ -28,13 +28,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.is;
@@ -55,7 +54,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
assertThat(actionGet.isTimedOut(), is(false));
}
- @Test
public void testNodeCounts() {
ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
assertCounts(response.getNodesStats().getCounts(), 1, 0, 0, 1, 0);
@@ -84,7 +82,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
assertThat(stats.getReplication(), Matchers.equalTo(replicationFactor));
}
- @Test
public void testIndicesShardStats() {
ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
assertThat(response.getStatus(), Matchers.equalTo(ClusterHealthStatus.GREEN));
@@ -129,7 +126,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
}
- @Test
public void testValuesSmokeScreen() throws IOException {
internalCluster().ensureAtMostNumDataNodes(5);
internalCluster().ensureAtLeastNumDataNodes(1);
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java
index a02860e8a8..95fa5b2600 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java
@@ -21,16 +21,16 @@ package org.elasticsearch.action.admin.cluster.tasks;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class PendingTasksBlocksIT extends ESIntegTestCase {
-
- @Test
public void testPendingTasksWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheBlocksIT.java
index deb57cfa24..dbc7e5cddc 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheBlocksIT.java
@@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.cache.clear;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class ClearIndicesCacheBlocksIT extends ESIntegTestCase {
-
- @Test
public void testClearIndicesCacheWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
index 0871491301..bb15421821 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
@@ -52,7 +52,7 @@ import static org.hamcrest.core.IsNull.notNullValue;
@ClusterScope(scope = Scope.TEST)
public class CreateIndexIT extends ESIntegTestCase {
- public void testCreationDate_Given() {
+ public void testCreationDateGiven() {
prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_CREATION_DATE, 4l)).get();
ClusterStateResponse response = client().admin().cluster().prepareState().get();
ClusterState state = response.getState();
@@ -67,7 +67,7 @@ public class CreateIndexIT extends ESIntegTestCase {
assertThat(index.getCreationDate(), equalTo(4l));
}
- public void testCreationDate_Generated() {
+ public void testCreationDateGenerated() {
long timeBeforeRequest = System.currentTimeMillis();
prepareCreate("test").get();
long timeAfterRequest = System.currentTimeMillis();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java
index 98569b7db8..97375061de 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.rest.NoOpClient;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -56,7 +55,6 @@ public class CreateIndexRequestBuilderTests extends ESTestCase {
/**
* test setting the source with available setters
*/
- @Test
public void testSetSource() throws IOException {
CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE);
builder.setSource("{\""+KEY+"\" : \""+VALUE+"\"}");
@@ -82,7 +80,6 @@ public class CreateIndexRequestBuilderTests extends ESTestCase {
/**
* test setting the settings with available setters
*/
- @Test
public void testSetSettings() throws IOException {
CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE);
builder.setSettings(KEY, VALUE);
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexBlocksIT.java
index 85e0072bfe..a83c209a3c 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexBlocksIT.java
@@ -21,14 +21,11 @@ package org.elasticsearch.action.admin.indices.delete;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class DeleteIndexBlocksIT extends ESIntegTestCase {
-
- @Test
public void testDeleteIndexWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/flush/FlushBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/flush/FlushBlocksIT.java
index 803262f829..50d5de4b70 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/flush/FlushBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/flush/FlushBlocksIT.java
@@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.flush;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class FlushBlocksIT extends ESIntegTestCase {
-
- @Test
public void testFlushWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexIT.java
index 9484c5e07f..e878a3df45 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexIT.java
@@ -28,22 +28,25 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_METADATA_BLOCK;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.SuiteScopeTestCase
public class GetIndexIT extends ESIntegTestCase {
-
- private static final String[] allFeatures = { "_alias", "_aliases", "_mapping", "_mappings", "_settings", "_warmer", "_warmers" };
-
@Override
protected void setupSuiteScopeCluster() throws Exception {
assertAcked(prepareCreate("idx").addAlias(new Alias("alias_idx")).addMapping("type1", "{\"type1\":{}}")
@@ -54,7 +57,6 @@ public class GetIndexIT extends ESIntegTestCase {
ensureSearchable("idx", "empty_idx");
}
- @Test
public void testSimple() {
GetIndexResponse response = client().admin().indices().prepareGetIndex().addIndices("idx").get();
String[] indices = response.indices();
@@ -67,12 +69,15 @@ public class GetIndexIT extends ESIntegTestCase {
assertWarmers(response, "idx");
}
- @Test(expected=IndexNotFoundException.class)
public void testSimpleUnknownIndex() {
- client().admin().indices().prepareGetIndex().addIndices("missing_idx").get();
+ try {
+ client().admin().indices().prepareGetIndex().addIndices("missing_idx").get();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
public void testEmpty() {
GetIndexResponse response = client().admin().indices().prepareGetIndex().addIndices("empty_idx").get();
String[] indices = response.indices();
@@ -85,7 +90,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
- @Test
public void testSimpleMapping() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.MAPPINGS);
@@ -99,7 +103,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
- @Test
public void testSimpleAlias() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.ALIASES);
@@ -113,7 +116,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
- @Test
public void testSimpleSettings() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.SETTINGS);
@@ -127,7 +129,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
- @Test
public void testSimpleWarmer() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.WARMERS);
@@ -141,7 +142,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptySettings(response);
}
- @Test
public void testSimpleMixedFeatures() {
int numFeatures = randomIntBetween(1, Feature.values().length);
List<Feature> features = new ArrayList<Feature>(numFeatures);
@@ -176,7 +176,6 @@ public class GetIndexIT extends ESIntegTestCase {
}
}
- @Test
public void testEmptyMixedFeatures() {
int numFeatures = randomIntBetween(1, Feature.values().length);
List<Feature> features = new ArrayList<Feature>(numFeatures);
@@ -203,7 +202,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
- @Test
public void testGetIndexWithBlocks() {
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
try {
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/optimize/OptimizeBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/optimize/OptimizeBlocksIT.java
index 6b6e663b29..cfe2c2c7a6 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/optimize/OptimizeBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/optimize/OptimizeBlocksIT.java
@@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.optimize;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class OptimizeBlocksIT extends ESIntegTestCase {
-
- @Test
public void testOptimizeWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/refresh/RefreshBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/refresh/RefreshBlocksIT.java
index 5815ce8c26..33e03010d5 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/refresh/RefreshBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/refresh/RefreshBlocksIT.java
@@ -22,19 +22,19 @@ package org.elasticsearch.action.admin.indices.refresh;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class RefreshBlocksIT extends ESIntegTestCase {
-
- @Test
public void testRefreshWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsBlocksIT.java
index fcb7a509d5..035c760d84 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsBlocksIT.java
@@ -21,18 +21,18 @@ package org.elasticsearch.action.admin.indices.segments;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesSegmentsBlocksIT extends ESIntegTestCase {
-
- @Test
public void testIndicesSegmentsWithBlocks() {
createIndex("test-blocks");
ensureGreen("test-blocks");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequestTests.java
index 9db47f6ab3..011ce815a0 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequestTests.java
@@ -22,14 +22,16 @@ package org.elasticsearch.action.admin.indices.segments;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.engine.Segment;
+import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.util.List;
+import static org.hamcrest.Matchers.is;
+
public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
-
+
@Before
public void setupIndex() {
Settings settings = Settings.builder()
@@ -51,7 +53,7 @@ public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
List<Segment> segments = rsp.getIndices().get("test").iterator().next().getShards()[0].getSegments();
assertNull(segments.get(0).ramTree);
}
-
+
public void testVerbose() {
IndicesSegmentResponse rsp = client().admin().indices().prepareSegments("test").setVerbose(true).get();
List<Segment> segments = rsp.getIndices().get("test").iterator().next().getShards()[0].getSegments();
@@ -61,10 +63,14 @@ public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
/**
* with the default IndicesOptions inherited from BroadcastOperationRequest this will raise an exception
*/
- @Test(expected=org.elasticsearch.indices.IndexClosedException.class)
public void testRequestOnClosedIndex() {
client().admin().indices().prepareClose("test").get();
- client().admin().indices().prepareSegments("test").get();
+ try {
+ client().admin().indices().prepareSegments("test").get();
+ fail("Expected IndexClosedException");
+ } catch (IndexClosedException e) {
+ assertThat(e.getMessage(), is("closed"));
+ }
}
/**
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
index de9eadaf05..8d5fb6567e 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
@@ -20,14 +20,16 @@
package org.elasticsearch.action.admin.indices.shards;
import com.carrotsearch.hppc.cursors.IntObjectCursor;
-
import com.carrotsearch.hppc.cursors.ObjectCursor;
+
import org.apache.lucene.index.CorruptIndexException;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.IndexRoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
@@ -37,27 +39,31 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.store.MockFSDirectoryService;
-import org.junit.Test;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.function.Predicate;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesShardStoreRequestIT extends ESIntegTestCase {
-
- @Test
public void testEmpty() {
ensureGreen();
IndicesShardStoresResponse rsp = client().admin().indices().prepareShardStores().get();
assertThat(rsp.getStoreStatuses().size(), equalTo(0));
}
- @Test
@TestLogging("action.admin.indices.shards:TRACE,cluster.service:TRACE")
public void testBasic() throws Exception {
String index = "test";
@@ -108,7 +114,6 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
enableAllocation(index);
}
- @Test
public void testIndices() throws Exception {
String index1 = "test1";
String index2 = "test2";
@@ -137,7 +142,6 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
assertThat(shardStatuses.get(index1).size(), equalTo(2));
}
- @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/12416")
public void testCorruptedShards() throws Exception {
String index = "test";
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java
index 777555f5b7..c862583a3f 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java
@@ -26,19 +26,24 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.transport.DummyTransportAddress;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.NodeDisconnectedException;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
public class IndicesShardStoreResponseTests extends ESTestCase {
-
- @Test
public void testBasicSerialization() throws Exception {
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>>> indexStoreStatuses = ImmutableOpenMap.builder();
List<IndicesShardStoresResponse.Failure> failures = new ArrayList<>();
@@ -104,7 +109,6 @@ public class IndicesShardStoreResponseTests extends ESTestCase {
}
}
- @Test
public void testStoreStatusOrdering() throws Exception {
DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, Version.CURRENT);
List<IndicesShardStoresResponse.StoreStatus> orderedStoreStatuses = new ArrayList<>();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsBlocksIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsBlocksIT.java
index 125c4e4602..25fdb7a84d 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsBlocksIT.java
@@ -23,16 +23,15 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesStatsBlocksIT extends ESIntegTestCase {
-
- @Test
public void testIndicesStatsWithBlocks() {
createIndex("ro");
ensureGreen("ro");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
index 9c9802dbb5..4abb43e4ed 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService.PutReques
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.InvalidIndexTemplateException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,7 +38,6 @@ import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
public class MetaDataIndexTemplateServiceTests extends ESTestCase {
- @Test
public void testIndexTemplateInvalidNumberOfShards() {
PutRequest request = new PutRequest("test", "test_shards");
request.template("test_shards*");
@@ -54,7 +52,6 @@ public class MetaDataIndexTemplateServiceTests extends ESTestCase {
assertThat(throwables.get(0).getMessage(), containsString("index must have 1 or more primary shards"));
}
- @Test
public void testIndexTemplateValidationAccumulatesValidationErrors() {
PutRequest request = new PutRequest("test", "putTemplate shards");
request.template("_test_shards*");
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java
index 1a17a4c78a..f20564e171 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java
@@ -20,14 +20,12 @@ package org.elasticsearch.action.admin.indices.warmer.put;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.hasSize;
public class PutWarmerRequestTests extends ESTestCase {
-
- @Test // issue 4196
+ // issue 4196
public void testThatValidationWithoutSpecifyingSearchRequestFails() {
PutWarmerRequest putWarmerRequest = new PutWarmerRequest("foo");
ActionRequestValidationException validationException = putWarmerRequest.validate();
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
index 7d946ed378..4300a629fb 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
@@ -20,17 +20,14 @@
package org.elasticsearch.action.bulk;
-import java.nio.charset.StandardCharsets;
-
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+
+import java.nio.charset.StandardCharsets;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
public class BulkIntegrationIT extends ESIntegTestCase {
-
- @Test
public void testBulkIndexCreatesMapping() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/bulk-log.json");
BulkRequestBuilder bulkBuilder = client().prepareBulk();
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
index b26a10f100..35fb73b7bf 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
@@ -23,12 +23,9 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class BulkProcessorClusterSettingsIT extends ESIntegTestCase {
-
- @Test
public void testBulkProcessorAutoCreateRestrictions() throws Exception {
// See issue #8125
Settings settings = Settings.settingsBuilder().put("action.auto_create_index", false).build();
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java
index dd39f85338..ded2abb494 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@@ -45,13 +44,16 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class BulkProcessorIT extends ESIntegTestCase {
-
- @Test
public void testThatBulkProcessorCountIsCorrect() throws InterruptedException {
-
final CountDownLatch latch = new CountDownLatch(1);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
@@ -74,7 +76,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
}
}
- @Test
public void testBulkProcessorFlush() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
@@ -101,7 +102,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
}
}
- @Test
public void testBulkProcessorConcurrentRequests() throws Exception {
int bulkActions = randomIntBetween(10, 100);
int numDocs = randomIntBetween(bulkActions, bulkActions + 100);
@@ -153,7 +153,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
assertMultiGetResponse(multiGetRequestBuilder.get(), numDocs);
}
- @Test
//https://github.com/elasticsearch/elasticsearch/issues/5038
public void testBulkProcessorConcurrentRequestsNoNodeAvailableException() throws Exception {
//we create a transport client with no nodes to make sure it throws NoNodeAvailableException
@@ -196,7 +195,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
transportClient.close();
}
- @Test
public void testBulkProcessorWaitOnClose() throws Exception {
BulkProcessorTestListener listener = new BulkProcessorTestListener();
@@ -205,7 +203,7 @@ public class BulkProcessorIT extends ESIntegTestCase {
//let's make sure that the bulk action limit trips, one single execution will index all the documents
.setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs)
.setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10),
- (ByteSizeUnit)RandomPicks.randomFrom(getRandom(), ByteSizeUnit.values())))
+ RandomPicks.randomFrom(getRandom(), ByteSizeUnit.values())))
.build();
MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs);
@@ -227,7 +225,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
assertMultiGetResponse(multiGetRequestBuilder.get(), numDocs);
}
- @Test
public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception {
createIndex("test-ro");
assertAcked(client().admin().indices().prepareUpdateSettings("test-ro")
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
index 207ebdb9f6..0242edae31 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
@@ -19,8 +19,6 @@
package org.elasticsearch.action.bulk;
-import java.nio.charset.StandardCharsets;
-
import org.apache.lucene.util.Constants;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.delete.DeleteRequest;
@@ -31,8 +29,8 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.script.Script;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -43,8 +41,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
public class BulkRequestTests extends ESTestCase {
-
- @Test
public void testSimpleBulk1() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
// translate Windows line endings (\r\n) to standard ones (\n)
@@ -59,7 +55,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(((IndexRequest) bulkRequest.requests().get(2)).source().toBytes(), equalTo(new BytesArray("{ \"field1\" : \"value3\" }").toBytes()));
}
- @Test
public void testSimpleBulk2() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk2.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -67,7 +62,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
- @Test
public void testSimpleBulk3() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk3.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -75,7 +69,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
- @Test
public void testSimpleBulk4() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk4.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -98,7 +91,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(((UpdateRequest) bulkRequest.requests().get(1)).upsertRequest().source().toUtf8(), equalTo("{\"counter\":1}"));
}
- @Test
public void testBulkAllowExplicitIndex() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
try {
@@ -112,7 +104,6 @@ public class BulkRequestTests extends ESTestCase {
new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", null, false);
}
- @Test
public void testBulkAddIterable() {
BulkRequest bulkRequest = Requests.bulkRequest();
List<ActionRequest> requests = new ArrayList<>();
@@ -126,7 +117,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.requests().get(2), instanceOf(DeleteRequest.class));
}
- @Test
public void testSimpleBulk6() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk6.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -139,7 +129,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
- @Test
public void testSimpleBulk7() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk7.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -152,7 +141,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
- @Test
public void testSimpleBulk8() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk8.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -165,7 +153,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
- @Test
public void testSimpleBulk9() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk9.json");
BulkRequest bulkRequest = new BulkRequest();
@@ -178,7 +165,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
- @Test
public void testSimpleBulk10() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk10.json");
BulkRequest bulkRequest = new BulkRequest();
diff --git a/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java b/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java
index c48f65be4b..451ade6258 100644
--- a/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -32,8 +31,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class MultiGetShardRequestTests extends ESTestCase {
-
- @Test
public void testSerialization() throws IOException {
MultiGetRequest multiGetRequest = new MultiGetRequest();
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestBuilderTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestBuilderTests.java
index f9dc86b59e..badb79e21b 100644
--- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestBuilderTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.rest.NoOpClient;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
@@ -55,7 +54,6 @@ public class IndexRequestBuilderTests extends ESTestCase {
/**
* test setting the source for the request with different available setters
*/
- @Test
public void testSetSource() throws Exception {
IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(this.testClient, IndexAction.INSTANCE);
Map<String, String> source = new HashMap<>();
diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java
index 7c08a0db35..0739b5da02 100644
--- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java
@@ -20,19 +20,19 @@ package org.elasticsearch.action.index;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
/**
*/
public class IndexRequestTests extends ESTestCase {
-
- @Test
public void testIndexRequestOpTypeFromString() throws Exception {
String create = "create";
String index = "index";
@@ -45,10 +45,13 @@ public class IndexRequestTests extends ESTestCase {
assertThat(IndexRequest.OpType.fromString(indexUpper), equalTo(IndexRequest.OpType.INDEX));
}
- @Test(expected = IllegalArgumentException.class)
public void testReadBogusString() {
- String foobar = "foobar";
- IndexRequest.OpType.fromString(foobar);
+ try {
+ IndexRequest.OpType.fromString("foobar");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("opType [foobar] not allowed"));
+ }
}
public void testCreateOperationRejectsVersions() {
diff --git a/core/src/test/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequestTests.java b/core/src/test/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequestTests.java
index ea1d3ba8d9..af09af9a64 100644
--- a/core/src/test/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequestTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -31,8 +30,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class GetIndexedScriptRequestTests extends ESTestCase {
-
- @Test
public void testGetIndexedScriptRequestSerialization() throws IOException {
GetIndexedScriptRequest request = new GetIndexedScriptRequest("lang", "id");
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java b/core/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java
index 48c75d8267..16251463d5 100644
--- a/core/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java
@@ -20,20 +20,19 @@ package org.elasticsearch.action.percolate;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.collect.MapBuilder;
-import org.elasticsearch.test.StreamsUtils;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.StreamsUtils;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
public class MultiPercolatorRequestTests extends ESTestCase {
-
- @Test
public void testParseBulkRequests() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate1.json");
MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length);
@@ -150,8 +149,7 @@ public class MultiPercolatorRequestTests extends ESTestCase {
assertThat(sourceMap.get("doc"), nullValue());
}
- @Test
- public void testParseBulkRequests_defaults() throws Exception {
+ public void testParseBulkRequestsDefaults() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate2.json");
MultiPercolateRequest request = new MultiPercolateRequest();
request.indices("my-index1").documentType("my-type1").indicesOptions(IndicesOptions.lenientExpandOpen());
diff --git a/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java b/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
index 5d486f88b4..ee0ceef172 100644
--- a/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.rest.action.search.RestMultiSearchAction;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.StreamsUtils;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@@ -42,9 +41,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class MultiSearchRequestTests extends ESTestCase {
-
- @Test
- public void simpleAdd() throws Exception {
+ public void testSimpleAdd() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch1.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@@ -71,9 +68,8 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(7).types().length, equalTo(0));
}
- @Test
- public void simpleAdd2() throws Exception {
- IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
+ public void testSimpleAdd2() throws Exception {
+ IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch2.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
null, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true, registry, ParseFieldMatcher.EMPTY);
@@ -91,8 +87,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(4).types().length, equalTo(0));
}
- @Test
- public void simpleAdd3() throws Exception {
+ public void testSimpleAdd3() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch3.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@@ -112,8 +107,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(3).searchType(), equalTo(SearchType.DFS_QUERY_THEN_FETCH));
}
- @Test
- public void simpleAdd4() throws Exception {
+ public void testSimpleAdd4() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch4.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@@ -135,8 +129,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(2).routing(), equalTo("123"));
}
- @Test
- public void simpleAdd5() throws Exception {
+ public void testSimpleAdd5() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch5.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), true, null, null,
diff --git a/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java b/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java
index 34bea06d13..fc6453318c 100644
--- a/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java
@@ -27,12 +27,10 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
public class SearchRequestBuilderTests extends ESTestCase {
-
private static Client client;
@BeforeClass
@@ -51,27 +49,23 @@ public class SearchRequestBuilderTests extends ESTestCase {
client = null;
}
- @Test
public void testEmptySourceToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().toString()));
}
- @Test
public void testQueryBuilderQueryToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()).toString()));
}
- @Test
public void testSearchSourceBuilderToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
searchRequestBuilder.setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")).toString()));
}
- @Test
public void testThatToStringDoesntWipeRequestSource() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch().setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
String preToString = searchRequestBuilder.request().toString();
diff --git a/core/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java b/core/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java
index c681a6107c..d5ed5302b9 100644
--- a/core/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java
@@ -23,14 +23,11 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class IndicesOptionsTests extends ESTestCase {
-
- @Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {
@@ -55,7 +52,6 @@ public class IndicesOptionsTests extends ESTestCase {
}
}
- @Test
public void testFromOptions() {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {
diff --git a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
index 148fc70d12..f21013b7fb 100644
--- a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -41,7 +40,9 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.notNullValue;
public class TransportActionFilterChainTests extends ESTestCase {
@@ -52,9 +53,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
counter = new AtomicInteger();
}
- @Test
public void testActionFiltersRequest() throws ExecutionException, InterruptedException {
-
int numFilters = randomInt(10);
Set<Integer> orders = new HashSet<>(numFilters);
while (orders.size() < numFilters) {
@@ -134,9 +133,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
- @Test
public void testActionFiltersResponse() throws ExecutionException, InterruptedException {
-
int numFilters = randomInt(10);
Set<Integer> orders = new HashSet<>(numFilters);
while (orders.size() < numFilters) {
@@ -216,9 +213,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
- @Test
public void testTooManyContinueProcessingRequest() throws ExecutionException, InterruptedException {
-
final int additionalContinueCount = randomInt(10);
RequestTestFilter testFilter = new RequestTestFilter(randomInt(), new RequestCallback() {
@@ -274,9 +269,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
- @Test
public void testTooManyContinueProcessingResponse() throws ExecutionException, InterruptedException {
-
final int additionalContinueCount = randomInt(10);
ResponseTestFilter testFilter = new ResponseTestFilter(randomInt(), new ResponseCallback() {
diff --git a/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java b/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
index d3dd75c8de..59a69149be 100644
--- a/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
@@ -49,7 +49,6 @@ import org.elasticsearch.transport.TransportService;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
@@ -146,7 +145,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
}
}
- @Test
public void testLocalOperationWithoutBlocks() throws ExecutionException, InterruptedException {
final boolean masterOperationFailure = randomBoolean();
@@ -182,7 +180,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
}
}
- @Test
public void testLocalOperationWithBlocks() throws ExecutionException, InterruptedException {
final boolean retryableBlock = randomBoolean();
final boolean unblockBeforeTimeout = randomBoolean();
@@ -217,7 +214,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertListenerThrows("ClusterBlockException should be thrown", listener, ClusterBlockException.class);
}
- @Test
public void testForceLocalOperation() throws ExecutionException, InterruptedException {
Request request = new Request();
PlainActionFuture<Response> listener = new PlainActionFuture<>();
@@ -235,7 +231,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
listener.get();
}
- @Test
public void testMasterNotAvailable() throws ExecutionException, InterruptedException {
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(0));
clusterService.setState(ClusterStateCreationUtils.state(localNode, null, allNodes));
@@ -245,7 +240,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertListenerThrows("MasterNotDiscoveredException should be thrown", listener, MasterNotDiscoveredException.class);
}
- @Test
public void testMasterBecomesAvailable() throws ExecutionException, InterruptedException {
Request request = new Request();
clusterService.setState(ClusterStateCreationUtils.state(localNode, null, allNodes));
@@ -257,7 +251,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
listener.get();
}
- @Test
public void testDelegateToMaster() throws ExecutionException, InterruptedException {
Request request = new Request();
clusterService.setState(ClusterStateCreationUtils.state(localNode, remoteNode, allNodes));
@@ -286,7 +279,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertThat(listener.get(), equalTo(response));
}
- @Test
public void testDelegateToFailingMaster() throws ExecutionException, InterruptedException {
boolean failsWithConnectTransportException = randomBoolean();
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(failsWithConnectTransportException ? 60 : 0));
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
index 2fe04bb923..d31a024187 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
@@ -48,7 +48,6 @@ import org.elasticsearch.transport.local.LocalTransport;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.util.Date;
@@ -59,8 +58,12 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.state;
+import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithAssignedPrimariesAndOneReplica;
+import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithNoShard;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class BroadcastReplicationTests extends ESTestCase {
@@ -92,7 +95,6 @@ public class BroadcastReplicationTests extends ESTestCase {
threadPool = null;
}
- @Test
public void testNotStartedPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
clusterService.setState(state(index, randomBoolean(),
@@ -112,7 +114,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(2, 0, 0, response.get(), null);
}
- @Test
public void testStartedPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
clusterService.setState(state(index, randomBoolean(),
@@ -128,7 +129,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(1, 1, 0, response.get(), null);
}
- @Test
public void testResultCombine() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
int numShards = randomInt(3);
@@ -161,7 +161,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(2 * numShards, succeeded, failed, response.get(), Exception.class);
}
- @Test
public void testNoShards() throws InterruptedException, ExecutionException, IOException {
clusterService.setState(stateWithNoShard());
logger.debug("--> using initial state:\n{}", clusterService.state().prettyPrint());
@@ -169,7 +168,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(0, 0, 0, response, null);
}
- @Test
public void testShardsList() throws InterruptedException, ExecutionException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
index d368194dae..b015614e32 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
@@ -61,7 +61,6 @@ import org.elasticsearch.transport.TransportService;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashSet;
@@ -125,7 +124,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
- @Test
public void testBlocks() throws ExecutionException, InterruptedException {
Request request = new Request();
PlainActionFuture<Response> listener = new PlainActionFuture<>();
@@ -162,7 +160,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertEquals(1, count.get());
}
- @Test
public void testNotStartedPrimary() throws InterruptedException, ExecutionException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -192,7 +189,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
- @Test
public void testRoutingToPrimary() {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -227,7 +223,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
- @Test
public void testWriteConsistency() throws ExecutionException, InterruptedException {
action = new ActionWithConsistency(Settings.EMPTY, "testActionWithConsistency", transportService, clusterService, threadPool);
final String index = "test";
@@ -295,7 +290,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
- @Test
public void testReplication() throws ExecutionException, InterruptedException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -319,7 +313,6 @@ public class TransportReplicationActionTests extends ESTestCase {
runReplicateTest(shardRoutingTable, assignedReplicas, totalShards);
}
- @Test
public void testReplicationWithShadowIndex() throws ExecutionException, InterruptedException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -410,7 +403,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
- @Test
public void testCounterOnPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -451,7 +443,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertThat(transport.capturedRequests().length, equalTo(0));
}
- @Test
public void testCounterIncrementedWhileReplicationOngoing() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@@ -479,7 +470,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
- @Test
public void testReplicasCounter() throws Exception {
final ShardId shardId = new ShardId("test", 0);
clusterService.setState(state(shardId.index().getName(), true,
@@ -514,7 +504,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
- @Test
public void testCounterDecrementedIfShardOperationThrowsException() throws InterruptedException, ExecutionException, IOException {
action = new ActionWithExceptions(Settings.EMPTY, "testActionWithExceptions", transportService, clusterService, threadPool);
final String index = "test";
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java
index 1d0c317f5a..28d4b0f4c4 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java
@@ -31,7 +31,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
@@ -59,7 +58,6 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase {
.build();
}
- @Test
public void testSimpleTermVectors() throws IOException {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
index 6f04697463..5507686e35 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
@@ -20,6 +20,7 @@
package org.elasticsearch.action.termvectors;
import com.carrotsearch.hppc.ObjectIntHashMap;
+
import org.apache.lucene.analysis.payloads.PayloadHelper;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DirectoryReader;
@@ -41,7 +42,6 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.mapper.FieldMapper;
import org.hamcrest.Matcher;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -63,8 +63,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
-
- @Test
public void testNoSuchDoc() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@@ -91,7 +89,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@@ -119,7 +116,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(actionGet.getFields().terms("existingfield"), nullValue());
}
- @Test
public void testExistingFieldButNotInDocNPE() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@@ -150,7 +146,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(actionGet.getFields().terms("existingfield"), nullValue());
}
- @Test
public void testNotIndexedField() throws Exception {
// must be of type string and indexed.
assertAcked(prepareCreate("test")
@@ -193,7 +188,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testSimpleTermVectors() throws IOException {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@@ -231,7 +225,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testRandomSingleTermVectors() throws IOException {
FieldType ft = new FieldType();
int config = randomInt(6);
@@ -392,7 +385,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return ret;
}
- @Test
public void testDuelESLucene() throws Exception {
TestFieldSetting[] testFieldSettings = getFieldSettings();
createIndexBasedOnFieldSettings("test", "alias", testFieldSettings);
@@ -419,7 +411,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOException {
//create the test document
int encoding = randomIntBetween(0, 2);
@@ -587,7 +578,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
// like testSimpleTermVectors but we create fields with no term vectors
- @Test
public void testSimpleTermVectorsWithGenerate() throws IOException {
String[] fieldNames = new String[10];
for (int i = 0; i < fieldNames.length; i++) {
@@ -680,7 +670,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(iterator.next(), nullValue());
}
- @Test
public void testDuelWithAndWithoutTermVectors() throws IOException, ExecutionException, InterruptedException {
// setup indices
String[] indexNames = new String[] {"with_tv", "without_tv"};
@@ -769,7 +758,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(iter1.next(), nullValue());
}
- @Test
public void testSimpleWildCards() throws IOException {
int numFields = 25;
@@ -797,7 +785,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat("All term vectors should have been generated", response.getFields().size(), equalTo(numFields));
}
- @Test
public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException {
// setup indices
Settings.Builder settings = settingsBuilder()
@@ -856,7 +843,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testArtificialNoDoc() throws IOException {
// setup indices
Settings.Builder settings = settingsBuilder()
@@ -885,7 +871,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
checkBrownFoxTermVector(resp.getFields(), "field1", false);
}
- @Test
public void testArtificialNonExistingField() throws Exception {
// setup indices
Settings.Builder settings = settingsBuilder()
@@ -933,7 +918,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testPerFieldAnalyzer() throws IOException {
int numFields = 25;
@@ -1030,7 +1014,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return randomBoolean() ? "test" : "alias";
}
- @Test
public void testDfs() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@@ -1135,7 +1118,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return lessThan(value);
}
- @Test
public void testTermVectorsWithVersion() {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
@@ -1239,7 +1221,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(2l));
}
- @Test
public void testFilterLength() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@@ -1278,7 +1259,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@@ -1319,7 +1299,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
- @Test
public void testFilterDocFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
index e70937ed57..516eaf371e 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
@@ -28,16 +28,16 @@ import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.engine.VersionConflictEngineException;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
-
- @Test
public void testDuelESLucene() throws Exception {
AbstractTermVectorsTestCase.TestFieldSetting[] testFieldSettings = getFieldSettings();
createIndexBasedOnFieldSettings("test", "alias", testFieldSettings);
@@ -73,7 +73,6 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
}
- @Test
public void testMissingIndexThrowsMissingIndex() throws Exception {
TermVectorsRequestBuilder requestBuilder = client().prepareTermVectors("testX", "typeX", Integer.toString(1));
MultiTermVectorsRequestBuilder mtvBuilder = client().prepareMultiTermVectors();
@@ -84,7 +83,6 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getResponses()[0].getFailure().getCause().getMessage(), equalTo("no such index"));
}
- @Test
public void testMultiTermVectorsWithVersion() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java b/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java
index 82809d1c5c..cab27df693 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java
@@ -20,9 +20,17 @@
package org.elasticsearch.action.termvectors;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.*;
-import org.apache.lucene.index.*;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.Fields;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -44,7 +52,6 @@ import org.elasticsearch.rest.action.termvectors.RestTermVectorsAction;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.StreamsUtils;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -57,10 +64,7 @@ import java.util.Set;
import static org.hamcrest.Matchers.equalTo;
public class TermVectorsUnitTests extends ESTestCase {
-
- @Test
- public void streamResponse() throws Exception {
-
+ public void testStreamResponse() throws Exception {
TermVectorsResponse outResponse = new TermVectorsResponse("a", "b", "c");
outResponse.setExists(true);
writeStandardTermVector(outResponse);
@@ -169,7 +173,6 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat(fields.size(), equalTo(2));
}
- @Test
public void testRestRequestParsing() throws Exception {
BytesReference inputBytes = new BytesArray(
" {\"fields\" : [\"a\", \"b\",\"c\"], \"offsets\":false, \"positions\":false, \"payloads\":true}");
@@ -207,7 +210,6 @@ public class TermVectorsUnitTests extends ESTestCase {
}
- @Test
public void testRequestParsingThrowsException() throws Exception {
BytesReference inputBytes = new BytesArray(
" {\"fields\" : \"a, b,c \", \"offsets\":false, \"positions\":false, \"payloads\":true, \"meaningless_term\":2}");
@@ -223,9 +225,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
- @Test
- public void streamRequest() throws IOException {
-
+ public void testStreamRequest() throws IOException {
for (int i = 0; i < 10; i++) {
TermVectorsRequest request = new TermVectorsRequest("index", "type", "id");
request.offsets(random().nextBoolean());
@@ -259,8 +259,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
}
-
- @Test
+
public void testFieldTypeToTermVectorString() throws Exception {
FieldType ft = new FieldType();
ft.setStoreTermVectorOffsets(false);
@@ -279,7 +278,6 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.", exceptiontrown, equalTo(false));
}
- @Test
public void testTermVectorStringGenerationWithoutPositions() throws Exception {
FieldType ft = new FieldType();
ft.setStoreTermVectorOffsets(true);
@@ -290,14 +288,13 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat(ftOpts, equalTo("with_offsets"));
}
- @Test
public void testMultiParser() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest1.json");
BytesReference bytes = new BytesArray(data);
MultiTermVectorsRequest request = new MultiTermVectorsRequest();
request.add(new TermVectorsRequest(), bytes);
checkParsedParameters(request);
-
+
data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest2.json");
bytes = new BytesArray(data);
request = new MultiTermVectorsRequest();
@@ -326,7 +323,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
}
- @Test // issue #12311
+ // issue #12311
public void testMultiParserFilter() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest3.json");
BytesReference bytes = new BytesArray(data);
diff --git a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
index 6be5fe95fd..bc9bd2b909 100644
--- a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
@@ -29,18 +29,17 @@ import org.elasticsearch.index.get.GetResult;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class UpdateRequestTests extends ESTestCase {
-
- @Test
public void testUpdateRequest() throws Exception {
UpdateRequest request = new UpdateRequest("test", "type", "1");
// simple script
@@ -126,7 +125,7 @@ public class UpdateRequestTests extends ESTestCase {
assertThat(((Map) doc.get("compound")).get("field2").toString(), equalTo("value2"));
}
- @Test // Related to issue 3256
+ // Related to issue 3256
public void testUpdateRequestWithTTL() throws Exception {
long providedTTLValue = randomIntBetween(500, 1000);
Settings settings = settings(Version.CURRENT).build();
diff --git a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java
index 2742f554e3..81b09c8c8e 100644
--- a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java
+++ b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java
@@ -44,7 +44,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@@ -80,8 +79,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class IndexAliasesIT extends ESIntegTestCase {
-
- @Test
public void testAliases() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@@ -108,7 +105,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(indexResponse.getIndex(), equalTo("test_x"));
}
- @Test
public void testFailedFilter() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@@ -134,7 +130,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testFilteringAliases() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "user", "type=string"));
@@ -153,7 +148,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
- @Test
public void testEmptyFilter() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@@ -163,7 +157,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", "{}"));
}
- @Test
public void testSearchingFilteringAliasesSingleIndex() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type1", "id", "type=string", "name", "type=string"));
@@ -244,7 +237,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
}
- @Test
public void testSearchingFilteringAliasesTwoIndices() throws Exception {
logger.info("--> creating index [test1]");
assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string"));
@@ -308,7 +300,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("foos", "aliasToTests").setSize(0).setQuery(QueryBuilders.termQuery("name", "something")).get().getHits().totalHits(), equalTo(2L));
}
- @Test
public void testSearchingFilteringAliasesMultipleIndices() throws Exception {
logger.info("--> creating indices");
createIndex("test1", "test2", "test3");
@@ -373,7 +364,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("filter23", "filter13", "test1", "test2").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().totalHits(), equalTo(8L));
}
- @Test
public void testDeletingByQueryFilteringAliases() throws Exception {
logger.info("--> creating index [test1] and [test2");
assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string"));
@@ -411,9 +401,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("bars").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().totalHits(), equalTo(1L));
}
-
-
- @Test
public void testDeleteAliases() throws Exception {
logger.info("--> creating index [test1] and [test2]");
assertAcked(prepareCreate("test1").addMapping("type", "name", "type=string"));
@@ -442,8 +429,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.exists(), equalTo(false));
}
-
- @Test
public void testWaitForAliasCreationMultipleShards() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@@ -456,7 +441,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testWaitForAliasCreationSingleShard() throws Exception {
logger.info("--> creating index [test]");
assertAcked(admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.numberOfReplicas", 0).put("index.numberOfShards", 1))).get());
@@ -469,7 +453,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testWaitForAliasSimultaneousUpdate() throws Exception {
final int aliasCount = 10;
@@ -497,8 +480,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
-
- @Test
public void testSameAlias() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "name", "type=string"));
@@ -540,18 +521,20 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
- @Test(expected = AliasesNotFoundException.class)
public void testIndicesRemoveNonExistingAliasResponds404() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
ensureGreen();
logger.info("--> deleting alias1 which does not exist");
- assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1")));
+ try {
+ admin().indices().prepareAliases().removeAlias("test", "alias1").get();
+ fail("Expected AliasesNotFoundException");
+ } catch (AliasesNotFoundException e) {
+ assertThat(e.getMessage(), containsString("[alias1] missing"));
+ }
}
- @Test
public void testIndicesGetAliases() throws Exception {
-
logger.info("--> creating indices [foobar, test, test123, foobarbaz, bazbar]");
createIndex("foobar");
createIndex("test");
@@ -736,7 +719,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(existsResponse.exists(), equalTo(false));
}
- @Test
public void testAddAliasNullWithoutExistingIndices() {
try {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction(null, "alias1")));
@@ -747,7 +729,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testAddAliasNullWithExistingIndices() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@@ -764,64 +745,89 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test(expected = ActionRequestValidationException.class)
public void testAddAliasEmptyIndex() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "alias1")).get();
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "alias1")).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("[index] may not be empty string"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
public void testAddAliasNullAlias() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", null)).get();
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", null)).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("requires an [alias] to be set"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
public void testAddAliasEmptyAlias() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", "")).get();
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", "")).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("requires an [alias] to be set"));
+ }
}
- @Test
public void testAddAliasNullAliasNullIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction(null, null)).get();
- assertTrue("Should throw " + ActionRequestValidationException.class.getSimpleName(), false);
+ fail("Should throw " + ActionRequestValidationException.class.getSimpleName());
} catch (ActionRequestValidationException e) {
assertThat(e.validationErrors(), notNullValue());
assertThat(e.validationErrors().size(), equalTo(2));
}
}
- @Test
public void testAddAliasEmptyAliasEmptyIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "")).get();
- assertTrue("Should throw " + ActionRequestValidationException.class.getSimpleName(), false);
+ fail("Should throw " + ActionRequestValidationException.class.getSimpleName());
} catch (ActionRequestValidationException e) {
assertThat(e.validationErrors(), notNullValue());
assertThat(e.validationErrors().size(), equalTo(2));
}
}
- @Test(expected = ActionRequestValidationException.class)
- public void tesRemoveAliasNullIndex() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, "alias1")).get();
+ public void testRemoveAliasNullIndex() {
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, "alias1")).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("[index] may not be empty string"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
- public void tesRemoveAliasEmptyIndex() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("", "alias1")).get();
+ public void testRemoveAliasEmptyIndex() {
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("", "alias1")).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("[index] may not be empty string"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
- public void tesRemoveAliasNullAlias() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", null)).get();
+ public void testRemoveAliasNullAlias() {
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", null)).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("[alias] may not be empty string"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
- public void tesRemoveAliasEmptyAlias() {
- admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", "")).get();
+ public void testRemoveAliasEmptyAlias() {
+ try {
+ admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", "")).get();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("[alias] may not be empty string"));
+ }
}
- @Test
public void testRemoveAliasNullAliasNullIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, null)).get();
@@ -832,7 +838,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testRemoveAliasEmptyAliasEmptyIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "")).get();
@@ -843,7 +848,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testGetAllAliasesWorks() {
createIndex("index1");
createIndex("index2");
@@ -857,7 +861,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.getAliases(), hasKey("index1"));
}
- @Test
public void testCreateIndexWithAliases() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", "field", "type=string")
@@ -868,7 +871,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
- @Test
public void testCreateIndexWithAliasesInSource() throws Exception {
assertAcked(prepareCreate("test").setSource("{\n" +
" \"aliases\" : {\n" +
@@ -881,7 +883,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
- @Test
public void testCreateIndexWithAliasesSource() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", "field", "type=string")
@@ -894,7 +895,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
- @Test
public void testCreateIndexWithAliasesFilterNotValid() {
//non valid filter, invalid json
CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").addAlias(new Alias("alias2").filter("f"));
@@ -917,7 +917,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
// Before 2.0 alias filters were parsed at alias creation time, in order
// for filters to work correctly ES required that fields mentioned in those
// filters exist in the mapping.
@@ -936,7 +935,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
.get();
}
- @Test
public void testAliasFilterWithNowInRangeFilterAndQuery() throws Exception {
assertAcked(prepareCreate("my-index").addMapping("my-type", "_timestamp", "enabled=true"));
assertAcked(admin().indices().prepareAliases().addAlias("my-index", "filter1", rangeQuery("_timestamp").from("now-1d").to("now")));
@@ -956,7 +954,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
- @Test
public void testAliasesFilterWithHasChildQuery() throws Exception {
assertAcked(prepareCreate("my-index")
.addMapping("parent")
@@ -977,7 +974,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).id(), equalTo("2"));
}
- @Test
public void testAliasesWithBlocks() {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/blocks/SimpleBlocksIT.java b/core/src/test/java/org/elasticsearch/blocks/SimpleBlocksIT.java
index d256c6a2c9..f7270ca2c3 100644
--- a/core/src/test/java/org/elasticsearch/blocks/SimpleBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/blocks/SimpleBlocksIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
@@ -37,9 +36,7 @@ import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class SimpleBlocksIT extends ESIntegTestCase {
-
- @Test
- public void verifyIndexAndClusterReadOnly() throws Exception {
+ public void testVerifyIndexAndClusterReadOnly() throws Exception {
// cluster.read_only = null: write and metadata not blocked
canCreateIndex("test1");
canIndexDocument("test1");
@@ -82,7 +79,6 @@ public class SimpleBlocksIT extends ESIntegTestCase {
canIndexExists("ro");
}
- @Test
public void testIndexReadWriteMetaDataBlocks() {
canCreateIndex("test1");
canIndexDocument("test1");
diff --git a/core/src/test/java/org/elasticsearch/bootstrap/JNANativesTests.java b/core/src/test/java/org/elasticsearch/bootstrap/JNANativesTests.java
index 8497f91cdc..4768370232 100644
--- a/core/src/test/java/org/elasticsearch/bootstrap/JNANativesTests.java
+++ b/core/src/test/java/org/elasticsearch/bootstrap/JNANativesTests.java
@@ -21,20 +21,16 @@ package org.elasticsearch.bootstrap;
import org.apache.lucene.util.Constants;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class JNANativesTests extends ESTestCase {
-
- @Test
public void testMlockall() {
if (Constants.MAC_OS_X) {
assertFalse("Memory locking is not available on OS X platforms", JNANatives.LOCAL_MLOCKALL);
}
}
-
- @Test
+
public void testConsoleCtrlHandler() {
if (Constants.WINDOWS) {
assertNotNull(JNAKernel32Library.getInstance());
diff --git a/core/src/test/java/org/elasticsearch/bootstrap/JavaVersionTests.java b/core/src/test/java/org/elasticsearch/bootstrap/JavaVersionTests.java
index 851e0fd9f8..21bfa05c1d 100644
--- a/core/src/test/java/org/elasticsearch/bootstrap/JavaVersionTests.java
+++ b/core/src/test/java/org/elasticsearch/bootstrap/JavaVersionTests.java
@@ -20,14 +20,12 @@
package org.elasticsearch.bootstrap;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
public class JavaVersionTests extends ESTestCase {
- @Test
public void testParse() {
JavaVersion javaVersion = JavaVersion.parse("1.7.0");
List<Integer> version = javaVersion.getVersion();
@@ -37,13 +35,11 @@ public class JavaVersionTests extends ESTestCase {
assertThat(0, is(version.get(2)));
}
- @Test
public void testToString() {
JavaVersion javaVersion = JavaVersion.parse("1.7.0");
assertThat("1.7.0", is(javaVersion.toString()));
}
- @Test
public void testCompare() {
JavaVersion onePointSix = JavaVersion.parse("1.6");
JavaVersion onePointSeven = JavaVersion.parse("1.7");
@@ -61,7 +57,6 @@ public class JavaVersionTests extends ESTestCase {
assertTrue(onePointSevenPointTwo.compareTo(onePointSevenPointTwoPointOne) < 0);
}
- @Test
public void testValidVersions() {
String[] versions = new String[]{"1.7", "1.7.0", "0.1.7", "1.7.0.80"};
for (String version : versions) {
@@ -69,7 +64,6 @@ public class JavaVersionTests extends ESTestCase {
}
}
- @Test
public void testInvalidVersions() {
String[] versions = new String[]{"", "1.7.0_80", "1.7."};
for (String version : versions) {
diff --git a/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java b/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java
index 4b7f602252..18c1572e86 100644
--- a/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java
+++ b/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java
@@ -23,7 +23,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -39,7 +38,6 @@ public class BroadcastActionsIT extends ESIntegTestCase {
return 1;
}
- @Test
public void testBroadcastOperations() throws IOException {
assertAcked(prepareCreate("test", 1).execute().actionGet(5000));
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java
index 3a58d71051..07d59b820a 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java
@@ -19,6 +19,7 @@
package org.elasticsearch.bwcompat;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.Version;
@@ -26,7 +27,6 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
import org.elasticsearch.indices.analysis.PreBuiltAnalyzers;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.List;
@@ -48,10 +48,8 @@ public class BasicAnalysisBackwardCompatibilityIT extends ESBackcompatTestCase {
* Simple upgrade test for analyzers to make sure they analyze to the same tokens after upgrade
* TODO we need this for random tokenizers / tokenfilters as well
*/
- @Test
public void testAnalyzerTokensAfterUpgrade() throws IOException, ExecutionException, InterruptedException {
int numFields = randomIntBetween(PreBuiltAnalyzers.values().length, PreBuiltAnalyzers.values().length * 10);
- StringBuilder builder = new StringBuilder();
String[] fields = new String[numFields * 2];
int fieldId = 0;
for (int i = 0; i < fields.length; i++) {
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java
index 2be80f71d9..e5ed7f1484 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java
@@ -19,6 +19,7 @@
package org.elasticsearch.bwcompat;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.apache.lucene.index.Fields;
import org.apache.lucene.util.English;
import org.elasticsearch.ExceptionsHelper;
@@ -31,7 +32,11 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.explain.ExplainResponse;
-import org.elasticsearch.action.get.*;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.get.MultiGetItemResponse;
+import org.elasticsearch.action.get.MultiGetRequest;
+import org.elasticsearch.action.get.MultiGetRequestBuilder;
+import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
@@ -58,7 +63,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -66,11 +70,20 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
import static org.elasticsearch.index.query.QueryBuilders.missingQuery;
-import static org.elasticsearch.index.query.QueryBuilders.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
/**
*/
@@ -79,7 +92,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Basic test using Index &amp; Realtime Get with external versioning. This test ensures routing works correctly across versions.
*/
- @Test
public void testExternalVersion() throws Exception {
createIndex("test");
final boolean routing = randomBoolean();
@@ -103,7 +115,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Basic test using Index &amp; Realtime Get with internal versioning. This test ensures routing works correctly across versions.
*/
- @Test
public void testInternalVersion() throws Exception {
createIndex("test");
final boolean routing = randomBoolean();
@@ -127,7 +138,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Very basic bw compat test with a mixed version cluster random indexing and lookup by ID via term query
*/
- @Test
public void testIndexAndSearch() throws Exception {
createIndex("test");
int numDocs = randomIntBetween(10, 20);
@@ -144,7 +154,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertVersionCreated(compatibilityVersion(), "test");
}
- @Test
public void testRecoverFromPreviousVersion() throws ExecutionException, InterruptedException {
if (backwardsCluster().numNewDataNodes() == 0) {
backwardsCluster().startNewNode();
@@ -201,7 +210,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Test that ensures that we will never recover from a newer to an older version (we are not forward compatible)
*/
- @Test
public void testNoRecoveryFromNewNodes() throws ExecutionException, InterruptedException {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.routing.allocation.exclude._name", backwardsCluster().backwardsNodePattern()).put(indexSettings())));
if (backwardsCluster().numNewDataNodes() == 0) {
@@ -269,7 +277,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Upgrades a single node to the current version
*/
- @Test
public void testIndexUpgradeSingleNode() throws Exception {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.routing.allocation.exclude._name", backwardsCluster().newNodePattern()).put(indexSettings())));
ensureYellow();
@@ -308,7 +315,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
* one node after another is shut down and restarted from a newer version and we verify
* that all documents are still around after each nodes upgrade.
*/
- @Test
public void testIndexRollingUpgrade() throws Exception {
String[] indices = new String[randomIntBetween(1, 3)];
for (int i = 0; i < indices.length; i++) {
@@ -371,7 +377,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
}
- @Test
public void testUnsupportedFeatures() throws IOException {
XContentBuilder mapping = XContentBuilder.builder(JsonXContent.jsonXContent)
.startObject()
@@ -399,7 +404,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
* This filter had a major upgrade in 1.3 where we started to index the field names. Lets see if they still work as expected...
* this test is basically copied from SimpleQueryTests...
*/
- @Test
public void testExistsFilter() throws IOException, ExecutionException, InterruptedException {
int indexId = 0;
String indexName;
@@ -472,7 +476,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
return client().admin().cluster().prepareState().get().getState().nodes().masterNode().getVersion();
}
- @Test
public void testDeleteRoutingRequired() throws ExecutionException, InterruptedException, IOException {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource(
@@ -509,7 +512,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs - 1));
}
- @Test
public void testIndexGetAndDelete() throws ExecutionException, InterruptedException {
createIndexWithAlias();
ensureYellow("test");
@@ -546,7 +548,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs - 1));
}
- @Test
public void testUpdate() {
createIndexWithAlias();
ensureYellow("test");
@@ -577,7 +578,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(getResponse.getSourceAsMap().containsKey("field2"), equalTo(true));
}
- @Test
public void testAnalyze() {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=string,analyzer=keyword"));
@@ -587,7 +587,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(analyzeResponse.getTokens().get(0).getTerm(), equalTo("this is a test"));
}
- @Test
public void testExplain() {
createIndexWithAlias();
ensureYellow("test");
@@ -604,7 +603,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(response.getExplanation().getDetails().length, equalTo(1));
}
- @Test
public void testGetTermVector() throws IOException {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("field", "type=string,term_vector=with_positions_offsets_payloads").get());
@@ -622,7 +620,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(fields.terms("field").size(), equalTo(8l));
}
- @Test
public void testIndicesStats() {
createIndex("test");
ensureYellow("test");
@@ -632,7 +629,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(indicesStatsResponse.getIndices().containsKey("test"), equalTo(true));
}
- @Test
public void testMultiGet() throws ExecutionException, InterruptedException {
createIndexWithAlias();
ensureYellow("test");
@@ -665,7 +661,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
}
- @Test
public void testScroll() throws ExecutionException, InterruptedException {
createIndex("test");
ensureYellow("test");
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java
index ed155895cb..665aa5217a 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java
@@ -30,17 +30,16 @@ import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.hamcrest.Matchers.equalTo;
public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase {
-
- @Test
public void testClusterState() throws Exception {
createIndex("test");
@@ -57,7 +56,6 @@ public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase {
}
}
- @Test
public void testClusterStateWithBlocks() {
createIndex("test-blocks");
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/GetIndexBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/GetIndexBackwardsCompatibilityIT.java
index a7e9380d02..9a87c88874 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/GetIndexBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/GetIndexBackwardsCompatibilityIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.util.List;
@@ -40,8 +39,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
-
- @Test
public void testGetAliases() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").addAlias(new Alias("testAlias")).execute().actionGet();
assertAcked(createIndexResponse);
@@ -58,7 +55,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(alias.alias(), equalTo("testAlias"));
}
- @Test
public void testGetMappings() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").addMapping("type1", "{\"type1\":{}}").execute().actionGet();
assertAcked(createIndexResponse);
@@ -79,7 +75,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(mapping.type(), equalTo("type1"));
}
- @Test
public void testGetSettings() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").setSettings(Settings.builder().put("number_of_shards", 1)).execute().actionGet();
assertAcked(createIndexResponse);
@@ -93,7 +88,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(settings.get("index.number_of_shards"), equalTo("1"));
}
- @Test
public void testGetWarmers() throws Exception {
createIndex("test");
ensureSearchable("test");
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java
index 8cb9fc7566..5a82384071 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java
@@ -25,17 +25,14 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilde
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase;
import java.lang.reflect.Method;
@ESIntegTestCase.ClusterScope(scope= ESIntegTestCase.Scope.SUITE, numClientNodes = 0)
public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
-
- @Test
public void testNodeStatsSetIndices() throws Exception {
createIndex("test");
@@ -54,7 +51,6 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
}
}
- @Test
public void testNodeStatsSetRandom() throws Exception {
createIndex("test");
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java
index 990c399d8e..6459cc4f30 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java
@@ -54,7 +54,6 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -71,7 +70,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.concurrent.Future;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@@ -277,7 +275,6 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase {
}
}
- @Test
public void testHandlingOfUnsupportedDanglingIndexes() throws Exception {
setupCluster();
Collections.shuffle(unsupportedIndexes, getRandom());
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java b/core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java
index 895748514d..a573a8374e 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java
@@ -20,13 +20,10 @@ package org.elasticsearch.bwcompat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
-import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
public class RecoveryWithUnsupportedIndicesIT extends StaticIndexBackwardCompatibilityIT {
-
- @Test
public void testUpgradeStartClusterOn_0_20_6() throws Exception {
String indexName = "unsupported-0.20.6";
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
index 740b185e74..bccd4290d8 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
@@ -34,7 +34,6 @@ import org.elasticsearch.snapshots.SnapshotInfo;
import org.elasticsearch.snapshots.SnapshotRestoreException;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Modifier;
@@ -51,7 +50,10 @@ import java.util.TreeSet;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(scope = Scope.TEST)
public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
@@ -79,8 +81,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
}
- @Test
- public void restoreOldSnapshots() throws Exception {
+ public void testRestoreOldSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";
List<String> repoVersions = repoVersions();
@@ -115,7 +116,6 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
}
- @Test
public void testRestoreUnsupportedSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/TransportClientBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/TransportClientBackwardsCompatibilityIT.java
index e071c17b94..0e2f94e3cf 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/TransportClientBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/TransportClientBackwardsCompatibilityIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.CompositeTestCluster;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.util.concurrent.ExecutionException;
@@ -38,10 +37,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSear
import static org.hamcrest.CoreMatchers.equalTo;
public class TransportClientBackwardsCompatibilityIT extends ESBackcompatTestCase {
-
- @Test
public void testSniffMode() throws ExecutionException, InterruptedException {
-
Settings settings = Settings.builder().put(requiredSettings()).put("client.transport.nodes_sampler_interval", "1s")
.put("name", "transport_client_sniff_mode").put(ClusterName.SETTING, cluster().getClusterName())
.put("client.transport.sniff", true).build();
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java
index 59dd669521..ab7e95812f 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java
@@ -22,12 +22,10 @@ package org.elasticsearch.bwcompat;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class UnicastBackwardsCompatibilityIT extends ESBackcompatTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
@@ -46,7 +44,6 @@ public class UnicastBackwardsCompatibilityIT extends ESBackcompatTestCase {
.build();
}
- @Test
public void testUnicastDiscovery() {
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().get();
assertThat(healthResponse.getNumberOfDataNodes(), equalTo(cluster().numDataNodes()));
diff --git a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
index b00b677a4b..b814cff520 100644
--- a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
+++ b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
@@ -53,7 +53,6 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportMessage;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -72,7 +71,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
.put(Headers.PREFIX + ".key2", "val 2")
.build();
- @SuppressWarnings("unchecked")
private static final GenericAction[] ACTIONS = new GenericAction[] {
// client actions
GetAction.INSTANCE, SearchAction.INSTANCE, DeleteAction.INSTANCE, DeleteIndexedScriptAction.INSTANCE,
@@ -107,7 +105,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
protected abstract Client buildClient(Settings headersSettings, GenericAction[] testedActions);
- @Test
public void testActions() {
// TODO this is a really shitty way to test it, we need to figure out a way to test all the client methods
@@ -134,7 +131,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
client.admin().indices().prepareFlush().execute().addListener(new AssertingActionListener<FlushResponse>(FlushAction.NAME));
}
- @Test
public void testOverideHeader() throws Exception {
String key1Val = randomAsciiOfLength(5);
Map<String, Object> expected = new HashMap<>();
diff --git a/core/src/test/java/org/elasticsearch/client/node/NodeClientIT.java b/core/src/test/java/org/elasticsearch/client/node/NodeClientIT.java
index 499998096b..966553b8f3 100644
--- a/core/src/test/java/org/elasticsearch/client/node/NodeClientIT.java
+++ b/core/src/test/java/org/elasticsearch/client/node/NodeClientIT.java
@@ -21,11 +21,10 @@ package org.elasticsearch.client.node;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.is;
/**
@@ -33,17 +32,14 @@ import static org.hamcrest.Matchers.is;
*/
@ClusterScope(scope = Scope.SUITE)
public class NodeClientIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Client.CLIENT_TYPE_SETTING, "anything").build();
}
- @Test
public void testThatClientTypeSettingCannotBeChanged() {
for (Settings settings : internalCluster().getInstances(Settings.class)) {
assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("node"));
}
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java
index 22d5ba20e1..f4b29768b9 100644
--- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java
+++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java
@@ -46,7 +46,6 @@ import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportResponseHandler;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -75,7 +74,6 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
return client;
}
- @Test
public void testWithSniffing() throws Exception {
TransportClient client = TransportClient.builder()
.settings(Settings.builder()
diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java
index 144d79db35..4d824453f0 100644
--- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java
+++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java
@@ -28,12 +28,11 @@ import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
@@ -41,8 +40,6 @@ import static org.hamcrest.Matchers.startsWith;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 1.0)
public class TransportClientIT extends ESIntegTestCase {
-
- @Test
public void testPickingUpChangesInDiscoveryNode() {
String nodeName = internalCluster().startNode(Settings.builder().put("node.data", false));
@@ -51,7 +48,6 @@ public class TransportClientIT extends ESIntegTestCase {
}
- @Test
public void testNodeVersionIsUpdated() {
TransportClient client = (TransportClient) internalCluster().client();
TransportClientNodesService nodeService = client.nodeService();
@@ -85,14 +81,12 @@ public class TransportClientIT extends ESIntegTestCase {
}
}
- @Test
public void testThatTransportClientSettingIsSet() {
TransportClient client = (TransportClient) internalCluster().client();
Settings settings = client.injector.getInstance(Settings.class);
assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("transport"));
}
- @Test
public void testThatTransportClientSettingCannotBeChanged() {
Settings baseSettings = settingsBuilder().put(Client.CLIENT_TYPE_SETTING, "anything").put("path.home", createTempDir()).build();
try (TransportClient client = TransportClient.builder().settings(baseSettings).build()) {
diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
index 98cef9783f..89b39f4302 100644
--- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
@@ -28,8 +28,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.BaseTransportResponseHandler;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportResponse;
+import org.elasticsearch.transport.TransportService;
import java.io.Closeable;
import java.util.Collections;
@@ -39,7 +43,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -89,9 +95,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
}
}
- @Test
public void testListenerFailures() throws InterruptedException {
-
int iters = iterations(10, 100);
for (int i = 0; i <iters; i++) {
try(final TestIteration iteration = new TestIteration()) {
diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java
index 020106ab86..b28fdba8c7 100644
--- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java
+++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java
@@ -29,26 +29,22 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ClusterScope(scope = Scope.TEST, numClientNodes = 0)
@TestLogging("discovery.zen:TRACE")
public class TransportClientRetryIT extends ESIntegTestCase {
-
- @Test
public void testRetry() throws IOException, ExecutionException, InterruptedException {
-
Iterable<TransportService> instances = internalCluster().getInstances(TransportService.class);
TransportAddress[] addresses = new TransportAddress[internalCluster().size()];
int i = 0;
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterHealthIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterHealthIT.java
index f34f693af9..b90a0228a8 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterHealthIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterHealthIT.java
@@ -23,15 +23,11 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class ClusterHealthIT extends ESIntegTestCase {
-
-
- @Test
- public void simpleLocalHealthTest() {
+ public void testSimpleLocalHealth() {
createIndex("test");
ensureGreen(); // master should thing it's green now.
@@ -43,7 +39,6 @@ public class ClusterHealthIT extends ESIntegTestCase {
}
}
- @Test
public void testHealth() {
logger.info("--> running cluster health on an index that does not exists");
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth("test1").setWaitForYellowStatus().setTimeout("1s").execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
index f938a78c76..1cce41e6a2 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
@@ -52,7 +52,6 @@ import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -137,7 +136,6 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
MockTransportService.TestPlugin.class);
}
- @Test
public void testClusterInfoServiceCollectsInformation() throws Exception {
internalCluster().startNodesAsync(2,
Settings.builder().put(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, "200ms").build())
@@ -187,7 +185,6 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
}
- @Test
public void testClusterInfoServiceInformationClearOnError() throws InterruptedException, ExecutionException {
internalCluster().startNodesAsync(2,
// manually control publishing
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java
index aab7e89dfc..96a865f4da 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java
@@ -37,21 +37,29 @@ import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.MockLogAppender;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.threadpool.ThreadPool;
-import org.junit.Test;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
/**
*
@@ -65,7 +73,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
return pluginList(TestPlugin.class);
}
- @Test
public void testTimeoutUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -134,7 +141,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(executeCalled.get(), equalTo(false));
}
- @Test
public void testAckedUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -211,7 +217,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
- @Test
public void testAckedUpdateTaskSameClusterState() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -283,7 +288,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
- @Test
public void testMasterAwareExecution() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -340,7 +344,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertFalse("non-master cluster state update task was not executed", taskFailed[0]);
}
- @Test
public void testAckedUpdateTaskNoAckExpected() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -413,7 +416,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(onFailure.get(), equalTo(false));
}
- @Test
public void testAckedUpdateTaskTimeoutZero() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -490,7 +492,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
- @Test
public void testPendingUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -626,7 +627,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
block2.countDown();
}
- @Test
public void testLocalNodeMasterListenerCallbacks() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
@@ -705,7 +705,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
/**
* Note, this test can only work as long as we have a single thread executor executing the state update tasks!
*/
- @Test
public void testPrioritizedTasks() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@@ -738,7 +737,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
}
- @Test
@TestLogging("cluster:TRACE") // To ensure that we log cluster state events on TRACE level
public void testClusterStateUpdateLogging() throws Exception {
Settings settings = settingsBuilder()
@@ -828,7 +826,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
mockAppender.assertAllExpectationsMatched();
}
- @Test
@TestLogging("cluster:WARN") // To ensure that we log cluster state events on WARN level
public void testLongClusterStateUpdateLogging() throws Exception {
Settings settings = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java
index 301dc8bb5b..c2e646dde1 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java
@@ -53,7 +53,6 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collections;
import java.util.List;
@@ -71,8 +70,6 @@ import static org.hamcrest.Matchers.is;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0, numClientNodes = 0)
public class ClusterStateDiffIT extends ESIntegTestCase {
-
- @Test
public void testClusterStateDiffSerialization() throws Exception {
DiscoveryNode masterNode = new DiscoveryNode("master", new LocalTransportAddress("master"), Version.CURRENT);
DiscoveryNode otherNode = new DiscoveryNode("other", new LocalTransportAddress("other"), Version.CURRENT);
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java
index 19f90f2962..9ee095e610 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java
@@ -18,7 +18,6 @@
*/
package org.elasticsearch.cluster;
-import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
diff --git a/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java b/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java
index 595dbc9a94..e48ca834f5 100644
--- a/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java
@@ -33,16 +33,13 @@ import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.store.StoreStats;
import org.elasticsearch.monitor.fs.FsInfo;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.nio.file.Path;
import static org.hamcrest.Matchers.equalTo;
public class DiskUsageTests extends ESTestCase {
-
- @Test
- public void diskUsageCalcTest() {
+ public void testDiskUsageCalc() {
DiskUsage du = new DiskUsage("node1", "n1", "random", 100, 40);
assertThat(du.getFreeDiskAsPercentage(), equalTo(40.0));
assertThat(du.getUsedDiskAsPercentage(), equalTo(100.0 - 40.0));
@@ -71,8 +68,7 @@ public class DiskUsageTests extends ESTestCase {
assertThat(du4.getTotalBytes(), equalTo(0L));
}
- @Test
- public void randomDiskUsageTest() {
+ public void testRandomDiskUsage() {
int iters = scaledRandomIntBetween(1000, 10000);
for (int i = 1; i < iters; i++) {
long total = between(Integer.MIN_VALUE, Integer.MAX_VALUE);
diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
index bb1b381262..1ae83985a6 100644
--- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
@@ -34,12 +34,16 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.disruption.NetworkDelaysPartition;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
-import org.junit.Test;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -47,9 +51,15 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.isOneOf;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
@@ -62,9 +72,8 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
return classes;
}
- @Test
@TestLogging("cluster.service:TRACE,discovery.zen:TRACE,gateway:TRACE,transport.tracer:TRACE")
- public void simpleMinimumMasterNodes() throws Exception {
+ public void testSimpleMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
@@ -177,8 +186,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
}
}
- @Test
- public void multipleNodesShutdownNonMasterNodes() throws Exception {
+ public void testMultipleNodesShutdownNonMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put("discovery.zen.minimum_master_nodes", 3)
@@ -254,8 +262,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
}
}
- @Test
- public void dynamicUpdateMinimumMasterNodes() throws Exception {
+ public void testDynamicUpdateMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put(ZenDiscovery.SETTING_PING_TIMEOUT, "400ms")
@@ -312,7 +319,6 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
);
}
- @Test
public void testCanNotBringClusterDown() throws ExecutionException, InterruptedException {
int nodeCount = scaledRandomIntBetween(1, 5);
Settings.Builder settings = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
index bcc5edec79..e0f8b2cb84 100644
--- a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
@@ -39,22 +39,23 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.util.HashMap;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.lessThan;
/**
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
public class NoMasterNodeIT extends ESIntegTestCase {
-
- @Test
public void testNoMasterActions() throws Exception {
// note, sometimes, we want to check with the fact that an index gets created, sometimes not...
boolean autoCreateIndex = randomBoolean();
@@ -211,8 +212,7 @@ public class NoMasterNodeIT extends ESIntegTestCase {
}
}
- @Test
- public void testNoMasterActions_writeMasterBlock() throws Exception {
+ public void testNoMasterActionsWriteMasterBlock() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put("action.auto_create_index", false)
diff --git a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
index 8433ace075..d78356cbf6 100644
--- a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
@@ -34,11 +34,12 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.hamcrest.CollectionAssertions;
import org.junit.Before;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertIndexTemplateExists;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
/**
* Checking simple filtering capabilites of the cluster state
@@ -54,7 +55,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
refresh();
}
- @Test
public void testRoutingTable() throws Exception {
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setRoutingTable(true).get();
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("foo"), is(true));
@@ -69,7 +69,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().routingTable().hasIndex("non-existent"), is(false));
}
- @Test
public void testNodes() throws Exception {
ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setNodes(true).get();
assertThat(clusterStateResponse.getState().nodes().nodes().size(), is(cluster().size()));
@@ -78,7 +77,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponseFiltered.getState().nodes().nodes().size(), is(0));
}
- @Test
public void testMetadata() throws Exception {
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setMetaData(true).get();
assertThat(clusterStateResponseUnfiltered.getState().metaData().indices().size(), is(3));
@@ -87,7 +85,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().metaData().indices().size(), is(0));
}
- @Test
public void testIndexTemplates() throws Exception {
client().admin().indices().preparePutTemplate("foo_template")
.setTemplate("te*")
@@ -113,7 +110,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertIndexTemplateExists(getIndexTemplatesResponse, "foo_template");
}
- @Test
public void testThatFilteringByIndexWorksForMetadataAndRoutingTable() throws Exception {
ClusterStateResponse clusterStateResponseFiltered = client().admin().cluster().prepareState().clear()
.setMetaData(true).setRoutingTable(true).setIndices("foo", "fuu", "non-existent").get();
@@ -129,7 +125,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponseFiltered.getState().routingTable().hasIndex("baz"), is(false));
}
- @Test
public void testLargeClusterStatePublishing() throws Exception {
int estimatedBytesSize = scaledRandomIntBetween(ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
@@ -162,7 +157,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
}
}
- @Test
public void testIndicesOptions() throws Exception {
ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("f*")
.get();
@@ -195,17 +189,25 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().metaData().indices().isEmpty(), is(true));
}
- @Test(expected=IndexNotFoundException.class)
public void testIndicesOptionsOnAllowNoIndicesFalse() throws Exception {
// empty wildcard expansion throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false);
- client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
+ try {
+ client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test(expected=IndexNotFoundException.class)
public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
- client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
+ try {
+ client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/SimpleDataNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
index 2979b1eac8..bc3aea4ac7 100644
--- a/core/src/test/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
@@ -25,12 +25,11 @@ import org.elasticsearch.client.Requests;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.client.Requests.createIndexRequest;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
/**
@@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleDataNodesIT extends ESIntegTestCase {
-
- @Test
public void testDataNodes() throws Exception {
internalCluster().startNode(settingsBuilder().put("node.data", false).build());
client().admin().indices().create(createIndexRequest("test")).actionGet();
diff --git a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
index 43b403d306..90c39d7bbe 100644
--- a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
@@ -25,24 +25,23 @@ import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.io.IOException;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
public class SpecificMasterNodesIT extends ESIntegTestCase {
-
protected final Settings.Builder settingsBuilder() {
return Settings.builder().put("discovery.type", "zen");
}
- @Test
- public void simpleOnlyMasterNodeElection() throws IOException {
+ public void testSimpleOnlyMasterNodeElection() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
try {
@@ -72,8 +71,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligibleNodeName));
}
- @Test
- public void electOnlyBetweenMasterNodes() throws IOException {
+ public void testElectOnlyBetweenMasterNodes() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
try {
@@ -103,7 +101,6 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
* Tests that putting custom default mapping and then putting a type mapping will have the default mapping merged
* to the type mapping.
*/
- @Test
public void testCustomDefaultMapping() throws Exception {
logger.info("--> start master node / non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("node.master", true));
@@ -124,7 +121,6 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
assertThat(type1Mapping.getSourceAsMap().get("_timestamp"), notNullValue());
}
- @Test
public void testAliasFilterValidation() throws Exception {
logger.info("--> start master node / non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("node.master", true));
diff --git a/core/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java b/core/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
index c91915bd9c..526f64a8b4 100644
--- a/core/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
@@ -23,20 +23,17 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
/**
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class UpdateSettingsValidationIT extends ESIntegTestCase {
-
- @Test
public void testUpdateSettingsValidation() throws Exception {
List<String> nodes = internalCluster().startNodesAsync(
settingsBuilder().put("node.data", false).build(),
diff --git a/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java b/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java
index d6e4abb020..12147ffb78 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java
@@ -33,10 +33,9 @@ import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocation
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -71,7 +70,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT, "0")));
}
- @Test
public void testClusterUpdateSettingsAcknowledgement() {
createIndex("test");
ensureGreen();
@@ -112,7 +110,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
}
}
- @Test
public void testClusterUpdateSettingsNoAcknowledgement() {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@@ -143,7 +140,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
return client.admin().cluster().prepareState().setLocal(true).get().getState();
}
- @Test
public void testOpenIndexNoAcknowledgement() {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java b/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
index 392528d9f5..47517a753a 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
@@ -20,6 +20,7 @@
package org.elasticsearch.cluster.ack;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
+
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
@@ -35,6 +36,7 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.AliasOrIndex;
import org.elasticsearch.cluster.metadata.IndexMetaData;
+import org.elasticsearch.cluster.metadata.IndexMetaData.State;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
@@ -44,16 +46,18 @@ import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(minNumDataNodes = 2)
public class AckIT extends ESIntegTestCase {
@@ -66,7 +70,6 @@ public class AckIT extends ESIntegTestCase {
.put(DiscoverySettings.PUBLISH_TIMEOUT, 0).build();
}
- @Test
public void testUpdateSettingsAcknowledgement() {
createIndex("test");
@@ -79,7 +82,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testUpdateSettingsNoAcknowledgement() {
createIndex("test");
UpdateSettingsResponse updateSettingsResponse = client().admin().indices().prepareUpdateSettings("test").setTimeout("0s")
@@ -87,7 +89,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(updateSettingsResponse.isAcknowledged(), equalTo(false));
}
- @Test
public void testPutWarmerAcknowledgement() {
createIndex("test");
// make sure one shard is started so the search during put warmer will not fail
@@ -106,7 +107,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testPutWarmerNoAcknowledgement() throws InterruptedException {
createIndex("test");
// make sure one shard is started so the search during put warmer will not fail
@@ -131,7 +131,6 @@ public class AckIT extends ESIntegTestCase {
assertAcked(client().admin().indices().prepareDeleteWarmer().setIndices("test").setNames("custom_warmer"));
}
- @Test
public void testDeleteWarmerAcknowledgement() {
createIndex("test");
index("test", "type", "1", "f", 1);
@@ -147,7 +146,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testDeleteWarmerNoAcknowledgement() throws InterruptedException {
createIndex("test");
index("test", "type", "1", "f", 1);
@@ -168,7 +166,6 @@ public class AckIT extends ESIntegTestCase {
}));
}
- @Test
public void testClusterRerouteAcknowledgement() throws InterruptedException {
assertAcked(prepareCreate("test").setSettings(Settings.builder()
.put(indexSettings())
@@ -203,7 +200,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testClusterRerouteNoAcknowledgement() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@@ -217,7 +213,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(clusterRerouteResponse.isAcknowledged(), equalTo(false));
}
- @Test
public void testClusterRerouteAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@@ -250,7 +245,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@@ -293,7 +287,6 @@ public class AckIT extends ESIntegTestCase {
return new MoveAllocationCommand(shardToBeMoved.shardId(), fromNodeId, toNodeId);
}
- @Test
public void testIndicesAliasesAcknowledgement() {
createIndex("test");
@@ -310,7 +303,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testIndicesAliasesNoAcknowledgement() {
createIndex("test");
@@ -330,7 +322,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testCloseIndexNoAcknowledgement() {
createIndex("test");
ensureGreen();
@@ -339,7 +330,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(closeIndexResponse.isAcknowledged(), equalTo(false));
}
- @Test
public void testOpenIndexAcknowledgement() {
createIndex("test");
ensureGreen();
@@ -354,7 +344,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testPutMappingAcknowledgement() {
createIndex("test");
ensureGreen();
@@ -366,7 +355,6 @@ public class AckIT extends ESIntegTestCase {
}
}
- @Test
public void testPutMappingNoAcknowledgement() {
createIndex("test");
ensureGreen();
@@ -375,7 +363,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(false));
}
- @Test
public void testCreateIndexAcknowledgement() {
createIndex("test");
@@ -388,7 +375,6 @@ public class AckIT extends ESIntegTestCase {
ensureGreen();
}
- @Test
public void testCreateIndexNoAcknowledgement() {
CreateIndexResponse createIndexResponse = client().admin().indices().prepareCreate("test").setTimeout("0s").get();
assertThat(createIndexResponse.isAcknowledged(), equalTo(false));
diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
index 8dbad73ff4..f9151628b8 100644
--- a/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
@@ -20,6 +20,7 @@
package org.elasticsearch.cluster.allocation;
import com.carrotsearch.hppc.ObjectIntHashMap;
+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
@@ -34,7 +35,6 @@ import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -55,7 +55,6 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
return 1;
}
- @Test
public void testSimpleAwareness() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put("cluster.routing.allocation.awareness.attributes", "rack_id")
@@ -104,8 +103,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
TimeUnit.SECONDS
), equalTo(true));
}
-
- @Test
+
public void testAwarenessZones() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP + "zone.values", "a,b")
@@ -153,8 +151,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(A_0), anyOf(equalTo(2),equalTo(3)));
assertThat(counts.get(B_0), anyOf(equalTo(2),equalTo(3)));
}
-
- @Test
+
public void testAwarenessZonesIncrementalNodes() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b")
@@ -208,7 +205,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(A_0), equalTo(5));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));
-
+
String noZoneNode = internalCluster().startNode();
health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("4").execute().actionGet();
assertThat(health.isTimedOut(), equalTo(false));
@@ -227,7 +224,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
}
}
}
-
+
assertThat(counts.get(A_0), equalTo(5));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));
@@ -248,7 +245,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
}
}
}
-
+
assertThat(counts.get(A_0), equalTo(3));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));
diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
index 2df79586b8..fd09a83211 100644
--- a/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
@@ -45,17 +45,19 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
-import org.junit.Test;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@@ -65,11 +67,9 @@ import static org.hamcrest.Matchers.hasSize;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class ClusterRerouteIT extends ESIntegTestCase {
-
private final ESLogger logger = Loggers.getLogger(ClusterRerouteIT.class);
- @Test
- public void rerouteWithCommands_disableAllocationSettings() throws Exception {
+ public void testRerouteWithCommands_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@@ -77,8 +77,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
rerouteWithCommands(commonSettings);
}
- @Test
- public void rerouteWithCommands_enableAllocationSettings() throws Exception {
+ public void testRerouteWithCommands_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.NONE.name())
.build();
@@ -146,8 +145,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).id()).get(0).state(), equalTo(ShardRoutingState.STARTED));
}
- @Test
- public void rerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception {
+ public void testRerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@@ -155,15 +153,13 @@ public class ClusterRerouteIT extends ESIntegTestCase {
rerouteWithAllocateLocalGateway(commonSettings);
}
- @Test
- public void rerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
+ public void testRerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.NONE.name())
.build();
rerouteWithAllocateLocalGateway(commonSettings);
}
- @Test
public void testDelayWithALargeAmountOfShards() throws Exception {
Settings commonSettings = settingsBuilder()
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CONCURRENT_RECOVERIES, 1)
@@ -264,8 +260,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
}
- @Test
- public void rerouteExplain() {
+ public void testRerouteExplain() {
Settings commonSettings = settingsBuilder().build();
logger.info("--> starting a node");
@@ -307,7 +302,6 @@ public class ClusterRerouteIT extends ESIntegTestCase {
assertThat(explanation.decisions().type(), equalTo(Decision.Type.YES));
}
- @Test
public void testClusterRerouteWithBlocks() throws Exception {
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
index ad2715db52..0c3eed1d53 100644
--- a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
@@ -29,12 +29,11 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
@@ -42,14 +41,13 @@ public class FilteringAllocationIT extends ESIntegTestCase {
private final ESLogger logger = Loggers.getLogger(FilteringAllocationIT.class);
- @Test
public void testDecommissionNodeNoReplicas() throws Exception {
logger.info("--> starting 2 nodes");
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
final String node_0 = nodesIds.get(0);
final String node_1 = nodesIds.get(1);
assertThat(cluster().size(), equalTo(2));
-
+
logger.info("--> creating an index with no replicas");
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_replicas", 0))
@@ -82,7 +80,6 @@ public class FilteringAllocationIT extends ESIntegTestCase {
assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l));
}
- @Test
public void testDisablingAllocationFiltering() throws Exception {
logger.info("--> starting 2 nodes");
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
@@ -118,7 +115,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", numShardsOnNode1)).execute().actionGet();
// make sure we can recover all the nodes at once otherwise we might run into a state where one of the shards has not yet started relocating
- // but we already fired up the request to wait for 0 relocating shards.
+ // but we already fired up the request to wait for 0 relocating shards.
}
logger.info("--> remove index from the first node");
client().admin().indices().prepareUpdateSettings("test")
diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
index 1360937a01..565104b08e 100644
--- a/core/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
@@ -18,16 +18,11 @@
*/
package org.elasticsearch.cluster.allocation;
-import org.elasticsearch.cluster.ClusterInfoService;
-import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -45,10 +40,9 @@ public class SimpleAllocationIT extends ESIntegTestCase {
}
/**
- * Test for
+ * Test for
* https://groups.google.com/d/msg/elasticsearch/y-SY_HyoB-8/EZdfNt9VO44J
*/
- @Test
public void testSaneAllocation() {
assertAcked(prepareCreate("test", 3));
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java b/core/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java
index 0cc7b70796..0de18e9e0b 100644
--- a/core/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.EnumSet;
@@ -32,8 +31,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class ClusterBlockTests extends ESTestCase {
-
- @Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(10, 100);
for (int i = 0; i < iterations; i++) {
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java
index d63319386b..0215f94d4d 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java
@@ -30,13 +30,13 @@ import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.joda.time.DateTimeZone.UTC;
@@ -176,24 +176,44 @@ public class DateMathExpressionResolverTests extends ESTestCase {
assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.withZone(timeZone))));
}
- @Test(expected = ElasticsearchParseException.class)
- public void testExpression_Invalid_Unescaped() throws Exception {
- expressionResolver.resolve(context, Arrays.asList("<.mar}vel-{now/d}>"));
+ public void testExpressionInvalidUnescaped() throws Exception {
+ try {
+ expressionResolver.resolve(context, Arrays.asList("<.mar}vel-{now/d}>"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("invalid dynamic name expression"));
+ assertThat(e.getMessage(), containsString("invalid character at position ["));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
- public void testExpression_Invalid_DateMathFormat() throws Exception {
- expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}>"));
+ public void testExpressionInvalidDateMathFormat() throws Exception {
+ try {
+ expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}>"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("invalid dynamic name expression"));
+ assertThat(e.getMessage(), containsString("date math placeholder is open ended"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
- public void testExpression_Invalid_EmptyDateMathFormat() throws Exception {
- expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}}>"));
+ public void testExpressionInvalidEmptyDateMathFormat() throws Exception {
+ try {
+ expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{}}>"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("invalid dynamic name expression"));
+ assertThat(e.getMessage(), containsString("missing date format"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
- public void testExpression_Invalid_OpenEnded() throws Exception {
- expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d>"));
+ public void testExpressionInvalidOpenEnded() throws Exception {
+ try {
+ expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d>"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("invalid dynamic name expression"));
+ assertThat(e.getMessage(), containsString("date math placeholder is open ended"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java
index 4163ad05d6..9be087e0e5 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java
@@ -24,13 +24,10 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import static org.elasticsearch.test.VersionUtils.randomVersion;
public class HumanReadableIndexSettingsTests extends ESTestCase {
-
- @Test
public void testHumanReadableSettings() {
Version versionCreated = randomVersion(random());
Version versionUpgraded = randomVersion(random());
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
index 3bae8e158d..11e8b6c6a0 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -42,16 +41,15 @@ import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
/**
*/
public class IndexNameExpressionResolverTests extends ESTestCase {
-
private final IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(Settings.EMPTY);
- @Test
- public void testIndexOptions_strict() {
+ public void testIndexOptionsStrict() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar")))
.put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar")))
@@ -79,7 +77,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar"));
results = indexNameExpressionResolver.concreteIndices(context, "foofoobar");
- assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")),
+ assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")),
new HashSet<>(Arrays.asList(results)));
try {
@@ -140,8 +138,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo", "foofoo-closed"));
}
- @Test
- public void testIndexOptions_lenient() {
+ public void testIndexOptionsLenient() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar")))
.put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar")))
@@ -166,7 +163,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
results = indexNameExpressionResolver.concreteIndices(context, "foofoobar");
assertEquals(2, results.length);
- assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")),
+ assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")),
new HashSet<>(Arrays.asList(results)));
results = indexNameExpressionResolver.concreteIndices(context, "foo", "bar");
@@ -208,8 +205,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo", "foofoo-closed"));
}
- @Test
- public void testIndexOptions_allowUnavailableDisallowEmpty() {
+ public void testIndexOptionsAllowUnavailableDisallowEmpty() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo"))
.put(indexBuilder("foobar"))
@@ -258,8 +254,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertEquals(4, results.length);
}
- @Test
- public void testIndexOptions_wildcardExpansion() {
+ public void testIndexOptionsWildcardExpansion() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo").state(IndexMetaData.State.CLOSE))
.put(indexBuilder("bar"))
@@ -329,8 +324,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
}
}
- @Test
- public void testIndexOptions_noExpandWildcards() {
+ public void testIndexOptionsNoExpandWildcards() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar")))
.put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar")))
@@ -423,8 +417,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
}
}
- @Test
- public void testIndexOptions_singleIndexNoExpandWildcards() {
+ public void testIndexOptionsSingleIndexNoExpandWildcards() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar")))
.put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar")))
@@ -481,8 +474,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(results, arrayContainingInAnyOrder("foo", "foofoo"));
}
- @Test
- public void testIndexOptions_emptyCluster() {
+ public void testIndexOptionsEmptyCluster() {
ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(MetaData.builder().build()).build();
IndicesOptions options = IndicesOptions.strictExpandOpen();
@@ -527,7 +519,6 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
return IndexMetaData.builder(index).settings(settings(Version.CURRENT).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
}
- @Test(expected = IndexNotFoundException.class)
public void testConcreteIndicesIgnoreIndicesOneMissingIndex() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -535,10 +526,14 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpandOpen());
- indexNameExpressionResolver.concreteIndices(context, "testZZZ");
+ try {
+ indexNameExpressionResolver.concreteIndices(context, "testZZZ");
+ fail("Expected IndexNotFoundException");
+ } catch(IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
public void testConcreteIndicesIgnoreIndicesOneMissingIndexOtherFound() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -549,7 +544,6 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(newHashSet(indexNameExpressionResolver.concreteIndices(context, "testXXX", "testZZZ")), equalTo(newHashSet("testXXX")));
}
- @Test(expected = IndexNotFoundException.class)
public void testConcreteIndicesIgnoreIndicesAllMissing() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -557,10 +551,14 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpandOpen());
- assertThat(newHashSet(indexNameExpressionResolver.concreteIndices(context, "testMo", "testMahdy")), equalTo(newHashSet("testXXX")));
+ try {
+ indexNameExpressionResolver.concreteIndices(context, "testMo", "testMahdy");
+ fail("Expected IndexNotFoundException");
+ } catch(IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
public void testConcreteIndicesIgnoreIndicesEmptyRequest() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -570,7 +568,6 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(newHashSet(indexNameExpressionResolver.concreteIndices(context, new String[]{})), equalTo(newHashSet("kuku", "testXXX")));
}
- @Test
public void testConcreteIndicesWildcardExpansion() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX").state(State.OPEN))
@@ -593,7 +590,6 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
/**
* test resolving _all pattern (null, empty array or "_all") for random IndicesOptions
*/
- @Test
public void testConcreteIndicesAllPatternRandom() {
for (int i = 0; i < 10; i++) {
String[] allIndices = null;
@@ -660,7 +656,6 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
/**
* test resolving wildcard pattern that matches no index of alias for random IndicesOptions
*/
- @Test
public void testConcreteIndicesWildcardNoMatch() {
for (int i = 0; i < 10; i++) {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
@@ -687,92 +682,76 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
}
}
- @Test
- public void testIsAllIndices_null() throws Exception {
+ public void testIsAllIndicesNull() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(null), equalTo(true));
}
- @Test
- public void testIsAllIndices_empty() throws Exception {
+ public void testIsAllIndicesEmpty() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(Collections.<String>emptyList()), equalTo(true));
}
- @Test
- public void testIsAllIndices_explicitAll() throws Exception {
+ public void testIsAllIndicesExplicitAll() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(Arrays.asList("_all")), equalTo(true));
}
- @Test
- public void testIsAllIndices_explicitAllPlusOther() throws Exception {
+ public void testIsAllIndicesExplicitAllPlusOther() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(Arrays.asList("_all", "other")), equalTo(false));
}
- @Test
- public void testIsAllIndices_normalIndexes() throws Exception {
+ public void testIsAllIndicesNormalIndexes() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(Arrays.asList("index1", "index2", "index3")), equalTo(false));
}
- @Test
- public void testIsAllIndices_wildcard() throws Exception {
+ public void testIsAllIndicesWildcard() throws Exception {
assertThat(IndexNameExpressionResolver.isAllIndices(Arrays.asList("*")), equalTo(false));
}
- @Test
- public void testIsExplicitAllIndices_null() throws Exception {
+ public void testIsExplicitAllIndicesNull() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(null), equalTo(false));
}
- @Test
- public void testIsExplicitAllIndices_empty() throws Exception {
+ public void testIsExplicitAllIndicesEmpty() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(Collections.<String>emptyList()), equalTo(false));
}
- @Test
- public void testIsExplicitAllIndices_explicitAll() throws Exception {
+ public void testIsExplicitAllIndicesExplicitAll() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(Arrays.asList("_all")), equalTo(true));
}
- @Test
- public void testIsExplicitAllIndices_explicitAllPlusOther() throws Exception {
+ public void testIsExplicitAllIndicesExplicitAllPlusOther() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(Arrays.asList("_all", "other")), equalTo(false));
}
- @Test
- public void testIsExplicitAllIndices_normalIndexes() throws Exception {
+ public void testIsExplicitAllIndicesNormalIndexes() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(Arrays.asList("index1", "index2", "index3")), equalTo(false));
}
- @Test
- public void testIsExplicitAllIndices_wildcard() throws Exception {
+ public void testIsExplicitAllIndicesWildcard() throws Exception {
assertThat(IndexNameExpressionResolver.isExplicitAllPattern(Arrays.asList("*")), equalTo(false));
}
- @Test
- public void testIsPatternMatchingAllIndices_explicitList() throws Exception {
+ public void testIsPatternMatchingAllIndicesExplicitList() throws Exception {
//even though it does identify all indices, it's not a pattern but just an explicit list of them
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
MetaData metaData = metaDataBuilder(concreteIndices);
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, concreteIndices, concreteIndices), equalTo(false));
}
- @Test
- public void testIsPatternMatchingAllIndices_onlyWildcard() throws Exception {
+ public void testIsPatternMatchingAllIndicesOnlyWildcard() throws Exception {
String[] indicesOrAliases = new String[]{"*"};
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
MetaData metaData = metaDataBuilder(concreteIndices);
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(true));
}
- @Test
- public void testIsPatternMatchingAllIndices_matchingTrailingWildcard() throws Exception {
+ public void testIsPatternMatchingAllIndicesMatchingTrailingWildcard() throws Exception {
String[] indicesOrAliases = new String[]{"index*"};
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
MetaData metaData = metaDataBuilder(concreteIndices);
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(true));
}
- @Test
- public void testIsPatternMatchingAllIndices_nonMatchingTrailingWildcard() throws Exception {
+ public void testIsPatternMatchingAllIndicesNonMatchingTrailingWildcard() throws Exception {
String[] indicesOrAliases = new String[]{"index*"};
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
String[] allConcreteIndices = new String[]{"index1", "index2", "index3", "a", "b"};
@@ -780,16 +759,14 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(false));
}
- @Test
- public void testIsPatternMatchingAllIndices_matchingSingleExclusion() throws Exception {
+ public void testIsPatternMatchingAllIndicesMatchingSingleExclusion() throws Exception {
String[] indicesOrAliases = new String[]{"-index1", "+index1"};
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
MetaData metaData = metaDataBuilder(concreteIndices);
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(true));
}
- @Test
- public void testIsPatternMatchingAllIndices_nonMatchingSingleExclusion() throws Exception {
+ public void testIsPatternMatchingAllIndicesNonMatchingSingleExclusion() throws Exception {
String[] indicesOrAliases = new String[]{"-index1"};
String[] concreteIndices = new String[]{"index2", "index3"};
String[] allConcreteIndices = new String[]{"index1", "index2", "index3"};
@@ -797,16 +774,14 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(false));
}
- @Test
- public void testIsPatternMatchingAllIndices_matchingTrailingWildcardAndExclusion() throws Exception {
+ public void testIsPatternMatchingAllIndicesMatchingTrailingWildcardAndExclusion() throws Exception {
String[] indicesOrAliases = new String[]{"index*", "-index1", "+index1"};
String[] concreteIndices = new String[]{"index1", "index2", "index3"};
MetaData metaData = metaDataBuilder(concreteIndices);
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(true));
}
- @Test
- public void testIsPatternMatchingAllIndices_nonMatchingTrailingWildcardAndExclusion() throws Exception {
+ public void testIsPatternMatchingAllIndicesNonMatchingTrailingWildcardAndExclusion() throws Exception {
String[] indicesOrAliases = new String[]{"index*", "-index1"};
String[] concreteIndices = new String[]{"index2", "index3"};
String[] allConcreteIndices = new String[]{"index1", "index2", "index3"};
@@ -814,8 +789,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertThat(indexNameExpressionResolver.isPatternMatchingAllIndices(metaData, indicesOrAliases, concreteIndices), equalTo(false));
}
- @Test
- public void testIndexOptions_failClosedIndicesAndAliases() {
+ public void testIndexOptionsFailClosedIndicesAndAliases() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo1-closed").state(IndexMetaData.State.CLOSE).putAlias(AliasMetaData.builder("foobar1-closed")).putAlias(AliasMetaData.builder("foobar2-closed")))
.put(indexBuilder("foo2-closed").state(IndexMetaData.State.CLOSE).putAlias(AliasMetaData.builder("foobar2-closed")))
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java
index 2211b20ad9..e4462007c9 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java
@@ -24,15 +24,12 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class MappingMetaDataParserTests extends ESTestCase {
-
- @Test
public void testParseIdAlone() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -49,8 +46,7 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), nullValue());
assertThat(parseContext.timestampResolved(), equalTo(false));
}
-
- @Test
+
public void testFailIfIdIsNoValue() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -65,7 +61,7 @@ public class MappingMetaDataParserTests extends ESTestCase {
} catch (MapperParsingException ex) {
// bogus its an array
}
-
+
bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
.startObject("id").field("x", "id").endObject().field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
parseContext = md.createParseContext(null, "routing_value", "1");
@@ -77,7 +73,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
}
}
- @Test
public void testParseRoutingAlone() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -95,7 +90,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestampResolved(), equalTo(false));
}
- @Test
public void testParseTimestampAlone() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -113,7 +107,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestampResolved(), equalTo(true));
}
- @Test
public void testParseTimestampEquals() throws Exception {
MappingMetaData md1 = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -126,7 +119,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(md1, equalTo(md2));
}
- @Test
public void testParseIdAndRoutingAndTimestamp() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -141,7 +133,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("1"));
}
- @Test
public void testParseIdAndRoutingAndTimestampWithPath() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -159,7 +150,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("1"));
}
- @Test
public void testParseIdWithPath() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -180,7 +170,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestampResolved(), equalTo(false));
}
- @Test
public void testParseRoutingWithPath() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -201,7 +190,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestampResolved(), equalTo(false));
}
- @Test
public void testParseTimestampWithPath() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -222,7 +210,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestampResolved(), equalTo(true));
}
- @Test
public void testParseIdAndRoutingAndTimestampWithinSamePath() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -240,7 +227,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("1"));
}
- @Test
public void testParseIdAndRoutingAndTimestampWithinSamePathAndMoreLevels() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.obj0.id"),
@@ -268,8 +254,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("1"));
}
-
- @Test
public void testParseIdAndRoutingAndTimestampWithSameRepeatedObject() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("obj1.id"),
@@ -288,8 +272,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("1"));
}
- //
- @Test
public void testParseIdRoutingTimestampWithRepeatedField() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("field1"),
@@ -312,7 +294,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("foo"));
}
- @Test
public void testParseNoIdRoutingWithRepeatedFieldAndObject() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id("id"),
@@ -335,7 +316,6 @@ public class MappingMetaDataParserTests extends ESTestCase {
assertThat(parseContext.timestamp(), equalTo("foo"));
}
- @Test
public void testParseRoutingWithRepeatedFieldAndValidRouting() throws Exception {
MappingMetaData md = new MappingMetaData("type1", new CompressedXContent("{}"),
new MappingMetaData.Id(null),
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java
index dba510afa0..cbb5b7dfbd 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java
@@ -23,20 +23,19 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class ToAndFromJsonMetaDataTests extends ESTestCase {
-
- @Test
public void testSimpleJsonFromAndTo() throws IOException {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test1")
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/WildcardExpressionResolverTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/WildcardExpressionResolverTests.java
index fa6217e3d1..324086a044 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/WildcardExpressionResolverTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/WildcardExpressionResolverTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
@@ -32,8 +31,6 @@ import static org.elasticsearch.common.util.set.Sets.newHashSet;
import static org.hamcrest.Matchers.equalTo;
public class WildcardExpressionResolverTests extends ESTestCase {
-
- @Test
public void testConvertWildcardsJustIndicesTests() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -52,7 +49,6 @@ public class WildcardExpressionResolverTests extends ESTestCase {
assertThat(newHashSet(resolver.resolve(context, Arrays.asList("testX*", "kuku"))), equalTo(newHashSet("testXXX", "testXYY", "kuku")));
}
- @Test
public void testConvertWildcardsTests() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX").putAlias(AliasMetaData.builder("alias1")).putAlias(AliasMetaData.builder("alias2")))
@@ -70,7 +66,6 @@ public class WildcardExpressionResolverTests extends ESTestCase {
assertThat(newHashSet(resolver.resolve(context, Arrays.asList("+testYYY", "+testX*"))), equalTo(newHashSet("testXXX", "testXYY", "testYYY")));
}
- @Test
public void testConvertWildcardsOpenClosedIndicesTests() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX").state(IndexMetaData.State.OPEN))
diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeFiltersTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeFiltersTests.java
index 2136d1e0a5..ef54814019 100644
--- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeFiltersTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeFiltersTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.test.ESTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -58,8 +57,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
localAddress = null;
}
- @Test
- public void nameMatch() {
+ public void testNameMatch() {
Settings settings = Settings.settingsBuilder()
.put("xxx.name", "name1")
.build();
@@ -72,8 +70,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void idMatch() {
+ public void testIdMatch() {
Settings settings = Settings.settingsBuilder()
.put("xxx._id", "id1")
.build();
@@ -86,8 +83,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void idOrNameMatch() {
+ public void testIdOrNameMatch() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx._id", "id1,blah")
.put("xxx.name", "blah,name2")
@@ -104,8 +100,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void tagAndGroupMatch() {
+ public void testTagAndGroupMatch() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx.group", "B")
@@ -139,8 +134,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void starMatch() {
+ public void testStarMatch() {
Settings settings = Settings.settingsBuilder()
.put("xxx.name", "*")
.build();
@@ -150,8 +144,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipBindFilteringMatchingAnd() {
+ public void testIpBindFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
@@ -162,8 +155,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipBindFilteringNotMatching() {
+ public void testIpBindFilteringNotMatching() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "B")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
@@ -174,8 +166,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void ipBindFilteringNotMatchingAnd() {
+ public void testIpBindFilteringNotMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8")
@@ -186,8 +177,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void ipBindFilteringMatchingOr() {
+ public void testIpBindFilteringMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
.put("xxx.tag", "A")
@@ -198,8 +188,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipBindFilteringNotMatchingOr() {
+ public void testIpBindFilteringNotMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8")
@@ -210,8 +199,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipPublishFilteringMatchingAnd() {
+ public void testIpPublishFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx._publish_ip", "192.1.1.54")
@@ -222,8 +210,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipPublishFilteringNotMatchingAnd() {
+ public void testIpPublishFilteringNotMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx._publish_ip", "8.8.8.8")
@@ -234,8 +221,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(false));
}
- @Test
- public void ipPublishFilteringMatchingOr() {
+ public void testIpPublishFilteringMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx._publish_ip", "192.1.1.54")
.put("xxx.tag", "A")
@@ -246,8 +232,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
assertThat(filters.match(node), equalTo(true));
}
- @Test
- public void ipPublishFilteringNotMatchingOr() {
+ public void testIpPublishFilteringNotMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder()
.put("xxx.tag", "A")
.put("xxx._publish_ip", "8.8.8.8")
@@ -260,13 +245,11 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
private Settings shuffleSettings(Settings source) {
Settings.Builder settings = Settings.settingsBuilder();
- List<String> keys = new ArrayList(source.getAsMap().keySet());
+ List<String> keys = new ArrayList<>(source.getAsMap().keySet());
Collections.shuffle(keys, getRandom());
for (String o : keys) {
settings.put(o, source.getAsMap().get(o));
}
return settings.build();
}
-
-
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/AllocationIdTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/AllocationIdTests.java
index 262b3db630..8d6953ed92 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/AllocationIdTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/AllocationIdTests.java
@@ -20,15 +20,15 @@
package org.elasticsearch.cluster.routing;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
public class AllocationIdTests extends ESTestCase {
-
- @Test
public void testShardToStarted() {
logger.info("-- create unassigned shard");
ShardRouting shard = ShardRouting.newUnassigned("test", 0, null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
@@ -49,7 +49,6 @@ public class AllocationIdTests extends ESTestCase {
assertThat(allocationId.getRelocationId(), nullValue());
}
- @Test
public void testSuccessfulRelocation() {
logger.info("-- build started shard");
ShardRouting shard = ShardRouting.newUnassigned("test", 0, null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
@@ -73,7 +72,6 @@ public class AllocationIdTests extends ESTestCase {
assertThat(target.allocationId().getRelocationId(), nullValue());
}
- @Test
public void testCancelRelocation() {
logger.info("-- build started shard");
ShardRouting shard = ShardRouting.newUnassigned("test", 0, null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
@@ -94,7 +92,6 @@ public class AllocationIdTests extends ESTestCase {
assertThat(shard.allocationId().getRelocationId(), nullValue());
}
- @Test
public void testMoveToUnassigned() {
logger.info("-- build started shard");
ShardRouting shard = ShardRouting.newUnassigned("test", 0, null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
@@ -106,7 +103,6 @@ public class AllocationIdTests extends ESTestCase {
assertThat(shard.allocationId(), nullValue());
}
- @Test
public void testReinitializing() {
logger.info("-- build started shard");
ShardRouting shard = ShardRouting.newUnassigned("test", 0, null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
index c6e9f0906e..6d6f0d65b5 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
-import org.junit.Test;
import java.util.Collections;
import java.util.List;
@@ -43,7 +42,6 @@ public class DelayedAllocationIT extends ESIntegTestCase {
* Verifies that when there is no delay timeout, a 1/1 index shard will immediately
* get allocated to a free node when the node hosting it leaves the cluster.
*/
- @Test
public void testNoDelayedTimeout() throws Exception {
internalCluster().startNodesAsync(3).get();
prepareCreate("test").setSettings(Settings.builder()
@@ -63,7 +61,6 @@ public class DelayedAllocationIT extends ESIntegTestCase {
* get allocated. Once we bring the node back, it gets allocated since it existed
* on it before.
*/
- @Test
public void testDelayedAllocationNodeLeavesAndComesBack() throws Exception {
internalCluster().startNodesAsync(3).get();
prepareCreate("test").setSettings(Settings.builder()
@@ -88,7 +85,6 @@ public class DelayedAllocationIT extends ESIntegTestCase {
* With a very small delay timeout, verify that it expires and we get to green even
* though the node hosting the shard is not coming back.
*/
- @Test
public void testDelayedAllocationTimesOut() throws Exception {
internalCluster().startNodesAsync(3).get();
prepareCreate("test").setSettings(Settings.builder()
@@ -111,7 +107,6 @@ public class DelayedAllocationIT extends ESIntegTestCase {
* allocation to a very small value, it kicks the allocation of the unassigned shard
* even though the node it was hosted on will not come back.
*/
- @Test
public void testDelayedAllocationChangeWithSettingTo100ms() throws Exception {
internalCluster().startNodesAsync(3).get();
prepareCreate("test").setSettings(Settings.builder()
@@ -138,7 +133,6 @@ public class DelayedAllocationIT extends ESIntegTestCase {
* allocation to 0, it kicks the allocation of the unassigned shard
* even though the node it was hosted on will not come back.
*/
- @Test
public void testDelayedAllocationChangeWithSettingTo0() throws Exception {
internalCluster().startNodesAsync(3).get();
prepareCreate("test").setSettings(Settings.builder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingServiceTests.java
index 9309fa7147..f0df406fa7 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingServiceTests.java
@@ -34,7 +34,6 @@ import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -58,14 +57,12 @@ public class RoutingServiceTests extends ESAllocationTestCase {
routingService.shutdown();
}
- @Test
public void testReroute() {
assertThat(routingService.hasReroutedAndClear(), equalTo(false));
routingService.reroute("test");
assertThat(routingService.hasReroutedAndClear(), equalTo(true));
}
- @Test
public void testNoDelayedUnassigned() throws Exception {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
@@ -94,7 +91,6 @@ public class RoutingServiceTests extends ESAllocationTestCase {
assertThat(routingService.hasReroutedAndClear(), equalTo(false));
}
- @Test
@TestLogging("_root:DEBUG")
public void testDelayedUnassignedScheduleReroute() throws Exception {
AllocationService allocation = createAllocationService();
@@ -142,7 +138,6 @@ public class RoutingServiceTests extends ESAllocationTestCase {
assertThat(routingService.getRegisteredNextDelaySetting(), equalTo(Long.MAX_VALUE));
}
- @Test
public void testDelayedUnassignedDoesNotRerouteForNegativeDelays() throws Exception {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java
index 2a7ed6a4a9..d7e54788c7 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Before;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
@@ -109,7 +108,6 @@ public class RoutingTableTests extends ESAllocationTestCase {
.numberOfShards(this.numberOfShards);
}
- @Test
public void testAllShards() {
assertThat(this.emptyRoutingTable.allShards().size(), is(0));
assertThat(this.testRoutingTable.allShards().size(), is(this.totalNumberOfShards));
@@ -123,26 +121,22 @@ public class RoutingTableTests extends ESAllocationTestCase {
}
}
- @Test
public void testHasIndex() {
assertThat(this.testRoutingTable.hasIndex(TEST_INDEX_1), is(true));
assertThat(this.testRoutingTable.hasIndex("foobar"), is(false));
}
- @Test
public void testIndex() {
assertThat(this.testRoutingTable.index(TEST_INDEX_1).getIndex(), is(TEST_INDEX_1));
assertThat(this.testRoutingTable.index("foobar"), is(nullValue()));
}
- @Test
public void testIndicesRouting() {
assertThat(this.testRoutingTable.indicesRouting().size(), is(2));
assertThat(this.testRoutingTable.getIndicesRouting().size(), is(2));
assertSame(this.testRoutingTable.getIndicesRouting(), this.testRoutingTable.indicesRouting());
}
- @Test
public void testShardsWithState() {
assertThat(this.testRoutingTable.shardsWithState(ShardRoutingState.UNASSIGNED).size(), is(this.totalNumberOfShards));
@@ -168,7 +162,6 @@ public class RoutingTableTests extends ESAllocationTestCase {
assertThat(this.testRoutingTable.shardsWithState(ShardRoutingState.STARTED).size(), is(this.totalNumberOfShards));
}
- @Test
public void testActivePrimaryShardsGrouped() {
assertThat(this.emptyRoutingTable.activePrimaryShardsGrouped(new String[0], true).size(), is(0));
assertThat(this.emptyRoutingTable.activePrimaryShardsGrouped(new String[0], false).size(), is(0));
@@ -198,7 +191,6 @@ public class RoutingTableTests extends ESAllocationTestCase {
}
}
- @Test
public void testAllActiveShardsGrouped() {
assertThat(this.emptyRoutingTable.allActiveShardsGrouped(new String[0], true).size(), is(0));
assertThat(this.emptyRoutingTable.allActiveShardsGrouped(new String[0], false).size(), is(0));
@@ -227,7 +219,6 @@ public class RoutingTableTests extends ESAllocationTestCase {
}
}
- @Test
public void testAllAssignedShardsGrouped() {
assertThat(this.testRoutingTable.allAssignedShardsGrouped(new String[]{TEST_INDEX_1}, false).size(), is(0));
assertThat(this.testRoutingTable.allAssignedShardsGrouped(new String[]{TEST_INDEX_1}, true).size(), is(this.shardsPerIndex));
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java
index fc7ce64c08..bd991303ea 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.Collections;
import java.util.EnumSet;
@@ -54,8 +53,6 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class UnassignedInfoTests extends ESAllocationTestCase {
-
- @Test
public void testReasonOrdinalOrder() {
UnassignedInfo.Reason[] order = new UnassignedInfo.Reason[]{
UnassignedInfo.Reason.INDEX_CREATED,
@@ -76,7 +73,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
assertThat(UnassignedInfo.Reason.values().length, equalTo(order.length));
}
- @Test
public void testSerialization() throws Exception {
UnassignedInfo meta = new UnassignedInfo(RandomPicks.randomFrom(getRandom(), UnassignedInfo.Reason.values()), randomBoolean() ? randomAsciiOfLength(4) : null);
BytesStreamOutput out = new BytesStreamOutput();
@@ -90,7 +86,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
assertThat(read.getDetails(), equalTo(meta.getDetails()));
}
- @Test
public void testIndexCreated() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -103,7 +98,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testClusterRecovered() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -116,7 +110,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testIndexReopened() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -129,7 +122,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testNewIndexRestored() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -142,7 +134,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testExistingIndexRestored() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -155,7 +146,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testDanglingIndexImported() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
@@ -168,7 +158,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
}
}
- @Test
public void testReplicaAdded() {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
@@ -195,7 +184,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
/**
* The unassigned meta is kept when a shard goes to INITIALIZING, but cleared when it moves to STARTED.
*/
- @Test
public void testStateTransitionMetaHandling() {
ShardRouting shard = TestShardRouting.newShardRouting("test", 1, null, null, null, true, ShardRoutingState.UNASSIGNED, 1, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
ShardRouting mutable = new ShardRouting(shard);
@@ -211,7 +199,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
/**
* Tests that during reroute when a node is detected as leaving the cluster, the right unassigned meta is set
*/
- @Test
public void testNodeLeave() {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
@@ -241,7 +228,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
/**
* Verifies that when a shard fails, reason is properly set and details are preserved.
*/
- @Test
public void testFailedShard() {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
@@ -273,7 +259,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
/**
* Verifies that delayed allocation calculation are correct.
*/
- @Test
public void testUnassignedDelayedOnlyOnNodeLeft() throws Exception {
final UnassignedInfo unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.NODE_LEFT, null);
long delay = unassignedInfo.getAllocationDelayTimeoutSetting(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), Settings.EMPTY);
@@ -292,7 +277,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
/**
* Verifies that delayed allocation is only computed when the reason is NODE_LEFT.
*/
- @Test
public void testUnassignedDelayOnlyNodeLeftNonNodeLeftReason() throws Exception {
EnumSet<UnassignedInfo.Reason> reasons = EnumSet.allOf(UnassignedInfo.Reason.class);
reasons.remove(UnassignedInfo.Reason.NODE_LEFT);
@@ -304,7 +288,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
assertThat(delay, equalTo(0l));
}
- @Test
public void testNumberOfDelayedUnassigned() throws Exception {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
@@ -330,7 +313,6 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), clusterState), equalTo(2));
}
- @Test
public void testFindNextDelayedAllocation() {
AllocationService allocation = createAllocationService();
MetaData metaData = MetaData.builder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
index 836422f251..958c2e75e3 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.test.ESAllocationTestCase;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -50,7 +49,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class AddIncrementallyTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class);
- @Test
public void testAddNodesAndIndices() {
Settings.Builder settings = settingsBuilder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
@@ -94,7 +92,6 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
logger.debug("ClusterState: {}", clusterState.getRoutingNodes().prettyPrint());
}
- @Test
public void testMinimalRelocations() {
Settings.Builder settings = settingsBuilder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString())
@@ -163,7 +160,6 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
logger.debug("ClusterState: {}", clusterState.getRoutingNodes().prettyPrint());
}
- @Test
public void testMinimalRelocationsNoLimit() {
Settings.Builder settings = settingsBuilder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString())
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java
index 96cba278fe..6d4013a98a 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java
@@ -40,7 +40,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
@@ -52,11 +51,9 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class AllocationCommandsTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(AllocationCommandsTests.class);
- @Test
- public void moveShardCommand() {
+ public void testMoveShardCommand() {
AllocationService allocation = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
logger.info("creating an index with 1 shard, no replica");
@@ -99,8 +96,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node(toNodeId).get(0).state(), equalTo(ShardRoutingState.STARTED));
}
- @Test
- public void allocateCommand() {
+ public void testAllocateCommand() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@@ -188,8 +184,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
}
}
- @Test
- public void cancelCommand() {
+ public void testCancelCommand() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@@ -338,8 +333,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node("node3").size(), equalTo(0));
}
- @Test
- public void serialization() throws Exception {
+ public void testSerialization() throws Exception {
AllocationCommands commands = new AllocationCommands(
new AllocateAllocationCommand(new ShardId("test", 1), "node1", true),
new MoveAllocationCommand(new ShardId("test", 3), "node2", "node3"),
@@ -363,8 +357,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
assertThat(((CancelAllocationCommand) (sCommands.commands().get(2))).allowPrimary(), equalTo(true));
}
- @Test
- public void xContent() throws Exception {
+ public void testXContent() throws Exception {
String commands = "{\n" +
" \"commands\" : [\n" +
" {\"allocate\" : {\"index\" : \"test\", \"shard\" : 1, \"node\" : \"node1\", \"allow_primary\" : true}}\n" +
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java
index e17ac30212..91c38e6b51 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java
@@ -35,7 +35,6 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
@@ -53,8 +52,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class);
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded1() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded1() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -122,8 +120,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
}
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded2() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded2() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -192,8 +189,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
}
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded3() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded3() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
@@ -293,8 +289,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
}
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded4() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded4() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
@@ -389,8 +384,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
}
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded5() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded5() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -468,8 +462,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
}
- @Test
- public void moveShardOnceNewNodeWithAttributeAdded6() {
+ public void testMoveShardOnceNewNodeWithAttributeAdded6() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -549,8 +542,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
}
- @Test
- public void fullAwareness1() {
+ public void testFullAwareness1() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -617,8 +609,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
}
- @Test
- public void fullAwareness2() {
+ public void testFullAwareness2() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -686,8 +677,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
}
- @Test
- public void fullAwareness3() {
+ public void testFullAwareness3() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
@@ -771,7 +761,6 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
}
- @Test
public void testUnbalancedZones() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b")
@@ -836,7 +825,6 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node("B-0").size(), equalTo(5));
}
- @Test
public void testUnassignedShardsWithUnbalancedZones() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java
index 2bd18f814d..8c7ff26a3a 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java
@@ -44,7 +44,6 @@ import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESAllocationTestCase;
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
import org.hamcrest.Matchers;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -59,7 +58,6 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
final int numberOfShards = 2;
final int numberOfReplicas = 2;
- @Test
public void testIndexBalance() {
/* Tests balance over indices only */
final float indexBalance = 1.0f;
@@ -85,7 +83,6 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
}
- @Test
public void testReplicaBalance() {
/* Tests balance over replicas only */
final float indexBalance = 0.0f;
@@ -280,7 +277,6 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
}
}
- @Test
public void testPersistedSettings() {
Settings.Builder settings = settingsBuilder();
settings.put(BalancedShardsAllocator.SETTING_INDEX_BALANCE_FACTOR, 0.2);
@@ -318,7 +314,6 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
assertThat(allocator.getThreshold(), Matchers.equalTo(3.0f));
}
- @Test
public void testNoRebalanceOnPrimaryOverload() {
Settings.Builder settings = settingsBuilder();
AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(),
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/CatAllocationTestCase.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/CatAllocationTestCase.java
index 6253febaec..022e0cca3a 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/CatAllocationTestCase.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/CatAllocationTestCase.java
@@ -19,26 +19,35 @@
package org.elasticsearch.cluster.routing.allocation;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.IndexRoutingTable;
+import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
+import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
+import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.io.BufferedReader;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/**
@@ -50,11 +59,9 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
* This can be used to debug cluster allocation decisions.
*/
public abstract class CatAllocationTestCase extends ESAllocationTestCase {
-
protected abstract Path getCatPath() throws IOException;
- @Test
- public void run() throws IOException {
+ public void testRun() throws IOException {
Set<String> nodes = new HashSet<>();
Map<String, Idx> indices = new HashMap<>();
try (BufferedReader reader = Files.newBufferedReader(getCatPath(), StandardCharsets.UTF_8)) {
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java
index 59e7529861..af71688e19 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java
@@ -30,18 +30,17 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ClusterRebalanceRoutingTests.class);
- @Test
public void testAlways() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
@@ -128,7 +127,6 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
}
- @Test
public void testClusterPrimariesActive1() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
@@ -233,7 +231,6 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").get(0).shardId().index().name(), equalTo("test1"));
}
- @Test
public void testClusterPrimariesActive2() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
@@ -318,7 +315,6 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").isEmpty(), equalTo(true));
}
- @Test
public void testClusterAllActive1() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
@@ -442,7 +438,6 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").get(0).shardId().index().name(), anyOf(equalTo("test1"), equalTo("test2")));
}
- @Test
public void testClusterAllActive2() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
@@ -527,7 +522,6 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").isEmpty(), equalTo(true));
}
- @Test
public void testClusterAllActive3() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java
index 7fe26d0725..957dec235d 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java
@@ -29,18 +29,18 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ConcurrentRebalanceRoutingTests.class);
- @Test
public void testClusterConcurrentRebalance() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -70,7 +70,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("start two nodes and fully start the shards");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
- RoutingTable prevRoutingTable = routingTable;
routingTable = strategy.reroute(clusterState).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
@@ -82,7 +81,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("start all the primary shards, replicas will start initializing");
RoutingNodes routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
@@ -97,7 +95,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
.put(newNode("node3")).put(newNode("node4")).put(newNode("node5")).put(newNode("node6")).put(newNode("node7")).put(newNode("node8")).put(newNode("node9")).put(newNode("node10")))
.build();
- prevRoutingTable = routingTable;
routingTable = strategy.reroute(clusterState).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
@@ -110,7 +107,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("start the replica shards, rebalancing should start, but, only 3 should be rebalancing");
routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
@@ -121,7 +117,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("finalize this session relocation, 3 more should relocate now");
routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
@@ -132,7 +127,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("finalize this session relocation, 2 more should relocate now");
routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
@@ -143,7 +137,6 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
logger.info("finalize this session relocation, no more relocation");
routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java
index 43f8479efe..80efb977ac 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java
@@ -31,20 +31,19 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
/**
*/
public class DeadNodesAllocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(DeadNodesAllocationTests.class);
- @Test
- public void simpleDeadNodeOnStartedPrimaryShard() {
+ public void testSimpleDeadNodeOnStartedPrimaryShard() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -95,8 +94,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node(nodeIdRemaining).get(0).state(), equalTo(STARTED));
}
- @Test
- public void deadNodeWhileRelocatingOnToNode() {
+ public void testDeadNodeWhileRelocatingOnToNode() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -170,8 +168,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node(origReplicaNodeId).get(0).state(), equalTo(STARTED));
}
- @Test
- public void deadNodeWhileRelocatingOnFromNode() {
+ public void testDeadNodeWhileRelocatingOnFromNode() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java
index d2ece37634..63dbfa3341 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -41,10 +40,8 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ElectReplicaAsPrimaryDuringRelocationTests.class);
- @Test
public void testElectReplicaAsPrimaryDuringRelocation() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java
index e6a0ec4bc9..7488c972c3 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java
@@ -32,28 +32,20 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.command.AllocationCommands;
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
-import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import java.util.Collections;
-
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
-import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
-import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.hamcrest.Matchers.equalTo;
/**
*/
public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ExpectedShardSizeAllocationTests.class);
- @Test
public void testInitializingHasExpectedSize() {
final long byteSize = randomIntBetween(0, Integer.MAX_VALUE);
AllocationService strategy = createAllocationService(Settings.EMPTY, new ClusterInfoService() {
@@ -112,7 +104,6 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
assertEquals(byteSize, clusterState.getRoutingNodes().getRoutingTable().shardsWithState(ShardRoutingState.INITIALIZING).get(0).getExpectedShardSize());
}
- @Test
public void testExpectedSizeOnMove() {
final long byteSize = randomIntBetween(0, Integer.MAX_VALUE);
final AllocationService allocation = createAllocationService(Settings.EMPTY, new ClusterInfoService() {
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java
index 70b056b629..c43dd192da 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -39,11 +38,9 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
public class FailedNodeRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(FailedNodeRoutingTests.class);
- @Test
- public void simpleFailedNodeTest() {
+ public void testSimpleFailedNodeTest() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java
index ff2ae1051e..480336e054 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java
@@ -24,30 +24,36 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.RoutingNodes;
+import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.command.AllocationCommands;
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class FailedShardsRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(FailedShardsRoutingTests.class);
- @Test
public void testFailedShardPrimaryRelocatingToAndFrom() {
AllocationService allocation = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -136,8 +142,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(clusterState.routingTable().index("test").shard(0).replicaShards().get(0).currentNodeId(), anyOf(equalTo(origPrimaryNodeId), equalTo("node3")));
}
- @Test
- public void failPrimaryStartedCheckReplicaElected() {
+ public void testFailPrimaryStartedCheckReplicaElected() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -218,8 +223,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(strategy.applyFailedShard(clusterState, shardToFail).changed(), equalTo(false));
}
- @Test
- public void firstAllocationFailureSingleNode() {
+ public void testFirstAllocationFailureSingleNode() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -275,8 +279,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(strategy.applyFailedShard(clusterState, firstShard).changed(), equalTo(false));
}
- @Test
- public void singleShardMultipleAllocationFailures() {
+ public void testSingleShardMultipleAllocationFailures() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -332,8 +335,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
}
}
- @Test
- public void firstAllocationFailureTwoNodes() {
+ public void testFirstAllocationFailureTwoNodes() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -393,8 +395,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(strategy.applyFailedShard(clusterState, firstShard).changed(), equalTo(false));
}
- @Test
- public void rebalanceFailure() {
+ public void testRebalanceFailure() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
@@ -489,7 +490,6 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").get(0).shardId(), not(equalTo(shardToFail.shardId())));
}
- @Test
public void testFailAllReplicasInitializingOnPrimaryFail() {
AllocationService allocation = createAllocationService(settingsBuilder()
.build());
@@ -536,7 +536,6 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(routingResult.changed(), equalTo(false));
}
- @Test
public void testFailAllReplicasInitializingOnPrimaryFailWhileHavingAReplicaToElect() {
AllocationService allocation = createAllocationService(settingsBuilder()
.build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java
index eb4d62a707..f7f694d5a4 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.List;
@@ -43,10 +42,8 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class FilterRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(FilterRoutingTests.class);
- @Test
public void testClusterFilters() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.include.tag1", "value1,value2")
@@ -92,7 +89,6 @@ public class FilterRoutingTests extends ESAllocationTestCase {
}
}
- @Test
public void testIndexFilters() {
AllocationService strategy = createAllocationService(settingsBuilder()
.build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java
index aece576a78..1df9de85e4 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java
@@ -30,9 +30,10 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@@ -41,10 +42,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class IndexBalanceTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class);
- @Test
public void testBalanceAllNodesStarted() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
@@ -175,7 +174,6 @@ public class IndexBalanceTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").shardsWithState("test1", STARTED).size(), equalTo(2));
}
- @Test
public void testBalanceIncrementallyStartNodes() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
@@ -338,7 +336,6 @@ public class IndexBalanceTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").shardsWithState("test1", STARTED).size(), equalTo(2));
}
- @Test
public void testBalanceAllNodesStartedAddIndex() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java
index 344d6b909e..d7d9a3fa46 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java
@@ -25,34 +25,36 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.VersionUtils.randomVersion;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(NodeVersionAllocationDeciderTests.class);
- @Test
public void testDoNotAllocateFromPrimary() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -167,8 +169,6 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
}
}
-
- @Test
public void testRandom() {
AllocationService service = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -218,7 +218,6 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
}
}
- @Test
public void testRollingRestart() {
AllocationService service = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferLocalPrimariesToRelocatingPrimariesTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferLocalPrimariesToRelocatingPrimariesTests.java
index 616949ec72..bcb4e34a0c 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferLocalPrimariesToRelocatingPrimariesTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferLocalPrimariesToRelocatingPrimariesTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
@@ -39,7 +38,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class PreferLocalPrimariesToRelocatingPrimariesTests extends ESAllocationTestCase {
- @Test
public void testPreferLocalPrimaryAllocationOverFiltered() {
int concurrentRecoveries = randomIntBetween(1, 10);
int primaryRecoveries = randomIntBetween(1, 10);
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java
index 108281eae7..219a7a5783 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
@@ -37,10 +36,8 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class PreferPrimaryAllocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(PreferPrimaryAllocationTests.class);
- @Test
public void testPreferPrimaryAllocationOverReplicas() {
logger.info("create an allocation with 1 initial recoveries");
AllocationService strategy = createAllocationService(settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java
index 69824f1a24..119348a976 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -41,10 +40,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(PrimaryElectionRoutingTests.class);
- @Test
public void testBackupElectionToPrimaryWhenPrimaryCanBeAllocatedToAnotherNode() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
@@ -95,7 +92,6 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).currentNodeId(), equalTo("node3"));
}
- @Test
public void testRemovingInitializingReplicasIfPrimariesFails() {
AllocationService allocation = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java
index c295b4f70e..8e4d68693d 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -40,11 +39,8 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(PrimaryNotRelocatedWhileBeingRecoveredTests.class);
-
- @Test
public void testPrimaryNotRelocatedWhileBeingRecoveredFrom() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java
index 4c828603ba..d0a86c0d63 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java
@@ -39,7 +39,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase;
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@@ -50,13 +49,11 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
public class RandomAllocationDeciderTests extends ESAllocationTestCase {
-
/* This test will make random allocation decision on a growing and shrinking
* cluster leading to a random distribution of the shards. After a certain
* amount of iterations the test allows allocation unless the same shard is
* already allocated on a node and balances the cluster to gain optimal
* balance.*/
- @Test
public void testRandomDecisions() {
RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(getRandom());
AllocationService strategy = new AllocationService(settingsBuilder().build(), new AllocationDeciders(Settings.EMPTY,
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java
index 4dd88501ec..51e1f89db3 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java
@@ -33,13 +33,12 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import java.util.Collections;
-
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@@ -48,10 +47,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class RebalanceAfterActiveTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(RebalanceAfterActiveTests.class);
- @Test
public void testRebalanceOnlyAfterAllShardsAreActive() {
final long[] sizes = new long[5];
for (int i =0; i < sizes.length; i++) {
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java
index 54440581b7..decaac5006 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java
@@ -29,20 +29,21 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class ReplicaAllocatedAfterPrimaryTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ReplicaAllocatedAfterPrimaryTests.class);
- @Test
public void testBackupIsAllocatedAfterPrimary() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingNodesIntegrityTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingNodesIntegrityTests.java
index 98009665f4..65a654d9f3 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingNodesIntegrityTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingNodesIntegrityTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@@ -42,10 +41,8 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class);
- @Test
public void testBalanceAllNodesStarted() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
@@ -118,7 +115,6 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
}
- @Test
public void testBalanceIncrementallyStartNodes() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
@@ -211,7 +207,6 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
assertThat(routingNodes.node("node3").shardsWithState("test1", STARTED).size(), equalTo(2));
}
- @Test
public void testBalanceAllNodesStartedAddIndex() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 1)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java
index 86369b967a..057071ef71 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static java.util.Collections.emptyMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
@@ -44,11 +43,9 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class SameShardRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(SameShardRoutingTests.class);
- @Test
- public void sameHost() {
+ public void testSameHost() {
AllocationService strategy = createAllocationService(settingsBuilder().put(SameShardAllocationDecider.SAME_HOST_SETTING, true).build());
MetaData metaData = MetaData.builder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java
index 1074f8b4e1..10118fac36 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java
@@ -30,18 +30,17 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
public class ShardVersioningTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ShardVersioningTests.class);
- @Test
- public void simple() {
+ public void testSimple() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE,
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
@@ -59,7 +58,6 @@ public class ShardVersioningTests extends ESAllocationTestCase {
logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
- RoutingTable prevRoutingTable = routingTable;
routingTable = strategy.reroute(clusterState).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
@@ -79,7 +77,6 @@ public class ShardVersioningTests extends ESAllocationTestCase {
logger.info("start all the primary shards for test1, replicas will start initializing");
RoutingNodes routingNodes = clusterState.getRoutingNodes();
- prevRoutingTable = routingTable;
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState("test1", INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
routingNodes = clusterState.getRoutingNodes();
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java
index c59e90f793..9ecae9c676 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java
@@ -24,17 +24,18 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
@@ -42,11 +43,9 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class ShardsLimitAllocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ShardsLimitAllocationTests.class);
- @Test
- public void indexLevelShardsLimitAllocate() {
+ public void testIndexLevelShardsLimitAllocate() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
logger.info("Building initial routing table");
@@ -88,8 +87,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
}
- @Test
- public void indexLevelShardsLimitRemain() {
+ public void testIndexLevelShardsLimitRemain() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
@@ -181,7 +179,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
routingNodes = clusterState.getRoutingNodes();
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
- // now we are done compared to EvenShardCountAllocator since the Balancer is not soely based on the average
+ // now we are done compared to EvenShardCountAllocator since the Balancer is not soely based on the average
assertThat(clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(STARTED), equalTo(5));
assertThat(clusterState.getRoutingNodes().node("node2").numberOfShardsWithState(STARTED), equalTo(5));
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
index e197dbd49c..7dd9893249 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.HashSet;
@@ -57,10 +56,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(SingleShardNoReplicasRoutingTests.class);
- @Test
public void testSingleIndexStartedShard() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
@@ -162,7 +159,6 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node2"));
}
- @Test
public void testSingleIndexShardFailed() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
@@ -212,7 +208,6 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue());
}
- @Test
public void testMultiIndexEvenDistribution() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -325,7 +320,6 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
assertThat(numberOfStartedShards, equalTo(25));
}
- @Test
public void testMultiIndexUnevenNodes() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java
index 7ea7e1cae2..405fa81993 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java
@@ -29,9 +29,10 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@@ -40,10 +41,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(SingleShardOneReplicaRoutingTests.class);
- @Test
public void testSingleIndexFirstStartPrimaryThenBackups() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/StartedShardsRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/StartedShardsRoutingTests.java
index 1e8a5fbc1e..28033915ab 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/StartedShardsRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/StartedShardsRoutingTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.Arrays;
@@ -40,9 +39,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class StartedShardsRoutingTests extends ESAllocationTestCase {
-
- @Test
- public void tesStartedShardsMatching() {
+ public void testStartedShardsMatching() {
AllocationService allocation = createAllocationService();
logger.info("--> building initial cluster state");
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java
index d6e7c86277..2e89a4bd1e 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java
@@ -30,20 +30,22 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(TenShardsOneReplicaRoutingTests.class);
- @Test
public void testSingleIndexFirstStartPrimaryThenBackups() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java
index c156aea3bd..0c4a7a80d7 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java
@@ -28,9 +28,10 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
@@ -38,10 +39,8 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class ThrottlingAllocationTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(ThrottlingAllocationTests.class);
- @Test
public void testPrimaryRecoveryThrottling() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 3)
@@ -102,7 +101,6 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
assertThat(routingTable.shardsWithState(UNASSIGNED).size(), equalTo(10));
}
- @Test
public void testReplicaAndPrimaryRecoveryThrottling() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 3)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java
index 0ae83627ac..d8d4fc5ba7 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java
@@ -29,20 +29,22 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
-import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
+import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class UpdateNumberOfReplicasTests extends ESAllocationTestCase {
-
private final ESLogger logger = Loggers.getLogger(UpdateNumberOfReplicasTests.class);
- @Test
public void testUpdateNumberOfReplicas() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java
index 525c446536..2f9104a570 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java
@@ -49,7 +49,6 @@ import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -71,8 +70,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
return new ShardsAllocators(NoopGatewayAllocator.INSTANCE);
}
- @Test
- public void diskThresholdTest() {
+ public void testDiskThreshold() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK, 0.7)
@@ -266,8 +264,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node("node4").size(), equalTo(1));
}
- @Test
- public void diskThresholdWithAbsoluteSizesTest() {
+ public void testDiskThresholdWithAbsoluteSizes() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK, "30b")
@@ -535,8 +532,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node("node5").size(), equalTo(1));
}
- @Test
- public void diskThresholdWithShardSizes() {
+ public void testDiskThresholdWithShardSizes() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK, 0.7)
@@ -603,8 +599,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(0));
}
- @Test
- public void unknownDiskUsageTest() {
+ public void testUnknownDiskUsage() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK, 0.7)
@@ -678,8 +673,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
}
- @Test
- public void averageUsageUnitTest() {
+ public void testAverageUsage() {
RoutingNode rn = new RoutingNode("node1", newNode("node1"));
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY);
@@ -692,8 +686,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(node1Usage.getFreeBytes(), equalTo(25L));
}
- @Test
- public void freeDiskPercentageAfterShardAssignedUnitTest() {
+ public void testFreeDiskPercentageAfterShardAssigned() {
RoutingNode rn = new RoutingNode("node1", newNode("node1"));
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY);
@@ -705,7 +698,6 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
assertThat(after, equalTo(19.0));
}
- @Test
public void testShardRelocationsTakenIntoAccount() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
@@ -812,7 +804,6 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
}
- @Test
public void testCanRemainWithShardRelocatingAway() {
Settings diskSettings = settingsBuilder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true)
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java
index 5417a9b85f..fa31d8306e 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java
@@ -43,7 +43,6 @@ import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
@@ -53,8 +52,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
* Unit tests for the DiskThresholdDecider
*/
public class DiskThresholdDeciderUnitTests extends ESTestCase {
-
- @Test
public void testDynamicSettings() {
NodeSettingsService nss = new NodeSettingsService(Settings.EMPTY);
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java
index 3823893977..801ffc0c54 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java
@@ -20,14 +20,15 @@
package org.elasticsearch.cluster.routing.allocation.decider;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.Allocation;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.Rebalance;
@@ -36,7 +37,6 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.EnumSet;
import java.util.List;
@@ -56,7 +56,6 @@ public class EnableAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(EnableAllocationTests.class);
- @Test
public void testClusterEnableNone() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.NONE.name())
@@ -85,7 +84,6 @@ public class EnableAllocationTests extends ESAllocationTestCase {
}
- @Test
public void testClusterEnableOnlyPrimaries() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.PRIMARIES.name())
@@ -119,7 +117,6 @@ public class EnableAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
}
- @Test
public void testIndexEnableNone() {
AllocationService strategy = createAllocationService(settingsBuilder()
.build());
@@ -158,10 +155,6 @@ public class EnableAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState("disabled", STARTED).size(), equalTo(0));
}
-
-
-
- @Test
public void testEnableClusterBalance() {
final boolean useClusterSetting = randomBoolean();
final Rebalance allowedOnes = RandomPicks.randomFrom(getRandom(), EnumSet.of(Rebalance.PRIMARIES, Rebalance.REPLICAS, Rebalance.ALL));
@@ -265,7 +258,6 @@ public class EnableAllocationTests extends ESAllocationTestCase {
}
- @Test
public void testEnableClusterBalanceNoReplicas() {
final boolean useClusterSetting = randomBoolean();
Settings build = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
index 8396f61b7f..126799f593 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -62,7 +61,6 @@ public class MockDiskUsagesIT extends ESIntegTestCase {
return pluginList(MockInternalClusterInfoService.TestPlugin.class);
}
- @Test
//@TestLogging("org.elasticsearch.cluster:TRACE,org.elasticsearch.cluster.routing.allocation.decider:TRACE")
public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
List<String> nodes = internalCluster().startNodesAsync(3).get();
diff --git a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java
index 308b00031b..9b010358af 100644
--- a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class ClusterSerializationTests extends ESAllocationTestCase {
-
- @Test
public void testClusterStateSerialization() throws Exception {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
@@ -59,12 +56,10 @@ public class ClusterSerializationTests extends ESAllocationTestCase {
ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), newNode("node1"));
assertThat(serializedClusterState.getClusterName().value(), equalTo(clusterState.getClusterName().value()));
-
+
assertThat(serializedClusterState.routingTable().prettyPrint(), equalTo(clusterState.routingTable().prettyPrint()));
}
-
- @Test
public void testRoutingTableSerialization() throws Exception {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
diff --git a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterStateToStringTests.java b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterStateToStringTests.java
index 573cb13105..4c45f40738 100644
--- a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterStateToStringTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterStateToStringTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
@@ -37,7 +36,6 @@ import static org.hamcrest.Matchers.containsString;
*
*/
public class ClusterStateToStringTests extends ESAllocationTestCase {
- @Test
public void testClusterStateSerialization() throws Exception {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test_idx").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
@@ -61,7 +59,5 @@ public class ClusterStateToStringTests extends ESAllocationTestCase {
assertThat(clusterStateString, containsString("test_idx"));
assertThat(clusterStateString, containsString("test_template"));
assertThat(clusterStateString, containsString("node_foo"));
-
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/serialization/DiffableTests.java b/core/src/test/java/org/elasticsearch/cluster/serialization/DiffableTests.java
index 87280f6acb..6c120e7ac6 100644
--- a/core/src/test/java/org/elasticsearch/cluster/serialization/DiffableTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/serialization/DiffableTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.StreamableReader;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -39,8 +38,6 @@ import static java.util.Collections.unmodifiableMap;
import static org.hamcrest.CoreMatchers.equalTo;
public class DiffableTests extends ESTestCase {
-
- @Test
public void testJdkMapDiff() throws IOException {
Map<String, TestDiffable> before = new HashMap<>();
before.put("foo", new TestDiffable("1"));
@@ -64,7 +61,6 @@ public class DiffableTests extends ESTestCase {
assertThat(serialized.get("new").value(), equalTo("5"));
}
- @Test
public void testImmutableOpenMapDiff() throws IOException {
ImmutableOpenMap.Builder<String, TestDiffable> builder = ImmutableOpenMap.builder();
builder.put("foo", new TestDiffable("1"));
diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java b/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
index 6b998523f1..c2a790c320 100644
--- a/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
@@ -31,21 +31,21 @@ import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.indices.store.IndicesStore;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = TEST)
public class ClusterSettingsIT extends ESIntegTestCase {
-
- @Test
- public void clusterNonExistingSettingsUpdate() {
+ public void testClusterNonExistingSettingsUpdate() {
String key1 = "no_idea_what_you_are_talking_about";
int value1 = 10;
@@ -58,8 +58,7 @@ public class ClusterSettingsIT extends ESIntegTestCase {
assertThat(response.getTransientSettings().getAsMap().entrySet(), Matchers.emptyIterable());
}
- @Test
- public void clusterSettingsUpdateResponse() {
+ public void testClusterSettingsUpdateResponse() {
String key1 = IndicesStore.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC;
int value1 = 10;
@@ -115,7 +114,6 @@ public class ClusterSettingsIT extends ESIntegTestCase {
assertThat(response3.getPersistentSettings().get(key2), notNullValue());
}
- @Test
public void testUpdateDiscoveryPublishTimeout() {
DiscoverySettings discoverySettings = internalCluster().getInstance(DiscoverySettings.class);
@@ -150,7 +148,6 @@ public class ClusterSettingsIT extends ESIntegTestCase {
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l));
}
- @Test
public void testClusterUpdateSettingsWithBlocks() {
String key1 = "cluster.routing.allocation.enable";
Settings transientSettings = Settings.builder().put(key1, false).build();
@@ -185,15 +182,18 @@ public class ClusterSettingsIT extends ESIntegTestCase {
assertThat(response.getPersistentSettings().get(key2), notNullValue());
}
- @Test(expected = IllegalArgumentException.class)
public void testMissingUnits() {
assertAcked(prepareCreate("test"));
- // Should fail (missing units for refresh_interval):
- client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", "10")).execute().actionGet();
+ try {
+ client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", "10")).execute().actionGet();
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("[index.refresh_interval] with value [10]"));
+ assertThat(e.getMessage(), containsString("unit is missing or unrecognized"));
+ }
}
- @Test
public void testMissingUnitsLenient() {
try {
createNode(Settings.builder().put(Settings.SETTINGS_REQUIRE_UNITS, "false").build());
diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
index b7670eaafe..c4ecb09b82 100644
--- a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -85,10 +84,7 @@ public class SettingsFilteringIT extends ESIntegTestCase {
}
}
-
- @Test
public void testSettingsFiltering() {
-
assertAcked(client().admin().indices().prepareCreate("test-idx").setSettings(Settings.builder()
.put("filter_test.foo", "test")
.put("filter_test.bar1", "test")
@@ -105,5 +101,4 @@ public class SettingsFilteringIT extends ESIntegTestCase {
assertThat(settings.get("index.filter_test.notbar"), equalTo("test"));
assertThat(settings.get("index.filter_test.notfoo"), equalTo("test"));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsValidatorTests.java b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsValidatorTests.java
index 1e041aae1b..498acef2eb 100644
--- a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsValidatorTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsValidatorTests.java
@@ -20,13 +20,12 @@
package org.elasticsearch.cluster.settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class SettingsValidatorTests extends ESTestCase {
-
- @Test
public void testValidators() throws Exception {
assertThat(Validator.EMPTY.validate("", "anything goes", null), nullValue());
@@ -98,7 +97,6 @@ public class SettingsValidatorTests extends ESTestCase {
assertThat(Validator.BYTES_SIZE_OR_PERCENTAGE.validate("", "0%", null), nullValue());
}
- @Test
public void testDynamicValidators() throws Exception {
DynamicSettings.Builder ds = new DynamicSettings.Builder();
ds.addSetting("my.test.*", Validator.POSITIVE_INTEGER);
diff --git a/core/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java b/core/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
index 422846fc48..9c5d80d128 100644
--- a/core/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
@@ -25,13 +25,15 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@@ -39,7 +41,7 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope= Scope.SUITE, numDataNodes = 2)
public class ClusterSearchShardsIT extends ESIntegTestCase {
-
+
@Override
protected Settings nodeSettings(int nodeOrdinal) {
switch(nodeOrdinal) {
@@ -51,7 +53,6 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
return super.nodeSettings(nodeOrdinal);
}
- @Test
public void testSingleShardAllocation() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(settingsBuilder()
.put("index.number_of_shards", "1").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet();
@@ -74,7 +75,6 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
}
- @Test
public void testMultipleShardsSingleNodeAllocation() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(settingsBuilder()
.put("index.number_of_shards", "4").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet();
@@ -94,7 +94,6 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
assertThat(response.getGroups()[0].getShardId(), equalTo(2));
}
- @Test
public void testMultipleIndicesAllocation() throws Exception {
client().admin().indices().prepareCreate("test1").setSettings(settingsBuilder()
.put("index.number_of_shards", "4").put("index.number_of_replicas", 1)).execute().actionGet();
@@ -128,7 +127,6 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
assertThat(response.getNodes().length, equalTo(2));
}
- @Test
public void testClusterSearchShardsWithBlocks() {
createIndex("test-blocks");
diff --git a/core/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java b/core/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java
index 236378e87e..9947d1882d 100644
--- a/core/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java
@@ -40,7 +40,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.Collections;
import java.util.HashMap;
@@ -58,8 +57,6 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.sameInstance;
public class RoutingIteratorTests extends ESAllocationTestCase {
-
- @Test
public void testEmptyIterator() {
ShardShuffler shuffler = new RotationShardShuffler(0);
ShardIterator shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(Collections.<ShardRouting>emptyList()));
@@ -91,7 +88,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardIterator.remaining(), equalTo(0));
}
- @Test
public void testIterator1() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(2))
@@ -119,7 +115,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardIterator.remaining(), equalTo(0));
}
- @Test
public void testIterator2() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
@@ -200,7 +195,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardRouting10, sameInstance(shardRouting6));
}
- @Test
public void testRandomRouting() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
@@ -228,7 +222,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardRouting1, sameInstance(shardRouting3));
}
- @Test
public void testAttributePreferenceRouting() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -284,7 +277,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardRouting.currentNodeId(), equalTo("node2"));
}
- @Test
public void testNodeSelectorRouting(){
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -342,7 +334,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
}
- @Test
public void testShardsAndPreferNodeRouting() {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
@@ -404,7 +395,6 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
assertThat(shardIterators.iterator().next().nextOrNull().currentNodeId(), equalTo("node1"));
}
- @Test
public void testReplicaShardPreferenceIters() throws Exception {
AllocationService strategy = createAllocationService(settingsBuilder()
.put("cluster.routing.allocation.concurrent_recoveries", 10)
diff --git a/core/src/test/java/org/elasticsearch/common/Base64Tests.java b/core/src/test/java/org/elasticsearch/common/Base64Tests.java
index a2bf2da460..74691c0b73 100644
--- a/core/src/test/java/org/elasticsearch/common/Base64Tests.java
+++ b/core/src/test/java/org/elasticsearch/common/Base64Tests.java
@@ -18,11 +18,10 @@
*/
package org.elasticsearch.common;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Locale;
import static org.hamcrest.Matchers.is;
@@ -31,8 +30,7 @@ import static org.hamcrest.Matchers.is;
*
*/
public class Base64Tests extends ESTestCase {
-
- @Test // issue #6334
+ // issue #6334
public void testBase64DecodeWithExtraCharactersAfterPadding() throws Exception {
String plain = randomAsciiOfLengthBetween(1, 20) + ":" + randomAsciiOfLengthBetween(1, 20);
String encoded = Base64.encodeBytes(plain.getBytes(StandardCharsets.UTF_8));
diff --git a/core/src/test/java/org/elasticsearch/common/BooleansTests.java b/core/src/test/java/org/elasticsearch/common/BooleansTests.java
index 0baf4335cd..6e5446cebf 100644
--- a/core/src/test/java/org/elasticsearch/common/BooleansTests.java
+++ b/core/src/test/java/org/elasticsearch/common/BooleansTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.common;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Locale;
@@ -29,8 +28,6 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
public class BooleansTests extends ESTestCase {
-
- @Test
public void testIsBoolean() {
String[] booleans = new String[]{"true", "false", "on", "off", "yes", "no", "0", "1"};
String[] notBooleans = new String[]{"11", "00", "sdfsdfsf", "F", "T"};
@@ -46,8 +43,8 @@ public class BooleansTests extends ESTestCase {
assertThat("recognized [" + nb + "] as boolean", Booleans.isBoolean(t.toCharArray(), "prefix".length(), nb.length()), Matchers.equalTo(false));
}
}
- @Test
- public void parseBoolean() {
+
+ public void testParseBoolean() {
assertThat(Booleans.parseBoolean(randomFrom("true", "on", "yes", "1"), randomBoolean()), is(true));
assertThat(Booleans.parseBoolean(randomFrom("false", "off", "no", "0"), randomBoolean()), is(false));
assertThat(Booleans.parseBoolean(randomFrom("true", "on", "yes").toUpperCase(Locale.ROOT), randomBoolean()), is(true));
@@ -69,8 +66,7 @@ public class BooleansTests extends ESTestCase {
assertThat(Booleans.parseBoolean(chars,0, chars.length, randomBoolean()), is(true));
}
- @Test
- public void parseBooleanExact() {
+ public void testParseBooleanExact() {
assertThat(Booleans.parseBooleanExact(randomFrom("true", "on", "yes", "1")), is(true));
assertThat(Booleans.parseBooleanExact(randomFrom("false", "off", "no", "0")), is(false));
try {
diff --git a/core/src/test/java/org/elasticsearch/common/ChannelsTests.java b/core/src/test/java/org/elasticsearch/common/ChannelsTests.java
index 46e65ad1e7..5bb9c614b8 100644
--- a/core/src/test/java/org/elasticsearch/common/ChannelsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/ChannelsTests.java
@@ -29,7 +29,6 @@ import org.jboss.netty.buffer.ByteBufferBackedChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffer;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.EOFException;
import java.io.IOException;
@@ -42,6 +41,8 @@ import java.nio.channels.WritableByteChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
+import static org.hamcrest.Matchers.containsString;
+
public class ChannelsTests extends ESTestCase {
byte[] randomBytes;
@@ -64,7 +65,6 @@ public class ChannelsTests extends ESTestCase {
super.tearDown();
}
- @Test
public void testReadWriteThoughArrays() throws Exception {
Channels.writeToChannel(randomBytes, fileChannel);
byte[] readBytes = Channels.readFromFileChannel(fileChannel, 0, randomBytes.length);
@@ -72,7 +72,6 @@ public class ChannelsTests extends ESTestCase {
}
- @Test
public void testPartialReadWriteThroughArrays() throws Exception {
int length = randomIntBetween(1, randomBytes.length / 2);
int offset = randomIntBetween(0, randomBytes.length - length);
@@ -89,14 +88,17 @@ public class ChannelsTests extends ESTestCase {
assertThat("read bytes didn't match written bytes", source.toBytes(), Matchers.equalTo(read.toBytes()));
}
- @Test(expected = EOFException.class)
public void testBufferReadPastEOFWithException() throws Exception {
int bytesToWrite = randomIntBetween(0, randomBytes.length - 1);
Channels.writeToChannel(randomBytes, 0, bytesToWrite, fileChannel);
- Channels.readFromFileChannel(fileChannel, 0, bytesToWrite + 1 + randomInt(1000));
+ try {
+ Channels.readFromFileChannel(fileChannel, 0, bytesToWrite + 1 + randomInt(1000));
+ fail("Expected an EOFException");
+ } catch (EOFException e) {
+ assertThat(e.getMessage(), containsString("read past EOF"));
+ }
}
- @Test
public void testBufferReadPastEOFWithoutException() throws Exception {
int bytesToWrite = randomIntBetween(0, randomBytes.length - 1);
Channels.writeToChannel(randomBytes, 0, bytesToWrite, fileChannel);
@@ -105,7 +107,6 @@ public class ChannelsTests extends ESTestCase {
assertThat(read, Matchers.lessThan(0));
}
- @Test
public void testReadWriteThroughBuffers() throws IOException {
ByteBuffer source;
if (randomBoolean()) {
@@ -130,7 +131,6 @@ public class ChannelsTests extends ESTestCase {
assertThat("read bytes didn't match written bytes", randomBytes, Matchers.equalTo(copyBytes));
}
- @Test
public void testPartialReadWriteThroughBuffers() throws IOException {
int length = randomIntBetween(1, randomBytes.length / 2);
int offset = randomIntBetween(0, randomBytes.length - length);
@@ -163,7 +163,6 @@ public class ChannelsTests extends ESTestCase {
}
- @Test
public void testWriteFromChannel() throws IOException {
int length = randomIntBetween(1, randomBytes.length / 2);
int offset = randomIntBetween(0, randomBytes.length - length);
diff --git a/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java b/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java
index b3397a55b3..f4b8747ccd 100644
--- a/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java
+++ b/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java
@@ -19,15 +19,14 @@
package org.elasticsearch.common;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.EnumSet;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.sameInstance;
public class ParseFieldTests extends ESTestCase {
-
- @Test
public void testParse() {
String[] values = new String[]{"foo_bar", "fooBar"};
ParseField field = new ParseField(randomFrom(values));
@@ -68,7 +67,6 @@ public class ParseFieldTests extends ESTestCase {
}
}
- @Test
public void testAllDeprecated() {
String[] values = new String[]{"like_text", "likeText"};
diff --git a/core/src/test/java/org/elasticsearch/common/PidFileTests.java b/core/src/test/java/org/elasticsearch/common/PidFileTests.java
index a98ac1d027..1ea4f302b7 100644
--- a/core/src/test/java/org/elasticsearch/common/PidFileTests.java
+++ b/core/src/test/java/org/elasticsearch/common/PidFileTests.java
@@ -19,22 +19,21 @@
package org.elasticsearch.common;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
+import static org.hamcrest.Matchers.containsString;
+
/**
* UnitTest for {@link org.elasticsearch.common.PidFile}
*/
public class PidFileTests extends ESTestCase {
-
- @Test(expected = IllegalArgumentException.class)
public void testParentIsFile() throws IOException {
Path dir = createTempDir();
Path parent = dir.resolve("foo");
@@ -42,10 +41,14 @@ public class PidFileTests extends ESTestCase {
stream.write("foo");
}
- PidFile.create(parent.resolve("bar.pid"), false);
+ try {
+ PidFile.create(parent.resolve("bar.pid"), false);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("exists but is not a directory"));
+ }
}
- @Test
public void testPidFile() throws IOException {
Path dir = createTempDir();
Path parent = dir.resolve("foo");
diff --git a/core/src/test/java/org/elasticsearch/common/TableTests.java b/core/src/test/java/org/elasticsearch/common/TableTests.java
index 1afdf59296..46da20190d 100644
--- a/core/src/test/java/org/elasticsearch/common/TableTests.java
+++ b/core/src/test/java/org/elasticsearch/common/TableTests.java
@@ -20,52 +20,80 @@
package org.elasticsearch.common;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.List;
import java.util.Map;
-public class TableTests extends ESTestCase {
+import static org.hamcrest.Matchers.is;
- @Test(expected = IllegalStateException.class)
+public class TableTests extends ESTestCase {
public void testFailOnStartRowWithoutHeader() {
Table table = new Table();
- table.startRow();
+ try {
+ table.startRow();
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("no headers added..."));
+ }
}
- @Test(expected = IllegalStateException.class)
public void testFailOnEndHeadersWithoutStart() {
Table table = new Table();
- table.endHeaders();
+ try {
+ table.endHeaders();
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("no headers added..."));
+ }
+
}
- @Test(expected = IllegalStateException.class)
public void testFailOnAddCellWithoutHeader() {
Table table = new Table();
- table.addCell("error");
+ try {
+ table.addCell("error");
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("no block started..."));
+ }
+
}
- @Test(expected = IllegalStateException.class)
public void testFailOnAddCellWithoutRow() {
Table table = this.getTableWithHeaders();
- table.addCell("error");
+ try {
+ table.addCell("error");
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("no block started..."));
+ }
+
}
- @Test(expected = IllegalStateException.class)
public void testFailOnEndRowWithoutStart() {
Table table = this.getTableWithHeaders();
- table.endRow();
+ try {
+ table.endRow();
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("no row started..."));
+ }
+
}
- @Test(expected = IllegalStateException.class)
public void testFailOnLessCellsThanDeclared() {
Table table = this.getTableWithHeaders();
table.startRow();
table.addCell("foo");
- table.endRow(true);
+ try {
+ table.endRow(true);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("mismatch on number of cells 1 in a row compared to header 2"));
+ }
+
}
- @Test
public void testOnLessCellsThanDeclaredUnchecked() {
Table table = this.getTableWithHeaders();
table.startRow();
@@ -73,16 +101,20 @@ public class TableTests extends ESTestCase {
table.endRow(false);
}
- @Test(expected = IllegalStateException.class)
public void testFailOnMoreCellsThanDeclared() {
Table table = this.getTableWithHeaders();
table.startRow();
table.addCell("foo");
table.addCell("bar");
- table.addCell("foobar");
+ try {
+ table.addCell("foobar");
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("can't add more cells to a row than the header"));
+ }
+
}
- @Test
public void testSimple() {
Table table = this.getTableWithHeaders();
table.startRow();
diff --git a/core/src/test/java/org/elasticsearch/common/UUIDTests.java b/core/src/test/java/org/elasticsearch/common/UUIDTests.java
index af5f382ec3..f82e1a464d 100644
--- a/core/src/test/java/org/elasticsearch/common/UUIDTests.java
+++ b/core/src/test/java/org/elasticsearch/common/UUIDTests.java
@@ -19,36 +19,32 @@
package org.elasticsearch.common;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.HashSet;
+import java.util.Set;
public class UUIDTests extends ESTestCase {
static UUIDGenerator timeUUIDGen = new TimeBasedUUIDGenerator();
static UUIDGenerator randomUUIDGen = new RandomBasedUUIDGenerator();
- @Test
public void testRandomUUID() {
verifyUUIDSet(100000, randomUUIDGen);
}
- @Test
public void testTimeUUID() {
verifyUUIDSet(100000, timeUUIDGen);
}
- @Test
public void testThreadedTimeUUID() {
testUUIDThreaded(timeUUIDGen);
}
- @Test
public void testThreadedRandomUUID() {
testUUIDThreaded(randomUUIDGen);
}
- HashSet verifyUUIDSet(int count, UUIDGenerator uuidSource) {
+ Set<String> verifyUUIDSet(int count, UUIDGenerator uuidSource) {
HashSet<String> uuidSet = new HashSet<>();
for (int i = 0; i < count; ++i) {
uuidSet.add(uuidSource.getBase64UUID());
@@ -59,7 +55,7 @@ public class UUIDTests extends ESTestCase {
class UUIDGenRunner implements Runnable {
int count;
- public HashSet<String> uuidSet = null;
+ public Set<String> uuidSet = null;
UUIDGenerator uuidSource;
public UUIDGenRunner(int count, UUIDGenerator uuidSource) {
diff --git a/core/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTests.java b/core/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTests.java
index fdf07cb03e..80afa5d51f 100644
--- a/core/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTests.java
+++ b/core/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -41,8 +40,6 @@ import static org.hamcrest.CoreMatchers.notNullValue;
@LuceneTestCase.SuppressFileSystems("ExtrasFS")
public class BlobStoreTests extends ESTestCase {
-
- @Test
public void testWriteRead() throws IOException {
final BlobStore store = newBlobStore();
final BlobContainer container = store.blobContainer(new BlobPath());
@@ -62,7 +59,6 @@ public class BlobStoreTests extends ESTestCase {
store.close();
}
- @Test
public void testMoveAndList() throws IOException {
final BlobStore store = newBlobStore();
final BlobContainer container = store.blobContainer(new BlobPath());
diff --git a/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java b/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
index 2a9f87a866..fa4ce357a5 100644
--- a/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
+++ b/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -39,8 +38,6 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
* Tests for the Memory Aggregating Circuit Breaker
*/
public class MemoryCircuitBreakerTests extends ESTestCase {
-
- @Test
public void testThreadedUpdatesToBreaker() throws Exception {
final int NUM_THREADS = scaledRandomIntBetween(3, 15);
final int BYTES_PER_THREAD = scaledRandomIntBetween(500, 4500);
@@ -82,7 +79,6 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
assertThat("breaker was tripped at least once", breaker.getTrippedCount(), greaterThanOrEqualTo(1L));
}
- @Test
public void testThreadedUpdatesToChildBreaker() throws Exception {
final int NUM_THREADS = scaledRandomIntBetween(3, 15);
final int BYTES_PER_THREAD = scaledRandomIntBetween(500, 4500);
@@ -140,7 +136,6 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
assertThat("breaker was tripped at least once", breaker.getTrippedCount(), greaterThanOrEqualTo(1L));
}
- @Test
public void testThreadedUpdatesToChildBreakerWithParentLimit() throws Exception {
final int NUM_THREADS = scaledRandomIntBetween(3, 15);
final int BYTES_PER_THREAD = scaledRandomIntBetween(500, 4500);
@@ -212,7 +207,6 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
assertThat("total breaker was tripped at least once", tripped.get(), greaterThanOrEqualTo(1));
}
- @Test
public void testConstantFactor() throws Exception {
final MemoryCircuitBreaker breaker = new MemoryCircuitBreaker(new ByteSizeValue(15), 1.6, logger);
String field = "myfield";
diff --git a/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java b/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java
index 802ea7cc62..95a65f8292 100644
--- a/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java
+++ b/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java
@@ -32,7 +32,6 @@ import org.hamcrest.Matchers;
import org.jboss.netty.buffer.ChannelBuffer;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.EOFException;
import java.io.IOException;
@@ -61,7 +60,6 @@ public class PagedBytesReferenceTests extends ESTestCase {
super.tearDown();
}
- @Test
public void testGet() {
int length = randomIntBetween(1, PAGE_SIZE * 3);
BytesReference pbr = getRandomizedPagedBytesReference(length);
diff --git a/core/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java b/core/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java
index d1480047ad..95d0789fbf 100644
--- a/core/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java
+++ b/core/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java
@@ -19,16 +19,16 @@
package org.elasticsearch.common.cli;
-import java.nio.charset.StandardCharsets;
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
+
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.env.Environment;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -59,79 +59,66 @@ public class CheckFileCommandTests extends ESTestCase {
CHANGE, KEEP, DISABLED
}
- @Test
public void testThatCommandLogsErrorMessageOnFail() throws Exception {
executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE));
assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(containsString("Please ensure that the user account running Elasticsearch has read access to this file")));
}
- @Test
public void testThatCommandLogsNothingWhenPermissionRemains() throws Exception {
executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingWhenDisabled() throws Exception {
executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingIfFilesystemDoesNotSupportPermissions() throws Exception {
executeCommand(jimFsConfigurationWithoutPermissions, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsOwnerChange() throws Exception {
executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE));
assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(allOf(containsString("Owner of file ["), containsString("] used to be ["), containsString("], but now is ["))));
}
- @Test
public void testThatCommandLogsNothingIfOwnerRemainsSame() throws Exception {
executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingIfOwnerIsDisabled() throws Exception {
executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingIfFileSystemDoesNotSupportOwners() throws Exception {
executeCommand(jimFsConfigurationWithoutPermissions, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsIfGroupChanges() throws Exception {
executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE));
assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(allOf(containsString("Group of file ["), containsString("] used to be ["), containsString("], but now is ["))));
}
- @Test
public void testThatCommandLogsNothingIfGroupRemainsSame() throws Exception {
executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingIfGroupIsDisabled() throws Exception {
executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandLogsNothingIfFileSystemDoesNotSupportGroups() throws Exception {
executeCommand(jimFsConfigurationWithoutPermissions, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED));
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandDoesNotLogAnythingOnFileCreation() throws Exception {
Configuration configuration = randomBoolean() ? jimFsConfiguration : jimFsConfigurationWithoutPermissions;
@@ -147,7 +134,6 @@ public class CheckFileCommandTests extends ESTestCase {
assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0));
}
- @Test
public void testThatCommandWorksIfFileIsDeletedByCommand() throws Exception {
Configuration configuration = randomBoolean() ? jimFsConfiguration : jimFsConfigurationWithoutPermissions;
diff --git a/core/src/test/java/org/elasticsearch/common/cli/CliToolTests.java b/core/src/test/java/org/elasticsearch/common/cli/CliToolTests.java
index f275d1db5c..20fbaa0ea9 100644
--- a/core/src/test/java/org/elasticsearch/common/cli/CliToolTests.java
+++ b/core/src/test/java/org/elasticsearch/common/cli/CliToolTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -47,8 +46,6 @@ import static org.hamcrest.Matchers.is;
*
*/
public class CliToolTests extends CliToolTestCase {
-
- @Test
public void testOK() throws Exception {
Terminal terminal = new MockTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
@@ -65,7 +62,6 @@ public class CliToolTests extends CliToolTestCase {
assertCommandHasBeenExecuted(executed);
}
- @Test
public void testUsageError() throws Exception {
Terminal terminal = new MockTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
@@ -82,7 +78,6 @@ public class CliToolTests extends CliToolTestCase {
assertCommandHasBeenExecuted(executed);
}
- @Test
public void testIOError() throws Exception {
Terminal terminal = new MockTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
@@ -99,7 +94,6 @@ public class CliToolTests extends CliToolTestCase {
assertCommandHasBeenExecuted(executed);
}
- @Test
public void testCodeError() throws Exception {
Terminal terminal = new MockTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
@@ -116,7 +110,6 @@ public class CliToolTests extends CliToolTestCase {
assertCommandHasBeenExecuted(executed);
}
- @Test
public void testMultiCommand() {
Terminal terminal = new MockTerminal();
int count = randomIntBetween(2, 7);
@@ -144,8 +137,7 @@ public class CliToolTests extends CliToolTestCase {
}
}
- @Test
- public void testMultiCommand_UnknownCommand() {
+ public void testMultiCommandUnknownCommand() {
Terminal terminal = new MockTerminal();
int count = randomIntBetween(2, 7);
final AtomicReference<Boolean>[] executed = new AtomicReference[count];
@@ -171,8 +163,7 @@ public class CliToolTests extends CliToolTestCase {
}
}
- @Test
- public void testSingleCommand_ToolHelp() throws Exception {
+ public void testSingleCommandToolHelp() throws Exception {
CaptureOutputTerminal terminal = new CaptureOutputTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
final NamedCommand cmd = new NamedCommand("cmd1", terminal) {
@@ -189,8 +180,7 @@ public class CliToolTests extends CliToolTestCase {
assertThat(terminal.getTerminalOutput(), hasItem(containsString("cmd1 help")));
}
- @Test
- public void testMultiCommand_ToolHelp() {
+ public void testMultiCommandToolHelp() {
CaptureOutputTerminal terminal = new CaptureOutputTerminal();
NamedCommand[] cmds = new NamedCommand[2];
cmds[0] = new NamedCommand("cmd0", terminal) {
@@ -212,8 +202,7 @@ public class CliToolTests extends CliToolTestCase {
assertThat(terminal.getTerminalOutput(), hasItem(containsString("tool help")));
}
- @Test
- public void testMultiCommand_CmdHelp() {
+ public void testMultiCommandCmdHelp() {
CaptureOutputTerminal terminal = new CaptureOutputTerminal();
NamedCommand[] cmds = new NamedCommand[2];
cmds[0] = new NamedCommand("cmd0", terminal) {
@@ -235,7 +224,6 @@ public class CliToolTests extends CliToolTestCase {
assertThat(terminal.getTerminalOutput(), hasItem(containsString("cmd1 help")));
}
- @Test
public void testThatThrowExceptionCanBeLogged() throws Exception {
CaptureOutputTerminal terminal = new CaptureOutputTerminal();
NamedCommand cmd = new NamedCommand("cmd", terminal) {
@@ -263,7 +251,6 @@ public class CliToolTests extends CliToolTestCase {
}
}
- @Test
public void testMultipleLaunch() throws Exception {
Terminal terminal = new MockTerminal();
final AtomicReference<Boolean> executed = new AtomicReference<>(false);
@@ -280,7 +267,6 @@ public class CliToolTests extends CliToolTestCase {
tool.parse("cmd", Strings.splitStringByCommaToArray("--help"));
}
- @Test
public void testPromptForSetting() throws Exception {
final AtomicInteger counter = new AtomicInteger();
final AtomicReference<String> promptedSecretValue = new AtomicReference<>(null);
@@ -323,7 +309,6 @@ public class CliToolTests extends CliToolTestCase {
assertThat(promptedTextValue.get(), is("replaced"));
}
- @Test
public void testStopAtNonOptionParsing() throws Exception {
final CliToolConfig.Cmd lenientCommand = cmd("lenient", CliTool.Command.Exit.class).stopAtNonOption(true).build();
final CliToolConfig.Cmd strictCommand = cmd("strict", CliTool.Command.Exit.class).stopAtNonOption(false).build();
diff --git a/core/src/test/java/org/elasticsearch/common/cli/TerminalTests.java b/core/src/test/java/org/elasticsearch/common/cli/TerminalTests.java
index da0347790b..f49e1f3a16 100644
--- a/core/src/test/java/org/elasticsearch/common/cli/TerminalTests.java
+++ b/core/src/test/java/org/elasticsearch/common/cli/TerminalTests.java
@@ -19,16 +19,14 @@
package org.elasticsearch.common.cli;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
/**
*
*/
public class TerminalTests extends CliToolTestCase {
-
- @Test
public void testVerbosity() throws Exception {
CaptureOutputTerminal terminal = new CaptureOutputTerminal(Terminal.Verbosity.SILENT);
assertPrinted(terminal, Terminal.Verbosity.SILENT, "text");
diff --git a/core/src/test/java/org/elasticsearch/common/geo/GeoDistanceTests.java b/core/src/test/java/org/elasticsearch/common/geo/GeoDistanceTests.java
index 924926b9b3..8f8e8b4ea1 100644
--- a/core/src/test/java/org/elasticsearch/common/geo/GeoDistanceTests.java
+++ b/core/src/test/java/org/elasticsearch/common/geo/GeoDistanceTests.java
@@ -22,20 +22,18 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
-import static org.hamcrest.Matchers.equalTo;
/**
* Basic Tests for {@link GeoDistance}
*/
public class GeoDistanceTests extends ESTestCase {
-
- @Test
public void testGeoDistanceSerialization() throws IOException {
// make sure that ordinals don't change, because we rely on then in serialization
assertThat(GeoDistance.PLANE.ordinal(), equalTo(0));
@@ -54,7 +52,6 @@ public class GeoDistanceTests extends ESTestCase {
}
}
- @Test(expected = IOException.class)
public void testInvalidReadFrom() throws Exception {
try (BytesStreamOutput out = new BytesStreamOutput()) {
if (randomBoolean()) {
@@ -64,11 +61,12 @@ public class GeoDistanceTests extends ESTestCase {
}
try (StreamInput in = StreamInput.wrap(out.bytes())) {
GeoDistance.readGeoDistanceFrom(in);
+ } catch (IOException e) {
+ assertThat(e.getMessage(), containsString("Unknown GeoDistance ordinal ["));
}
}
}
- @Test
public void testDistanceCheck() {
// Note, is within is an approximation, so, even though 0.52 is outside 50mi, we still get "true"
GeoDistance.DistanceBoundingCheck check = GeoDistance.distanceBoundingCheck(0, 0, 50, DistanceUnit.MILES);
@@ -81,7 +79,6 @@ public class GeoDistanceTests extends ESTestCase {
assertThat(check.isWithin(0, -178), equalTo(false));
}
- @Test
public void testArcDistanceVsPlaneInEllipsis() {
GeoPoint centre = new GeoPoint(48.8534100, 2.3488000);
GeoPoint northernPoint = new GeoPoint(48.8801108681, 2.35152032666);
diff --git a/core/src/test/java/org/elasticsearch/common/geo/GeoHashTests.java b/core/src/test/java/org/elasticsearch/common/geo/GeoHashTests.java
index 063fd76f84..934400d818 100644
--- a/core/src/test/java/org/elasticsearch/common/geo/GeoHashTests.java
+++ b/core/src/test/java/org/elasticsearch/common/geo/GeoHashTests.java
@@ -18,9 +18,8 @@
*/
package org.elasticsearch.common.geo;
-import org.elasticsearch.test.ESTestCase;
import org.apache.lucene.util.XGeoHashUtils;
-import org.junit.Test;
+import org.elasticsearch.test.ESTestCase;
@@ -28,12 +27,11 @@ import org.junit.Test;
* Tests for {@link org.apache.lucene.util.XGeoHashUtils}
*/
public class GeoHashTests extends ESTestCase {
- @Test
public void testGeohashAsLongRoutines() {
final GeoPoint expected = new GeoPoint();
final GeoPoint actual = new GeoPoint();
//Ensure that for all points at all supported levels of precision
- // that the long encoding of a geohash is compatible with its
+ // that the long encoding of a geohash is compatible with its
// String based counterpart
for (double lat=-90;lat<90;lat++)
{
diff --git a/core/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java b/core/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java
index 703ab2ffaa..b153d77a81 100644
--- a/core/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java
@@ -28,12 +28,15 @@ import com.spatial4j.core.shape.impl.PointImpl;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;
+
import org.elasticsearch.common.geo.builders.PolygonBuilder;
import org.elasticsearch.common.geo.builders.ShapeBuilder;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiLineString;
+import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiPolygon;
+import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertPolygon;
+import static org.hamcrest.Matchers.containsString;
/**
* Tests for {@link ShapeBuilder}
*/
@@ -105,7 +108,7 @@ public class ShapeBuilderTests extends ESTestCase {
.point(-45.0, -15.0)
.point(-110.0, -15.0)
.point(-110.0, 55.0).build();
-
+
// Building a linestring that needs to be wrapped
ShapeBuilder.newLineString()
.point(100.0, 50.0)
@@ -117,7 +120,7 @@ public class ShapeBuilderTests extends ESTestCase {
.point(130.0, -30.0)
.point(130.0, 60.0)
.build();
-
+
// Building a lineString on the dateline
ShapeBuilder.newLineString()
.point(-180.0, 80.0)
@@ -125,7 +128,7 @@ public class ShapeBuilderTests extends ESTestCase {
.point(-180.0, -40.0)
.point(-180.0, -80.0)
.build();
-
+
// Building a lineString on the dateline
ShapeBuilder.newLineString()
.point(180.0, 80.0)
@@ -151,7 +154,7 @@ public class ShapeBuilderTests extends ESTestCase {
.end()
.build();
-
+
// LineString that needs to be wrappped
ShapeBuilder.newMultiLinestring()
.linestring()
@@ -169,14 +172,18 @@ public class ShapeBuilderTests extends ESTestCase {
.build();
}
- @Test(expected = InvalidShapeException.class)
public void testPolygonSelfIntersection() {
- ShapeBuilder.newPolygon()
- .point(-40.0, 50.0)
- .point(40.0, 50.0)
- .point(-40.0, -50.0)
- .point(40.0, -50.0)
- .close().build();
+ try {
+ ShapeBuilder.newPolygon()
+ .point(-40.0, 50.0)
+ .point(40.0, 50.0)
+ .point(-40.0, -50.0)
+ .point(40.0, -50.0)
+ .close().build();
+ fail("Expected InvalidShapeException");
+ } catch (InvalidShapeException e) {
+ assertThat(e.getMessage(), containsString("Self-intersection at or near point (0.0"));
+ }
}
public void testGeoCircle() {
@@ -211,7 +218,7 @@ public class ShapeBuilderTests extends ESTestCase {
.point(-250.0, -65.0)
.point(-150.0, -65.0)
.close().build();
-
+
assertMultiPolygon(shape);
}
@@ -488,7 +495,6 @@ public class ShapeBuilderTests extends ESTestCase {
assertMultiPolygon(shape);
}
- @Test(expected = InvalidShapeException.class)
public void testShapeWithInvalidTangentialHole() {
// test a shape with one invalid tangential (shared) vertex (should throw exception)
PolygonBuilder builder = ShapeBuilder.newPolygon()
@@ -504,8 +510,12 @@ public class ShapeBuilderTests extends ESTestCase {
.point(175, 5)
.point(179, -10)
.point(164, 0);
- Shape shape = builder.close().build();
- assertMultiPolygon(shape);
+ try {
+ builder.close().build();
+ fail("Expected InvalidShapeException");
+ } catch (InvalidShapeException e) {
+ assertThat(e.getMessage(), containsString("interior cannot share more than one point with the exterior"));
+ }
}
public void testBoundaryShapeWithTangentialHole() {
@@ -532,7 +542,6 @@ public class ShapeBuilderTests extends ESTestCase {
assertMultiPolygon(shape);
}
- @Test(expected = InvalidShapeException.class)
public void testBoundaryShapeWithInvalidTangentialHole() {
// test shape with two tangential (shared) vertices (should throw exception)
PolygonBuilder builder = ShapeBuilder.newPolygon()
@@ -548,14 +557,17 @@ public class ShapeBuilderTests extends ESTestCase {
.point(180, -5)
.point(176, -10)
.point(-177, 10);
- Shape shape = builder.close().build();
- assertMultiPolygon(shape);
+ try {
+ builder.close().build();
+ fail("Expected InvalidShapeException");
+ } catch (InvalidShapeException e) {
+ assertThat(e.getMessage(), containsString("interior cannot share more than one point with the exterior"));
+ }
}
/**
* Test an enveloping polygon around the max mercator bounds
*/
- @Test
public void testBoundaryShape() {
PolygonBuilder builder = ShapeBuilder.newPolygon()
.point(-180, 90)
@@ -568,7 +580,6 @@ public class ShapeBuilderTests extends ESTestCase {
assertPolygon(shape);
}
- @Test
public void testShapeWithAlternateOrientation() {
// cw: should produce a multi polygon spanning hemispheres
PolygonBuilder builder = ShapeBuilder.newPolygon()
@@ -592,7 +603,6 @@ public class ShapeBuilderTests extends ESTestCase {
assertMultiPolygon(shape);
}
- @Test(expected = InvalidShapeException.class)
public void testInvalidShapeWithConsecutiveDuplicatePoints() {
PolygonBuilder builder = ShapeBuilder.newPolygon()
.point(180, 0)
@@ -600,7 +610,11 @@ public class ShapeBuilderTests extends ESTestCase {
.point(176, 4)
.point(-176, 4)
.point(180, 0);
- Shape shape = builder.close().build();
- assertPolygon(shape);
+ try {
+ builder.close().build();
+ fail("Expected InvalidShapeException");
+ } catch (InvalidShapeException e) {
+ assertThat(e.getMessage(), containsString("duplicate consecutive coordinates at: ("));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/geo/ShapeRelationTests.java b/core/src/test/java/org/elasticsearch/common/geo/ShapeRelationTests.java
index 83b6671998..bba56e38ec 100644
--- a/core/src/test/java/org/elasticsearch/common/geo/ShapeRelationTests.java
+++ b/core/src/test/java/org/elasticsearch/common/geo/ShapeRelationTests.java
@@ -22,10 +22,10 @@ package org.elasticsearch.common.geo;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class ShapeRelationTests extends ESTestCase {
@@ -80,13 +80,16 @@ public class ShapeRelationTests extends ESTestCase {
}
}
- @Test(expected = IOException.class)
public void testInvalidReadFrom() throws Exception {
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.writeVInt(randomIntBetween(3, Integer.MAX_VALUE));
try (StreamInput in = StreamInput.wrap(out.bytes())) {
ShapeRelation.DISJOINT.readFrom(in);
+ fail("Expected IOException");
+ } catch(IOException e) {
+ assertThat(e.getMessage(), containsString("Unknown ShapeRelation ordinal ["));
}
+
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/geo/SpatialStrategyTests.java b/core/src/test/java/org/elasticsearch/common/geo/SpatialStrategyTests.java
index c53a3fb18c..e3e99d0e2f 100644
--- a/core/src/test/java/org/elasticsearch/common/geo/SpatialStrategyTests.java
+++ b/core/src/test/java/org/elasticsearch/common/geo/SpatialStrategyTests.java
@@ -22,10 +22,10 @@ package org.elasticsearch.common.geo;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class SpatialStrategyTests extends ESTestCase {
@@ -66,12 +66,14 @@ public class SpatialStrategyTests extends ESTestCase {
}
}
- @Test(expected = IOException.class)
public void testInvalidReadFrom() throws Exception {
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.writeVInt(randomIntBetween(2, Integer.MAX_VALUE));
try (StreamInput in = StreamInput.wrap(out.bytes())) {
SpatialStrategy.TERM.readFrom(in);
+ fail("Expected IOException");
+ } catch(IOException e) {
+ assertThat(e.getMessage(), containsString("Unknown SpatialStrategy ordinal ["));
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/hash/MessageDigestsTests.java b/core/src/test/java/org/elasticsearch/common/hash/MessageDigestsTests.java
index dbc174ba2d..4063c1b7be 100644
--- a/core/src/test/java/org/elasticsearch/common/hash/MessageDigestsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/hash/MessageDigestsTests.java
@@ -20,21 +20,17 @@
package org.elasticsearch.common.hash;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
-import static org.junit.Assert.*;
-
public class MessageDigestsTests extends ESTestCase {
private void assertHash(String expected, String test, MessageDigest messageDigest) {
String actual = MessageDigests.toHexString(messageDigest.digest(test.getBytes(StandardCharsets.UTF_8)));
assertEquals(expected, actual);
}
- @Test
public void testMd5() throws Exception {
assertHash("d41d8cd98f00b204e9800998ecf8427e", "", MessageDigests.md5());
assertHash("900150983cd24fb0d6963f7d28e17f72", "abc", MessageDigests.md5());
@@ -44,7 +40,6 @@ public class MessageDigestsTests extends ESTestCase {
assertHash("1055d3e698d289f2af8663725127bd4b", "The quick brown fox jumps over the lazy cog", MessageDigests.md5());
}
- @Test
public void testSha1() throws Exception {
assertHash("da39a3ee5e6b4b0d3255bfef95601890afd80709", "", MessageDigests.sha1());
assertHash("a9993e364706816aba3e25717850c26c9cd0d89d", "abc", MessageDigests.sha1());
@@ -54,7 +49,6 @@ public class MessageDigestsTests extends ESTestCase {
assertHash("de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3", "The quick brown fox jumps over the lazy cog", MessageDigests.sha1());
}
- @Test
public void testSha256() throws Exception {
assertHash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "", MessageDigests.sha256());
assertHash("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", "abc", MessageDigests.sha256());
@@ -64,7 +58,6 @@ public class MessageDigestsTests extends ESTestCase {
assertHash("e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be", "The quick brown fox jumps over the lazy cog", MessageDigests.sha256());
}
- @Test
public void testToHexString() throws Exception {
for (int i = 0; i < 1024; i++) {
BigInteger expected = BigInteger.probablePrime(256, random());
diff --git a/core/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java b/core/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java
index 8998d1bccf..a4f35389bd 100644
--- a/core/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java
@@ -19,9 +19,9 @@
package org.elasticsearch.common.hppc;
import com.carrotsearch.hppc.ObjectHashSet;
+
import org.elasticsearch.common.collect.HppcMaps;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -29,8 +29,6 @@ import java.util.List;
import static org.hamcrest.Matchers.equalTo;
public class HppcMapsTests extends ESTestCase {
-
- @Test
public void testIntersection() throws Exception {
boolean enabled = false;
assert enabled = true;
diff --git a/core/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java b/core/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java
index 08b49e8ddd..a364c15064 100644
--- a/core/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java
@@ -19,16 +19,14 @@
package org.elasticsearch.common.io;
-import java.nio.charset.StandardCharsets;
-
-import org.elasticsearch.test.ESTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
+import org.elasticsearch.test.ESTestCase;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
@@ -60,7 +58,6 @@ public class FileSystemUtilsTests extends ESTestCase {
FileSystemUtils.copyDirectoryRecursively(path, src);
}
- @Test
public void testMoveOverExistingFileAndAppend() throws IOException {
FileSystemUtils.moveFilesWithoutOverwriting(src.resolve("v1"), dst, ".new");
@@ -87,7 +84,6 @@ public class FileSystemUtilsTests extends ESTestCase {
assertFileContent(dst, "dir/subdir/file5.txt", "version1");
}
- @Test
public void testMoveOverExistingFileAndIgnore() throws IOException {
Path dest = createTempDir();
@@ -115,7 +111,6 @@ public class FileSystemUtilsTests extends ESTestCase {
assertFileContent(dest, "dir/subdir/file5.txt", "version1");
}
- @Test
public void testMoveFilesDoesNotCreateSameFileWithSuffix() throws Exception {
Path[] dirs = new Path[] { createTempDir(), createTempDir(), createTempDir()};
for (Path dir : dirs) {
@@ -162,7 +157,6 @@ public class FileSystemUtilsTests extends ESTestCase {
}
}
- @Test
public void testAppend() {
assertEquals(FileSystemUtils.append(PathUtils.get("/foo/bar"), PathUtils.get("/hello/world/this_is/awesome"), 0),
PathUtils.get("/foo/bar/hello/world/this_is/awesome"));
diff --git a/core/src/test/java/org/elasticsearch/common/io/StreamsTests.java b/core/src/test/java/org/elasticsearch/common/io/StreamsTests.java
index 1dd809da62..5c6c1e1789 100644
--- a/core/src/test/java/org/elasticsearch/common/io/StreamsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/io/StreamsTests.java
@@ -19,25 +19,27 @@
package org.elasticsearch.common.io;
-import java.nio.charset.StandardCharsets;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import static org.elasticsearch.common.io.Streams.*;
+import static org.elasticsearch.common.io.Streams.copy;
+import static org.elasticsearch.common.io.Streams.copyToString;
import static org.hamcrest.Matchers.equalTo;
/**
* Unit tests for {@link org.elasticsearch.common.io.Streams}.
*/
public class StreamsTests extends ESTestCase {
-
- @Test
public void testCopyFromInputStream() throws IOException {
byte[] content = "content".getBytes(StandardCharsets.UTF_8);
ByteArrayInputStream in = new ByteArrayInputStream(content);
@@ -48,7 +50,6 @@ public class StreamsTests extends ESTestCase {
assertThat(Arrays.equals(content, out.toByteArray()), equalTo(true));
}
- @Test
public void testCopyFromByteArray() throws IOException {
byte[] content = "content".getBytes(StandardCharsets.UTF_8);
ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
@@ -56,7 +57,6 @@ public class StreamsTests extends ESTestCase {
assertThat(Arrays.equals(content, out.toByteArray()), equalTo(true));
}
- @Test
public void testCopyFromReader() throws IOException {
String content = "content";
StringReader in = new StringReader(content);
@@ -66,7 +66,6 @@ public class StreamsTests extends ESTestCase {
assertThat(out.toString(), equalTo(content));
}
- @Test
public void testCopyFromString() throws IOException {
String content = "content";
StringWriter out = new StringWriter();
@@ -74,15 +73,13 @@ public class StreamsTests extends ESTestCase {
assertThat(out.toString(), equalTo(content));
}
- @Test
public void testCopyToString() throws IOException {
String content = "content";
StringReader in = new StringReader(content);
String result = copyToString(in);
assertThat(result, equalTo(content));
}
-
- @Test
+
public void testBytesStreamInput() throws IOException {
byte stuff[] = new byte[] { 0, 1, 2, 3 };
BytesRef stuffRef = new BytesRef(stuff, 2, 2);
@@ -93,5 +90,4 @@ public class StreamsTests extends ESTestCase {
assertEquals(-1, input.read());
input.close();
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java
index 50e51bab22..7f232363f7 100644
--- a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java
@@ -24,21 +24,18 @@ import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-
import java.util.Objects;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
/**
* Tests for {@link BytesStreamOutput} paging behaviour.
*/
public class BytesStreamsTests extends ESTestCase {
-
- @Test
public void testEmpty() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -49,7 +46,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleByte() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
assertEquals(0, out.size());
@@ -65,7 +61,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleShortPage() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -83,7 +78,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testIllegalBulkWrite() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -99,7 +93,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleShortPageBulkWrite() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -120,7 +113,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleFullPageBulkWrite() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -136,7 +128,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleFullPageBulkWriteWithOffset() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -156,7 +147,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleFullPageBulkWriteWithOffsetCrossover() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -176,7 +166,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSingleFullPage() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -194,7 +183,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testOneFullOneShortPage() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -212,7 +200,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testTwoFullOneShortPage() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -230,7 +217,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSeek() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -247,7 +233,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSkip() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
@@ -261,7 +246,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testSimpleStreams() throws Exception {
assumeTrue("requires a 64-bit JRE ... ?!", Constants.JRE_IS_64BIT);
BytesStreamOutput out = new BytesStreamOutput();
@@ -312,7 +296,6 @@ public class BytesStreamsTests extends ESTestCase {
out.close();
}
- @Test
public void testNamedWriteable() throws IOException {
BytesStreamOutput out = new BytesStreamOutput();
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
@@ -324,7 +307,6 @@ public class BytesStreamsTests extends ESTestCase {
assertEquals(namedWriteableOut, namedWriteableIn);
}
- @Test
public void testNamedWriteableDuplicates() throws IOException {
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
namedWriteableRegistry.registerPrototype(BaseNamedWriteable.class, new TestNamedWriteable(null, null));
@@ -337,7 +319,6 @@ public class BytesStreamsTests extends ESTestCase {
}
}
- @Test
public void testNamedWriteableUnknownCategory() throws IOException {
BytesStreamOutput out = new BytesStreamOutput();
out.writeNamedWriteable(new TestNamedWriteable("test1", "test2"));
@@ -351,7 +332,6 @@ public class BytesStreamsTests extends ESTestCase {
}
}
- @Test
public void testNamedWriteableUnknownNamedWriteable() throws IOException {
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
namedWriteableRegistry.registerPrototype(BaseNamedWriteable.class, new TestNamedWriteable(null, null));
@@ -381,13 +361,17 @@ public class BytesStreamsTests extends ESTestCase {
}
}
- @Test(expected = UnsupportedOperationException.class)
public void testNamedWriteableNotSupportedWithoutWrapping() throws IOException {
BytesStreamOutput out = new BytesStreamOutput();
TestNamedWriteable testNamedWriteable = new TestNamedWriteable("test1", "test2");
out.writeNamedWriteable(testNamedWriteable);
StreamInput in = StreamInput.wrap(out.bytes().toBytes());
- in.readNamedWriteable(BaseNamedWriteable.class);
+ try {
+ in.readNamedWriteable(BaseNamedWriteable.class);
+ fail("Expected UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ assertThat(e.getMessage(), is("can't read named writeable from StreamInput"));
+ }
}
private static abstract class BaseNamedWriteable<T> implements NamedWriteable<T> {
@@ -440,7 +424,6 @@ public class BytesStreamsTests extends ESTestCase {
// we ignore this test for now since all existing callers of BytesStreamOutput happily
// call bytes() after close().
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/12620")
- @Test
public void testAccessAfterClose() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
diff --git a/core/src/test/java/org/elasticsearch/common/joda/DateMathParserTests.java b/core/src/test/java/org/elasticsearch/common/joda/DateMathParserTests.java
index 6a1f146046..96a4a3fdf3 100644
--- a/core/src/test/java/org/elasticsearch/common/joda/DateMathParserTests.java
+++ b/core/src/test/java/org/elasticsearch/common/joda/DateMathParserTests.java
@@ -23,12 +23,12 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.util.TimeZone;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class DateMathParserTests extends ESTestCase {
@@ -48,12 +48,12 @@ public class DateMathParserTests extends ESTestCase {
void assertDateMathEquals(String toTest, String expected) {
assertDateMathEquals(toTest, expected, 0, false, null);
}
-
+
void assertDateMathEquals(String toTest, String expected, final long now, boolean roundUp, DateTimeZone timeZone) {
long gotMillis = parser.parse(toTest, callable(now), roundUp, timeZone);
assertDateEquals(gotMillis, toTest, expected);
}
-
+
void assertDateEquals(long gotMillis, String original, String expected) {
long expectedMillis = parser.parse(expected, callable(0));
if (gotMillis != expectedMillis) {
@@ -65,7 +65,7 @@ public class DateMathParserTests extends ESTestCase {
"Actual milliseconds : " + gotMillis + "\n");
}
}
-
+
public void testBasicDates() {
assertDateMathEquals("2014", "2014-01-01T00:00:00.000");
assertDateMathEquals("2014-05", "2014-05-01T00:00:00.000");
@@ -92,7 +92,7 @@ public class DateMathParserTests extends ESTestCase {
assertDateMathEquals("2014-05-30T20:21+03:00", "2014-05-30T17:21:00.000", 0, false, DateTimeZone.forID("-08:00"));
assertDateMathEquals("2014-05-30T20:21Z", "2014-05-30T20:21:00.000", 0, false, DateTimeZone.forID("-08:00"));
}
-
+
public void testBasicMath() {
assertDateMathEquals("2014-11-18||+y", "2015-11-18");
assertDateMathEquals("2014-11-18||-2y", "2012-11-18");
@@ -117,7 +117,7 @@ public class DateMathParserTests extends ESTestCase {
assertDateMathEquals("2014-11-18T14:27:32||+60s", "2014-11-18T14:28:32");
assertDateMathEquals("2014-11-18T14:27:32||-3600s", "2014-11-18T13:27:32");
}
-
+
public void testLenientEmptyMath() {
assertDateMathEquals("2014-05-30T20:21||", "2014-05-30T20:21:00.000");
}
@@ -133,12 +133,12 @@ public class DateMathParserTests extends ESTestCase {
public void testNow() {
final long now = parser.parse("2014-11-18T14:27:32", callable(0), false, null);
-
+
assertDateMathEquals("now", "2014-11-18T14:27:32", now, false, null);
assertDateMathEquals("now+M", "2014-12-18T14:27:32", now, false, null);
assertDateMathEquals("now-2d", "2014-11-16T14:27:32", now, false, null);
assertDateMathEquals("now/m", "2014-11-18T14:27", now, false, null);
-
+
// timezone does not affect now
assertDateMathEquals("now/m", "2014-11-18T14:27", now, false, DateTimeZone.forID("+02:00"));
}
@@ -151,14 +151,14 @@ public class DateMathParserTests extends ESTestCase {
// rounding should also take into account time zone
assertDateMathEquals("2014-11-18||/y", "2013-12-31T23:00:00.000Z", 0, false, DateTimeZone.forID("CET"));
assertDateMathEquals("2014-11-18||/y", "2014-12-31T22:59:59.999Z", 0, true, DateTimeZone.forID("CET"));
-
+
assertDateMathEquals("2014-11-18||/M", "2014-11-01", 0, false, null);
assertDateMathEquals("2014-11-18||/M", "2014-11-30T23:59:59.999", 0, true, null);
assertDateMathEquals("2014-11||/M", "2014-11-01", 0, false, null);
assertDateMathEquals("2014-11||/M", "2014-11-30T23:59:59.999", 0, true, null);
assertDateMathEquals("2014-11-18||/M", "2014-10-31T23:00:00.000Z", 0, false, DateTimeZone.forID("CET"));
assertDateMathEquals("2014-11-18||/M", "2014-11-30T22:59:59.999Z", 0, true, DateTimeZone.forID("CET"));
-
+
assertDateMathEquals("2014-11-18T14||/w", "2014-11-17", 0, false, null);
assertDateMathEquals("2014-11-18T14||/w", "2014-11-23T23:59:59.999", 0, true, null);
assertDateMathEquals("2014-11-18||/w", "2014-11-17", 0, false, null);
@@ -168,12 +168,12 @@ public class DateMathParserTests extends ESTestCase {
assertDateMathEquals("2014-11-18||/w", "2014-11-16T23:00:00.000Z", 0, false, DateTimeZone.forID("CET"));
assertDateMathEquals("2014-11-18||/w", "2014-11-23T22:59:59.999Z", 0, true, DateTimeZone.forID("CET"));
assertDateMathEquals("2014-07-22||/w", "2014-07-20T22:00:00.000Z", 0, false, DateTimeZone.forID("CET")); // with DST
-
+
assertDateMathEquals("2014-11-18T14||/d", "2014-11-18", 0, false, null);
assertDateMathEquals("2014-11-18T14||/d", "2014-11-18T23:59:59.999", 0, true, null);
assertDateMathEquals("2014-11-18||/d", "2014-11-18", 0, false, null);
assertDateMathEquals("2014-11-18||/d", "2014-11-18T23:59:59.999", 0, true, null);
-
+
assertDateMathEquals("2014-11-18T14:27||/h", "2014-11-18T14", 0, false, null);
assertDateMathEquals("2014-11-18T14:27||/h", "2014-11-18T14:59:59.999", 0, true, null);
assertDateMathEquals("2014-11-18T14||/H", "2014-11-18T14", 0, false, null);
@@ -182,12 +182,12 @@ public class DateMathParserTests extends ESTestCase {
assertDateMathEquals("2014-11-18T14:27||/h", "2014-11-18T14:59:59.999", 0, true, null);
assertDateMathEquals("2014-11-18T14||/H", "2014-11-18T14", 0, false, null);
assertDateMathEquals("2014-11-18T14||/H", "2014-11-18T14:59:59.999", 0, true, null);
-
+
assertDateMathEquals("2014-11-18T14:27:32||/m", "2014-11-18T14:27", 0, false, null);
assertDateMathEquals("2014-11-18T14:27:32||/m", "2014-11-18T14:27:59.999", 0, true, null);
assertDateMathEquals("2014-11-18T14:27||/m", "2014-11-18T14:27", 0, false, null);
assertDateMathEquals("2014-11-18T14:27||/m", "2014-11-18T14:27:59.999", 0, true, null);
-
+
assertDateMathEquals("2014-11-18T14:27:32.123||/s", "2014-11-18T14:27:32", 0, false, null);
assertDateMathEquals("2014-11-18T14:27:32.123||/s", "2014-11-18T14:27:32.999", 0, true, null);
assertDateMathEquals("2014-11-18T14:27:32||/s", "2014-11-18T14:27:32", 0, false, null);
@@ -199,12 +199,12 @@ public class DateMathParserTests extends ESTestCase {
// datemath still works on timestamps
assertDateMathEquals("1418248078000||/m", "2014-12-10T21:47:00.000");
-
+
// also check other time units
DateMathParser parser = new DateMathParser(Joda.forPattern("epoch_second||dateOptionalTime"));
long datetime = parser.parse("1418248078", callable(0));
assertDateEquals(datetime, "1418248078", "2014-12-10T21:47:58.000");
-
+
// a timestamp before 10000 is a year
assertDateMathEquals("9999", "9999-01-01T00:00:00.000");
// 10000 is also a year, breaking bwc, used to be a timestamp
@@ -221,7 +221,7 @@ public class DateMathParserTests extends ESTestCase {
assertThat(ExceptionsHelper.detailedMessage(e).contains(exc), equalTo(true));
}
}
-
+
public void testIllegalMathFormat() {
assertParseException("Expected date math unsupported operator exception", "2014-11-18||*5", "operator not supported");
assertParseException("Expected date math incompatible rounding exception", "2014-11-18||/2m", "rounding");
@@ -229,7 +229,7 @@ public class DateMathParserTests extends ESTestCase {
assertParseException("Expected date math truncation exception", "2014-11-18||+12", "truncated");
assertParseException("Expected date math truncation exception", "2014-11-18||-", "truncated");
}
-
+
public void testIllegalDateFormat() {
assertParseException("Expected bad timestamp exception", Long.toString(Long.MAX_VALUE) + "0", "failed to parse date field");
assertParseException("Expected bad date format exception", "123bogus", "with format");
@@ -250,9 +250,14 @@ public class DateMathParserTests extends ESTestCase {
assertTrue(called.get());
}
- @Test(expected = ElasticsearchParseException.class)
public void testThatUnixTimestampMayNotHaveTimeZone() {
DateMathParser parser = new DateMathParser(Joda.forPattern("epoch_millis"));
- parser.parse("1234567890123", callable(42), false, DateTimeZone.forTimeZone(TimeZone.getTimeZone("CET")));
+ try {
+ parser.parse("1234567890123", callable(42), false, DateTimeZone.forTimeZone(TimeZone.getTimeZone("CET")));
+ fail("Expected ElasticsearchParseException");
+ } catch(ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse date field"));
+ assertThat(e.getMessage(), containsString("with format [epoch_millis]"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/logging/jdk/JDKESLoggerTests.java b/core/src/test/java/org/elasticsearch/common/logging/jdk/JDKESLoggerTests.java
index 748994da9f..0c38ee0b03 100644
--- a/core/src/test/java/org/elasticsearch/common/logging/jdk/JDKESLoggerTests.java
+++ b/core/src/test/java/org/elasticsearch/common/logging/jdk/JDKESLoggerTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.common.logging.jdk;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -51,8 +50,7 @@ public class JDKESLoggerTests extends ESTestCase {
testLogger.addHandler(testHandler);
}
- @Test
- public void locationInfoTest() {
+ public void testLocationInfoTest() {
esTestLogger.error("This is an error");
esTestLogger.warn("This is a warning");
esTestLogger.info("This is an info");
@@ -66,31 +64,31 @@ public class JDKESLoggerTests extends ESTestCase {
assertThat(record.getLevel(), equalTo(Level.SEVERE));
assertThat(record.getMessage(), equalTo("This is an error"));
assertThat(record.getSourceClassName(), equalTo(JDKESLoggerTests.class.getCanonicalName()));
- assertThat(record.getSourceMethodName(), equalTo("locationInfoTest"));
+ assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
record = records.get(1);
assertThat(record, notNullValue());
assertThat(record.getLevel(), equalTo(Level.WARNING));
assertThat(record.getMessage(), equalTo("This is a warning"));
assertThat(record.getSourceClassName(), equalTo(JDKESLoggerTests.class.getCanonicalName()));
- assertThat(record.getSourceMethodName(), equalTo("locationInfoTest"));
+ assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
record = records.get(2);
assertThat(record, notNullValue());
assertThat(record.getLevel(), equalTo(Level.INFO));
assertThat(record.getMessage(), equalTo("This is an info"));
assertThat(record.getSourceClassName(), equalTo(JDKESLoggerTests.class.getCanonicalName()));
- assertThat(record.getSourceMethodName(), equalTo("locationInfoTest"));
+ assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
record = records.get(3);
assertThat(record, notNullValue());
assertThat(record.getLevel(), equalTo(Level.FINE));
assertThat(record.getMessage(), equalTo("This is a debug"));
assertThat(record.getSourceClassName(), equalTo(JDKESLoggerTests.class.getCanonicalName()));
- assertThat(record.getSourceMethodName(), equalTo("locationInfoTest"));
+ assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
record = records.get(4);
assertThat(record, notNullValue());
assertThat(record.getLevel(), equalTo(Level.FINEST));
assertThat(record.getMessage(), equalTo("This is a trace"));
assertThat(record.getSourceClassName(), equalTo(JDKESLoggerTests.class.getCanonicalName()));
- assertThat(record.getSourceMethodName(), equalTo("locationInfoTest"));
+ assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
}
private static class TestHandler extends Handler {
diff --git a/core/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java b/core/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java
index d0cd3879db..8f9c900907 100644
--- a/core/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java
+++ b/core/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
-import org.junit.Test;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -84,8 +83,7 @@ public class Log4jESLoggerTests extends ESTestCase {
deprecationLogger.removeAppender(deprecationAppender);
}
- @Test
- public void locationInfoTest() {
+ public void testLocationInfoTest() {
esTestLogger.error("This is an error");
esTestLogger.warn("This is a warning");
esTestLogger.info("This is an info");
@@ -101,7 +99,7 @@ public class Log4jESLoggerTests extends ESTestCase {
LocationInfo locationInfo = event.getLocationInformation();
assertThat(locationInfo, notNullValue());
assertThat(locationInfo.getClassName(), equalTo(Log4jESLoggerTests.class.getCanonicalName()));
- assertThat(locationInfo.getMethodName(), equalTo("locationInfoTest"));
+ assertThat(locationInfo.getMethodName(), equalTo("testLocationInfoTest"));
event = events.get(1);
assertThat(event, notNullValue());
assertThat(event.getLevel(), equalTo(Level.WARN));
@@ -109,7 +107,7 @@ public class Log4jESLoggerTests extends ESTestCase {
locationInfo = event.getLocationInformation();
assertThat(locationInfo, notNullValue());
assertThat(locationInfo.getClassName(), equalTo(Log4jESLoggerTests.class.getCanonicalName()));
- assertThat(locationInfo.getMethodName(), equalTo("locationInfoTest"));
+ assertThat(locationInfo.getMethodName(), equalTo("testLocationInfoTest"));
event = events.get(2);
assertThat(event, notNullValue());
assertThat(event.getLevel(), equalTo(Level.INFO));
@@ -117,7 +115,7 @@ public class Log4jESLoggerTests extends ESTestCase {
locationInfo = event.getLocationInformation();
assertThat(locationInfo, notNullValue());
assertThat(locationInfo.getClassName(), equalTo(Log4jESLoggerTests.class.getCanonicalName()));
- assertThat(locationInfo.getMethodName(), equalTo("locationInfoTest"));
+ assertThat(locationInfo.getMethodName(), equalTo("testLocationInfoTest"));
event = events.get(3);
assertThat(event, notNullValue());
assertThat(event.getLevel(), equalTo(Level.DEBUG));
@@ -125,7 +123,7 @@ public class Log4jESLoggerTests extends ESTestCase {
locationInfo = event.getLocationInformation();
assertThat(locationInfo, notNullValue());
assertThat(locationInfo.getClassName(), equalTo(Log4jESLoggerTests.class.getCanonicalName()));
- assertThat(locationInfo.getMethodName(), equalTo("locationInfoTest"));
+ assertThat(locationInfo.getMethodName(), equalTo("testLocationInfoTest"));
event = events.get(4);
assertThat(event, notNullValue());
assertThat(event.getLevel(), equalTo(Level.TRACE));
@@ -133,10 +131,9 @@ public class Log4jESLoggerTests extends ESTestCase {
locationInfo = event.getLocationInformation();
assertThat(locationInfo, notNullValue());
assertThat(locationInfo.getClassName(), equalTo(Log4jESLoggerTests.class.getCanonicalName()));
- assertThat(locationInfo.getMethodName(), equalTo("locationInfoTest"));
+ assertThat(locationInfo.getMethodName(), equalTo("testLocationInfoTest"));
}
- @Test
public void testDeprecationLogger() {
deprecationLogger.deprecated("This is a deprecation message");
List<LoggingEvent> deprecationEvents = deprecationAppender.getEvents();
diff --git a/core/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java b/core/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java
index 2b84bec93e..2a08dd1e55 100644
--- a/core/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java
+++ b/core/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java
@@ -28,16 +28,16 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
@@ -49,7 +49,6 @@ public class LoggingConfigurationTests extends ESTestCase {
LogConfigurator.reset();
}
- @Test
public void testResolveMultipleConfigs() throws Exception {
String level = Log4jESLoggerFactory.getLogger("test").getLevel();
try {
@@ -79,7 +78,6 @@ public class LoggingConfigurationTests extends ESTestCase {
}
}
- @Test
public void testResolveJsonLoggingConfig() throws Exception {
Path tmpDir = createTempDir();
Path loggingConf = tmpDir.resolve(loggingConfiguration("json"));
@@ -97,7 +95,6 @@ public class LoggingConfigurationTests extends ESTestCase {
assertThat(logSettings.get("json"), is("foo"));
}
- @Test
public void testResolvePropertiesLoggingConfig() throws Exception {
Path tmpDir = createTempDir();
Path loggingConf = tmpDir.resolve(loggingConfiguration("properties"));
@@ -115,7 +112,6 @@ public class LoggingConfigurationTests extends ESTestCase {
assertThat(logSettings.get("key"), is("value"));
}
- @Test
public void testResolveYamlLoggingConfig() throws Exception {
Path tmpDir = createTempDir();
Path loggingConf1 = tmpDir.resolve(loggingConfiguration("yml"));
@@ -136,7 +132,6 @@ public class LoggingConfigurationTests extends ESTestCase {
assertThat(logSettings.get("yaml"), is("bar"));
}
- @Test
public void testResolveConfigInvalidFilename() throws Exception {
Path tmpDir = createTempDir();
Path invalidSuffix = tmpDir.resolve(loggingConfiguration(randomFrom(LogConfigurator.ALLOWED_SUFFIXES)) + randomInvalidSuffix());
@@ -155,7 +150,6 @@ public class LoggingConfigurationTests extends ESTestCase {
}
// tests that custom settings are not overwritten by settings in the config file
- @Test
public void testResolveOrder() throws Exception {
Path tmpDir = createTempDir();
Path loggingConf = tmpDir.resolve(loggingConfiguration("yaml"));
@@ -182,7 +176,6 @@ public class LoggingConfigurationTests extends ESTestCase {
}
// tests that config file is not read when we call LogConfigurator.configure(Settings, false)
- @Test
public void testConfigNotRead() throws Exception {
Path tmpDir = createTempDir();
Path loggingConf = tmpDir.resolve(loggingConfiguration("yaml"));
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java b/core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java
index 2edd266af6..fcd2f7d876 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java
@@ -23,7 +23,14 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.NoDeletionPolicy;
+import org.apache.lucene.index.NoMergePolicy;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.SegmentInfos;
+import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TermQuery;
@@ -32,23 +39,23 @@ import org.apache.lucene.store.MMapDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.Version;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
/**
- *
+ *
*/
public class LuceneTests extends ESTestCase {
-
-
- /*
+ /**
* simple test that ensures that we bump the version on Upgrade
*/
- @Test
public void testVersion() {
// note this is just a silly sanity check, we test it in lucene, and we point to it this way
assertEquals(Lucene.VERSION, Version.LATEST);
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java b/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
index ccf657cf76..f4f3034528 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
@@ -28,14 +28,22 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -45,8 +53,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class SimpleAllTests extends ESTestCase {
-
- @Test
public void testBoostOnEagerTokenizer() throws Exception {
AllEntries allEntries = new AllEntries();
allEntries.addText("field1", "all", 2.0f);
@@ -91,7 +97,6 @@ public class SimpleAllTests extends ESTestCase {
assertFalse(ts.incrementToken());
}
- @Test
public void testAllEntriesRead() throws Exception {
AllEntries allEntries = new AllEntries();
allEntries.addText("field1", "something", 1.0f);
@@ -122,7 +127,6 @@ public class SimpleAllTests extends ESTestCase {
assertEquals(scoreDoc.score, expl.getValue(), 0.00001f);
}
- @Test
public void testSimpleAllNoBoost() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -169,7 +173,6 @@ public class SimpleAllTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testSimpleAllWithBoost() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -217,7 +220,6 @@ public class SimpleAllTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testMultipleTokensAllNoBoost() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -268,7 +270,6 @@ public class SimpleAllTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testMultipleTokensAllWithBoost() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -319,7 +320,6 @@ public class SimpleAllTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testNoTokensWithKeywordAnalyzer() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.KEYWORD_ANALYZER));
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
index da9cfe1fb9..96715a05b3 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
@@ -41,7 +41,6 @@ import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -174,21 +173,18 @@ public class FreqTermsEnumTests extends ESTestCase {
super.tearDown();
}
- @Test
public void testAllFreqs() throws Exception {
assertAgainstReference(true, true, null, referenceAll);
assertAgainstReference(true, false, null, referenceAll);
assertAgainstReference(false, true, null, referenceAll);
}
- @Test
public void testNonDeletedFreqs() throws Exception {
assertAgainstReference(true, true, Queries.newMatchAllQuery(), referenceNotDeleted);
assertAgainstReference(true, false, Queries.newMatchAllQuery(), referenceNotDeleted);
assertAgainstReference(false, true, Queries.newMatchAllQuery(), referenceNotDeleted);
}
- @Test
public void testFilterFreqs() throws Exception {
assertAgainstReference(true, true, filter, referenceFilter);
assertAgainstReference(true, false, filter, referenceFilter);
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java
index 43e151e486..5cb8060711 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java
@@ -22,19 +22,21 @@ package org.elasticsearch.common.lucene.search;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
import org.apache.lucene.store.RAMDirectory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class MultiPhrasePrefixQueryTests extends ESTestCase {
-
- @Test
- public void simpleTests() throws Exception {
+ public void testSimple() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
Document doc = new Document();
doc.add(new Field("field", "aaa bbb ccc ddd", TextField.TYPE_NOT_STORED));
@@ -63,7 +65,6 @@ public class MultiPhrasePrefixQueryTests extends ESTestCase {
assertThat(searcher.count(query), equalTo(0));
}
- @Test
public void testBoost() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
Document doc = new Document();
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java
index b6c6384597..199ffaf8c0 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java
@@ -26,18 +26,15 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptException;
import org.elasticsearch.script.SearchScript;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
public class ScriptScoreFunctionTests extends ESTestCase {
-
/**
* Tests https://github.com/elasticsearch/elasticsearch/issues/2426
*/
- @Test
public void testScriptScoresReturnsNaN() throws IOException {
ScoreFunction scoreFunction = new ScriptScoreFunction(new Script("Float.NaN"), new FloatValueScript(Float.NaN));
LeafScoreFunction leafScoreFunction = scoreFunction.getLeafScoreFunction(null);
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java
index 119c595ea9..573138c50f 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java
@@ -32,7 +32,6 @@ import org.apache.lucene.store.RAMDirectory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.lucene.search.MoreLikeThisQuery;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -40,14 +39,11 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class MoreLikeThisQueryTests extends ESTestCase {
-
- @Test
public void testSimple() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
indexWriter.commit();
-
Document document = new Document();
document.add(new TextField("_id", "1", Field.Store.YES));
document.add(new TextField("text", "lucene", Field.Store.YES));
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java
index 29d794ad59..e1c71b0f62 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java
@@ -32,7 +32,6 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -40,7 +39,6 @@ import java.util.Arrays;
import java.util.List;
public class XMoreLikeThisTests extends ESTestCase {
-
private void addDoc(RandomIndexWriter writer, String[] texts) throws IOException {
Document doc = new Document();
for (String text : texts) {
@@ -49,7 +47,6 @@ public class XMoreLikeThisTests extends ESTestCase {
writer.addDocument(doc);
}
- @Test
public void testTopN() throws Exception {
int numDocs = 100;
int topN = 25;
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInputTests.java b/core/src/test/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInputTests.java
index 8f4f013629..7113a301e7 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInputTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInputTests.java
@@ -19,18 +19,15 @@
package org.elasticsearch.common.lucene.store;
-import java.nio.charset.StandardCharsets;
import org.apache.lucene.store.IndexInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import static org.hamcrest.Matchers.containsString;
public class ByteArrayIndexInputTests extends ESTestCase {
-
- @Test
public void testRandomReads() throws IOException {
for (int i = 0; i < 100; i++) {
byte[] input = randomUnicodeOfLength(randomIntBetween(1, 1000)).getBytes(StandardCharsets.UTF_8);
@@ -42,7 +39,6 @@ public class ByteArrayIndexInputTests extends ESTestCase {
}
}
- @Test
public void testRandomOverflow() throws IOException {
for (int i = 0; i < 100; i++) {
byte[] input = randomUnicodeOfLength(randomIntBetween(1, 1000)).getBytes(StandardCharsets.UTF_8);
@@ -61,7 +57,6 @@ public class ByteArrayIndexInputTests extends ESTestCase {
}
}
- @Test
public void testSeekOverflow() throws IOException {
for (int i = 0; i < 100; i++) {
byte[] input = randomUnicodeOfLength(randomIntBetween(1, 1000)).getBytes(StandardCharsets.UTF_8);
@@ -130,7 +125,7 @@ public class ByteArrayIndexInputTests extends ESTestCase {
default:
fail();
}
- assertEquals((long) readPos, indexInput.getFilePointer());
+ assertEquals(readPos, indexInput.getFilePointer());
}
return output;
}
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java b/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java
index e8540d3cba..99acdde7af 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java
@@ -24,11 +24,9 @@ import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.RAMDirectory;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
@@ -36,8 +34,6 @@ import static org.hamcrest.Matchers.lessThan;
*
*/
public class InputStreamIndexInputTests extends ESTestCase {
-
- @Test
public void testSingleReadSingleByteLimit() throws IOException {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
@@ -74,7 +70,6 @@ public class InputStreamIndexInputTests extends ESTestCase {
assertThat(is.read(), equalTo(-1));
}
- @Test
public void testReadMultiSingleByteLimit1() throws IOException {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
@@ -113,7 +108,6 @@ public class InputStreamIndexInputTests extends ESTestCase {
assertThat(is.read(read), equalTo(-1));
}
- @Test
public void testSingleReadTwoBytesLimit() throws IOException {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
@@ -155,7 +149,6 @@ public class InputStreamIndexInputTests extends ESTestCase {
assertThat(is.read(), equalTo(-1));
}
- @Test
public void testReadMultiTwoBytesLimit1() throws IOException {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
@@ -199,7 +192,6 @@ public class InputStreamIndexInputTests extends ESTestCase {
assertThat(is.read(read), equalTo(-1));
}
- @Test
public void testReadMultiFourBytesLimit() throws IOException {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
@@ -238,7 +230,6 @@ public class InputStreamIndexInputTests extends ESTestCase {
assertThat(is.read(read), equalTo(-1));
}
- @Test
public void testMarkRest() throws Exception {
RAMDirectory dir = new RAMDirectory();
IndexOutput output = dir.createOutput("test", IOContext.DEFAULT);
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java b/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java
index 6c2397e092..fb3c021fd5 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java
@@ -48,7 +48,6 @@ import org.elasticsearch.index.shard.ElasticsearchMergePolicy;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -76,7 +75,7 @@ public class VersionsTests extends ESTestCase {
}
return newReader;
}
- @Test
+
public void testVersions() throws Exception {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -128,7 +127,6 @@ public class VersionsTests extends ESTestCase {
dir.close();
}
- @Test
public void testNestedDocuments() throws IOException {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -169,7 +167,6 @@ public class VersionsTests extends ESTestCase {
dir.close();
}
- @Test
public void testBackwardCompatibility() throws IOException {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -236,7 +233,6 @@ public class VersionsTests extends ESTestCase {
}
}
- @Test
public void testMergingOldIndices() throws Exception {
final IndexWriterConfig iwConf = new IndexWriterConfig(new KeywordAnalyzer());
iwConf.setMergePolicy(new ElasticsearchMergePolicy(iwConf.getMergePolicy()));
diff --git a/core/src/test/java/org/elasticsearch/common/math/MathUtilsTests.java b/core/src/test/java/org/elasticsearch/common/math/MathUtilsTests.java
index 85fd28da68..a25b7a3a78 100644
--- a/core/src/test/java/org/elasticsearch/common/math/MathUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/math/MathUtilsTests.java
@@ -20,12 +20,9 @@
package org.elasticsearch.common.math;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
public class MathUtilsTests extends ESTestCase {
-
- @Test
- public void mod() {
+ public void testMod() {
final int iters = scaledRandomIntBetween(1000, 10000);
for (int i = 0; i < iters; ++i) {
final int v = rarely() ? Integer.MIN_VALUE : rarely() ? Integer.MAX_VALUE : randomInt();
@@ -35,5 +32,4 @@ public class MathUtilsTests extends ESTestCase {
assertTrue(mod < m);
}
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/property/PropertyPlaceholderTests.java b/core/src/test/java/org/elasticsearch/common/property/PropertyPlaceholderTests.java
index bfa08ddfda..4d8fbc3add 100644
--- a/core/src/test/java/org/elasticsearch/common/property/PropertyPlaceholderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/property/PropertyPlaceholderTests.java
@@ -20,14 +20,13 @@
package org.elasticsearch.common.property;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.LinkedHashMap;
import java.util.Map;
-public class PropertyPlaceholderTests extends ESTestCase {
+import static org.hamcrest.Matchers.is;
- @Test
+public class PropertyPlaceholderTests extends ESTestCase {
public void testSimple() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("{", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -40,7 +39,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("a bar1 b bar2 c", propertyPlaceholder.replacePlaceholders("a {foo1} b {foo2} c", placeholderResolver));
}
- @Test
public void testVariousPrefixSuffix() {
// Test various prefix/suffix lengths
PropertyPlaceholder ppEqualsPrefix = new PropertyPlaceholder("{", "}", false);
@@ -54,7 +52,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("bar", ppShorterPrefix.replacePlaceholders("{foo}}", placeholderResolver));
}
- @Test
public void testDefaultValue() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -63,7 +60,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("", propertyPlaceholder.replacePlaceholders("${foo:}", placeholderResolver));
}
- @Test
public void testIgnoredUnresolvedPlaceholder() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", true);
Map<String, String> map = new LinkedHashMap<>();
@@ -71,15 +67,18 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("${foo}", propertyPlaceholder.replacePlaceholders("${foo}", placeholderResolver));
}
- @Test(expected = IllegalArgumentException.class)
public void testNotIgnoredUnresolvedPlaceholder() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
PropertyPlaceholder.PlaceholderResolver placeholderResolver = new SimplePlaceholderResolver(map, false, true);
- propertyPlaceholder.replacePlaceholders("${foo}", placeholderResolver);
+ try {
+ propertyPlaceholder.replacePlaceholders("${foo}", placeholderResolver);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Could not resolve placeholder 'foo'"));
+ }
}
- @Test
public void testShouldIgnoreMissing() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -87,7 +86,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("bar", propertyPlaceholder.replacePlaceholders("bar${foo}", placeholderResolver));
}
- @Test
public void testRecursive() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -99,7 +97,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("abarb", propertyPlaceholder.replacePlaceholders("a${foo}b", placeholderResolver));
}
- @Test
public void testNestedLongerPrefix() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -111,7 +108,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("baz", propertyPlaceholder.replacePlaceholders("${bar${foo}}", placeholderResolver));
}
- @Test
public void testNestedSameLengthPrefixSuffix() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("{", "}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -123,7 +119,6 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("baz", propertyPlaceholder.replacePlaceholders("{bar{foo}}", placeholderResolver));
}
- @Test
public void testNestedShorterPrefix() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("{", "}}", false);
Map<String, String> map = new LinkedHashMap<>();
@@ -135,17 +130,20 @@ public class PropertyPlaceholderTests extends ESTestCase {
assertEquals("baz", propertyPlaceholder.replacePlaceholders("{bar{foo}}}}", placeholderResolver));
}
- @Test(expected = IllegalArgumentException.class)
public void testCircularReference() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
map.put("foo", "${bar}");
map.put("bar", "${foo}");
PropertyPlaceholder.PlaceholderResolver placeholderResolver = new SimplePlaceholderResolver(map, false, true);
- propertyPlaceholder.replacePlaceholders("${foo}", placeholderResolver);
+ try {
+ propertyPlaceholder.replacePlaceholders("${foo}", placeholderResolver);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Circular placeholder reference 'foo' in property definitions"));
+ }
}
- @Test
public void testShouldRemoveMissing() {
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false);
Map<String, String> map = new LinkedHashMap<>();
diff --git a/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java b/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java
index 18ff2c1d00..ee0756f28c 100644
--- a/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java
+++ b/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.common.regex;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Random;
import java.util.regex.Pattern;
@@ -27,8 +26,6 @@ import java.util.regex.Pattern;
import static org.hamcrest.Matchers.equalTo;
public class RegexTests extends ESTestCase {
-
- @Test
public void testFlags() {
String[] supportedFlags = new String[]{"CASE_INSENSITIVE", "MULTILINE", "DOTALL", "UNICODE_CASE", "CANON_EQ", "UNIX_LINES",
"LITERAL", "COMMENTS", "UNICODE_CHAR_CLASS"};
@@ -55,7 +52,6 @@ public class RegexTests extends ESTestCase {
}
}
- @Test(timeout = 1000)
public void testDoubleWildcardMatch() {
assertTrue(Regex.simpleMatch("ddd", "ddd"));
assertTrue(Regex.simpleMatch("d*d*d", "dadd"));
@@ -67,5 +63,4 @@ public class RegexTests extends ESTestCase {
assertTrue(Regex.simpleMatch("fff*******ddd", "fffabcddd"));
assertFalse(Regex.simpleMatch("fff******ddd", "fffabcdd"));
}
-
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/common/rounding/RoundingTests.java b/core/src/test/java/org/elasticsearch/common/rounding/RoundingTests.java
index 53998c5cad..7819e4b60a 100644
--- a/core/src/test/java/org/elasticsearch/common/rounding/RoundingTests.java
+++ b/core/src/test/java/org/elasticsearch/common/rounding/RoundingTests.java
@@ -20,18 +20,15 @@
package org.elasticsearch.common.rounding;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class RoundingTests extends ESTestCase {
-
/**
* simple test case to illustrate how Rounding.Interval works on readable input
*/
- @Test
public void testInterval() {
int interval = 10;
Rounding.Interval rounding = new Rounding.Interval(interval);
@@ -44,7 +41,6 @@ public class RoundingTests extends ESTestCase {
assertEquals(message, 0, r % interval);
}
- @Test
public void testIntervalRandom() {
final long interval = randomIntBetween(1, 100);
Rounding.Interval rounding = new Rounding.Interval(interval);
@@ -65,7 +61,6 @@ public class RoundingTests extends ESTestCase {
* offset shifts input value back before rounding (so here 6 - 7 -&gt; -1)
* then shifts rounded Value back (here -10 -&gt; -3)
*/
- @Test
public void testOffsetRounding() {
final long interval = 10;
final long offset = 7;
@@ -86,7 +81,6 @@ public class RoundingTests extends ESTestCase {
/**
* test OffsetRounding with an internal interval rounding on random inputs
*/
- @Test
public void testOffsetRoundingRandom() {
for (int i = 0; i < 1000; ++i) {
final long interval = randomIntBetween(1, 100);
diff --git a/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java b/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java
index cc6f9cb1c1..e90691ee40 100644
--- a/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java
+++ b/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
-import org.junit.Test;
import java.util.concurrent.TimeUnit;
@@ -35,10 +34,8 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
/**
*/
public class TimeZoneRoundingTests extends ESTestCase {
-
final static DateTimeZone JERUSALEM_TIMEZONE = DateTimeZone.forID("Asia/Jerusalem");
- @Test
public void testUTCTimeUnitRounding() {
Rounding tzRounding = TimeZoneRounding.builder(DateTimeUnit.MONTH_OF_YEAR).build();
assertThat(tzRounding.round(utc("2009-02-03T01:01:01")), equalTo(utc("2009-02-01T00:00:00.000Z")));
@@ -53,7 +50,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
assertThat(tzRounding.nextRoundingValue(utc("2012-01-08T00:00:00.000Z")), equalTo(utc("2012-01-15T00:00:00.000Z")));
}
- @Test
public void testUTCIntervalRounding() {
Rounding tzRounding = TimeZoneRounding.builder(TimeValue.timeValueHours(12)).build();
assertThat(tzRounding.round(utc("2009-02-03T01:01:01")), equalTo(utc("2009-02-03T00:00:00.000Z")));
@@ -74,7 +70,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
/**
* test TimeIntervalTimeZoneRounding, (interval &lt; 12h) with time zone shift
*/
- @Test
public void testTimeIntervalTimeZoneRounding() {
Rounding tzRounding = TimeZoneRounding.builder(TimeValue.timeValueHours(6)).timeZone(DateTimeZone.forOffsetHours(-1)).build();
assertThat(tzRounding.round(utc("2009-02-03T00:01:01")), equalTo(utc("2009-02-02T19:00:00.000Z")));
@@ -90,7 +85,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
/**
* test DayIntervalTimeZoneRounding, (interval &gt;= 12h) with time zone shift
*/
- @Test
public void testDayIntervalTimeZoneRounding() {
Rounding tzRounding = TimeZoneRounding.builder(TimeValue.timeValueHours(12)).timeZone(DateTimeZone.forOffsetHours(-8)).build();
assertThat(tzRounding.round(utc("2009-02-03T00:01:01")), equalTo(utc("2009-02-02T20:00:00.000Z")));
@@ -103,7 +97,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
assertThat(tzRounding.nextRoundingValue(utc("2009-02-03T08:00:00.000Z")), equalTo(utc("2009-02-03T20:00:00.000Z")));
}
- @Test
public void testDayTimeZoneRounding() {
int timezoneOffset = -2;
Rounding tzRounding = TimeZoneRounding.builder(DateTimeUnit.DAY_OF_MONTH).timeZone(DateTimeZone.forOffsetHours(timezoneOffset))
@@ -139,7 +132,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
assertThat(tzRounding.nextRoundingValue(utc("2009-02-03T02:00:00")), equalTo(utc("2009-02-04T02:00:00")));
}
- @Test
public void testTimeTimeZoneRounding() {
// hour unit
Rounding tzRounding = TimeZoneRounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(DateTimeZone.forOffsetHours(-2)).build();
@@ -151,7 +143,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
assertThat(tzRounding.nextRoundingValue(utc("2009-02-03T01:00:00")), equalTo(utc("2009-02-03T02:00:00")));
}
- @Test
public void testTimeUnitRoundingDST() {
Rounding tzRounding;
// testing savings to non savings switch
@@ -203,7 +194,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
/**
* randomized test on TimeUnitRounding with random time units and time zone offsets
*/
- @Test
public void testTimeZoneRoundingRandom() {
for (int i = 0; i < 1000; ++i) {
DateTimeUnit timeUnit = randomTimeUnit();
@@ -223,7 +213,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
/**
* randomized test on TimeIntervalRounding with random interval and time zone offsets
*/
- @Test
public void testIntervalRoundingRandom() {
for (int i = 0; i < 1000; ++i) {
// max random interval is a year, can be negative
@@ -245,7 +234,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
/**
* special test for DST switch from #9491
*/
- @Test
public void testAmbiguousHoursAfterDSTSwitch() {
Rounding tzRounding;
tzRounding = TimeZoneRounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(JERUSALEM_TIMEZONE).build();
@@ -284,7 +272,6 @@ public class TimeZoneRoundingTests extends ESTestCase {
* test for #10025, strict local to UTC conversion can cause joda exceptions
* on DST start
*/
- @Test
public void testLenientConversionDST() {
DateTimeZone tz = DateTimeZone.forID("America/Sao_Paulo");
long start = time("2014-10-18T20:50:00.000", tz);
diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java
index a00c9af037..5eb8ef8ca0 100644
--- a/core/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java
+++ b/core/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java
@@ -20,18 +20,15 @@ package org.elasticsearch.common.settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
+import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
-import org.elasticsearch.rest.RestRequest;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.equalTo;
public class SettingsFilterTests extends ESTestCase {
-
- @Test
public void testAddingAndRemovingFilters() {
SettingsFilter settingsFilter = new SettingsFilter(Settings.EMPTY);
settingsFilter.addFilter("foo");
@@ -49,7 +46,6 @@ public class SettingsFilterTests extends ESTestCase {
assertThat(settingsFilter.getPatterns(), equalTo(""));
}
- @Test
public void testSettingsFiltering() throws IOException {
testFiltering(Settings.builder()
diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java
index a17bb4fd9d..8cc861a7e0 100644
--- a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java
@@ -19,12 +19,9 @@
package org.elasticsearch.common.settings;
-import org.elasticsearch.common.settings.bar.BarTestClass;
-import org.elasticsearch.common.settings.foo.FooTestClass;
import org.elasticsearch.common.settings.loader.YamlSettingsLoader;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.List;
@@ -32,13 +29,17 @@ import java.util.Map;
import java.util.Set;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.arrayContaining;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
public class SettingsTests extends ESTestCase {
-
- @Test
public void testCamelCaseSupport() {
Settings settings = settingsBuilder()
.put("test.camelCase", "bar")
@@ -47,7 +48,6 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.get("test.camel_case"), equalTo("bar"));
}
- @Test
public void testLoadFromDelimitedString() {
Settings settings = settingsBuilder()
.loadFromDelimitedString("key1=value1;key2=value2", ';')
@@ -66,7 +66,6 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.toDelimitedString(';'), equalTo("key1=value1;key2=value2;"));
}
- @Test
public void testReplacePropertiesPlaceholderSystemProperty() {
System.setProperty("sysProp1", "sysVal1");
try {
@@ -92,7 +91,6 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.get("setting1"), is(nullValue()));
}
- @Test
public void testReplacePropertiesPlaceholderIgnoreEnvUnset() {
Settings settings = settingsBuilder()
.put("setting1", "${env.UNSET_ENV_VAR}")
@@ -101,7 +99,6 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.get("setting1"), is(nullValue()));
}
- @Test
public void testReplacePropertiesPlaceholderIgnoresPrompt() {
Settings settings = settingsBuilder()
.put("setting1", "${prompt.text}")
@@ -112,7 +109,6 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.get("setting2"), is("${prompt.secret}"));
}
- @Test
public void testUnFlattenedSettings() {
Settings settings = settingsBuilder()
.put("foo", "abc")
@@ -137,7 +133,6 @@ public class SettingsTests extends ESTestCase {
}
- @Test
public void testFallbackToFlattenedSettings() {
Settings settings = settingsBuilder()
.put("foo", "abc")
@@ -163,7 +158,6 @@ public class SettingsTests extends ESTestCase {
Matchers.<String, Object>hasEntry("foo.baz", "ghi")));
}
- @Test
public void testGetAsSettings() {
Settings settings = settingsBuilder()
.put("foo", "abc")
@@ -175,7 +169,6 @@ public class SettingsTests extends ESTestCase {
assertThat(fooSettings.get("baz"), equalTo("ghi"));
}
- @Test
public void testNames() {
Settings settings = settingsBuilder()
.put("bar", "baz")
@@ -195,7 +188,6 @@ public class SettingsTests extends ESTestCase {
assertTrue(names.contains("baz"));
}
- @Test
public void testThatArraysAreOverriddenCorrectly() throws IOException {
// overriding a single value with an array
Settings settings = settingsBuilder()
@@ -300,9 +292,7 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.get("value"), is(nullValue()));
}
- @Test
public void testPrefixNormalization() {
-
Settings settings = settingsBuilder().normalizePrefix("foo.").build();
assertThat(settings.names().size(), equalTo(0));
@@ -337,6 +327,4 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.getAsMap().size(), equalTo(1));
assertThat(settings.get("foo.test"), equalTo("test"));
}
-
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java b/core/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java
index 0f90b8c372..18591d9a59 100644
--- a/core/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
@@ -32,7 +31,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class JsonSettingsLoaderTests extends ESTestCase {
- @Test
public void testSimpleJsonSettings() throws Exception {
String json = "/org/elasticsearch/common/settings/loader/test-settings.json";
Settings settings = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java b/core/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java
index 60bf80a6e9..48703044ec 100644
--- a/core/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java
@@ -23,16 +23,15 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
public class YamlSettingsLoaderTests extends ESTestCase {
- @Test
public void testSimpleYamlSettings() throws Exception {
String yaml = "/org/elasticsearch/common/settings/loader/test-settings.yml";
Settings settings = settingsBuilder()
@@ -51,20 +50,28 @@ public class YamlSettingsLoaderTests extends ESTestCase {
assertThat(settings.getAsArray("test1.test3")[1], equalTo("test3-2"));
}
- @Test(expected = SettingsException.class)
public void testIndentation() {
String yaml = "/org/elasticsearch/common/settings/loader/indentation-settings.yml";
- settingsBuilder()
- .loadFromStream(yaml, getClass().getResourceAsStream(yaml))
- .build();
+ try {
+ settingsBuilder()
+ .loadFromStream(yaml, getClass().getResourceAsStream(yaml))
+ .build();
+ fail("Expected SettingsException");
+ } catch(SettingsException e ) {
+ assertThat(e.getMessage(), containsString("Failed to load settings"));
+ }
}
- @Test(expected = SettingsException.class)
public void testIndentationWithExplicitDocumentStart() {
String yaml = "/org/elasticsearch/common/settings/loader/indentation-with-explicit-document-start-settings.yml";
- settingsBuilder()
- .loadFromStream(yaml, getClass().getResourceAsStream(yaml))
- .build();
+ try {
+ settingsBuilder()
+ .loadFromStream(yaml, getClass().getResourceAsStream(yaml))
+ .build();
+ fail("Expected SettingsException");
+ } catch (SettingsException e) {
+ assertThat(e.getMessage(), containsString("Failed to load settings"));
+ }
}
public void testDuplicateKeysThrowsException() {
diff --git a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java
index 5e8a55a347..70ea1d19cb 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java
@@ -20,17 +20,19 @@
package org.elasticsearch.common.unit;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.elasticsearch.common.unit.ByteSizeUnit.*;
+import static org.elasticsearch.common.unit.ByteSizeUnit.BYTES;
+import static org.elasticsearch.common.unit.ByteSizeUnit.GB;
+import static org.elasticsearch.common.unit.ByteSizeUnit.KB;
+import static org.elasticsearch.common.unit.ByteSizeUnit.MB;
+import static org.elasticsearch.common.unit.ByteSizeUnit.PB;
+import static org.elasticsearch.common.unit.ByteSizeUnit.TB;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
public class ByteSizeUnitTests extends ESTestCase {
-
- @Test
public void testBytes() {
assertThat(BYTES.toBytes(1), equalTo(1l));
assertThat(BYTES.toKB(1024), equalTo(1l));
@@ -38,7 +40,6 @@ public class ByteSizeUnitTests extends ESTestCase {
assertThat(BYTES.toGB(1024 * 1024 * 1024), equalTo(1l));
}
- @Test
public void testKB() {
assertThat(KB.toBytes(1), equalTo(1024l));
assertThat(KB.toKB(1), equalTo(1l));
@@ -46,7 +47,6 @@ public class ByteSizeUnitTests extends ESTestCase {
assertThat(KB.toGB(1024 * 1024), equalTo(1l));
}
- @Test
public void testMB() {
assertThat(MB.toBytes(1), equalTo(1024l * 1024));
assertThat(MB.toKB(1), equalTo(1024l));
@@ -54,7 +54,6 @@ public class ByteSizeUnitTests extends ESTestCase {
assertThat(MB.toGB(1024), equalTo(1l));
}
- @Test
public void testGB() {
assertThat(GB.toBytes(1), equalTo(1024l * 1024 * 1024));
assertThat(GB.toKB(1), equalTo(1024l * 1024));
@@ -62,7 +61,6 @@ public class ByteSizeUnitTests extends ESTestCase {
assertThat(GB.toGB(1), equalTo(1l));
}
- @Test
public void testTB() {
assertThat(TB.toBytes(1), equalTo(1024l * 1024 * 1024 * 1024));
assertThat(TB.toKB(1), equalTo(1024l * 1024 * 1024));
@@ -71,7 +69,6 @@ public class ByteSizeUnitTests extends ESTestCase {
assertThat(TB.toTB(1), equalTo(1l));
}
- @Test
public void testPB() {
assertThat(PB.toBytes(1), equalTo(1024l * 1024 * 1024 * 1024 * 1024));
assertThat(PB.toKB(1), equalTo(1024l * 1024 * 1024 * 1024));
diff --git a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java
index 200d04aa8b..56e6179832 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java
@@ -22,8 +22,8 @@ package org.elasticsearch.common.unit;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -31,23 +31,18 @@ import static org.hamcrest.Matchers.is;
*
*/
public class ByteSizeValueTests extends ESTestCase {
-
- @Test
public void testActualPeta() {
MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.PB).bytes(), equalTo(4503599627370496l));
}
- @Test
public void testActualTera() {
MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.TB).bytes(), equalTo(4398046511104l));
}
- @Test
public void testActual() {
MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l));
}
- @Test
public void testSimple() {
assertThat(ByteSizeUnit.BYTES.toBytes(10), is(new ByteSizeValue(10, ByteSizeUnit.BYTES).bytes()));
assertThat(ByteSizeUnit.KB.toKB(10), is(new ByteSizeValue(10, ByteSizeUnit.KB).kb()));
@@ -64,7 +59,6 @@ public class ByteSizeValueTests extends ESTestCase {
assertThat(value1, equalTo(value2));
}
- @Test
public void testToString() {
assertThat("10b", is(new ByteSizeValue(10, ByteSizeUnit.BYTES).toString()));
assertThat("1.5kb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.BYTES).toString()));
@@ -75,7 +69,6 @@ public class ByteSizeValueTests extends ESTestCase {
assertThat("1536pb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.PB).toString()));
}
- @Test
public void testParsing() {
assertThat(ByteSizeValue.parseBytesSizeValue("42PB", "testParsing").toString(), is("42pb"));
assertThat(ByteSizeValue.parseBytesSizeValue("42 PB", "testParsing").toString(), is("42pb"));
@@ -128,28 +121,48 @@ public class ByteSizeValueTests extends ESTestCase {
assertThat(ByteSizeValue.parseBytesSizeValue("1 b", "testParsing").toString(), is("1b"));
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnMissingUnits() {
- ByteSizeValue.parseBytesSizeValue("23", "test");
+ try {
+ ByteSizeValue.parseBytesSizeValue("23", "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse setting [test]"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnUnknownUnits() {
- ByteSizeValue.parseBytesSizeValue("23jw", "test");
+ try {
+ ByteSizeValue.parseBytesSizeValue("23jw", "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse setting [test]"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnEmptyParsing() {
- assertThat(ByteSizeValue.parseBytesSizeValue("", "emptyParsing").toString(), is("23kb"));
+ try {
+ assertThat(ByteSizeValue.parseBytesSizeValue("", "emptyParsing").toString(), is("23kb"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse setting [emptyParsing]"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnEmptyNumberParsing() {
- assertThat(ByteSizeValue.parseBytesSizeValue("g", "emptyNumberParsing").toString(), is("23b"));
+ try {
+ assertThat(ByteSizeValue.parseBytesSizeValue("g", "emptyNumberParsing").toString(), is("23b"));
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse [g]"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testNoDotsAllowed() {
- ByteSizeValue.parseBytesSizeValue("42b.", null, "test");
+ try {
+ ByteSizeValue.parseBytesSizeValue("42b.", null, "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("failed to parse setting [test]"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java b/core/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java
index e29cd1e686..1010d2a5e8 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java
@@ -20,7 +20,6 @@
package org.elasticsearch.common.unit;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
@@ -29,8 +28,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class DistanceUnitTests extends ESTestCase {
-
- @Test
public void testSimpleDistanceUnit() {
assertThat(DistanceUnit.KILOMETERS.convert(10, DistanceUnit.MILES), closeTo(16.09344, 0.001));
assertThat(DistanceUnit.MILES.convert(10, DistanceUnit.MILES), closeTo(10, 0.001));
@@ -41,8 +38,7 @@ public class DistanceUnitTests extends ESTestCase {
assertThat(DistanceUnit.KILOMETERS.convert(1000,DistanceUnit.METERS), closeTo(1, 0.001));
assertThat(DistanceUnit.METERS.convert(1, DistanceUnit.KILOMETERS), closeTo(1000, 0.001));
}
-
- @Test
+
public void testDistanceUnitParsing() {
assertThat(DistanceUnit.Distance.parseDistance("50km").unit, equalTo(DistanceUnit.KILOMETERS));
assertThat(DistanceUnit.Distance.parseDistance("500m").unit, equalTo(DistanceUnit.METERS));
@@ -53,7 +49,7 @@ public class DistanceUnitTests extends ESTestCase {
assertThat(DistanceUnit.Distance.parseDistance("12in").unit, equalTo(DistanceUnit.INCH));
assertThat(DistanceUnit.Distance.parseDistance("23mm").unit, equalTo(DistanceUnit.MILLIMETERS));
assertThat(DistanceUnit.Distance.parseDistance("23cm").unit, equalTo(DistanceUnit.CENTIMETERS));
-
+
double testValue = 12345.678;
for (DistanceUnit unit : DistanceUnit.values()) {
assertThat("Unit can be parsed from '" + unit.toString() + "'", DistanceUnit.fromString(unit.toString()), equalTo(unit));
@@ -61,5 +57,4 @@ public class DistanceUnitTests extends ESTestCase {
assertThat("Value can be parsed from '" + testValue + unit.toString() + "'", DistanceUnit.Distance.parseDistance(unit.toString(testValue)).value, equalTo(testValue));
}
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java b/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java
index 807b4a72bf..4c64e04ec3 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java
@@ -24,17 +24,16 @@ import org.elasticsearch.common.xcontent.XContent;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.number.IsCloseTo.closeTo;
public class FuzzinessTests extends ESTestCase {
-
- @Test
public void testNumerics() {
String[] options = new String[]{"1.0", "1", "1.000000"};
assertThat(Fuzziness.build(randomFrom(options)).asByte(), equalTo((byte) 1));
@@ -45,7 +44,6 @@ public class FuzzinessTests extends ESTestCase {
assertThat(Fuzziness.build(randomFrom(options)).asShort(), equalTo((short) 1));
}
- @Test
public void testParseFromXContent() throws IOException {
final int iters = randomIntBetween(10, 50);
for (int i = 0; i < iters; i++) {
@@ -61,7 +59,7 @@ public class FuzzinessTests extends ESTestCase {
assertThat(parser.nextToken(), equalTo(XContentParser.Token.VALUE_NUMBER));
Fuzziness parse = Fuzziness.parse(parser);
assertThat(parse.asFloat(), equalTo(floatValue));
- assertThat(parse.asDouble(), closeTo((double) floatValue, 0.000001));
+ assertThat(parse.asDouble(), closeTo(floatValue, 0.000001));
assertThat(parser.nextToken(), equalTo(XContentParser.Token.END_OBJECT));
}
{
@@ -140,10 +138,7 @@ public class FuzzinessTests extends ESTestCase {
}
- @Test
public void testAuto() {
- final int codePoints = randomIntBetween(0, 10);
- String string = randomRealisticUnicodeOfCodepointLength(codePoints);
assertThat(Fuzziness.AUTO.asByte(), equalTo((byte) 1));
assertThat(Fuzziness.AUTO.asInt(), equalTo(1));
assertThat(Fuzziness.AUTO.asFloat(), equalTo(1f));
@@ -154,7 +149,6 @@ public class FuzzinessTests extends ESTestCase {
}
- @Test
public void testAsDistance() {
final int iters = randomIntBetween(10, 50);
for (int i = 0; i < iters; i++) {
@@ -164,7 +158,6 @@ public class FuzzinessTests extends ESTestCase {
}
}
- @Test
public void testSerialization() throws IOException {
Fuzziness fuzziness = Fuzziness.AUTO;
Fuzziness deserializedFuzziness = doSerializeRoundtrip(fuzziness);
@@ -175,7 +168,6 @@ public class FuzzinessTests extends ESTestCase {
assertEquals(fuzziness, deserializedFuzziness);
}
- @Test
public void testSerializationAuto() throws IOException {
Fuzziness fuzziness = Fuzziness.AUTO;
Fuzziness deserializedFuzziness = doSerializeRoundtrip(fuzziness);
diff --git a/core/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java
index b9ac8e5287..e918a579df 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/RatioValueTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.common.unit;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.is;
@@ -29,8 +28,6 @@ import static org.hamcrest.Matchers.is;
* Tests for the {@link RatioValue} class
*/
public class RatioValueTests extends ESTestCase {
-
- @Test
public void testParsing() {
assertThat(RatioValue.parseRatioValue("100%").toString(), is("100.0%"));
assertThat(RatioValue.parseRatioValue("0%").toString(), is("0.0%"));
@@ -46,7 +43,6 @@ public class RatioValueTests extends ESTestCase {
assertThat(RatioValue.parseRatioValue("0.001").toString(), is("0.1%"));
}
- @Test
public void testNegativeCase() {
testInvalidRatio("100.0001%");
testInvalidRatio("-0.1%");
diff --git a/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java
index c1595acf58..f2f85e0c7f 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java
@@ -19,16 +19,14 @@
package org.elasticsearch.common.unit;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
/**
*
*/
public class SizeValueTests extends ESTestCase {
-
- @Test
public void testThatConversionWorks() {
SizeValue sizeValue = new SizeValue(1000);
assertThat(sizeValue.kilo(), is(1l));
@@ -55,15 +53,18 @@ public class SizeValueTests extends ESTestCase {
assertThat(sizeValue.toString(), is("1000p"));
}
- @Test
public void testThatParsingWorks() {
assertThat(SizeValue.parseSizeValue("1k").toString(), is(new SizeValue(1000).toString()));
assertThat(SizeValue.parseSizeValue("1p").toString(), is(new SizeValue(1, SizeUnit.PETA).toString()));
assertThat(SizeValue.parseSizeValue("1G").toString(), is(new SizeValue(1, SizeUnit.GIGA).toString()));
}
- @Test(expected = IllegalArgumentException.class)
public void testThatNegativeValuesThrowException() {
- new SizeValue(-1);
+ try {
+ new SizeValue(-1);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("may not be negative"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java
index 19738bc28d..ec0e26091d 100644
--- a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java
+++ b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java
@@ -24,11 +24,11 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.joda.time.PeriodType;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
@@ -136,18 +136,30 @@ public class TimeValueTests extends ESTestCase {
assertEqualityAfterSerialize(new TimeValue(1, TimeUnit.NANOSECONDS));
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnUnknownUnits() {
- TimeValue.parseTimeValue("23tw", null, "test");
+ try {
+ TimeValue.parseTimeValue("23tw", null, "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("Failed to parse"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testFailOnMissingUnits() {
- TimeValue.parseTimeValue("42", null, "test");
+ try {
+ TimeValue.parseTimeValue("42", null, "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("Failed to parse"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testNoDotsAllowed() {
- TimeValue.parseTimeValue("42ms.", null, "test");
+ try {
+ TimeValue.parseTimeValue("42ms.", null, "test");
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("Failed to parse"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/ArrayUtilsTests.java b/core/src/test/java/org/elasticsearch/common/util/ArrayUtilsTests.java
index 735fda1679..172a064b69 100644
--- a/core/src/test/java/org/elasticsearch/common/util/ArrayUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/ArrayUtilsTests.java
@@ -19,28 +19,20 @@
package org.elasticsearch.common.util;
-import org.apache.lucene.util.ArrayUtil;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
*
*/
public class ArrayUtilsTests extends ESTestCase {
-
- @Test
- public void binarySearch() throws Exception {
-
+ public void testBinarySearch() throws Exception {
for (int j = 0; j < 100; j++) {
-
int index = Math.min(randomInt(0, 10), 9);
double tolerance = Math.random() * 0.01;
double lookForValue = randomFreq(0.9) ? -1 : Double.NaN; // sometimes we'll look for NaN
@@ -110,5 +102,4 @@ public class ArrayUtilsTests extends ESTestCase {
}
assertArrayEquals(sourceOfTruth.toArray(new String[0]), ArrayUtils.concat(first, second));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java
index 91c74762df..df26f2d55b 100644
--- a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java
@@ -19,17 +19,21 @@
package org.elasticsearch.common.util;
-import com.carrotsearch.hppc.ObjectLongMap;
import com.carrotsearch.hppc.ObjectLongHashMap;
+import com.carrotsearch.hppc.ObjectLongMap;
import com.carrotsearch.hppc.cursors.ObjectLongCursor;
+
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
public class BytesRefHashTests extends ESSingleNodeTestCase {
@@ -92,7 +96,6 @@ public class BytesRefHashTests extends ESSingleNodeTestCase {
/**
* Test method for {@link org.apache.lucene.util.BytesRefHash#size()}.
*/
- @Test
public void testSize() {
BytesRefBuilder ref = new BytesRefBuilder();
int num = scaledRandomIntBetween(2, 20);
@@ -123,7 +126,6 @@ public class BytesRefHashTests extends ESSingleNodeTestCase {
* {@link org.apache.lucene.util.BytesRefHash#get(int, BytesRef)}
* .
*/
- @Test
public void testGet() {
BytesRefBuilder ref = new BytesRefBuilder();
BytesRef scratch = new BytesRef();
@@ -163,7 +165,6 @@ public class BytesRefHashTests extends ESSingleNodeTestCase {
* {@link org.apache.lucene.util.BytesRefHash#add(org.apache.lucene.util.BytesRef)}
* .
*/
- @Test
public void testAdd() {
BytesRefBuilder ref = new BytesRefBuilder();
BytesRef scratch = new BytesRef();
@@ -199,7 +200,6 @@ public class BytesRefHashTests extends ESSingleNodeTestCase {
hash.close();
}
- @Test
public void testFind() throws Exception {
BytesRefBuilder ref = new BytesRefBuilder();
BytesRef scratch = new BytesRef();
diff --git a/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java b/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
index 2bdaea34d1..5c6a93254a 100644
--- a/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
@@ -21,14 +21,11 @@ package org.elasticsearch.common.util;
import org.elasticsearch.common.util.CancellableThreads.Interruptable;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.concurrent.CountDownLatch;
public class CancellableThreadsTests extends ESTestCase {
-
public static class CustomException extends RuntimeException {
-
public CustomException(String msg) {
super(msg);
}
@@ -53,7 +50,6 @@ public class CancellableThreadsTests extends ESTestCase {
}
- @Test
public void testCancellableThreads() throws InterruptedException {
Thread[] threads = new Thread[randomIntBetween(3, 10)];
final TestPlan[] plans = new TestPlan[threads.length];
diff --git a/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java b/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
index 73611c80be..fe9ba6b1fc 100644
--- a/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
@@ -24,23 +24,26 @@ import org.apache.lucene.util.BytesRefArray;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.Counter;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
import static org.elasticsearch.common.util.CollectionUtils.eagerPartition;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
public class CollectionUtilsTests extends ESTestCase {
-
- @Test
- public void rotateEmpty() {
+ public void testRotateEmpty() {
assertTrue(CollectionUtils.rotate(Collections.emptyList(), randomInt()).isEmpty());
}
- @Test
- public void rotate() {
+ public void testRotate() {
final int iters = scaledRandomIntBetween(10, 100);
for (int k = 0; k < iters; ++k) {
final int size = randomIntBetween(1, 100);
@@ -65,7 +68,6 @@ public class CollectionUtilsTests extends ESTestCase {
}
}
- @Test
public void testSortAndDedupByteRefArray() {
SortedSet<BytesRef> set = new TreeSet<>();
final int numValues = scaledRandomIntBetween(0, 10000);
@@ -99,7 +101,6 @@ public class CollectionUtilsTests extends ESTestCase {
}
- @Test
public void testSortByteRefArray() {
List<BytesRef> values = new ArrayList<>();
final int numValues = scaledRandomIntBetween(0, 10000);
diff --git a/core/src/test/java/org/elasticsearch/common/util/LongHashTests.java b/core/src/test/java/org/elasticsearch/common/util/LongHashTests.java
index 09221b5151..aa21f32318 100644
--- a/core/src/test/java/org/elasticsearch/common/util/LongHashTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/LongHashTests.java
@@ -22,13 +22,16 @@ package org.elasticsearch.common.util;
import com.carrotsearch.hppc.LongLongHashMap;
import com.carrotsearch.hppc.LongLongMap;
import com.carrotsearch.hppc.cursors.LongLongCursor;
+
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
public class LongHashTests extends ESSingleNodeTestCase {
-
LongHash hash;
private void newHash() {
@@ -86,7 +89,6 @@ public class LongHashTests extends ESSingleNodeTestCase {
hash.close();
}
- @Test
public void testSize() {
int num = scaledRandomIntBetween(2, 20);
for (int j = 0; j < num; j++) {
@@ -106,7 +108,6 @@ public class LongHashTests extends ESSingleNodeTestCase {
hash.close();
}
- @Test
public void testKey() {
int num = scaledRandomIntBetween(2, 20);
for (int j = 0; j < num; j++) {
@@ -138,7 +139,6 @@ public class LongHashTests extends ESSingleNodeTestCase {
hash.close();
}
- @Test
public void testAdd() {
int num = scaledRandomIntBetween(2, 20);
for (int j = 0; j < num; j++) {
@@ -167,7 +167,6 @@ public class LongHashTests extends ESSingleNodeTestCase {
hash.close();
}
- @Test
public void testFind() throws Exception {
int num = scaledRandomIntBetween(2, 20);
for (int j = 0; j < num; j++) {
@@ -206,5 +205,4 @@ public class LongHashTests extends ESSingleNodeTestCase {
assertTrue("key: " + key + " count: " + count + " long: " + l, key < count);
}
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java b/core/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java
index 2036535a61..35fa7bec05 100644
--- a/core/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java
@@ -20,13 +20,11 @@
package org.elasticsearch.common.util;
import com.carrotsearch.hppc.LongObjectHashMap;
+
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
public class LongObjectHashMapTests extends ESSingleNodeTestCase {
-
- @Test
- public void duel() {
+ public void testDuel() {
final LongObjectHashMap<Object> map1 = new LongObjectHashMap<>();
final LongObjectPagedHashMap<Object> map2 = new LongObjectPagedHashMap<>(randomInt(42), 0.6f + randomFloat() * 0.39f, BigArraysTests.randombigArrays());
final int maxKey = randomIntBetween(1, 10000);
diff --git a/core/src/test/java/org/elasticsearch/common/util/URIPatternTests.java b/core/src/test/java/org/elasticsearch/common/util/URIPatternTests.java
index 4923a3ea97..80e2524f29 100644
--- a/core/src/test/java/org/elasticsearch/common/util/URIPatternTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/URIPatternTests.java
@@ -19,13 +19,10 @@
package org.elasticsearch.common.util;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.net.URI;
public class URIPatternTests extends ESTestCase {
-
- @Test
public void testURIPattern() throws Exception {
assertTrue(new URIPattern("http://test.local/").match(new URI("http://test.local/")));
assertFalse(new URIPattern("http://test.local/somepath").match(new URI("http://test.local/")));
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java
index 6a45bfbd3d..db10addfe2 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.common.util.concurrent;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
@@ -31,8 +30,6 @@ import static org.hamcrest.Matchers.greaterThan;
public class CountDownTests extends ESTestCase {
-
- @Test
public void testConcurrent() throws InterruptedException {
final AtomicInteger count = new AtomicInteger(0);
final CountDown countDown = new CountDown(scaledRandomIntBetween(10, 1000));
@@ -80,8 +77,7 @@ public class CountDownTests extends ESTestCase {
assertThat(countDown.isCountedDown(), equalTo(true));
assertThat(count.get(), Matchers.equalTo(1));
}
-
- @Test
+
public void testSingleThreaded() {
int atLeast = scaledRandomIntBetween(10, 1000);
final CountDown countDown = new CountDown(atLeast);
@@ -100,6 +96,5 @@ public class CountDownTests extends ESTestCase {
}
assertThat(atLeast, greaterThan(0));
}
-
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
index 520b619caa..1d2d214116 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
@@ -22,7 +22,6 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,8 +43,6 @@ import static org.hamcrest.Matchers.is;
*
*/
public class PrioritizedExecutorsTests extends ESTestCase {
-
- @Test
public void testPriorityQueue() throws Exception {
PriorityBlockingQueue<Priority> queue = new PriorityBlockingQueue<>();
List<Priority> priorities = Arrays.asList(Priority.values());
@@ -65,7 +62,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
}
}
- @Test
public void testSubmitPrioritizedExecutorWithRunnables() throws Exception {
ExecutorService executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()));
List<Integer> results = new ArrayList<>(8);
@@ -95,7 +91,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
terminate(executor);
}
- @Test
public void testExecutePrioritizedExecutorWithRunnables() throws Exception {
ExecutorService executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()));
List<Integer> results = new ArrayList<>(8);
@@ -125,7 +120,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
terminate(executor);
}
- @Test
public void testSubmitPrioritizedExecutorWithCallables() throws Exception {
ExecutorService executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()));
List<Integer> results = new ArrayList<>(8);
@@ -155,7 +149,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
terminate(executor);
}
- @Test
public void testSubmitPrioritizedExecutorWithMixed() throws Exception {
ExecutorService executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()));
List<Integer> results = new ArrayList<>(8);
@@ -185,7 +178,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
terminate(executor);
}
- @Test
public void testTimeout() throws Exception {
ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(EsExecutors.daemonThreadFactory(getTestName()));
PrioritizedEsThreadPoolExecutor executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()));
@@ -247,7 +239,6 @@ public class PrioritizedExecutorsTests extends ESTestCase {
assertTrue(terminate(timer, executor));
}
- @Test
public void testTimeoutCleanup() throws Exception {
ThreadPool threadPool = new ThreadPool("test");
final ScheduledThreadPoolExecutor timer = (ScheduledThreadPoolExecutor) threadPool.scheduler();
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
index 9b01b785f2..9338beccb9 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.common.util.concurrent;
import org.apache.lucene.store.AlreadyClosedException;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -34,8 +33,6 @@ import static org.hamcrest.Matchers.is;
/**
*/
public class RefCountedTests extends ESTestCase {
-
- @Test
public void testRefCount() throws IOException {
MyRefCounted counted = new MyRefCounted();
@@ -87,7 +84,6 @@ public class RefCountedTests extends ESTestCase {
}
}
- @Test
public void testMultiThreaded() throws InterruptedException {
final MyRefCounted counted = new MyRefCounted();
Thread[] threads = new Thread[randomIntBetween(2, 5)];
diff --git a/core/src/test/java/org/elasticsearch/common/util/iterable/IterablesTests.java b/core/src/test/java/org/elasticsearch/common/util/iterable/IterablesTests.java
index 76fc51d8b6..5ce816927c 100644
--- a/core/src/test/java/org/elasticsearch/common/util/iterable/IterablesTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/iterable/IterablesTests.java
@@ -20,17 +20,12 @@
package org.elasticsearch.common.util.iterable;
import org.elasticsearch.test.ESTestCase;
-import org.hamcrest.Matchers;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.List;
import java.util.NoSuchElementException;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.object.HasToString.hasToString;
-import static org.junit.Assert.*;
public class IterablesTests extends ESTestCase {
public void testGetOverList() {
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/XContentFactoryTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/XContentFactoryTests.java
index 0f803509bc..fb12c7508c 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/XContentFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/XContentFactoryTests.java
@@ -21,10 +21,10 @@ package org.elasticsearch.common.xcontent;
import com.fasterxml.jackson.dataformat.cbor.CBORConstants;
import com.fasterxml.jackson.dataformat.smile.SmileConstants;
+
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -35,24 +35,18 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class XContentFactoryTests extends ESTestCase {
-
-
- @Test
public void testGuessJson() throws IOException {
testGuessType(XContentType.JSON);
}
- @Test
public void testGuessSmile() throws IOException {
testGuessType(XContentType.SMILE);
}
- @Test
public void testGuessYaml() throws IOException {
testGuessType(XContentType.YAML);
}
- @Test
public void testGuessCbor() throws IOException {
testGuessType(XContentType.CBOR);
}
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java
index 9cfedcc1cf..9bb26b635e 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java
@@ -25,34 +25,27 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
public class BuilderRawFieldTests extends ESTestCase {
-
- @Test
public void testJsonRawField() throws IOException {
testRawField(XContentType.JSON);
}
- @Test
public void testSmileRawField() throws IOException {
testRawField(XContentType.SMILE);
}
- @Test
public void testYamlRawField() throws IOException {
testRawField(XContentType.YAML);
}
- @Test
public void testCborRawField() throws IOException {
testRawField(XContentType.CBOR);
}
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
index 4ce1a7c463..d6cec176fc 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.common.xcontent.XContentGenerator;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
@@ -54,8 +53,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class XContentBuilderTests extends ESTestCase {
-
- @Test
public void testPrettyWithLfAtEnd() throws Exception {
FastCharArrayWriter writer = new FastCharArrayWriter();
XContentGenerator generator = XContentFactory.xContent(XContentType.JSON).createGenerator(writer);
@@ -74,8 +71,7 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(writer.unsafeCharArray()[writer.size() - 1], equalTo('\n'));
}
- @Test
- public void verifyReuseJsonGenerator() throws Exception {
+ public void testReuseJsonGenerator() throws Exception {
FastCharArrayWriter writer = new FastCharArrayWriter();
XContentGenerator generator = XContentFactory.xContent(XContentType.JSON).createGenerator(writer);
generator.writeStartObject();
@@ -95,7 +91,6 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(writer.toStringTrim(), equalTo("{\"test\":\"value\"}"));
}
- @Test
public void testRaw() throws IOException {
{
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON);
@@ -141,7 +136,6 @@ public class XContentBuilderTests extends ESTestCase {
}
}
- @Test
public void testSimpleGenerator() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject().field("test", "value").endObject();
@@ -152,14 +146,12 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(builder.string(), equalTo("{\"test\":\"value\"}"));
}
- @Test
public void testOverloadedList() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject().field("test", Arrays.asList("1", "2")).endObject();
assertThat(builder.string(), equalTo("{\"test\":[\"1\",\"2\"]}"));
}
- @Test
public void testWritingBinaryToStream() throws Exception {
BytesStreamOutput bos = new BytesStreamOutput();
@@ -177,7 +169,6 @@ public class XContentBuilderTests extends ESTestCase {
System.out.println("DATA: " + sData);
}
- @Test
public void testFieldCaseConversion() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).fieldCaseConversion(CAMELCASE);
builder.startObject().field("test_name", "value").endObject();
@@ -188,14 +179,12 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(builder.string(), equalTo("{\"test_name\":\"value\"}"));
}
- @Test
public void testByteConversion() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject().field("test_name", (Byte)(byte)120).endObject();
assertThat(builder.bytes().toUtf8(), equalTo("{\"test_name\":120}"));
}
- @Test
public void testDateTypesConversion() throws Exception {
Date date = new Date();
String expectedDate = XContentBuilder.defaultDatePrinter.print(date.getTime());
@@ -222,7 +211,6 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(builder.string(), equalTo("{\"calendar\":\"" + expectedCalendar + "\"}"));
}
- @Test
public void testCopyCurrentStructure() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject()
@@ -277,19 +265,16 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(i, equalTo(terms.size()));
}
- @Test
public void testHandlingOfPath() throws IOException {
Path path = PathUtils.get("path");
checkPathSerialization(path);
}
- @Test
public void testHandlingOfPath_relative() throws IOException {
Path path = PathUtils.get("..", "..", "path");
checkPathSerialization(path);
}
- @Test
public void testHandlingOfPath_absolute() throws IOException {
Path path = createTempDir().toAbsolutePath();
checkPathSerialization(path);
@@ -305,7 +290,6 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(pathBuilder.string(), equalTo(stringBuilder.string()));
}
- @Test
public void testHandlingOfPath_XContentBuilderStringName() throws IOException {
Path path = PathUtils.get("path");
XContentBuilderString name = new XContentBuilderString("file");
@@ -319,7 +303,6 @@ public class XContentBuilderTests extends ESTestCase {
assertThat(pathBuilder.string(), equalTo(stringBuilder.string()));
}
- @Test
public void testHandlingOfCollectionOfPaths() throws IOException {
Path path = PathUtils.get("path");
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/cbor/CborXContentParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/cbor/CborXContentParserTests.java
index 20e4d4163b..173a58cff8 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/cbor/CborXContentParserTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/cbor/CborXContentParserTests.java
@@ -24,13 +24,10 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
public class CborXContentParserTests extends ESTestCase {
-
- @Test
public void testEmptyValue() throws IOException {
BytesReference ref = XContentFactory.cborBuilder().startObject().field("field", "").endObject().bytes();
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/cbor/JsonVsCborTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/cbor/JsonVsCborTests.java
index 903914bc5f..bf2dd442b6 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/cbor/JsonVsCborTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/cbor/JsonVsCborTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentGenerator;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -36,9 +35,7 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class JsonVsCborTests extends ESTestCase {
-
- @Test
- public void compareParsingTokens() throws IOException {
+ public void testCompareParsingTokens() throws IOException {
BytesStreamOutput xsonOs = new BytesStreamOutput();
XContentGenerator xsonGen = XContentFactory.xContent(XContentType.CBOR).createGenerator(xsonOs);
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java
index e1a89ff242..9e686fe78f 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java
@@ -25,11 +25,9 @@ import org.elasticsearch.common.xcontent.XContentGenerator;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@@ -37,18 +35,7 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class JsonVsSmileTests extends ESTestCase {
-
-// @Test public void testBinarySmileField() throws Exception {
-// JsonGenerator gen = new SmileFactory().createJsonGenerator(new ByteArrayOutputStream());
-//// JsonGenerator gen = new JsonFactory().createJsonGenerator(new ByteArrayOutputStream(), JsonEncoding.UTF8);
-// gen.writeStartObject();
-// gen.writeFieldName("field1");
-// gen.writeBinary(new byte[]{1, 2, 3});
-// gen.writeEndObject();
-// }
-
- @Test
- public void compareParsingTokens() throws IOException {
+ public void testCompareParsingTokens() throws IOException {
BytesStreamOutput xsonOs = new BytesStreamOutput();
XContentGenerator xsonGen = XContentFactory.xContent(XContentType.SMILE).createGenerator(xsonOs);
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentHelperTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentHelperTests.java
index 067c553828..a8091fc112 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentHelperTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentHelperTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.common.xcontent.support;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -51,9 +50,7 @@ public class XContentHelperTests extends ESTestCase {
return Arrays.asList(values);
}
- @Test
public void testMergingListValuesAreMapsOfOne() {
-
Map<String, Object> defaults = getMap("test", getList(getNamedMap("name1", "t1", "1"), getNamedMap("name2", "t2", "2")));
Map<String, Object> content = getMap("test", getList(getNamedMap("name2", "t3", "3"), getNamedMap("name4", "t4", "4")));
Map<String, Object> expected = getMap("test",
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java
index abce42b623..1c4ff9874a 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -48,8 +47,6 @@ import static org.hamcrest.core.IsEqual.equalTo;
/**
*/
public class XContentMapValuesTests extends ESTestCase {
-
- @Test
public void testFilter() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.field("test1", "value1")
@@ -106,7 +103,6 @@ public class XContentMapValuesTests extends ESTestCase {
}
@SuppressWarnings({"unchecked"})
- @Test
public void testExtractValue() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.field("test", "value")
@@ -196,8 +192,6 @@ public class XContentMapValuesTests extends ESTestCase {
assertThat(XContentMapValues.extractValue("path1.xxx.path2.yyy.test", map).toString(), equalTo("value"));
}
- @SuppressWarnings({"unchecked"})
- @Test
public void testExtractRawValue() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.field("test", "value")
@@ -237,8 +231,7 @@ public class XContentMapValuesTests extends ESTestCase {
assertThat(XContentMapValues.extractRawValues("path1.xxx.path2.yyy.test", map).get(0).toString(), equalTo("value"));
}
- @Test
- public void prefixedNamesFilteringTest() {
+ public void testPrefixedNamesFilteringTest() {
Map<String, Object> map = new HashMap<>();
map.put("obj", "value");
map.put("obj_name", "value_name");
@@ -248,9 +241,8 @@ public class XContentMapValuesTests extends ESTestCase {
}
- @Test
@SuppressWarnings("unchecked")
- public void nestedFilteringTest() {
+ public void testNestedFiltering() {
Map<String, Object> map = new HashMap<>();
map.put("field", "value");
map.put("array",
@@ -295,8 +287,7 @@ public class XContentMapValuesTests extends ESTestCase {
}
@SuppressWarnings("unchecked")
- @Test
- public void completeObjectFilteringTest() {
+ public void testCompleteObjectFiltering() {
Map<String, Object> map = new HashMap<>();
map.put("field", "value");
map.put("obj",
@@ -340,8 +331,7 @@ public class XContentMapValuesTests extends ESTestCase {
}
@SuppressWarnings("unchecked")
- @Test
- public void filterIncludesUsingStarPrefix() {
+ public void testFilterIncludesUsingStarPrefix() {
Map<String, Object> map = new HashMap<>();
map.put("field", "value");
map.put("obj",
@@ -382,8 +372,7 @@ public class XContentMapValuesTests extends ESTestCase {
}
- @Test
- public void filterWithEmptyIncludesExcludes() {
+ public void testFilterWithEmptyIncludesExcludes() {
Map<String, Object> map = new HashMap<>();
map.put("field", "value");
Map<String, Object> filteredMap = XContentMapValues.filter(map, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY);
@@ -392,8 +381,6 @@ public class XContentMapValuesTests extends ESTestCase {
}
- @SuppressWarnings({"unchecked"})
- @Test
public void testThatFilterIncludesEmptyObjectWhenUsingIncludes() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.startObject("obj")
@@ -406,7 +393,6 @@ public class XContentMapValuesTests extends ESTestCase {
assertThat(mapTuple.v2(), equalTo(filteredSource));
}
- @Test
public void testThatFilterIncludesEmptyObjectWhenUsingExcludes() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.startObject("obj")
@@ -419,7 +405,6 @@ public class XContentMapValuesTests extends ESTestCase {
assertThat(mapTuple.v2(), equalTo(filteredSource));
}
- @Test
public void testNotOmittingObjectsWithExcludedProperties() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.startObject("obj")
@@ -436,7 +421,6 @@ public class XContentMapValuesTests extends ESTestCase {
}
@SuppressWarnings({"unchecked"})
- @Test
public void testNotOmittingObjectWithNestedExcludedObject() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.startObject("obj1")
@@ -470,7 +454,6 @@ public class XContentMapValuesTests extends ESTestCase {
}
@SuppressWarnings({"unchecked"})
- @Test
public void testIncludingObjectWithNestedIncludedObject() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.startObject("obj1")
@@ -568,5 +551,4 @@ public class XContentMapValuesTests extends ESTestCase {
parser.list());
}
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/AbstractFilteringJsonGeneratorTestCase.java b/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/AbstractFilteringJsonGeneratorTestCase.java
index 9669b0992d..8073468ce8 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/AbstractFilteringJsonGeneratorTestCase.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/AbstractFilteringJsonGeneratorTestCase.java
@@ -20,9 +20,12 @@
package org.elasticsearch.common.xcontent.support.filtering;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.XContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -170,7 +173,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
return sample(newXContentBuilder(filters));
}
- @Test
public void testNoFiltering() throws Exception {
XContentBuilder expected = sample();
@@ -179,23 +181,18 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("**"));
}
- @Test
public void testNoMatch() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject().endObject();
assertXContentBuilder(expected, sample("xyz"));
}
- @Test
public void testSimpleField() throws Exception {
- XContentBuilder expected = newXContentBuilder().startObject()
- .field("title", "My awesome book")
- .endObject();
+ XContentBuilder expected = newXContentBuilder().startObject().field("title", "My awesome book").endObject();
assertXContentBuilder(expected, sample("title"));
}
- @Test
public void testSimpleFieldWithWildcard() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.field("price", 27.99)
@@ -252,7 +249,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("pr*"));
}
- @Test
public void testMultipleFields() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.field("title", "My awesome book")
@@ -262,7 +258,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("title", "pages"));
}
- @Test
public void testSimpleArray() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startArray("tags")
@@ -274,7 +269,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("tags"));
}
- @Test
public void testSimpleArrayOfObjects() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startArray("authors")
@@ -296,7 +290,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("authors.*name"));
}
- @Test
public void testSimpleArrayOfObjectsProperty() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startArray("authors")
@@ -313,7 +306,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("authors.l*"));
}
- @Test
public void testRecurseField1() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startArray("authors")
@@ -366,7 +358,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("**.name"));
}
- @Test
public void testRecurseField2() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startObject("properties")
@@ -411,7 +402,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("properties.**.name"));
}
- @Test
public void testRecurseField3() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startObject("properties")
@@ -441,7 +431,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("properties.*.en.**.name"));
}
- @Test
public void testRecurseField4() throws Exception {
XContentBuilder expected = newXContentBuilder().startObject()
.startObject("properties")
@@ -473,7 +462,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expected, sample("properties.**.distributors.name"));
}
- @Test
public void testRawField() throws Exception {
XContentBuilder expectedRawField = newXContentBuilder().startObject().field("foo", 0).startObject("raw").field("content", "hello world!").endObject().endObject();
@@ -498,7 +486,6 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
assertXContentBuilder(expectedRawFieldNotFiltered, newXContentBuilder("r*").startObject().field("foo", 0).rawField("raw", new ByteArrayInputStream(raw.toBytes())).endObject());
}
- @Test
public void testArrays() throws Exception {
// Test: Array of values (no filtering)
XContentBuilder expected = newXContentBuilder().startObject().startArray("tags").value("lorem").value("ipsum").value("dolor").endArray().endObject();
@@ -519,6 +506,5 @@ public abstract class AbstractFilteringJsonGeneratorTestCase extends ESTestCase
// Test: Array of objects (with partial filtering)
expected = newXContentBuilder().startObject().startArray("tags").startObject().field("firstname", "ipsum").endObject().endArray().endObject();
assertXContentBuilder(expected, newXContentBuilder("t*.firstname").startObject().startArray("tags").startObject().field("lastname", "lorem").endObject().startObject().field("firstname", "ipsum").endObject().endArray().endObject());
-
}
}
diff --git a/core/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelIT.java b/core/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelIT.java
index 50637cb801..bb08cd0468 100644
--- a/core/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelIT.java
+++ b/core/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
@@ -37,9 +36,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class WriteConsistencyLevelIT extends ESIntegTestCase {
-
-
- @Test
public void testWriteConsistencyLevelReplication2() throws Exception {
prepareCreate("test", 1, Settings.settingsBuilder().put("index.number_of_shards", 1).put("index.number_of_replicas", 2)).execute().actionGet();
@@ -68,7 +64,7 @@ public class WriteConsistencyLevelIT extends ESIntegTestCase {
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
- // this should work, since we now have
+ // this should work, since we now have
client().prepareIndex("test", "type1", "1").setSource(source("1", "test"))
.setConsistencyLevel(WriteConsistencyLevel.QUORUM)
.setTimeout(timeValueSeconds(1)).execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java b/core/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java
index 92e68cec43..8e44c7a544 100644
--- a/core/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java
+++ b/core/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java
@@ -23,21 +23,18 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
+
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
public class JacksonLocationTests extends ESTestCase {
-
- @Test
public void testLocationExtraction() throws IOException {
// {
// "index" : "test",
diff --git a/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java b/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java
index b1bddc1c54..bb531c41da 100644
--- a/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java
+++ b/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java
@@ -28,20 +28,24 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import org.joda.time.MutableDateTime;
-import org.joda.time.format.*;
-import org.junit.Test;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.DateTimeFormatterBuilder;
+import org.joda.time.format.DateTimeParser;
+import org.joda.time.format.ISODateTimeFormat;
import java.util.Date;
import java.util.Locale;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
/**
*
*/
public class SimpleJodaTests extends ESTestCase {
-
- @Test
public void testMultiParsers() {
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
DateTimeParser[] parsers = new DateTimeParser[3];
@@ -55,7 +59,6 @@ public class SimpleJodaTests extends ESTestCase {
formatter.parseMillis("2009-11-15 14:12:12");
}
- @Test
public void testIsoDateFormatDateTimeNoMillisUTC() {
DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC);
long millis = formatter.parseMillis("1970-01-01T00:00:00Z");
@@ -63,7 +66,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(millis, equalTo(0l));
}
- @Test
public void testUpperBound() {
MutableDateTime dateTime = new MutableDateTime(3000, 12, 31, 23, 59, 59, 999, DateTimeZone.UTC);
DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC);
@@ -74,7 +76,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(dateTime.toString(), equalTo("2000-01-01T23:59:59.999Z"));
}
- @Test
public void testIsoDateFormatDateOptionalTimeUTC() {
DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC);
long millis = formatter.parseMillis("1970-01-01T00:00:00Z");
@@ -105,7 +106,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(millis, equalTo(TimeValue.timeValueHours(2).millis()));
}
- @Test
public void testIsoVsCustom() {
DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC);
long millis = formatter.parseMillis("1970-01-01T00:00:00");
@@ -120,7 +120,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(millis, equalTo(0l));
}
- @Test
public void testWriteAndParse() {
DateTimeFormatter dateTimeWriter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC);
@@ -128,7 +127,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(formatter.parseMillis(dateTimeWriter.print(date.getTime())), equalTo(date.getTime()));
}
- @Test
public void testSlashInFormat() {
FormatDateTimeFormatter formatter = Joda.forPattern("MM/yyyy");
formatter.parser().parseMillis("01/2001");
@@ -145,14 +143,12 @@ public class SimpleJodaTests extends ESTestCase {
}
}
- @Test
public void testMultipleFormats() {
FormatDateTimeFormatter formatter = Joda.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd");
long millis = formatter.parser().parseMillis("1970/01/01 00:00:00");
assertThat("1970/01/01 00:00:00", is(formatter.printer().print(millis)));
}
- @Test
public void testMultipleDifferentFormats() {
FormatDateTimeFormatter formatter = Joda.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd");
String input = "1970/01/01 00:00:00";
@@ -166,7 +162,6 @@ public class SimpleJodaTests extends ESTestCase {
Joda.forPattern(" date_time || date_time_no_millis");
}
- @Test
public void testInvalidPatterns() {
expectInvalidPattern("does_not_exist_pattern", "Invalid format: [does_not_exist_pattern]: Illegal pattern component: o");
expectInvalidPattern("OOOOO", "Invalid format: [OOOOO]: Illegal pattern component: OOOOO");
@@ -186,7 +181,6 @@ public class SimpleJodaTests extends ESTestCase {
}
}
- @Test
public void testRounding() {
long TIME = utcTimeInMillis("2009-02-03T01:01:01");
MutableDateTime time = new MutableDateTime(DateTimeZone.UTC);
@@ -198,7 +192,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(time.dayOfMonth().roundFloor().toString(), equalTo("2009-02-03T00:00:00.000Z"));
}
- @Test
public void testRoundingSetOnTime() {
MutableDateTime time = new MutableDateTime(DateTimeZone.UTC);
time.setRounding(time.getChronology().monthOfYear(), MutableDateTime.ROUND_FLOOR);
@@ -227,7 +220,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(time.getMillis(), equalTo(utcTimeInMillis("2011-05-02T00:00:00.000Z")));
}
- @Test
public void testRoundingWithTimeZone() {
MutableDateTime time = new MutableDateTime(DateTimeZone.UTC);
time.setZone(DateTimeZone.forOffsetHours(-2));
@@ -252,7 +244,6 @@ public class SimpleJodaTests extends ESTestCase {
assertThat(time.getMillis(), equalTo(utcTime.getMillis() - TimeValue.timeValueHours(22).millis()));
}
- @Test
public void testThatEpochsCanBeParsed() {
boolean parseMilliSeconds = randomBoolean();
@@ -274,7 +265,6 @@ public class SimpleJodaTests extends ESTestCase {
}
}
- @Test
public void testThatNegativeEpochsCanBeParsed() {
// problem: negative epochs can be arbitrary in size...
boolean parseMilliSeconds = randomBoolean();
@@ -305,16 +295,24 @@ public class SimpleJodaTests extends ESTestCase {
}
}
- @Test(expected = IllegalArgumentException.class)
public void testForInvalidDatesInEpochSecond() {
FormatDateTimeFormatter formatter = Joda.forPattern("epoch_second");
- formatter.parser().parseDateTime(randomFrom("invalid date", "12345678901", "12345678901234"));
+ try {
+ formatter.parser().parseDateTime(randomFrom("invalid date", "12345678901", "12345678901234"));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("Invalid format"));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testForInvalidDatesInEpochMillis() {
FormatDateTimeFormatter formatter = Joda.forPattern("epoch_millis");
- formatter.parser().parseDateTime(randomFrom("invalid date", "12345678901234"));
+ try {
+ formatter.parser().parseDateTime(randomFrom("invalid date", "12345678901234"));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("Invalid format"));
+ }
}
public void testThatEpochParserIsPrinter() {
@@ -670,7 +668,6 @@ public class SimpleJodaTests extends ESTestCase {
assertDateFormatParsingThrowingException("strictYearMonthDay", "2014-05-5");
}
- @Test
public void testThatRootObjectParsingIsStrict() throws Exception {
String[] datesThatWork = new String[] { "2014/10/10", "2014/10/10 12:12:12", "2014-05-05", "2014-05-05T12:12:12.123Z" };
String[] datesThatShouldNotWork = new String[]{ "5-05-05", "2014-5-05", "2014-05-5",
diff --git a/core/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java b/core/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java
index 77fd17eec8..9c702acb2c 100644
--- a/core/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java
+++ b/core/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java
@@ -19,9 +19,34 @@
package org.elasticsearch.deps.lucene;
-import org.apache.lucene.document.*;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.SortedDocValuesField;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.index.PostingsEnum;
+import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.index.StoredFieldVisitor;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.FieldDoc;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
@@ -29,7 +54,6 @@ import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.NumericUtils;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -40,8 +64,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class SimpleLuceneTests extends ESTestCase {
-
- @Test
public void testSortValues() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -61,7 +83,6 @@ public class SimpleLuceneTests extends ESTestCase {
}
}
- @Test
public void testSimpleNumericOps() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -93,7 +114,6 @@ public class SimpleLuceneTests extends ESTestCase {
* of the field. This means that heavily accessed fields that use field selector should be added
* first (with load and break).
*/
- @Test
public void testOrdering() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -122,7 +142,6 @@ public class SimpleLuceneTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testBoost() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -157,7 +176,6 @@ public class SimpleLuceneTests extends ESTestCase {
indexWriter.close();
}
- @Test
public void testNRTSearchOnClosedWriter() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -182,7 +200,6 @@ public class SimpleLuceneTests extends ESTestCase {
* A test just to verify that term freqs are not stored for numeric fields. <tt>int1</tt> is not storing termFreq
* and <tt>int2</tt> does.
*/
- @Test
public void testNumericTermDocsFreqs() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
diff --git a/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java b/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
index 0e0ff0f84e..66dc054267 100644
--- a/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
+++ b/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
@@ -22,25 +22,31 @@ package org.elasticsearch.deps.lucene;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.PrefixQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.vectorhighlight.CustomFieldQuery;
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class VectorHighlighterTests extends ESTestCase {
-
- @Test
public void testVectorHighlighter() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -63,7 +69,6 @@ public class VectorHighlighterTests extends ESTestCase {
assertThat(fragment, equalTo("the big <b>bad</b> dog"));
}
- @Test
public void testVectorHighlighterPrefixQuery() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -101,7 +106,6 @@ public class VectorHighlighterTests extends ESTestCase {
assertThat(fragment, notNullValue());
}
- @Test
public void testVectorHighlighterNoStore() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
@@ -123,7 +127,6 @@ public class VectorHighlighterTests extends ESTestCase {
assertThat(fragment, nullValue());
}
- @Test
public void testVectorHighlighterNoTermVector() throws Exception {
Directory dir = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
index ded7d9d9af..d44e27ce71 100644
--- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
@@ -25,7 +25,11 @@ import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
-import org.elasticsearch.cluster.*;
+import org.elasticsearch.cluster.ClusterChangedEvent;
+import org.elasticsearch.cluster.ClusterService;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.ClusterStateListener;
+import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -51,9 +55,20 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.store.IndicesStoreIntegrationIT;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
-import org.elasticsearch.test.disruption.*;
+import org.elasticsearch.test.disruption.BlockClusterStateProcessing;
+import org.elasticsearch.test.disruption.IntermittentLongGCDisruption;
+import org.elasticsearch.test.disruption.LongGCDisruption;
+import org.elasticsearch.test.disruption.NetworkDelaysPartition;
+import org.elasticsearch.test.disruption.NetworkDisconnectPartition;
+import org.elasticsearch.test.disruption.NetworkPartition;
+import org.elasticsearch.test.disruption.NetworkUnresponsivePartition;
+import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
+import org.elasticsearch.test.disruption.SingleNodeDisruption;
+import org.elasticsearch.test.disruption.SlowClusterStateProcessing;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.TransportException;
@@ -61,20 +76,33 @@ import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
@ESIntegTestCase.SuppressLocalMode
@@ -170,9 +198,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
/**
* Test that no split brain occurs under partial network partition. See https://github.com/elasticsearch/elasticsearch/issues/2488
*/
- @Test
- public void failWithMinimumMasterNodesConfigured() throws Exception {
-
+ public void testFailWithMinimumMasterNodesConfigured() throws Exception {
List<String> nodes = startCluster(3);
// Figure out what is the elected master node
@@ -213,7 +239,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
/**
* Verify that nodes fault detection works after master (re) election
*/
- @Test
public void testNodesFDAfterMasterReelection() throws Exception {
startCluster(4);
@@ -244,7 +269,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
/**
* Verify that the proper block is applied when nodes loose their master
*/
- @Test
public void testVerifyApiBlocksDuringPartition() throws Exception {
startCluster(3);
@@ -326,7 +350,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* This test isolates the master from rest of the cluster, waits for a new master to be elected, restores the partition
* and verifies that all node agree on the new cluster state
*/
- @Test
public void testIsolateMasterAndVerifyClusterStateConsensus() throws Exception {
final List<String> nodes = startCluster(3);
@@ -394,7 +417,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* <p>
* This test is a superset of tests run in the Jepsen test suite, with the exception of versioned updates
*/
- @Test
// NOTE: if you remove the awaitFix, make sure to port the test to the 1.x branch
@LuceneTestCase.AwaitsFix(bugUrl = "needs some more work to stabilize")
@TestLogging("action.index:TRACE,action.get:TRACE,discovery:TRACE,cluster.service:TRACE,indices.recovery:TRACE,indices.cluster:TRACE")
@@ -530,7 +552,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
/**
* Test that cluster recovers from a long GC on master that causes other nodes to elect a new one
*/
- @Test
public void testMasterNodeGCs() throws Exception {
List<String> nodes = startCluster(3, -1);
@@ -572,7 +593,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* that already are following another elected master node. These nodes should reject this cluster state and prevent
* them from following the stale master.
*/
- @Test
public void testStaleMasterNotHijackingMajority() throws Exception {
// 3 node cluster with unicast discovery and minimum_master_nodes set to 2:
final List<String> nodes = startCluster(3, 2);
@@ -682,7 +702,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* Test that a document which is indexed on the majority side of a partition, is available from the minority side,
* once the partition is healed
*/
- @Test
@TestLogging(value = "cluster.service:TRACE")
public void testRejoinDocumentExistsInAllShardCopies() throws Exception {
List<String> nodes = startCluster(3);
@@ -738,8 +757,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* The temporal unicast responses is empty. When partition is solved the one ping response contains a master node.
* The rejoining node should take this master node and connect.
*/
- @Test
- public void unicastSinglePingResponseContainsMaster() throws Exception {
+ public void testUnicastSinglePingResponseContainsMaster() throws Exception {
List<String> nodes = startCluster(4, -1, new int[]{0});
// Figure out what is the elected master node
final String masterNode = internalCluster().getMasterName();
@@ -774,9 +792,8 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
assertMaster(masterNode, nodes);
}
- @Test
@TestLogging("discovery.zen:TRACE,cluster.service:TRACE")
- public void isolatedUnicastNodes() throws Exception {
+ public void testIsolatedUnicastNodes() throws Exception {
List<String> nodes = startCluster(4, -1, new int[]{0});
// Figure out what is the elected master node
final String unicastTarget = nodes.get(0);
@@ -814,7 +831,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
/**
* Test cluster join with issues in cluster state publishing *
*/
- @Test
public void testClusterJoinDespiteOfPublishingIssues() throws Exception {
List<String> nodes = startCluster(2, 1);
@@ -867,8 +883,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
internalCluster().stopRandomNonMasterNode();
}
-
- @Test
public void testClusterFormingWithASlowNode() throws Exception {
configureUnicastCluster(3, null, 2);
@@ -894,7 +908,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* sure that the node is removed form the cluster, that the node start pinging and that
* the cluster reforms when healed.
*/
- @Test
@TestLogging("discovery.zen:TRACE,action:TRACE")
public void testNodeNotReachableFromMaster() throws Exception {
startCluster(3);
@@ -932,8 +945,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
* This test creates a scenario where a primary shard (0 replicas) relocates and is in POST_RECOVERY on the target
* node but already deleted on the source node. Search request should still work.
*/
- @Test
- public void searchWithRelocationAndSlowClusterStateProcessing() throws Exception {
+ public void testSearchWithRelocationAndSlowClusterStateProcessing() throws Exception {
configureUnicastCluster(3, null, 1);
InternalTestCluster.Async<String> masterNodeFuture = internalCluster().startMasterOnlyNodeAsync();
InternalTestCluster.Async<String> node_1Future = internalCluster().startDataOnlyNodeAsync();
@@ -972,7 +984,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
assertThat(client().prepareSearch().setSize(0).get().getHits().totalHits(), equalTo(100l));
}
- @Test
public void testIndexImportedFromDataOnlyNodesIfMasterLostDataFolder() throws Exception {
// test for https://github.com/elastic/elasticsearch/issues/8823
configureUnicastCluster(2, null, 1);
@@ -997,7 +1008,6 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
// tests if indices are really deleted even if a master transition inbetween
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/11665")
- @Test
public void testIndicesDeleted() throws Exception {
configureUnicastCluster(3, null, 2);
InternalTestCluster.Async<List<String>> masterNodes= internalCluster().startMasterOnlyNodesAsync(2);
diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
index 9d1ce5c2af..d9a75b297a 100644
--- a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
@@ -39,7 +39,6 @@ import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -48,7 +47,6 @@ import static java.util.Collections.emptyMap;
import static org.hamcrest.Matchers.equalTo;
public class ZenFaultDetectionTests extends ESTestCase {
-
protected ThreadPool threadPool;
protected static final Version version0 = Version.fromId(/*0*/99);
@@ -129,7 +127,6 @@ public class ZenFaultDetectionTests extends ESTestCase {
return builder.build();
}
- @Test
public void testNodesFaultDetectionConnectOnDisconnect() throws InterruptedException {
Settings.Builder settings = Settings.builder();
boolean shouldRetry = randomBoolean();
@@ -178,9 +175,7 @@ public class ZenFaultDetectionTests extends ESTestCase {
assertThat(failureReason[0], matcher);
}
- @Test
public void testMasterFaultDetectionConnectOnDisconnect() throws InterruptedException {
-
Settings.Builder settings = Settings.builder();
boolean shouldRetry = randomBoolean();
// make sure we don't ping
diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java
index ec7d81b040..efbfa80043 100644
--- a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
import org.junit.Before;
-import org.junit.Test;
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -51,7 +50,6 @@ public class ZenUnicastDiscoveryIT extends ESIntegTestCase {
discoveryConfig = null;
}
- @Test
public void testNormalClusterForming() throws ExecutionException, InterruptedException {
int currentNumNodes = randomIntBetween(3, 5);
@@ -74,7 +72,6 @@ public class ZenUnicastDiscoveryIT extends ESIntegTestCase {
}
}
- @Test
// Without the 'include temporalResponses responses to nodesToConnect' improvement in UnicastZenPing#sendPings this
// test fails, because 2 nodes elect themselves as master and the health request times out b/c waiting_for_nodes=N
// can't be satisfied.
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java
index eddc4d9bae..e7bded344d 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java
@@ -25,9 +25,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class ElectMasterServiceTests extends ESTestCase {
@@ -54,8 +57,7 @@ public class ElectMasterServiceTests extends ESTestCase {
return nodes;
}
- @Test
- public void sortByMasterLikelihood() {
+ public void testSortByMasterLikelihood() {
List<DiscoveryNode> nodes = generateRandomNodes();
List<DiscoveryNode> sortedNodes = electMasterService().sortByMasterLikelihood(nodes);
assertEquals(nodes.size(), sortedNodes.size());
@@ -72,8 +74,7 @@ public class ElectMasterServiceTests extends ESTestCase {
}
- @Test
- public void electMaster() {
+ public void testElectMaster() {
List<DiscoveryNode> nodes = generateRandomNodes();
ElectMasterService service = electMasterService();
int min_master_nodes = randomIntBetween(0, nodes.size());
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
index fbe6baab7c..11d94beac1 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
@@ -48,7 +48,6 @@ import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportService;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.net.InetAddress;
@@ -71,8 +70,6 @@ import static org.hamcrest.Matchers.sameInstance;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0)
@ESIntegTestCase.SuppressLocalMode
public class ZenDiscoveryIT extends ESIntegTestCase {
-
- @Test
public void testChangeRejoinOnMasterOptionIsDynamic() throws Exception {
Settings nodeSettings = Settings.settingsBuilder()
.put("discovery.type", "zen") // <-- To override the local setting if set externally
@@ -88,7 +85,6 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
assertThat(zenDiscovery.isRejoinOnMasterGone(), is(false));
}
- @Test
public void testNoShardRelocationsOccurWhenElectedMasterNodeFails() throws Exception {
Settings defaultSettings = Settings.builder()
.put(FaultDetection.SETTING_PING_TIMEOUT, "1s")
@@ -135,7 +131,6 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
assertThat(numRecoveriesAfterNewMaster, equalTo(numRecoveriesBeforeNewMaster));
}
- @Test
@TestLogging(value = "action.admin.cluster.health:TRACE")
public void testNodeFailuresAreProcessedOnce() throws ExecutionException, InterruptedException, IOException {
Settings defaultSettings = Settings.builder()
@@ -180,7 +175,6 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
assertThat(statesFound, Matchers.hasSize(2));
}
- @Test
public void testNodeRejectsClusterStateWithWrongMasterNode() throws Exception {
Settings settings = Settings.builder()
.put("discovery.type", "zen")
@@ -229,7 +223,6 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
assertThat(ExceptionsHelper.detailedMessage(reference.get()), containsString("cluster state from a different master than the current one, rejecting"));
}
- @Test
public void testHandleNodeJoin_incompatibleMinVersion() throws UnknownHostException {
Settings nodeSettings = Settings.settingsBuilder()
.put("discovery.type", "zen") // <-- To override the local setting if set externally
@@ -254,7 +247,6 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
assertThat(holder.get().getMessage(), equalTo("Can't handle join request from a node with a version [1.6.0] that is lower than the minimum compatible version [" + Version.V_2_0_0_beta1.minimumCompatibilityVersion() + "]"));
}
- @Test
public void testJoinElectedMaster_incompatibleMinVersion() {
ElectMasterService electMasterService = new ElectMasterService(Settings.EMPTY, Version.V_2_0_0_beta1);
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java
index e35f8d55c8..82733d9220 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.discovery.zen.ping.ZenPing;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -33,8 +32,6 @@ import java.util.Collections;
import static org.hamcrest.Matchers.equalTo;
public class ZenPingTests extends ESTestCase {
-
- @Test
public void testPingCollection() {
DiscoveryNode[] nodes = new DiscoveryNode[randomIntBetween(1, 30)];
long maxIdPerNode[] = new long[nodes.length];
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java
index 509740ee57..a3b2caca31 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java
@@ -38,15 +38,12 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.netty.NettyTransport;
-import org.junit.Test;
import java.net.InetSocketAddress;
import static org.hamcrest.Matchers.equalTo;
public class UnicastZenPingIT extends ESTestCase {
-
- @Test
public void testSimplePings() throws InterruptedException {
Settings settings = Settings.EMPTY;
int startPort = 11000 + randomIntBetween(0, 1000);
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
index 7bc4ac5d9b..d33aadd84a 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
@@ -21,7 +21,11 @@ package org.elasticsearch.discovery.zen.publish;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
-import org.elasticsearch.cluster.*;
+import org.elasticsearch.cluster.ClusterChangedEvent;
+import org.elasticsearch.cluster.ClusterName;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.ClusterStateListener;
+import org.elasticsearch.cluster.Diff;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
@@ -43,25 +47,38 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.*;
+import org.elasticsearch.transport.BytesTransportRequest;
+import org.elasticsearch.transport.TransportChannel;
+import org.elasticsearch.transport.TransportConnectionListener;
+import org.elasticsearch.transport.TransportResponse;
+import org.elasticsearch.transport.TransportResponseOptions;
+import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.local.LocalTransport;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
@TestLogging("discovery.zen.publish:TRACE")
public class PublishClusterStateActionTests extends ESTestCase {
-
protected ThreadPool threadPool;
protected Map<String, MockNode> nodes = new HashMap<>();
@@ -224,7 +241,6 @@ public class PublishClusterStateActionTests extends ESTestCase {
return new MockPublishAction(settings, transportService, nodesProvider, listener, discoverySettings, ClusterName.DEFAULT);
}
- @Test
public void testSimpleClusterStatePublishing() throws Exception {
MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, Version.CURRENT).setAsMaster();
MockNode nodeB = createMockNode("nodeB", Settings.EMPTY, Version.CURRENT);
@@ -304,9 +320,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
assertSameStateFromFull(nodeC.clusterState, clusterState);
}
- @Test
public void testUnexpectedDiffPublishing() throws Exception {
-
MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, Version.CURRENT, new ClusterStateListener() {
@Override
public void clusterChanged(ClusterChangedEvent event) {
@@ -330,7 +344,6 @@ public class PublishClusterStateActionTests extends ESTestCase {
assertSameStateFromDiff(nodeB.clusterState, clusterState);
}
- @Test
public void testDisablingDiffPublishing() throws Exception {
Settings noDiffPublishingSettings = Settings.builder().put(DiscoverySettings.PUBLISH_DIFF_ENABLE, false).build();
@@ -368,7 +381,6 @@ public class PublishClusterStateActionTests extends ESTestCase {
/**
* Test not waiting on publishing works correctly (i.e., publishing times out)
*/
- @Test
public void testSimultaneousClusterStatePublishing() throws Exception {
int numberOfNodes = randomIntBetween(2, 10);
int numberOfIterations = scaledRandomIntBetween(5, 50);
@@ -416,9 +428,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
}
}
- @Test
public void testSerializationFailureDuringDiffPublishing() throws Exception {
-
MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, Version.CURRENT, new ClusterStateListener() {
@Override
public void clusterChanged(ClusterChangedEvent event) {
diff --git a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java
index 8e8f466f13..7b2690c9c7 100644
--- a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java
+++ b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java
@@ -32,11 +32,13 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.elasticsearch.client.Requests.*;
+import static org.elasticsearch.client.Requests.clearIndicesCacheRequest;
+import static org.elasticsearch.client.Requests.getRequest;
+import static org.elasticsearch.client.Requests.indexRequest;
+import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@@ -46,17 +48,14 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class DocumentActionsIT extends ESIntegTestCase {
-
protected void createIndex() {
createIndex(getConcreteIndexName());
}
-
protected String getConcreteIndexName() {
return "test";
}
- @Test
public void testIndexActions() throws Exception {
createIndex();
NumShards numShards = getNumShards(getConcreteIndexName());
@@ -171,7 +170,6 @@ public class DocumentActionsIT extends ESIntegTestCase {
}
}
- @Test
public void testBulk() throws Exception {
createIndex();
NumShards numShards = getNumShards(getConcreteIndexName());
diff --git a/core/src/test/java/org/elasticsearch/document/ShardInfoIT.java b/core/src/test/java/org/elasticsearch/document/ShardInfoIT.java
index 529b60562b..d4907d8212 100644
--- a/core/src/test/java/org/elasticsearch/document/ShardInfoIT.java
+++ b/core/src/test/java/org/elasticsearch/document/ShardInfoIT.java
@@ -32,7 +32,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -43,11 +42,9 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class ShardInfoIT extends ESIntegTestCase {
-
private int numCopies;
private int numNodes;
- @Test
public void testIndexAndDelete() throws Exception {
prepareIndex(1);
IndexResponse indexResponse = client().prepareIndex("idx", "type").setSource("{}").get();
@@ -56,15 +53,13 @@ public class ShardInfoIT extends ESIntegTestCase {
assertShardInfo(deleteResponse);
}
- @Test
public void testUpdate() throws Exception {
prepareIndex(1);
UpdateResponse updateResponse = client().prepareUpdate("idx", "type", "1").setDoc("{}").setDocAsUpsert(true).get();
assertShardInfo(updateResponse);
}
- @Test
- public void testBulk_withIndexAndDeleteItems() throws Exception {
+ public void testBulkWithIndexAndDeleteItems() throws Exception {
prepareIndex(1);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
for (int i = 0; i < 10; i++) {
@@ -86,8 +81,7 @@ public class ShardInfoIT extends ESIntegTestCase {
}
}
- @Test
- public void testBulk_withUpdateItems() throws Exception {
+ public void testBulkWithUpdateItems() throws Exception {
prepareIndex(1);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
for (int i = 0; i < 10; i++) {
diff --git a/core/src/test/java/org/elasticsearch/env/EnvironmentTests.java b/core/src/test/java/org/elasticsearch/env/EnvironmentTests.java
index 06cf1e2cbf..79f9efbb81 100644
--- a/core/src/test/java/org/elasticsearch/env/EnvironmentTests.java
+++ b/core/src/test/java/org/elasticsearch/env/EnvironmentTests.java
@@ -20,7 +20,6 @@ package org.elasticsearch.env;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.net.URL;
@@ -34,7 +33,6 @@ import static org.hamcrest.CoreMatchers.nullValue;
* Simple unit-tests for Environment.java
*/
public class EnvironmentTests extends ESTestCase {
-
public Environment newEnvironment() throws IOException {
return newEnvironment(Settings.EMPTY);
}
@@ -47,7 +45,6 @@ public class EnvironmentTests extends ESTestCase {
return new Environment(build);
}
- @Test
public void testRepositoryResolution() throws IOException {
Environment environment = newEnvironment();
assertThat(environment.resolveRepoFile("/test/repos/repo1"), nullValue());
diff --git a/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java b/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
index 6b766e5627..6a3145647d 100644
--- a/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
+++ b/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -45,10 +44,8 @@ import static org.hamcrest.CoreMatchers.equalTo;
@LuceneTestCase.SuppressFileSystems("ExtrasFS") // TODO: fix test to allow extras
public class NodeEnvironmentTests extends ESTestCase {
-
private final Settings idxSettings = Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).build();
- @Test
public void testNodeLockSingleEnvironment() throws IOException {
NodeEnvironment env = newNodeEnvironment(Settings.builder()
.put("node.max_local_storage_nodes", 1).build());
@@ -75,7 +72,6 @@ public class NodeEnvironmentTests extends ESTestCase {
}
- @Test
public void testNodeLockMultipleEnvironment() throws IOException {
final NodeEnvironment first = newNodeEnvironment();
String[] dataPaths = first.getSettings().getAsArray("path.data");
@@ -88,7 +84,6 @@ public class NodeEnvironmentTests extends ESTestCase {
IOUtils.close(first, second);
}
- @Test
public void testShardLock() throws IOException {
final NodeEnvironment env = newNodeEnvironment();
@@ -129,7 +124,6 @@ public class NodeEnvironmentTests extends ESTestCase {
env.close();
}
- @Test
public void testGetAllIndices() throws Exception {
final NodeEnvironment env = newNodeEnvironment();
final int numIndices = randomIntBetween(1, 10);
@@ -147,7 +141,6 @@ public class NodeEnvironmentTests extends ESTestCase {
env.close();
}
- @Test
public void testDeleteSafe() throws IOException, InterruptedException {
final NodeEnvironment env = newNodeEnvironment();
ShardLock fooLock = env.shardLock(new ShardId("foo", 0));
@@ -235,7 +228,6 @@ public class NodeEnvironmentTests extends ESTestCase {
env.close();
}
- @Test
public void testStressShardLock() throws IOException, InterruptedException {
class Int {
int value = 0;
@@ -297,7 +289,6 @@ public class NodeEnvironmentTests extends ESTestCase {
env.close();
}
- @Test
public void testCustomDataPaths() throws Exception {
String[] dataPaths = tmpPaths();
NodeEnvironment env = newNodeEnvironment(dataPaths, "/tmp", Settings.EMPTY);
diff --git a/core/src/test/java/org/elasticsearch/exists/SimpleExistsIT.java b/core/src/test/java/org/elasticsearch/exists/SimpleExistsIT.java
index 3046a85be0..7cf41509b9 100644
--- a/core/src/test/java/org/elasticsearch/exists/SimpleExistsIT.java
+++ b/core/src/test/java/org/elasticsearch/exists/SimpleExistsIT.java
@@ -23,16 +23,12 @@ import org.elasticsearch.action.exists.ExistsResponse;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
public class SimpleExistsIT extends ESIntegTestCase {
-
-
- @Test
public void testExistsRandomPreference() throws Exception {
createIndex("test");
indexRandom(true, client().prepareIndex("test", "type", "1").setSource("field", "value"),
@@ -56,9 +52,7 @@ public class SimpleExistsIT extends ESIntegTestCase {
}
}
-
- @Test
- public void simpleIpTests() throws Exception {
+ public void testSimpleIp() throws Exception {
createIndex("test");
client().admin().indices().preparePutMapping("test").setType("type1")
@@ -80,8 +74,7 @@ public class SimpleExistsIT extends ESIntegTestCase {
assertExists(existsResponse, false);
}
- @Test
- public void simpleIdTests() {
+ public void testSimpleId() {
createIndex("test");
client().prepareIndex("test", "type", "XXX1").setSource("field", "value").setRefresh(true).execute().actionGet();
@@ -99,8 +92,7 @@ public class SimpleExistsIT extends ESIntegTestCase {
assertExists(existsResponse, true);
}
- @Test
- public void simpleNonExistenceTests() throws Exception {
+ public void testSimpleNonExistence() throws Exception {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("field", 2).execute().actionGet();
client().prepareIndex("test", "type1", "2").setSource("field", 5).execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java b/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java
index d2b1e6d4e3..54480e02b1 100644
--- a/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java
+++ b/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java
@@ -32,7 +32,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -50,8 +49,6 @@ import static org.hamcrest.Matchers.notNullValue;
/**
*/
public class ExplainActionIT extends ESIntegTestCase {
-
- @Test
public void testSimple() throws Exception {
assertAcked(prepareCreate("test")
.addAlias(new Alias("alias"))
@@ -116,8 +113,6 @@ public class ExplainActionIT extends ESIntegTestCase {
assertThat(response.getId(), equalTo("2"));
}
- @SuppressWarnings("unchecked")
- @Test
public void testExplainWithFields() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen("test");
@@ -177,7 +172,6 @@ public class ExplainActionIT extends ESIntegTestCase {
}
@SuppressWarnings("unchecked")
- @Test
public void testExplainWitSource() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen("test");
@@ -213,7 +207,6 @@ public class ExplainActionIT extends ESIntegTestCase {
assertThat(((Map<String, Object>) response.getGetResult().getSource().get("obj1")).get("field1").toString(), equalTo("value1"));
}
- @Test
public void testExplainWithFilteredAlias() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("test", "field2", "type=string")
@@ -230,7 +223,6 @@ public class ExplainActionIT extends ESIntegTestCase {
assertFalse(response.isMatch());
}
- @Test
public void testExplainWithFilteredAliasFetchSource() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test")
.addMapping("test", "field2", "type=string")
@@ -257,8 +249,7 @@ public class ExplainActionIT extends ESIntegTestCase {
assertThat((String)response.getGetResult().getSource().get("field1"), equalTo("value1"));
}
- @Test
- public void explainDateRangeInQueryString() {
+ public void testExplainDateRangeInQueryString() {
createIndex("test");
String aMonthAgo = ISODateTimeFormat.yearMonthDay().print(new DateTime(DateTimeZone.UTC).minusMonths(1));
@@ -277,10 +268,7 @@ public class ExplainActionIT extends ESIntegTestCase {
return randomBoolean() ? "test" : "alias";
}
-
- @Test
- public void streamExplainTest() throws Exception {
-
+ public void testStreamExplain() throws Exception {
Explanation exp = Explanation.match(2f, "some explanation");
// write
@@ -308,6 +296,5 @@ public class ExplainActionIT extends ESIntegTestCase {
result = Lucene.readExplanation(esBuffer);
assertThat(exp.toString(),equalTo(result.toString()));
-
}
}
diff --git a/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java b/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
index 88f47e7b83..e81db454e0 100644
--- a/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -45,7 +44,6 @@ import static org.hamcrest.Matchers.sameInstance;
/**
*/
public class AsyncShardFetchTests extends ESTestCase {
-
private final DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, Version.CURRENT);
private final Response response1 = new Response(node1);
private final Throwable failure1 = new Throwable("simulated failure 1");
@@ -69,7 +67,6 @@ public class AsyncShardFetchTests extends ESTestCase {
terminate(threadPool);
}
- @Test
public void testClose() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).build();
test.addSimulation(node1.getId(), response1);
@@ -92,8 +89,6 @@ public class AsyncShardFetchTests extends ESTestCase {
}
}
-
- @Test
public void testFullCircleSingleNodeSuccess() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).build();
test.addSimulation(node1.getId(), response1);
@@ -113,7 +108,6 @@ public class AsyncShardFetchTests extends ESTestCase {
assertThat(fetchData.getData().get(node1), sameInstance(response1));
}
- @Test
public void testFullCircleSingleNodeFailure() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).build();
// add a failed response for node1
@@ -146,7 +140,6 @@ public class AsyncShardFetchTests extends ESTestCase {
assertThat(fetchData.getData().get(node1), sameInstance(response1));
}
- @Test
public void testTwoNodesOnSetup() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).put(node2).build();
test.addSimulation(node1.getId(), response1);
@@ -175,7 +168,6 @@ public class AsyncShardFetchTests extends ESTestCase {
assertThat(fetchData.getData().get(node2), sameInstance(response2));
}
- @Test
public void testTwoNodesOnSetupAndFailure() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).put(node2).build();
test.addSimulation(node1.getId(), response1);
@@ -202,7 +194,6 @@ public class AsyncShardFetchTests extends ESTestCase {
assertThat(fetchData.getData().get(node1), sameInstance(response1));
}
- @Test
public void testTwoNodesAddedInBetween() throws Exception {
DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).build();
test.addSimulation(node1.getId(), response1);
diff --git a/core/src/test/java/org/elasticsearch/gateway/DanglingIndicesStateTests.java b/core/src/test/java/org/elasticsearch/gateway/DanglingIndicesStateTests.java
index e9b0e4a89f..6b28b7f789 100644
--- a/core/src/test/java/org/elasticsearch/gateway/DanglingIndicesStateTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/DanglingIndicesStateTests.java
@@ -26,26 +26,22 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
/**
*/
public class DanglingIndicesStateTests extends ESTestCase {
-
private static Settings indexSettings = Settings.builder()
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
- @Test
public void testCleanupWhenEmpty() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(Settings.EMPTY, env);
@@ -58,7 +54,6 @@ public class DanglingIndicesStateTests extends ESTestCase {
}
}
- @Test
public void testDanglingProcessing() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(Settings.EMPTY, env);
@@ -102,7 +97,6 @@ public class DanglingIndicesStateTests extends ESTestCase {
}
}
- @Test
public void testRenameOfIndexState() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(Settings.EMPTY, env);
diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
index 4cc1d61abc..c804239c69 100644
--- a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
@@ -34,12 +34,11 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster.RestartCallback;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.equalTo;
@@ -50,9 +49,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
private final ESLogger logger = Loggers.getLogger(GatewayIndexStateIT.class);
- @Test
public void testMappingMetaDataParsed() throws Exception {
-
logger.info("--> starting 1 nodes");
internalCluster().startNode();
@@ -79,9 +76,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
assertThat(mappingMd.routing().required(), equalTo(true));
}
- @Test
public void testSimpleOpenClose() throws Exception {
-
logger.info("--> starting 2 nodes");
internalCluster().startNodesAsync(2).get();
@@ -181,7 +176,6 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "2").setSource("field1", "value1").execute().actionGet();
}
- @Test
public void testJustMasterNode() throws Exception {
logger.info("--> cleaning nodes");
@@ -206,7 +200,6 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().metaData().hasIndex("test"), equalTo(true));
}
- @Test
public void testJustMasterNodeAndJustDataNode() throws Exception {
logger.info("--> cleaning nodes");
@@ -223,7 +216,6 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
client().prepareIndex("test", "type1").setSource("field1", "value1").setTimeout("100ms").execute().actionGet();
}
- @Test
public void testTwoNodesSingleDoc() throws Exception {
logger.info("--> cleaning nodes");
@@ -263,7 +255,6 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
}
}
- @Test
public void testDanglingIndicesConflictWithAlias() throws Exception {
logger.info("--> starting two nodes");
internalCluster().startNodesAsync(2).get();
@@ -323,7 +314,6 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true));
}
- @Test
public void testDanglingIndices() throws Exception {
logger.info("--> starting two nodes");
diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java
index 62e2e23585..bf7a726758 100644
--- a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.test.ESAllocationTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Iterator;
@@ -191,7 +190,6 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
}
}
- @Test
public void testVersionChangeIsAlwaysWritten() throws Exception {
// test that version changes are always written
boolean initializing = randomBoolean();
@@ -203,7 +201,6 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
assertState(event, stateInMemory, expectMetaData);
}
- @Test
public void testNewShardsAlwaysWritten() throws Exception {
// make sure new shards on data only node always written
boolean initializing = true;
@@ -215,7 +212,6 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
assertState(event, stateInMemory, expectMetaData);
}
- @Test
public void testAllUpToDateNothingWritten() throws Exception {
// make sure state is not written again if we wrote already
boolean initializing = false;
@@ -227,7 +223,6 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
assertState(event, stateInMemory, expectMetaData);
}
- @Test
public void testNoWriteIfNothingChanged() throws Exception {
boolean initializing = false;
boolean versionChanged = false;
@@ -239,7 +234,6 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
assertState(newEventWithNothingChanged, stateInMemory, expectMetaData);
}
- @Test
public void testWriteClosedIndex() throws Exception {
// test that the closing of an index is written also on data only node
boolean masterEligible = randomBoolean();
diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java b/core/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java
index ccb0746101..486092fd40 100644
--- a/core/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java
@@ -24,14 +24,10 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.cluster.NoopClusterService;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
-
public class GatewayServiceTests extends ESTestCase {
-
-
private GatewayService createService(Settings.Builder settings) {
return new GatewayService(Settings.builder()
.put("http.enabled", "false")
@@ -40,9 +36,7 @@ public class GatewayServiceTests extends ESTestCase {
}
- @Test
public void testDefaultRecoverAfterTime() throws IOException {
-
// check that the default is not set
GatewayService service = createService(Settings.builder());
assertNull(service.recoverAfterTime());
diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java
index 0c7566d538..d7f4c9176d 100644
--- a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java
@@ -39,10 +39,9 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
@@ -68,8 +67,6 @@ import static org.hamcrest.Matchers.startsWith;
@LuceneTestCase.SuppressFileSystems("ExtrasFS") // TODO: fix test to work with ExtrasFS
public class MetaDataStateFormatTests extends ESTestCase {
-
-
/**
* Ensure we can read a pre-generated cluster state.
*/
@@ -138,7 +135,6 @@ public class MetaDataStateFormatTests extends ESTestCase {
}
}
- @Test
public void testVersionMismatch() throws IOException {
Path[] dirs = new Path[randomIntBetween(1, 5)];
for (int i = 0; i < dirs.length; i++) {
@@ -208,7 +204,7 @@ public class MetaDataStateFormatTests extends ESTestCase {
long filePointer = raf.position();
ByteBuffer bb = ByteBuffer.wrap(new byte[1]);
raf.read(bb);
-
+
bb.flip();
byte oldValue = bb.get(0);
byte newValue = (byte) ~oldValue;
@@ -315,7 +311,6 @@ public class MetaDataStateFormatTests extends ESTestCase {
assertEquals(state.clusterUUID(), uuid);
}
- @Test
public void testLoadState() throws IOException {
final ToXContent.Params params = ToXContent.EMPTY_PARAMS;
final Path[] dirs = new Path[randomIntBetween(1, 5)];
diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
index 970819d4eb..1c3ec79dd9 100644
--- a/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
@@ -30,23 +30,20 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
-import org.junit.Test;
+import org.elasticsearch.test.InternalTestCluster.RestartCallback;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.InternalTestCluster.RestartCallback;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class MetaDataWriteDataNodesIT extends ESIntegTestCase {
-
- @Test
public void testMetaWrittenAlsoOnDataNode() throws Exception {
// this test checks that index state is written on data only nodes if they have a shard allocated
String masterNode = internalCluster().startMasterOnlyNode(Settings.EMPTY);
@@ -58,7 +55,6 @@ public class MetaDataWriteDataNodesIT extends ESIntegTestCase {
assertIndexInMetaState(masterNode, "test");
}
- @Test
public void testMetaIsRemovedIfAllShardsFromIndexRemoved() throws Exception {
// this test checks that the index state is removed from a data only node once all shards have been allocated away from it
String masterNode = internalCluster().startMasterOnlyNode(Settings.EMPTY);
@@ -84,7 +80,6 @@ public class MetaDataWriteDataNodesIT extends ESIntegTestCase {
assertIndexInMetaState(masterNode, index);
}
- @Test
public void testMetaWrittenWhenIndexIsClosedAndMetaUpdated() throws Exception {
String masterNode = internalCluster().startMasterOnlyNode(Settings.EMPTY);
final String dataNode = internalCluster().startDataOnlyNode(Settings.EMPTY);
diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaStateServiceTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaStateServiceTests.java
index de66f9519c..8bcb9c4540 100644
--- a/core/src/test/java/org/elasticsearch/gateway/MetaStateServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/MetaStateServiceTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@@ -33,14 +32,12 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class MetaStateServiceTests extends ESTestCase {
-
private static Settings indexSettings = Settings.builder()
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
- @Test
public void testWriteLoadIndex() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(randomSettings(), env);
@@ -51,7 +48,6 @@ public class MetaStateServiceTests extends ESTestCase {
}
}
- @Test
public void testLoadMissingIndex() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(randomSettings(), env);
@@ -59,7 +55,6 @@ public class MetaStateServiceTests extends ESTestCase {
}
}
- @Test
public void testWriteLoadGlobal() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(randomSettings(), env);
@@ -72,7 +67,6 @@ public class MetaStateServiceTests extends ESTestCase {
}
}
- @Test
public void testWriteGlobalStateWithIndexAndNoIndexIsLoaded() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(randomSettings(), env);
@@ -89,8 +83,7 @@ public class MetaStateServiceTests extends ESTestCase {
}
}
- @Test
- public void tesLoadGlobal() throws Exception {
+ public void testLoadGlobal() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) {
MetaStateService metaStateService = new MetaStateService(randomSettings(), env);
diff --git a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
index ce6a8b0a6e..2598215034 100644
--- a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
@@ -27,7 +27,13 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.metadata.SnapshotId;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.RestoreSource;
+import org.elasticsearch.cluster.routing.RoutingNodes;
+import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
+import org.elasticsearch.cluster.routing.TestShardRouting;
+import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
import org.elasticsearch.common.Nullable;
@@ -35,7 +41,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@@ -43,7 +48,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
/**
*/
@@ -64,13 +71,11 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Verifies that the canProcess method of primary allocation behaves correctly
* and processes only the applicable shard.
*/
- @Test
public void testNoProcessReplica() {
ShardRouting shard = TestShardRouting.newShardRouting("test", 0, null, null, null, false, ShardRoutingState.UNASSIGNED, 0, new UnassignedInfo(UnassignedInfo.Reason.CLUSTER_RECOVERED, null));
assertThat(testAllocator.needToFindPrimaryCopy(shard), equalTo(false));
}
- @Test
public void testNoProcessPrimayNotAllcoatedBefore() {
ShardRouting shard = TestShardRouting.newShardRouting("test", 0, null, null, null, true, ShardRoutingState.UNASSIGNED, 0, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
assertThat(testAllocator.needToFindPrimaryCopy(shard), equalTo(false));
@@ -79,7 +84,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
/**
* Tests that when async fetch returns that there is no data, the shard will not be allocated.
*/
- @Test
public void testNoAsyncFetchData() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders());
boolean changed = testAllocator.allocateUnassigned(allocation);
@@ -91,7 +95,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
/**
* Tests when the node returns that no data was found for it (-1), it will be moved to ignore unassigned.
*/
- @Test
public void testNoAllocationFound() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders());
testAllocator.addData(node1, -1);
@@ -104,7 +107,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
/**
* Tests when the node returns that no data was found for it (-1), it will be moved to ignore unassigned.
*/
- @Test
public void testStoreException() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders());
testAllocator.addData(node1, 3, new CorruptIndexException("test", "test"));
@@ -117,7 +119,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
/**
* Tests that when there is a node to allocate the shard to, it will be allocated to it.
*/
- @Test
public void testFoundAllocationAndAllocating() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders());
testAllocator.addData(node1, 10);
@@ -132,7 +133,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Tests that when there is a node to allocate to, but it is throttling (and it is the only one),
* it will be moved to ignore unassigned until it can be allocated to.
*/
- @Test
public void testFoundAllocationButThrottlingDecider() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(throttleAllocationDeciders());
testAllocator.addData(node1, 10);
@@ -146,7 +146,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Tests that when there is a node to be allocated to, but it the decider said "no", we still
* force the allocation to it.
*/
- @Test
public void testFoundAllocationButNoDecider() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(noAllocationDeciders());
testAllocator.addData(node1, 10);
@@ -160,7 +159,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
/**
* Tests that the highest version node is chosed for allocation.
*/
- @Test
public void testAllocateToTheHighestVersion() {
RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders());
testAllocator.addData(node1, 10).addData(node2, 12);
@@ -175,7 +173,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Tests that when restoring from snapshot, even if we didn't find any node to allocate on, the shard
* will remain in the unassigned list to be allocated later.
*/
- @Test
public void testRestoreIgnoresNoNodesToAllocate() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder(shardId.getIndex()).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
@@ -199,7 +196,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Tests that only when enough copies of the shard exists we are going to allocate it. This test
* verifies that with same version (1), and quorum allocation.
*/
- @Test
public void testEnoughCopiesFoundForAllocation() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder(shardId.getIndex()).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(2))
@@ -241,7 +237,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
* Tests that only when enough copies of the shard exists we are going to allocate it. This test
* verifies that even with different version, we treat different versions as a copy, and count them.
*/
- @Test
public void testEnoughCopiesFoundForAllocationWithDifferentVersion() {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder(shardId.getIndex()).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(2))
@@ -279,7 +274,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id()));
}
- @Test
public void testAllocationOnAnyNodeWithSharedFs() {
ShardRouting shard = TestShardRouting.newShardRouting("test", 0, null, null, null, false,
ShardRoutingState.UNASSIGNED, 0,
@@ -304,8 +298,6 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
assertThat(nAndV.nodes, contains(node2, node1, node3));
}
-
- @Test
public void testAllocationOnAnyNodeShouldPutNodesWithExceptionsLast() {
ShardRouting shard = TestShardRouting.newShardRouting("test", 0, null, null, null, false,
ShardRoutingState.UNASSIGNED, 0,
diff --git a/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java
index ee8a5206e3..3932101f49 100644
--- a/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java
@@ -26,8 +26,8 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster.RestartCallback;
-import org.junit.Test;
import java.util.concurrent.TimeUnit;
@@ -35,7 +35,6 @@ import static org.elasticsearch.client.Requests.clusterHealthRequest;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@@ -47,13 +46,11 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ClusterScope(numDataNodes =0, scope= Scope.TEST)
public class QuorumGatewayIT extends ESIntegTestCase {
-
@Override
protected int numberOfReplicas() {
return 2;
}
- @Test
public void testChangeInitialShardsRecovery() throws Exception {
logger.info("--> starting 3 nodes");
final String[] nodes = internalCluster().startNodesAsync(3).get().toArray(new String[0]);
@@ -73,7 +70,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
for (int i = 0; i < 10; i++) {
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2l);
}
-
+
final String nodeToRemove = nodes[between(0,2)];
logger.info("--> restarting 1 nodes -- kill 2");
internalCluster().fullRestart(new RestartCallback() {
@@ -81,7 +78,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
public Settings onNodeStopped(String nodeName) throws Exception {
return Settings.EMPTY;
}
-
+
@Override
public boolean doRestart(String nodeName) {
return nodeToRemove.equals(nodeName);
@@ -115,9 +112,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
}
}
- @Test
public void testQuorumRecovery() throws Exception {
-
logger.info("--> starting 3 nodes");
internalCluster().startNodesAsync(3).get();
// we are shutting down nodes - make sure we don't have 2 clusters if we test network
@@ -162,7 +157,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
}
}
}
-
+
});
logger.info("--> all nodes are started back, verifying we got the latest version");
logger.info("--> running cluster_health (wait for the shards to startup)");
diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
index 5766ef30d0..3dd6597a6e 100644
--- a/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.util.Set;
@@ -37,7 +36,6 @@ import static org.hamcrest.Matchers.hasItem;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class RecoverAfterNodesIT extends ESIntegTestCase {
-
private final static TimeValue BLOCK_WAIT_TIMEOUT = TimeValue.timeValueSeconds(10);
public Set<ClusterBlock> waitForNoBlocksOnNode(TimeValue timeout, Client nodeClient) throws InterruptedException {
@@ -56,7 +54,6 @@ public class RecoverAfterNodesIT extends ESIntegTestCase {
return internalCluster().client(name);
}
- @Test
public void testRecoverAfterNodes() throws Exception {
logger.info("--> start node (1)");
Client clientNode1 = startNode(settingsBuilder().put("gateway.recover_after_nodes", 3));
@@ -82,7 +79,6 @@ public class RecoverAfterNodesIT extends ESIntegTestCase {
assertThat(waitForNoBlocksOnNode(BLOCK_WAIT_TIMEOUT, clientNode3).isEmpty(), equalTo(true));
}
- @Test
public void testRecoverAfterMasterNodes() throws Exception {
logger.info("--> start master_node (1)");
Client master1 = startNode(settingsBuilder().put("gateway.recover_after_master_nodes", 2).put("node.data", false).put("node.master", true));
@@ -119,7 +115,6 @@ public class RecoverAfterNodesIT extends ESIntegTestCase {
assertThat(waitForNoBlocksOnNode(BLOCK_WAIT_TIMEOUT, data2).isEmpty(), equalTo(true));
}
- @Test
public void testRecoverAfterDataNodes() throws Exception {
logger.info("--> start master_node (1)");
Client master1 = startNode(settingsBuilder().put("gateway.recover_after_data_nodes", 2).put("node.data", false).put("node.master", true));
diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java
index d55343b1ce..2184fda47c 100644
--- a/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
@@ -40,8 +39,6 @@ import static org.hamcrest.Matchers.greaterThan;
@ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST, numClientNodes = 0, transportClientRatio = 0.0)
public class RecoveryBackwardsCompatibilityIT extends ESBackcompatTestCase {
-
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
@@ -60,7 +57,6 @@ public class RecoveryBackwardsCompatibilityIT extends ESBackcompatTestCase {
return 3;
}
- @Test
public void testReusePeerRecovery() throws Exception {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put(indexSettings())
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
index 46b0fcf13d..665eec83ff 100644
--- a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
@@ -34,10 +34,10 @@ import org.elasticsearch.indices.flush.SyncedFlushUtil;
import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster.RestartCallback;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.store.MockFSDirectoryService;
-import org.junit.Test;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
@@ -45,7 +45,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.equalTo;
@@ -55,8 +54,6 @@ import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(numDataNodes = 0, scope = Scope.TEST)
public class RecoveryFromGatewayIT extends ESIntegTestCase {
-
- @Test
public void testOneNodeRecoverFromGateway() throws Exception {
internalCluster().startNode();
@@ -98,9 +95,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)).execute().actionGet(), 2);
}
- @Test
public void testSingleNodeNoFlush() throws Exception {
-
internalCluster().startNode();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
@@ -183,10 +178,8 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("num", 179)).get(), value1Docs);
}
}
-
- @Test
- public void testSingleNodeWithFlush() throws Exception {
+ public void testSingleNodeWithFlush() throws Exception {
internalCluster().startNode();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).execute().actionGet();
flush();
@@ -217,9 +210,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
}
}
- @Test
public void testTwoNodeFirstNodeCleared() throws Exception {
-
final String firstNode = internalCluster().startNode();
internalCluster().startNode();
@@ -256,7 +247,6 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
}
}
- @Test
public void testLatestVersionLoaded() throws Exception {
// clean two nodes
internalCluster().startNodesAsync(2, settingsBuilder().put("gateway.recover_after_nodes", 2).build()).get();
@@ -329,7 +319,6 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
assertThat(state.metaData().index("test").getAliases().get("test_alias").filter(), notNullValue());
}
- @Test
@TestLogging("gateway:TRACE,indices.recovery:TRACE,index.engine:TRACE")
public void testReusePeerRecovery() throws Exception {
final Settings settings = settingsBuilder()
@@ -438,7 +427,6 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
}
}
- @Test
public void testRecoveryDifferentNodeOrderStartup() throws Exception {
// we need different data paths so we make sure we start the second node fresh
diff --git a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java
index e692b620d2..6a0aabe8d5 100644
--- a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java
@@ -50,7 +50,6 @@ import org.elasticsearch.index.store.StoreFileMetaData;
import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.util.Collections;
import java.util.EnumSet;
@@ -64,7 +63,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
-
private final ShardId shardId = new ShardId("test", 0);
private final DiscoveryNode node1 = newNode("node1");
private final DiscoveryNode node2 = newNode("node2");
@@ -80,7 +78,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
/**
* Verifies that when we are still fetching data in an async manner, the replica shard moves to ignore unassigned.
*/
- @Test
public void testNoAsyncFetchData() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
testAllocator.clean();
@@ -93,7 +90,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* Verifies that on index creation, we don't go and fetch data, but keep the replica shard unassigned to let
* the shard allocator to allocate it. There isn't a copy around to find anyhow.
*/
- @Test
public void testNoAsyncFetchOnIndexCreation() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders(), Settings.EMPTY, UnassignedInfo.Reason.INDEX_CREATED);
testAllocator.clean();
@@ -107,7 +103,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* Verifies that for anything but index creation, fetch data ends up being called, since we need to go and try
* and find a better copy for the shard.
*/
- @Test
public void testAsyncFetchOnAnythingButIndexCreation() {
UnassignedInfo.Reason reason = RandomPicks.randomFrom(getRandom(), EnumSet.complementOf(EnumSet.of(UnassignedInfo.Reason.INDEX_CREATED)));
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders(), Settings.EMPTY, reason);
@@ -119,7 +114,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
/**
* Verifies that when there is a full match (syncId and files) we allocate it to matching node.
*/
- @Test
public void testSimpleFullMatchAllocation() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
DiscoveryNode nodeToMatch = randomBoolean() ? node2 : node3;
@@ -133,7 +127,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
/**
* Verifies that when there is a sync id match but no files match, we allocate it to matching node.
*/
- @Test
public void testSyncIdMatch() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
DiscoveryNode nodeToMatch = randomBoolean() ? node2 : node3;
@@ -147,7 +140,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
/**
* Verifies that when there is no sync id match but files match, we allocate it to matching node.
*/
- @Test
public void testFileChecksumMatch() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
DiscoveryNode nodeToMatch = randomBoolean() ? node2 : node3;
@@ -164,7 +156,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* adding a replica and having that replica actually recover and cause the corruption to be identified
* See CorruptFileTest#
*/
- @Test
public void testNoPrimaryData() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
testAllocator.addData(node2, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"));
@@ -177,7 +168,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* Verifies that when there is primary data, but no data at all on other nodes, the shard keeps
* unassigned to be allocated later on.
*/
- @Test
public void testNoDataForReplicaOnAnyNode() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"));
@@ -190,7 +180,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* Verifies that when there is primary data, but no matching data at all on other nodes, the shard keeps
* unassigned to be allocated later on.
*/
- @Test
public void testNoMatchingFilesForReplicaOnAnyNode() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"))
@@ -204,7 +193,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* When there is no decision or throttle decision across all nodes for the shard, make sure the shard
* moves to the ignore unassigned list.
*/
- @Test
public void testNoOrThrottleDecidersRemainsInUnassigned() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(randomBoolean() ? noAllocationDeciders() : throttleAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"))
@@ -218,7 +206,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
* Tests when the node to allocate to due to matching is being throttled, we move the shard to ignored
* to wait till throttling on it is done.
*/
- @Test
public void testThrottleWhenAllocatingToMatchingNode() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(new AllocationDeciders(Settings.EMPTY,
new AllocationDecider[]{new TestAllocateDecision(Decision.YES), new AllocationDecider(Settings.EMPTY) {
@@ -237,7 +224,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
assertThat(allocation.routingNodes().unassigned().ignored().get(0).shardId(), equalTo(shardId));
}
- @Test
public void testDelayedAllocation() {
RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders(),
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, TimeValue.timeValueHours(1)).build(), UnassignedInfo.Reason.NODE_LEFT);
@@ -260,7 +246,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id()));
}
- @Test
public void testCancelRecoveryBetterSyncId() {
RoutingAllocation allocation = onePrimaryOnNode1And1ReplicaRecovering(yesAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"))
@@ -272,7 +257,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.UNASSIGNED).get(0).shardId(), equalTo(shardId));
}
- @Test
public void testNotCancellingRecoveryIfSyncedOnExistingRecovery() {
RoutingAllocation allocation = onePrimaryOnNode1And1ReplicaRecovering(yesAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"))
@@ -283,7 +267,6 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(0));
}
- @Test
public void testNotCancellingRecovery() {
RoutingAllocation allocation = onePrimaryOnNode1And1ReplicaRecovering(yesAllocationDeciders());
testAllocator.addData(node1, true, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM"))
diff --git a/core/src/test/java/org/elasticsearch/get/GetActionIT.java b/core/src/test/java/org/elasticsearch/get/GetActionIT.java
index b26e3ec220..1b58ea5d43 100644
--- a/core/src/test/java/org/elasticsearch/get/GetActionIT.java
+++ b/core/src/test/java/org/elasticsearch/get/GetActionIT.java
@@ -25,7 +25,11 @@ import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
import org.elasticsearch.action.delete.DeleteResponse;
-import org.elasticsearch.action.get.*;
+import org.elasticsearch.action.get.GetRequestBuilder;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.get.MultiGetRequest;
+import org.elasticsearch.action.get.MultiGetRequestBuilder;
+import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
@@ -38,7 +42,6 @@ import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@@ -49,12 +52,17 @@ import java.util.Set;
import static java.util.Collections.singleton;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.startsWith;
public class GetActionIT extends ESIntegTestCase {
-
- @Test
- public void simpleGetTests() {
+ public void testSimpleGet() {
assertAcked(prepareCreate("test")
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))
.addAlias(new Alias("alias")));
@@ -182,8 +190,7 @@ public class GetActionIT extends ESIntegTestCase {
return randomBoolean() ? "test" : "alias";
}
- @Test
- public void simpleMultiGetTests() throws Exception {
+ public void testSimpleMultiGet() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
ensureGreen();
@@ -235,8 +242,7 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(response.getResponses()[0].getResponse().getField("field").getValues().get(0).toString(), equalTo("value1"));
}
- @Test
- public void realtimeGetWithCompressBackcompat() throws Exception {
+ public void testRealtimeGetWithCompressBackcompat() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1).put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id))
.addMapping("type", jsonBuilder().startObject().startObject("type").startObject("_source").field("compress", true).endObject().endObject().endObject()));
@@ -255,7 +261,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo(fieldValue));
}
- @Test
public void testGetDocWithMultivaluedFields() throws Exception {
String mapping1 = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@@ -330,7 +335,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(response.getFields().get("field").getValues().get(1).toString(), equalTo("2"));
}
- @Test
public void testThatGetFromTranslogShouldWorkWithExcludeBackcompat() throws Exception {
String index = "test";
String type = "type1";
@@ -364,7 +368,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(responseBeforeFlush.getSourceAsString(), is(responseAfterFlush.getSourceAsString()));
}
- @Test
public void testThatGetFromTranslogShouldWorkWithIncludeBackcompat() throws Exception {
String index = "test";
String type = "type1";
@@ -399,7 +402,6 @@ public class GetActionIT extends ESIntegTestCase {
}
@SuppressWarnings("unchecked")
- @Test
public void testThatGetFromTranslogShouldWorkWithIncludeExcludeAndFieldsBackcompat() throws Exception {
String index = "test";
String type = "type1";
@@ -455,7 +457,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(responseBeforeFlushWithExtraFilters.getSourceAsString(), is(responseAfterFlushWithExtraFilters.getSourceAsString()));
}
- @Test
public void testGetWithVersion() {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
@@ -555,7 +556,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(response.getVersion(), equalTo(2l));
}
- @Test
public void testMultiGetWithVersion() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
@@ -671,8 +671,7 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(response.getResponses()[2].getResponse().getSourceAsMap().get("field").toString(), equalTo("value2"));
}
- @Test
- public void testGetFields_metaData() throws Exception {
+ public void testGetFieldsMetaData() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("my-type1", "_timestamp", "enabled=true", "_ttl", "enabled=true", "_parent", "type=parent")
@@ -726,8 +725,7 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(getResponse.getField("_parent").getValue().toString(), equalTo("parent_1"));
}
- @Test
- public void testGetFields_nonLeafField() throws Exception {
+ public void testGetFieldsNonLeafField() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.addMapping("my-type1", jsonBuilder().startObject().startObject("my-type1").startObject("properties")
.startObject("field1").startObject("properties")
@@ -757,9 +755,8 @@ public class GetActionIT extends ESIntegTestCase {
}
}
- @Test
@TestLogging("index.shard.service:TRACE,cluster.service:TRACE,action.admin.indices.flush:TRACE")
- public void testGetFields_complexField() throws Exception {
+ public void testGetFieldsComplexField() throws Exception {
assertAcked(prepareCreate("my-index")
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))
.addMapping("my-type2", jsonBuilder().startObject().startObject("my-type2").startObject("properties")
@@ -850,8 +847,7 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2"));
}
- @Test
- public void testGet_allField() throws Exception {
+ public void testGetAllField() throws Exception {
assertAcked(prepareCreate("test")
.addAlias(new Alias("alias"))
.addMapping("my-type1", jsonBuilder()
@@ -875,7 +871,6 @@ public class GetActionIT extends ESIntegTestCase {
assertThat(getResponse.getField("_all").getValue().toString(), equalTo("some text" + " "));
}
- @Test
public void testUngeneratedFieldsThatAreNeverStored() throws IOException {
String createIndexSource = "{\n" +
" \"settings\": {\n" +
@@ -916,7 +911,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysNull(indexOrAlias(), "doc", "1", fieldsList);
}
- @Test
public void testUngeneratedFieldsThatAreAlwaysStored() throws IOException {
String createIndexSource = "{\n" +
" \"settings\": {\n" +
@@ -955,7 +949,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "1");
}
- @Test
public void testUngeneratedFieldsPartOfSourceUnstoredSourceDisabledBackcompat() throws IOException {
indexSingleDocumentWithUngeneratedFieldsThatArePartOf_source(false, false);
String[] fieldsList = {};
@@ -969,7 +962,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysNull(indexOrAlias(), "doc", "1", fieldsList);
}
- @Test
public void testUngeneratedFieldsPartOfSourceEitherStoredOrSourceEnabledBackcompat() throws IOException {
boolean stored = randomBoolean();
boolean sourceEnabled = true;
@@ -1014,7 +1006,6 @@ public class GetActionIT extends ESIntegTestCase {
client().prepareIndex("test", "doc").setId("1").setSource(doc).setRouting("1").get();
}
- @Test
public void testUngeneratedFieldsNotPartOfSourceStored() throws IOException {
String createIndexSource = "{\n" +
" \"settings\": {\n" +
@@ -1048,7 +1039,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "1");
}
- @Test
public void testGeneratedStringFieldsUnstored() throws IOException {
indexSingleDocumentWithStringFieldsGeneratedFromText(false, randomBoolean());
String[] fieldsList = {"_all", "_field_names"};
@@ -1062,7 +1052,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysNull(indexOrAlias(), "doc", "1", fieldsList);
}
- @Test
public void testGeneratedStringFieldsStored() throws IOException {
indexSingleDocumentWithStringFieldsGeneratedFromText(true, randomBoolean());
String[] fieldsList = {"_all"};
@@ -1107,8 +1096,6 @@ public class GetActionIT extends ESIntegTestCase {
index("test", "doc", "1", doc);
}
-
- @Test
public void testGeneratedNumberFieldsUnstored() throws IOException {
indexSingleDocumentWithNumericFieldsGeneratedFromText(false, randomBoolean());
String[] fieldsList = {"token_count", "text.token_count"};
@@ -1122,7 +1109,6 @@ public class GetActionIT extends ESIntegTestCase {
assertGetFieldsAlwaysNull(indexOrAlias(), "doc", "1", fieldsList);
}
- @Test
public void testGeneratedNumberFieldsStored() throws IOException {
indexSingleDocumentWithNumericFieldsGeneratedFromText(true, randomBoolean());
String[] fieldsList = {"token_count", "text.token_count"};
diff --git a/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java b/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java
index 687c01520d..4d73b52576 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java
@@ -25,16 +25,16 @@ import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.instanceOf;
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class HttpPublishPortIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
@@ -44,7 +44,6 @@ public class HttpPublishPortIT extends ESIntegTestCase {
.build();
}
- @Test
public void testHttpPublishPort() throws Exception {
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get();
assertThat(response.getNodes(), arrayWithSize(greaterThanOrEqualTo(1)));
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java
index 0a4b057dd3..cb111a7198 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java
@@ -19,33 +19,42 @@
package org.elasticsearch.http.netty;
+import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.common.util.MockBigArrays;
-import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.threadpool.ThreadPool;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.*;
-import org.jboss.netty.handler.codec.http.*;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelConfig;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.http.DefaultHttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpVersion;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class NettyHttpChannelTests extends ESTestCase {
-
private NetworkService networkService;
private ThreadPool threadPool;
private MockBigArrays bigArrays;
@@ -69,7 +78,6 @@ public class NettyHttpChannelTests extends ESTestCase {
}
}
- @Test
public void testCorsEnabledWithoutAllowOrigins() {
// Set up a HTTP transport with only the CORS enabled setting
Settings settings = Settings.builder()
@@ -93,7 +101,6 @@ public class NettyHttpChannelTests extends ESTestCase {
assertThat(response.headers().get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN), nullValue());
}
- @Test
public void testCorsEnabledWithAllowOrigins() {
// create a http transport with CORS enabled and allow origin configured
Settings settings = Settings.builder()
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java
index 74e30d5f31..53c743d34d 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java
@@ -18,13 +18,13 @@
*/
package org.elasticsearch.http.netty;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.http.HttpServerTransport;
+import org.elasticsearch.http.netty.NettyHttpServerTransport.HttpChannelPipelineFactory;
import org.elasticsearch.http.netty.pipelining.OrderedDownstreamChannelEvent;
import org.elasticsearch.http.netty.pipelining.OrderedUpstreamMessageEvent;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
@@ -44,8 +44,8 @@ import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -55,8 +55,9 @@ import java.util.concurrent.Executors;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.http.netty.NettyHttpClient.returnHttpResponseBodies;
-import static org.elasticsearch.http.netty.NettyHttpServerTransport.HttpChannelPipelineFactory;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK;
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
@@ -65,7 +66,6 @@ import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
* This test just tests, if he pipelining works in general with out any connection the elasticsearch handler
*/
public class NettyHttpServerPipeliningTests extends ESTestCase {
-
private NetworkService networkService;
private ThreadPool threadPool;
private MockPageCacheRecycler mockPageCacheRecycler;
@@ -90,7 +90,6 @@ public class NettyHttpServerPipeliningTests extends ESTestCase {
}
}
- @Test
public void testThatHttpPipeliningWorksWhenEnabled() throws Exception {
Settings settings = settingsBuilder().put("http.pipelining", true).build();
httpServerTransport = new CustomNettyHttpServerTransport(settings);
@@ -105,7 +104,6 @@ public class NettyHttpServerPipeliningTests extends ESTestCase {
}
}
- @Test
public void testThatHttpPipeliningCanBeDisabled() throws Exception {
Settings settings = settingsBuilder().put("http.pipelining", false).build();
httpServerTransport = new CustomNettyHttpServerTransport(settings);
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
index 964f9851b0..f4ce3756e6 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
@@ -23,8 +23,9 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,8 +35,6 @@ import java.util.Locale;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.http.netty.NettyHttpClient.returnOpaqueIds;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
@@ -44,13 +43,11 @@ import static org.hamcrest.Matchers.hasSize;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 1)
public class NettyPipeliningDisabledIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Node.HTTP_ENABLED, true).put("http.pipelining", false).build();
}
- @Test
public void testThatNettyHttpServerDoesNotSupportPipelining() throws Exception {
ensureGreen();
List<String> requests = Arrays.asList("/", "/_nodes/stats", "/", "/_cluster/state", "/", "/_nodes", "/");
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningEnabledIT.java b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningEnabledIT.java
index eafd242ec3..9e5971c1d4 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningEnabledIT.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningEnabledIT.java
@@ -23,8 +23,9 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -33,21 +34,17 @@ import java.util.Locale;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.http.netty.NettyHttpClient.returnOpaqueIds;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
@ClusterScope(scope = Scope.TEST, numDataNodes = 1)
public class NettyPipeliningEnabledIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Node.HTTP_ENABLED, true).put("http.pipelining", true).build();
}
- @Test
public void testThatNettyHttpServerSupportsPipelining() throws Exception {
List<String> requests = Arrays.asList("/", "/_nodes/stats", "/", "/_cluster/state", "/");
diff --git a/core/src/test/java/org/elasticsearch/http/netty/pipelining/HttpPipeliningHandlerTests.java b/core/src/test/java/org/elasticsearch/http/netty/pipelining/HttpPipeliningHandlerTests.java
index f21153e45a..166d394a9c 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/pipelining/HttpPipeliningHandlerTests.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/pipelining/HttpPipeliningHandlerTests.java
@@ -22,16 +22,31 @@ import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.test.ESTestCase;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.*;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.jboss.netty.handler.codec.http.*;
+import org.jboss.netty.handler.codec.http.DefaultHttpChunk;
+import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
+import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpChunk;
+import org.jboss.netty.handler.codec.http.HttpClientCodec;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.util.HashedWheelTimer;
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.TimerTask;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -43,7 +58,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.jboss.netty.buffer.ChannelBuffers.EMPTY_BUFFER;
import static org.jboss.netty.buffer.ChannelBuffers.copiedBuffer;
-import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
+import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
+import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
+import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.HOST;
+import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.TRANSFER_ENCODING;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.CHUNKED;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.KEEP_ALIVE;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK;
@@ -115,8 +133,7 @@ public class HttpPipeliningHandlerTests extends ESTestCase {
clientBootstrap.releaseExternalResources();
}
- @Test
- public void shouldReturnMessagesInOrder() throws InterruptedException {
+ public void testShouldReturnMessagesInOrder() throws InterruptedException {
responsesIn = new CountDownLatch(1);
responses.clear();
diff --git a/core/src/test/java/org/elasticsearch/index/IndexRequestBuilderIT.java b/core/src/test/java/org/elasticsearch/index/IndexRequestBuilderIT.java
index 5db3e54669..c41051ec59 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexRequestBuilderIT.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexRequestBuilderIT.java
@@ -25,16 +25,14 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
+import static org.hamcrest.Matchers.containsString;
+
public class IndexRequestBuilderIT extends ESIntegTestCase {
-
-
- @Test
public void testSetSource() throws InterruptedException, ExecutionException {
createIndex("test");
ensureYellow();
@@ -52,10 +50,13 @@ public class IndexRequestBuilderIT extends ESIntegTestCase {
SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.termQuery("test_field", "foobar")).get();
ElasticsearchAssertions.assertHitCount(searchResponse, builders.length);
}
-
- @Test(expected = IllegalArgumentException.class)
- public void testOddNumberOfSourceObjetc() {
- client().prepareIndex("test", "test").setSource((Object)"test_field", (Object)"foobar", new Object());
- }
+ public void testOddNumberOfSourceObjects() {
+ try {
+ client().prepareIndex("test", "test").setSource("test_field", "foobar", new Object());
+ fail ("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("The number of object passed must be even but was [3]"));
+ }
+ }
}
diff --git a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
index 412141cdc8..72b262241f 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java
@@ -30,18 +30,16 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.indices.InvalidAliasNameException;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
/** Unit test(s) for IndexService */
public class IndexServiceTests extends ESSingleNodeTestCase {
-
- @Test
public void testDetermineShadowEngineShouldBeUsed() {
Settings regularSettings = Settings.builder()
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 2)
@@ -73,9 +71,7 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
return new CompressedXContent(builder.string());
}
- @Test
public void testFilteringAliases() throws Exception {
-
IndexService indexService = newIndexService();
add(indexService, "cats", filter(termQuery("animal", "cat")));
add(indexService, "dogs", filter(termQuery("animal", "dog")));
@@ -98,7 +94,6 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
assertThat(indexService.aliasFilter("dogs", "cats").toString(), equalTo("animal:canine animal:feline"));
}
- @Test
public void testAliasFilters() throws Exception {
IndexService indexService = newIndexService();
add(indexService, "cats", filter(termQuery("animal", "cat")));
@@ -114,17 +109,19 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
assertThat(indexService.aliasFilter("dogs", "cats").toString(), equalTo("animal:canine animal:feline"));
}
- @Test(expected = InvalidAliasNameException.class)
public void testRemovedAliasFilter() throws Exception {
IndexService indexService = newIndexService();
add(indexService, "cats", filter(termQuery("animal", "cat")));
remove(indexService, "cats");
- indexService.aliasFilter("cats");
+ try {
+ indexService.aliasFilter("cats");
+ fail("Expected InvalidAliasNameException");
+ } catch (InvalidAliasNameException e) {
+ assertThat(e.getMessage(), containsString("Invalid alias name [cats]"));
+ }
}
-
- @Test
public void testUnknownAliasFilter() throws Exception {
IndexService indexService = newIndexService();
add(indexService, "cats", filter(termQuery("animal", "cat")));
diff --git a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
index dd73e41c9f..ed1ce65eef 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRes
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
-import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
@@ -52,12 +51,11 @@ import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
-import java.util.Collection;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
@@ -66,8 +64,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
/**
* Tests for indices that use shadow replicas and a shared filesystem
@@ -167,7 +170,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
}
- @Test
public void testIndexWithFewDocuments() throws Exception {
final Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -246,7 +248,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertAcked(client().admin().indices().prepareDelete(IDX));
}
- @Test
public void testReplicaToPrimaryPromotion() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -305,7 +306,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertThat(gResp2.getField("foo").getValue().toString(), equalTo("foobar"));
}
- @Test
public void testPrimaryRelocation() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -366,7 +366,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertThat(gResp2.getField("foo").getValue().toString(), equalTo("bar"));
}
- @Test
public void testPrimaryRelocationWithConcurrentIndexing() throws Throwable {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -439,7 +438,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertHitCount(resp, numPhase1Docs + numPhase2Docs);
}
- @Test
public void testPrimaryRelocationWhereRecoveryFails() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = Settings.builder()
@@ -535,7 +533,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertHitCount(resp, counter.get());
}
- @Test
public void testIndexWithShadowReplicasCleansUp() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -576,7 +573,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
* Tests that shadow replicas can be "naturally" rebalanced and relocated
* around the cluster. By "naturally" I mean without using the reroute API
*/
- @Test
public void testShadowReplicaNaturalRelocation() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -630,7 +626,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertPathHasBeenCleared(dataPath);
}
- @Test
public void testShadowReplicasUsingFieldData() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -699,7 +694,6 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
});
}
- @Test
public void testIndexOnSharedFSRecoversToAnyNode() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
diff --git a/core/src/test/java/org/elasticsearch/index/TransportIndexFailuresIT.java b/core/src/test/java/org/elasticsearch/index/TransportIndexFailuresIT.java
index aed603ce39..5348211a84 100644
--- a/core/src/test/java/org/elasticsearch/index/TransportIndexFailuresIT.java
+++ b/core/src/test/java/org/elasticsearch/index/TransportIndexFailuresIT.java
@@ -34,7 +34,6 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.util.Collection;
import java.util.List;
@@ -76,7 +75,6 @@ public class TransportIndexFailuresIT extends ESIntegTestCase {
return 1;
}
- @Test
public void testNetworkPartitionDuringReplicaIndexOp() throws Exception {
final String INDEX = "testidx";
diff --git a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java
index 3f7ea54230..d54d1a953b 100644
--- a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java
+++ b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java
@@ -21,14 +21,11 @@ package org.elasticsearch.index;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class VersionTypeTests extends ESTestCase {
- @Test
public void testInternalVersionConflict() throws Exception {
-
assertFalse(VersionType.INTERNAL.isVersionConflictForWrites(10, Versions.MATCH_ANY, randomBoolean()));
assertFalse(VersionType.INTERNAL.isVersionConflictForReads(10, Versions.MATCH_ANY));
// if we don't have a version in the index we accept everything
@@ -70,7 +67,6 @@ public class VersionTypeTests extends ESTestCase {
// updatedVersion = (currentVersion == Versions.NOT_SET || currentVersion == Versions.NOT_FOUND) ? 1 : currentVersion + 1;
}
- @Test
public void testVersionValidation() {
assertTrue(VersionType.EXTERNAL.validateVersionForWrites(randomIntBetween(1, Integer.MAX_VALUE)));
assertFalse(VersionType.EXTERNAL.validateVersionForWrites(Versions.MATCH_ANY));
@@ -101,9 +97,7 @@ public class VersionTypeTests extends ESTestCase {
assertFalse(VersionType.INTERNAL.validateVersionForReads(randomIntBetween(Integer.MIN_VALUE, -1)));
}
- @Test
public void testExternalVersionConflict() throws Exception {
-
assertFalse(VersionType.EXTERNAL.isVersionConflictForWrites(Versions.NOT_FOUND, 10, randomBoolean()));
assertFalse(VersionType.EXTERNAL.isVersionConflictForWrites(Versions.NOT_SET, 10, randomBoolean()));
// MATCH_ANY must throw an exception in the case of external version, as the version must be set! it used as the new value
@@ -139,9 +133,7 @@ public class VersionTypeTests extends ESTestCase {
// updatedVersion = index.version();
}
- @Test
public void testExternalGTEVersionConflict() throws Exception {
-
assertFalse(VersionType.EXTERNAL_GTE.isVersionConflictForWrites(Versions.NOT_FOUND, 10, randomBoolean()));
assertFalse(VersionType.EXTERNAL_GTE.isVersionConflictForWrites(Versions.NOT_SET, 10, randomBoolean()));
// MATCH_ANY must throw an exception in the case of external version, as the version must be set! it used as the new value
@@ -168,9 +160,7 @@ public class VersionTypeTests extends ESTestCase {
}
- @Test
public void testForceVersionConflict() throws Exception {
-
assertFalse(VersionType.FORCE.isVersionConflictForWrites(Versions.NOT_FOUND, 10, randomBoolean()));
assertFalse(VersionType.FORCE.isVersionConflictForWrites(Versions.NOT_SET, 10, randomBoolean()));
@@ -201,9 +191,7 @@ public class VersionTypeTests extends ESTestCase {
assertFalse(VersionType.FORCE.isVersionConflictForReads(10, Versions.MATCH_ANY));
}
- @Test
public void testUpdateVersion() {
-
assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_SET, 10), equalTo(1l));
assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(1l));
assertThat(VersionType.INTERNAL.updateVersion(1, 1), equalTo(2l));
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactoryTests.java
index d31cc0a5c6..17bd9d587b 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactoryTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -30,7 +29,6 @@ import java.io.StringReader;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class ASCIIFoldingTokenFilterFactoryTests extends ESTokenStreamTestCase {
- @Test
public void testDefault() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -44,7 +42,6 @@ public class ASCIIFoldingTokenFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testPreserveOriginal() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -58,5 +55,4 @@ public class ASCIIFoldingTokenFilterFactoryTests extends ESTokenStreamTestCase {
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTests.java b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTests.java
index abfe52097e..061e0d9d29 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTests.java
@@ -22,15 +22,12 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.util.CharArraySet;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.is;
public class AnalysisTests extends ESTestCase {
- @Test
public void testParseStemExclusion() {
-
/* Comma separated list */
Settings settings = settingsBuilder().put("stem_exclusion", "foo,bar").build();
CharArraySet set = Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET);
@@ -45,5 +42,4 @@ public class AnalysisTests extends ESTestCase {
assertThat(set.contains("bar"), is(true));
assertThat(set.contains("baz"), is(false));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java
index 98ed9d2870..d2e2d4cc6e 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java
@@ -22,16 +22,13 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
public class CJKFilterFactoryTests extends ESTokenStreamTestCase {
-
private static final String RESOURCE = "/org/elasticsearch/index/analysis/cjk_analysis.json";
- @Test
public void testDefault() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("cjk_bigram");
@@ -42,7 +39,6 @@ public class CJKFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testNoFlags() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("cjk_no_flags");
@@ -52,8 +48,7 @@ public class CJKFilterFactoryTests extends ESTokenStreamTestCase {
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
-
- @Test
+
public void testHanOnly() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("cjk_han_only");
@@ -63,8 +58,7 @@ public class CJKFilterFactoryTests extends ESTokenStreamTestCase {
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
-
- @Test
+
public void testHanUnigramOnly() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("cjk_han_unigram_only");
@@ -74,7 +68,4 @@ public class CJKFilterFactoryTests extends ESTokenStreamTestCase {
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
-
-
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java
index 0171b4cc69..9f3544e684 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java
@@ -31,15 +31,12 @@ import org.elasticsearch.index.IndexNameModule;
import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/**
*/
public class CharFilterTests extends ESTokenStreamTestCase {
-
- @Test
public void testMappingCharFilter() throws Exception {
Index index = new Index("test");
Settings settings = settingsBuilder()
@@ -60,14 +57,13 @@ public class CharFilterTests extends ESTokenStreamTestCase {
AnalysisService analysisService = injector.getInstance(AnalysisService.class);
NamedAnalyzer analyzer1 = analysisService.analyzer("custom_with_char_filter");
-
+
assertTokenStreamContents(analyzer1.tokenStream("test", "jeff quit phish"), new String[]{"jeff", "qit", "fish"});
// Repeat one more time to make sure that char filter is reinitialized correctly
assertTokenStreamContents(analyzer1.tokenStream("test", "jeff quit phish"), new String[]{"jeff", "qit", "fish"});
}
- @Test
public void testHtmlStripCharFilter() throws Exception {
Index index = new Index("test");
Settings settings = settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java b/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java
index 28b30e9ff5..523760c797 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java
@@ -40,7 +40,6 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -54,8 +53,6 @@ import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class CompoundAnalysisTests extends ESTestCase {
-
- @Test
public void testDefaultsCompoundAnalysis() throws Exception {
Index index = new Index("test");
Settings settings = getJsonSettings();
@@ -74,7 +71,6 @@ public class CompoundAnalysisTests extends ESTestCase {
MatcherAssert.assertThat(filterFactory, instanceOf(DictionaryCompoundWordTokenFilterFactory.class));
}
- @Test
public void testDictionaryDecompounder() throws Exception {
Settings[] settingsArr = new Settings[]{getJsonSettings(), getYamlSettings()};
for (Settings settings : settingsArr) {
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java
index f81fef1f81..02c4e1a264 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java
@@ -20,7 +20,6 @@ package org.elasticsearch.index.analysis;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -29,8 +28,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
public class HunspellTokenFilterFactoryTests extends ESTestCase {
-
- @Test
public void testDedup() throws IOException {
Settings settings = settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -59,5 +56,4 @@ public class HunspellTokenFilterFactoryTests extends ESTestCase {
hunspellTokenFilter = (HunspellTokenFilterFactory) tokenFilter;
assertThat(hunspellTokenFilter.dedup(), is(false));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java
index df382b7cc7..fc1459a170 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java
@@ -22,10 +22,8 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.test.ESTokenStreamTestCase;
import org.junit.Assert;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -33,18 +31,14 @@ import java.io.StringReader;
import static org.hamcrest.Matchers.instanceOf;
public class KeepFilterFactoryTests extends ESTokenStreamTestCase {
-
private static final String RESOURCE = "/org/elasticsearch/index/analysis/keep_analysis.json";
-
- @Test
public void testLoadWithoutSettings() {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("keep");
Assert.assertNull(tokenFilter);
}
- @Test
public void testLoadOverConfiguredSettings() {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -60,7 +54,6 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testKeepWordsPathSettings() {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -88,7 +81,6 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase {
}
- @Test
public void testCaseInsensitiveMapping() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("my_keep_filter");
@@ -100,7 +92,6 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected, new int[]{1, 2});
}
- @Test
public void testCaseSensitiveMapping() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("my_case_sensitive_keep_filter");
@@ -111,5 +102,4 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase {
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected, new int[]{1});
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/KeepTypesFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/KeepTypesFilterFactoryTests.java
index fd8f70f6f7..1e8a0ba16e 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/KeepTypesFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/KeepTypesFilterFactoryTests.java
@@ -23,7 +23,6 @@ import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -31,8 +30,6 @@ import java.io.StringReader;
import static org.hamcrest.Matchers.instanceOf;
public class KeepTypesFilterFactoryTests extends ESTokenStreamTestCase {
-
- @Test
public void testKeepTypes() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir().toString())
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java
index 6f283f9555..e133ffc79a 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java
@@ -23,14 +23,11 @@ import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
public class LimitTokenCountFilterFactoryTests extends ESTokenStreamTestCase {
-
- @Test
public void testDefault() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("index.analysis.filter.limit_default.type", "limit")
@@ -55,7 +52,6 @@ public class LimitTokenCountFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testSettings() throws IOException {
{
Settings settings = Settings.settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java
index 11fcf066fe..1fddd12b23 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java
@@ -22,7 +22,12 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.ngram.*;
+import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
+import org.apache.lucene.analysis.ngram.EdgeNGramTokenizer;
+import org.apache.lucene.analysis.ngram.Lucene43EdgeNGramTokenFilter;
+import org.apache.lucene.analysis.ngram.Lucene43EdgeNGramTokenizer;
+import org.apache.lucene.analysis.ngram.Lucene43NGramTokenizer;
+import org.apache.lucene.analysis.ngram.NGramTokenizer;
import org.apache.lucene.analysis.reverse.ReverseStringFilter;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -30,7 +35,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.Settings.Builder;
import org.elasticsearch.index.Index;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -45,9 +49,6 @@ import static com.carrotsearch.randomizedtesting.RandomizedTest.scaledRandomIntB
import static org.hamcrest.Matchers.instanceOf;
public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
-
-
- @Test
public void testParseTokenChars() {
final Index index = new Index("test");
final String name = "ngr";
@@ -68,7 +69,6 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testNoTokenChars() throws IOException {
final Index index = new Index("test");
final String name = "ngr";
@@ -79,7 +79,6 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenizer, new String[] {"1.", "1.3", "1.34", ".3", ".34", "34"});
}
- @Test
public void testPreTokenization() throws IOException {
// Make sure that pretokenization works well and that it can be used even with token chars which are supplementary characters
final Index index = new Index("test");
@@ -97,7 +96,6 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
new String[] {" a", " a!", "a!", "a!$", "!$", "!$ ", "$ ", "$ 9", " 9"});
}
- @Test
public void testPreTokenizationEdge() throws IOException {
// Make sure that pretokenization works well and that it can be used even with token chars which are supplementary characters
final Index index = new Index("test");
@@ -114,8 +112,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenizer,
new String[] {" a", " a!"});
}
-
- @Test
+
public void testBackwardsCompatibilityEdgeNgramTokenizer() throws Exception {
int iters = scaledRandomIntBetween(20, 100);
final Index index = new Index("test");
@@ -154,10 +151,9 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
fail("should fail side:back is not supported anymore");
} catch (IllegalArgumentException ex) {
}
-
+
}
-
- @Test
+
public void testBackwardsCompatibilityNgramTokenizer() throws Exception {
int iters = scaledRandomIntBetween(20, 100);
for (int i = 0; i < iters; i++) {
@@ -174,7 +170,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build();
Tokenizer nGramTokenizer = new NGramTokenizerFactory(index, indexSettings, name, settings).create();
nGramTokenizer.setReader(new StringReader("foo bar"));
- if (compatVersion) {
+ if (compatVersion) {
assertThat(nGramTokenizer, instanceOf(Lucene43NGramTokenizer.class));
} else {
assertThat(nGramTokenizer, instanceOf(NGramTokenizer.class));
@@ -189,8 +185,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
}
}
}
-
- @Test
+
public void testBackwardsCompatibilityEdgeNgramTokenFilter() throws Exception {
int iters = scaledRandomIntBetween(20, 100);
for (int i = 0; i < iters; i++) {
@@ -214,7 +209,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(index, indexSettings, name, settings).create(tokenizer);
if (reverse) {
assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class));
- } else if (compatVersion) {
+ } else if (compatVersion) {
assertThat(edgeNGramTokenFilter, instanceOf(Lucene43EdgeNGramTokenFilter.class));
} else {
assertThat(edgeNGramTokenFilter, instanceOf(EdgeNGramTokenFilter.class));
@@ -240,7 +235,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase {
}
}
-
+
private Version randomVersion(Random random) throws IllegalArgumentException, IllegalAccessException {
Field[] declaredFields = Version.class.getDeclaredFields();
List<Field> versionFields = new ArrayList<>();
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java
index a9ca96cc5f..89940558d5 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java
@@ -24,7 +24,6 @@ import org.apache.lucene.analysis.NumericTokenStream.NumericTermAttribute;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -32,8 +31,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
public class NumericAnalyzerTests extends ESTestCase {
-
- @Test
public void testAttributeEqual() throws IOException {
final int precisionStep = 8;
final double value = randomDouble();
@@ -59,5 +56,4 @@ public class NumericAnalyzerTests extends ESTestCase {
ts1.end();
ts2.end();
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java
index 6a7275b73e..880d222900 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java
@@ -32,13 +32,11 @@ import org.elasticsearch.index.IndexNameModule;
import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.hamcrest.Matchers.containsString;
public class PatternCaptureTokenFilterTests extends ESTokenStreamTestCase {
-
- @Test
public void testPatternCaptureTokenFilter() throws Exception {
String json = "/org/elasticsearch/index/analysis/pattern_capture.json";
Index index = new Index("test");
@@ -68,11 +66,14 @@ public class PatternCaptureTokenFilterTests extends ESTokenStreamTestCase {
assertTokenStreamContents(analyzer3.tokenStream("test", "foobarbaz"), new String[]{"foobar","foo"});
}
-
-
- @Test(expected=IllegalArgumentException.class)
+
public void testNoPatterns() {
- new PatternCaptureGroupTokenFilterFactory(new Index("test"), settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(), "pattern_capture", settingsBuilder().put("pattern", "foobar").build());
+ try {
+ new PatternCaptureGroupTokenFilterFactory(new Index("test"), settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(), "pattern_capture", settingsBuilder().put("pattern", "foobar").build());
+ fail ("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("required setting 'patterns' is missing"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactoryTests.java
index c18e4fd760..2cb8f99e7b 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactoryTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.analysis.PreBuiltAnalyzers;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@@ -32,8 +31,6 @@ import static org.hamcrest.Matchers.not;
*
*/
public class PreBuiltAnalyzerProviderFactoryTests extends ESTestCase {
-
- @Test
public void testVersioningInFactoryProvider() throws Exception {
PreBuiltAnalyzerProviderFactory factory = new PreBuiltAnalyzerProviderFactory("default", AnalyzerScope.INDEX, PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT));
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java
index 77eb0cda1d..fecb7e9b88 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.indices.analysis.PreBuiltAnalyzers;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -37,14 +36,15 @@ import java.util.List;
import java.util.Locale;
import static org.elasticsearch.test.VersionUtils.randomVersion;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
/**
*
*/
public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
-
- @Test
public void testThatDefaultAndStandardAnalyzerAreTheSameInstance() {
Analyzer currentStandardAnalyzer = PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT);
Analyzer currentDefaultAnalyzer = PreBuiltAnalyzers.DEFAULT.getAnalyzer(Version.CURRENT);
@@ -53,7 +53,6 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
assertThat(currentDefaultAnalyzer, is(currentStandardAnalyzer));
}
- @Test
public void testThatDefaultAndStandardAnalyzerChangedIn10Beta1() throws IOException {
Analyzer currentStandardAnalyzer = PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.V_1_0_0_Beta1);
Analyzer currentDefaultAnalyzer = PreBuiltAnalyzers.DEFAULT.getAnalyzer(Version.V_1_0_0_Beta1);
@@ -90,7 +89,6 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testAnalyzerChangedIn10RC1() throws IOException {
Analyzer pattern = PreBuiltAnalyzers.PATTERN.getAnalyzer(Version.V_1_0_0_RC1);
Analyzer standardHtml = PreBuiltAnalyzers.STANDARD_HTML_STRIP.getAnalyzer(Version.V_1_0_0_RC1);
@@ -125,13 +123,11 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testThatInstancesAreTheSameAlwaysForKeywordAnalyzer() {
assertThat(PreBuiltAnalyzers.KEYWORD.getAnalyzer(Version.CURRENT),
is(PreBuiltAnalyzers.KEYWORD.getAnalyzer(Version.V_0_18_0)));
}
- @Test
public void testThatInstancesAreCachedAndReused() {
assertThat(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT),
is(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT)));
@@ -139,14 +135,12 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
is(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_0_18_0)));
}
- @Test
public void testThatInstancesWithSameLuceneVersionAreReused() {
// both are lucene 4.4 and should return the same instance
assertThat(PreBuiltAnalyzers.CATALAN.getAnalyzer(Version.V_0_90_4),
is(PreBuiltAnalyzers.CATALAN.getAnalyzer(Version.V_0_90_5)));
}
- @Test
public void testThatAnalyzersAreUsedInMapping() throws IOException {
int randomInt = randomInt(PreBuiltAnalyzers.values().length-1);
PreBuiltAnalyzers randomPreBuiltAnalyzer = PreBuiltAnalyzers.values()[randomInt];
@@ -164,7 +158,7 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
FieldMapper fieldMapper = docMapper.mappers().getMapper("field");
assertThat(fieldMapper.fieldType().searchAnalyzer(), instanceOf(NamedAnalyzer.class));
- NamedAnalyzer fieldMapperNamedAnalyzer = (NamedAnalyzer) fieldMapper.fieldType().searchAnalyzer();
+ NamedAnalyzer fieldMapperNamedAnalyzer = fieldMapper.fieldType().searchAnalyzer();
assertThat(fieldMapperNamedAnalyzer.analyzer(), is(namedAnalyzer.analyzer()));
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java
index 863ed96198..a506488079 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java
@@ -23,17 +23,13 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.analysis.PreBuiltCharFilters;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.CoreMatchers.is;
/**
*
*/
public class PreBuiltCharFilterFactoryFactoryTests extends ESTestCase {
-
- @Test
public void testThatDifferentVersionsCanBeLoaded() {
PreBuiltCharFilterFactoryFactory factory = new PreBuiltCharFilterFactoryFactory(PreBuiltCharFilters.HTML_STRIP.getCharFilterFactory(Version.CURRENT));
@@ -44,5 +40,4 @@ public class PreBuiltCharFilterFactoryFactoryTests extends ESTestCase {
assertThat(currentTokenizerFactory, is(former090TokenizerFactory));
assertThat(currentTokenizerFactory, is(former090TokenizerFactoryCopy));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java
index c1cbc1267c..27113793e9 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java
@@ -23,16 +23,14 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.analysis.PreBuiltTokenFilters;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
/**
*
*/
public class PreBuiltTokenFilterFactoryFactoryTests extends ESTestCase {
-
- @Test
public void testThatCachingWorksForCachingStrategyOne() {
PreBuiltTokenFilterFactoryFactory factory = new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.WORD_DELIMITER.getTokenFilterFactory(Version.CURRENT));
@@ -44,7 +42,6 @@ public class PreBuiltTokenFilterFactoryFactoryTests extends ESTestCase {
assertThat(currentTokenizerFactory, is(former090TokenizerFactoryCopy));
}
- @Test
public void testThatDifferentVersionsCanBeLoaded() {
PreBuiltTokenFilterFactoryFactory factory = new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.STOP.getTokenFilterFactory(Version.CURRENT));
@@ -55,5 +52,4 @@ public class PreBuiltTokenFilterFactoryFactoryTests extends ESTestCase {
assertThat(currentTokenizerFactory, is(not(former090TokenizerFactory)));
assertThat(former090TokenizerFactory, is(former090TokenizerFactoryCopy));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java
index a9e8f7b29f..ecf52a9dad 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java
@@ -23,16 +23,14 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.analysis.PreBuiltTokenizers;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
/**
*
*/
public class PreBuiltTokenizerFactoryFactoryTests extends ESTestCase {
-
- @Test
public void testThatDifferentVersionsCanBeLoaded() {
PreBuiltTokenizerFactoryFactory factory = new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.STANDARD.getTokenizerFactory(Version.CURRENT));
@@ -45,5 +43,4 @@ public class PreBuiltTokenizerFactoryFactoryTests extends ESTestCase {
assertThat(currentTokenizerFactory, is(not(former090TokenizerFactoryCopy)));
assertThat(former090TokenizerFactory, is(former090TokenizerFactoryCopy));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java
index 26883f562f..2e2a45fab6 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java
@@ -21,12 +21,12 @@ package org.elasticsearch.index.analysis;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
+
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.StopFilter;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -35,10 +35,8 @@ import static org.hamcrest.Matchers.instanceOf;
@ThreadLeakScope(Scope.NONE)
public class ShingleTokenFilterFactoryTests extends ESTokenStreamTestCase {
-
private static final String RESOURCE = "/org/elasticsearch/index/analysis/shingle_analysis.json";
- @Test
public void testDefault() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("shingle");
@@ -49,7 +47,6 @@ public class ShingleTokenFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testInverseMapping() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("shingle_inverse");
@@ -61,7 +58,6 @@ public class ShingleTokenFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testInverseMappingNoShingles() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("shingle_inverse");
@@ -73,7 +69,6 @@ public class ShingleTokenFilterFactoryTests extends ESTokenStreamTestCase {
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testFillerToken() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE);
TokenFilterFactory tokenFilter = analysisService.tokenFilter("shingle_filler");
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactoryTests.java
index 22a7effdaa..737a991f0e 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactoryTests.java
@@ -18,8 +18,8 @@
*/
package org.elasticsearch.index.analysis;
-import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.apache.lucene.analysis.en.PorterStemFilter;
import org.apache.lucene.analysis.snowball.SnowballFilter;
@@ -27,7 +27,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTokenStreamTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -40,8 +39,6 @@ import static org.hamcrest.Matchers.instanceOf;
*
*/
public class StemmerTokenFilterFactoryTests extends ESTokenStreamTestCase {
-
- @Test
public void testEnglishBackwardsCompatibility() throws IOException {
int iters = scaledRandomIntBetween(20, 100);
for (int i = 0; i < iters; i++) {
@@ -75,7 +72,6 @@ public class StemmerTokenFilterFactoryTests extends ESTokenStreamTestCase {
}
- @Test
public void testPorter2BackwardsCompatibility() throws IOException {
int iters = scaledRandomIntBetween(20, 100);
for (int i = 0; i < iters; i++) {
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java
index 9265587929..c48d723260 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java
@@ -32,13 +32,10 @@ import org.elasticsearch.index.IndexNameModule;
import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class StopAnalyzerTests extends ESTokenStreamTestCase {
-
- @Test
public void testDefaultsCompoundAnalysis() throws Exception {
String json = "/org/elasticsearch/index/analysis/stop.json";
Index index = new Index("test");
@@ -64,5 +61,4 @@ public class StopAnalyzerTests extends ESTokenStreamTestCase {
assertTokenStreamContents(analyzer2.tokenStream("test", "to be or not to be"), new String[0]);
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java
index 2d52599c6c..79e49cd8b8 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java
@@ -19,8 +19,8 @@
package org.elasticsearch.index.analysis;
-import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.Lucene43StopFilter;
import org.apache.lucene.analysis.core.StopFilter;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
@@ -30,17 +30,15 @@ import org.elasticsearch.common.inject.ProvisionException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.Settings.Builder;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
public class StopTokenFilterTests extends ESTokenStreamTestCase {
-
- @Test(expected = ProvisionException.class)
public void testPositionIncrementSetting() throws IOException {
Builder builder = Settings.settingsBuilder().put("index.analysis.filter.my_stop.type", "stop")
.put("index.analysis.filter.my_stop.enable_position_increments", false);
@@ -49,11 +47,14 @@ public class StopTokenFilterTests extends ESTokenStreamTestCase {
}
builder.put("path.home", createTempDir().toString());
Settings settings = builder.build();
- AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settings);
- analysisService.tokenFilter("my_stop");
+ try {
+ AnalysisTestsHelper.createAnalysisServiceFromSettings(settings);
+ fail("Expected ProvisionException");
+ } catch (ProvisionException e) {
+ assertThat(e.getMessage(), containsString("enable_position_increments is not supported anymore"));
+ }
}
- @Test
public void testCorrectPositionIncrementSetting() throws IOException {
Builder builder = Settings.settingsBuilder().put("index.analysis.filter.my_stop.type", "stop");
int thingToDo = random().nextInt(3);
@@ -81,7 +82,6 @@ public class StopTokenFilterTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testDeprecatedPositionIncrementSettingWithVersions() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("index.analysis.filter.my_stop.type", "stop")
@@ -98,7 +98,6 @@ public class StopTokenFilterTests extends ESTokenStreamTestCase {
assertThat(create, instanceOf(Lucene43StopFilter.class));
}
- @Test
public void testThatSuggestStopFilterWorks() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("index.analysis.filter.my_stop.type", "stop")
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java
index d29b2ebae9..54810028ae 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.test.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -30,8 +29,6 @@ import java.io.StringReader;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase {
-
- @Test
public void testDefault() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -45,7 +42,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testCatenateWords() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -61,7 +57,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testCatenateNumbers() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -77,7 +72,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testCatenateAll() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -94,7 +88,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testSplitOnCaseChange() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -109,7 +102,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testPreserveOriginal() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -124,7 +116,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testStemEnglishPossessive() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -140,7 +131,6 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
}
/** Correct offset order when doing both parts and concatenation: PowerShot is a synonym of Power */
- @Test
public void testPartsAndCatenate() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
@@ -155,10 +145,9 @@ public class WordDelimiterTokenFilterFactoryTests extends ESTokenStreamTestCase
tokenizer.setReader(new StringReader(source));
assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
}
-
- /** Back compat:
+
+ /** Back compat:
* old offset order when doing both parts and concatenation: PowerShot is a synonym of Shot */
- @Test
public void testDeprecatedPartsAndCatenate() throws IOException {
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settingsBuilder()
.put("path.home", createTempDir().toString())
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java
index c1bb7f8d3e..e7a1ebf579 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java
@@ -22,14 +22,12 @@ package org.elasticsearch.index.analysis.commongrams;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
-import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.analysis.AnalysisService;
import org.elasticsearch.index.analysis.AnalysisTestsHelper;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.test.ESTokenStreamTestCase;
import org.junit.Assert;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -39,8 +37,6 @@ import java.nio.file.Path;
import static org.hamcrest.Matchers.instanceOf;
public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
-
- @Test
public void testDefault() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("index.analysis.filter.common_grams_default.type", "common_grams")
@@ -54,7 +50,7 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
assertThat(e.getCause(), instanceOf(IllegalArgumentException.class));
}
}
- @Test
+
public void testWithoutCommonWordsMatch() throws IOException {
{
Settings settings = Settings.settingsBuilder().put("index.analysis.filter.common_grams_default.type", "common_grams")
@@ -91,7 +87,6 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testSettings() throws IOException {
{
Settings settings = Settings.settingsBuilder().put("index.analysis.filter.common_grams_1.type", "common_grams")
@@ -136,7 +131,6 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testCommonGramsAnalysis() throws IOException {
String json = "/org/elasticsearch/index/analysis/commongrams/commongrams.json";
Settings settings = Settings.settingsBuilder()
@@ -159,7 +153,6 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testQueryModeSettings() throws IOException {
{
Settings settings = Settings.settingsBuilder().put("index.analysis.filter.common_grams_1.type", "common_grams")
@@ -221,7 +214,6 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase {
}
}
- @Test
public void testQueryModeCommonGramsAnalysis() throws IOException {
String json = "/org/elasticsearch/index/analysis/commongrams/commongrams_query_mode.json";
Settings settings = Settings.settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java b/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java
index f695b1b197..65c2fa2164 100644
--- a/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java
+++ b/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java
@@ -42,7 +42,6 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -55,11 +54,9 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class SynonymsAnalysisTests extends ESTestCase {
-
protected final ESLogger logger = Loggers.getLogger(getClass());
private AnalysisService analysisService;
- @Test
public void testSynonymsAnalysis() throws IOException {
InputStream synonyms = getClass().getResourceAsStream("synonyms.txt");
InputStream synonymsWordnet = getClass().getResourceAsStream("synonyms_wordnet.txt");
diff --git a/core/src/test/java/org/elasticsearch/index/cache/bitset/BitSetFilterCacheTests.java b/core/src/test/java/org/elasticsearch/index/cache/bitset/BitSetFilterCacheTests.java
index 416c04de26..4c93ecada0 100644
--- a/core/src/test/java/org/elasticsearch/index/cache/bitset/BitSetFilterCacheTests.java
+++ b/core/src/test/java/org/elasticsearch/index/cache/bitset/BitSetFilterCacheTests.java
@@ -42,7 +42,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -51,7 +50,6 @@ import java.util.concurrent.atomic.AtomicLong;
import static org.hamcrest.Matchers.equalTo;
public class BitSetFilterCacheTests extends ESTestCase {
-
private static int matchCount(BitSetProducer producer, IndexReader reader) throws IOException {
int count = 0;
for (LeafReaderContext ctx : reader.leaves()) {
@@ -63,7 +61,6 @@ public class BitSetFilterCacheTests extends ESTestCase {
return count;
}
- @Test
public void testInvalidateEntries() throws Exception {
IndexWriter writer = new IndexWriter(
new RAMDirectory(),
diff --git a/core/src/test/java/org/elasticsearch/index/codec/CodecTests.java b/core/src/test/java/org/elasticsearch/index/codec/CodecTests.java
index 30a8e335fd..570ea3551f 100644
--- a/core/src/test/java/org/elasticsearch/index/codec/CodecTests.java
+++ b/core/src/test/java/org/elasticsearch/index/codec/CodecTests.java
@@ -41,14 +41,11 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.instanceOf;
@SuppressCodecs("*") // we test against default codec so never get a random one here!
public class CodecTests extends ESSingleNodeTestCase {
-
- @Test
public void testResolveDefaultCodecs() throws Exception {
CodecService codecService = createCodecService();
assertThat(codecService.codec("default"), instanceOf(PerFieldMappingPostingFormatCodec.class));
@@ -62,17 +59,17 @@ public class CodecTests extends ESSingleNodeTestCase {
assertThat(codecService.codec("Lucene41"), instanceOf(Lucene41Codec.class));
assertThat(codecService.codec("Lucene42"), instanceOf(Lucene42Codec.class));
}
-
+
public void testDefault() throws Exception {
Codec codec = createCodecService().codec("default");
assertCompressionEquals(Mode.BEST_SPEED, codec);
}
-
+
public void testBestCompression() throws Exception {
Codec codec = createCodecService().codec("best_compression");
assertCompressionEquals(Mode.BEST_COMPRESSION, codec);
}
-
+
// write some docs with it, inspect .si to see this was the used compression
private void assertCompressionEquals(Mode expected, Codec actual) throws Exception {
Directory dir = newDirectory();
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineIT.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineIT.java
index bae6be5ad4..76c07edcb0 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineIT.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineIT.java
@@ -26,15 +26,12 @@ import org.elasticsearch.action.admin.indices.segments.ShardSegments;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class InternalEngineIT extends ESIntegTestCase {
-
- @Test
public void testSetIndexCompoundOnFlush() {
client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("number_of_replicas", 0).put("number_of_shards", 1)).get();
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java
index 1ac7678c0a..a844f971ea 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java
@@ -25,22 +25,19 @@ import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@ClusterScope(numDataNodes = 1, scope = Scope.SUITE)
public class InternalEngineMergeIT extends ESIntegTestCase {
-
- @Test
public void testMergesHappening() throws InterruptedException, IOException, ExecutionException {
final int numOfShards = randomIntBetween(1,5);
// some settings to keep num segments low
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
index 2a6150267a..a7df234eb7 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
@@ -83,21 +83,23 @@ import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.internal.SourceFieldMapper;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.index.mapper.object.RootObjectMapper;
-import org.elasticsearch.index.shard.*;
+import org.elasticsearch.index.shard.IndexSearcherWrapper;
+import org.elasticsearch.index.shard.MergeSchedulerConfig;
+import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.index.shard.ShardUtils;
+import org.elasticsearch.index.shard.TranslogRecoveryPerformer;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.index.store.DirectoryService;
import org.elasticsearch.index.store.DirectoryUtils;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.index.translog.TranslogConfig;
-import org.elasticsearch.index.translog.TranslogTests;
import org.elasticsearch.test.DummyShardLock;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -108,7 +110,6 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -286,7 +287,6 @@ public class InternalEngineTests extends ESTestCase {
protected static final BytesReference B_2 = new BytesArray(new byte[]{2});
protected static final BytesReference B_3 = new BytesArray(new byte[]{3});
- @Test
public void testSegments() throws Exception {
try (Store store = createStore();
Engine engine = createEngine(defaultSettings, store, createTempDir(), new MergeSchedulerConfig(defaultSettings), NoMergePolicy.INSTANCE)) {
@@ -437,11 +437,8 @@ public class InternalEngineTests extends ESTestCase {
assertThat(segments.get(1).ramTree, notNullValue());
assertThat(segments.get(2).ramTree, notNullValue());
}
-
}
-
- @Test
public void testSegmentsWithMergeFlag() throws Exception {
try (Store store = createStore();
Engine engine = createEngine(defaultSettings, store, createTempDir(), new MergeSchedulerConfig(defaultSettings), new TieredMergePolicy())) {
@@ -516,7 +513,6 @@ public class InternalEngineTests extends ESTestCase {
assertThat(stats2.getUserData().get(Translog.TRANSLOG_UUID_KEY), equalTo(stats1.getUserData().get(Translog.TRANSLOG_UUID_KEY)));
}
- @Test
public void testIndexSearcherWrapper() throws Exception {
final AtomicInteger counter = new AtomicInteger();
IndexSearcherWrapper wrapper = new IndexSearcherWrapper() {
@@ -545,8 +541,6 @@ public class InternalEngineTests extends ESTestCase {
IOUtils.close(store, engine);
}
- @Test
- /* */
public void testConcurrentGetAndFlush() throws Exception {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocumentWithTextField(), B_1, null);
engine.index(new Engine.Index(newUid("1"), doc));
@@ -584,7 +578,6 @@ public class InternalEngineTests extends ESTestCase {
latestGetResult.get().release();
}
- @Test
public void testSimpleOperations() throws Exception {
Engine.Searcher searchResult = engine.acquireSearcher("test");
MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0));
@@ -739,7 +732,6 @@ public class InternalEngineTests extends ESTestCase {
searchResult.close();
}
- @Test
public void testSearchResultRelease() throws Exception {
Engine.Searcher searchResult = engine.acquireSearcher("test");
MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0));
@@ -845,7 +837,6 @@ public class InternalEngineTests extends ESTestCase {
assertNull("Sync ID must be gone since we have a document to replay", engine.getLastCommittedSegmentInfos().getUserData().get(Engine.SYNC_COMMIT_ID));
}
- @Test
public void testVersioningNewCreate() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED);
@@ -857,7 +848,6 @@ public class InternalEngineTests extends ESTestCase {
assertThat(create.version(), equalTo(1l));
}
- @Test
public void testVersioningNewIndex() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -869,7 +859,6 @@ public class InternalEngineTests extends ESTestCase {
assertThat(index.version(), equalTo(1l));
}
- @Test
public void testExternalVersioningNewIndex() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0);
@@ -881,7 +870,6 @@ public class InternalEngineTests extends ESTestCase {
assertThat(index.version(), equalTo(12l));
}
- @Test
public void testVersioningIndexConflict() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -910,7 +898,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testExternalVersioningIndexConflict() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0);
@@ -930,7 +917,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningIndexConflictWithFlush() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -961,7 +947,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testExternalVersioningIndexConflictWithFlush() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0);
@@ -1078,7 +1063,6 @@ public class InternalEngineTests extends ESTestCase {
}
- @Test
public void testVersioningDeleteConflict() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1129,7 +1113,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningDeleteConflictWithFlush() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1186,7 +1169,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningCreateExistsException() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, 0);
@@ -1202,7 +1184,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningCreateExistsExceptionWithFlush() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, 0);
@@ -1220,7 +1201,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningReplicaConflict1() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1256,7 +1236,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testVersioningReplicaConflict2() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1305,8 +1284,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
-
- @Test
public void testBasicCreatedFlag() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1321,7 +1298,6 @@ public class InternalEngineTests extends ESTestCase {
assertTrue(engine.index(index));
}
- @Test
public void testCreatedFlagAfterFlush() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
Engine.Index index = new Engine.Index(newUid("1"), doc);
@@ -1366,7 +1342,6 @@ public class InternalEngineTests extends ESTestCase {
// #5891: make sure IndexWriter's infoStream output is
// sent to lucene.iw with log level TRACE:
- @Test
public void testIndexWriterInfoStream() {
assumeFalse("who tests the tester?", VERBOSE);
MockAppender mockAppender = new MockAppender();
@@ -1432,7 +1407,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testEnableGcDeletes() throws Exception {
try (Store store = createStore();
Engine engine = new InternalEngine(config(defaultSettings, store, createTempDir(), new MergeSchedulerConfig(defaultSettings), newMergePolicy()), false)) {
@@ -1496,7 +1470,6 @@ public class InternalEngineTests extends ESTestCase {
return new Term("_uid", id);
}
- @Test
public void testExtractShardId() {
try (Engine.Searcher test = this.engine.acquireSearcher("test")) {
ShardId shardId = ShardUtils.extractShardId(test.getDirectoryReader());
@@ -1509,7 +1482,6 @@ public class InternalEngineTests extends ESTestCase {
* Random test that throws random exception and ensures all references are
* counted down / released and resources are closed.
*/
- @Test
public void testFailStart() throws IOException {
// this test fails if any reader, searcher or directory is not closed - MDW FTW
final int iters = scaledRandomIntBetween(10, 100);
@@ -1550,7 +1522,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testSettings() {
CodecService codecService = new CodecService(shardId.index());
LiveIndexWriterConfig currentIndexWriterConfig = engine.getCurrentIndexWriterConfig();
@@ -1560,7 +1531,6 @@ public class InternalEngineTests extends ESTestCase {
}
// #10312
- @Test
public void testDeletesAloneCanTriggerRefresh() throws Exception {
try (Store store = createStore();
Engine engine = new InternalEngine(config(defaultSettings, store, createTempDir(), new MergeSchedulerConfig(defaultSettings), newMergePolicy()),
@@ -1669,7 +1639,6 @@ public class InternalEngineTests extends ESTestCase {
}
}
- @Test
public void testSkipTranslogReplay() throws IOException {
final int numDocs = randomIntBetween(1, 10);
for (int i = 0; i < numDocs; i++) {
diff --git a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
index 7dadafb8a0..8bcc5d75bf 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
@@ -23,7 +23,13 @@ import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
+import org.apache.lucene.index.LiveIndexWriterConfig;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.NoMergePolicy;
+import org.apache.lucene.index.SnapshotDeletionPolicy;
+import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
@@ -60,7 +66,6 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
@@ -70,7 +75,12 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
* TODO: document me!
@@ -258,8 +268,6 @@ public class ShadowEngineTests extends ESTestCase {
assertThat(stats2.getUserData().get(Translog.TRANSLOG_UUID_KEY), equalTo(stats1.getUserData().get(Translog.TRANSLOG_UUID_KEY)));
}
-
- @Test
public void testSegments() throws Exception {
primaryEngine.close(); // recreate without merging
primaryEngine = createInternalEngine(defaultSettings, store, createTempDir(), NoMergePolicy.INSTANCE);
@@ -433,7 +441,6 @@ public class ShadowEngineTests extends ESTestCase {
assertThat(segments.get(2).isCompound(), equalTo(true));
}
- @Test
public void testVerboseSegments() throws Exception {
primaryEngine.close(); // recreate without merging
primaryEngine = createInternalEngine(defaultSettings, store, createTempDir(), NoMergePolicy.INSTANCE);
@@ -473,7 +480,6 @@ public class ShadowEngineTests extends ESTestCase {
}
- @Test
public void testShadowEngineIgnoresWriteOperations() throws Exception {
// create a document
ParseContext.Document document = testDocumentWithTextField();
@@ -563,7 +569,6 @@ public class ShadowEngineTests extends ESTestCase {
getResult.release();
}
- @Test
public void testSimpleOperations() throws Exception {
Engine.Searcher searchResult = primaryEngine.acquireSearcher("test");
MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0));
@@ -776,7 +781,6 @@ public class ShadowEngineTests extends ESTestCase {
searchResult.close();
}
- @Test
public void testSearchResultRelease() throws Exception {
Engine.Searcher searchResult = replicaEngine.acquireSearcher("test");
MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0));
@@ -827,7 +831,6 @@ public class ShadowEngineTests extends ESTestCase {
searchResult.close();
}
- @Test
public void testFailEngineOnCorruption() {
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocumentWithTextField(), B_1, null);
primaryEngine.index(new Engine.Index(newUid("1"), doc));
@@ -852,7 +855,6 @@ public class ShadowEngineTests extends ESTestCase {
}
}
- @Test
public void testExtractShardId() {
try (Engine.Searcher test = replicaEngine.acquireSearcher("test")) {
ShardId shardId = ShardUtils.extractShardId(test.getDirectoryReader());
@@ -865,7 +867,6 @@ public class ShadowEngineTests extends ESTestCase {
* Random test that throws random exception and ensures all references are
* counted down / released and resources are closed.
*/
- @Test
public void testFailStart() throws IOException {
// Need a commit point for this
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocumentWithTextField(), B_1, null);
@@ -910,13 +911,11 @@ public class ShadowEngineTests extends ESTestCase {
}
}
- @Test
public void testSettings() {
CodecService codecService = new CodecService(shardId.index());
assertEquals(replicaEngine.config().getCodec().getName(), codecService.codec(codecName).getName());
}
- @Test
public void testShadowEngineCreationRetry() throws Exception {
final Path srDir = createTempDir();
final Store srStore = createStore(srDir);
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
index ff072233ea..743be63785 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
@@ -21,13 +21,18 @@ package org.elasticsearch.index.fielddata;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.FieldDoc;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.Strings;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTestCase {
@@ -63,7 +68,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
return 1;
}
- @Test
public void testDeletedDocs() throws Exception {
add2SingleValuedDocumentsAndDeleteOneOfThem();
IndexFieldData indexFieldData = getForField("value");
@@ -76,7 +80,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
}
}
- @Test
public void testSingleValueAllSet() throws Exception {
fillSingleValueAllSet();
IndexFieldData indexFieldData = getForField("value");
@@ -122,7 +125,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
}
protected abstract void fillSingleValueWithMissing() throws Exception;
-
+
public void assertValues(SortedBinaryDocValues values, int docId, BytesRef... actualValues) {
values.setDocument(docId);
assertThat(values.count(), equalTo(actualValues.length));
@@ -130,7 +133,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
assertThat(values.valueAt(i), equalTo(actualValues[i]));
}
}
-
+
public void assertValues(SortedBinaryDocValues values, int docId, String... actualValues) {
values.setDocument(docId);
assertThat(values.count(), equalTo(actualValues.length));
@@ -139,8 +142,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
}
}
-
- @Test
public void testSingleValueWithMissing() throws Exception {
fillSingleValueWithMissing();
IndexFieldData indexFieldData = getForField("value");
@@ -157,7 +158,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
protected abstract void fillMultiValueAllSet() throws Exception;
- @Test
public void testMultiValueAllSet() throws Exception {
fillMultiValueAllSet();
IndexFieldData indexFieldData = getForField("value");
@@ -169,7 +169,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
assertValues(bytesValues, 0, two(), four());
assertValues(bytesValues, 1, one());
assertValues(bytesValues, 2, three());
-
+
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, true));
TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10, new Sort(new SortField("value", indexFieldData.comparatorSource(null, MultiValueMode.MIN, null))));
assertThat(topDocs.totalHits, equalTo(3));
@@ -188,7 +188,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
protected abstract void fillMultiValueWithMissing() throws Exception;
- @Test
public void testMultiValueWithMissing() throws Exception {
fillMultiValueWithMissing();
IndexFieldData indexFieldData = getForField("value");
@@ -223,7 +222,6 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
protected abstract void fillAllMissing() throws Exception;
- @Test
public void testSortMultiValuesFields() throws Exception {
fillExtendedMvSet();
IndexFieldData indexFieldData = getForField("value");
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractNumericFieldDataTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractNumericFieldDataTestCase.java
index 5c28a8f6c5..8303f8ef8d 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractNumericFieldDataTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractNumericFieldDataTestCase.java
@@ -24,10 +24,14 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.SortedNumericDocValues;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.FieldDoc;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TopFieldDocs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
import java.util.Locale;
@@ -36,7 +40,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldDataImplTestCase {
-
@Override
protected abstract FieldDataType getFieldDataType();
@@ -50,7 +53,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
return builder;
}
- @Test
public void testSingleValueAllSetNumber() throws Exception {
fillSingleValueAllSet();
IndexNumericFieldData indexFieldData = getForField("value");
@@ -106,7 +108,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
assertThat(topDocs.scoreDocs[2].doc, equalTo(1));
}
- @Test
public void testSingleValueWithMissingNumber() throws Exception {
fillSingleValueWithMissing();
IndexNumericFieldData indexFieldData = getForField("value");
@@ -188,7 +189,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
assertThat(topDocs.scoreDocs[2].doc, equalTo(1));
}
- @Test
public void testMultiValueAllSetNumber() throws Exception {
fillMultiValueAllSet();
IndexNumericFieldData indexFieldData = getForField("value");
@@ -229,7 +229,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
assertThat(doubleValues.valueAt(0), equalTo(3d));
}
- @Test
public void testMultiValueWithMissingNumber() throws Exception {
fillMultiValueWithMissing();
IndexNumericFieldData indexFieldData = getForField("value");
@@ -270,7 +269,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
}
@Override
- @Test
public void testMissingValueForAll() throws Exception {
fillAllMissing();
IndexNumericFieldData indexFieldData = getForField("value");
@@ -320,7 +318,6 @@ public abstract class AbstractNumericFieldDataTestCase extends AbstractFieldData
}
@Override
- @Test
public void testSortMultiValuesFields() throws Exception {
fillExtendedMvSet();
IndexFieldData indexFieldData = getForField("value");
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java
index 29e171c426..b1f9d73de7 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java
@@ -26,7 +26,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.RandomAccessOrds;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -50,7 +54,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.N
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -66,7 +69,6 @@ import static org.hamcrest.Matchers.sameInstance;
/**
*/
public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataImplTestCase {
-
private void addField(Document d, String name, String value) {
d.add(new StringField(name, value, Field.Store.YES));
d.add(new SortedSetDocValuesField(name, new BytesRef(value)));
@@ -463,7 +465,6 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI
}
}
- @Test
public void testGlobalOrdinals() throws Exception {
fillExtendedMvSet();
refreshReader();
@@ -554,7 +555,6 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI
assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!10"));
}
- @Test
public void testTermsEnum() throws Exception {
fillExtendedMvSet();
LeafReaderContext atomicReaderContext = refreshReader();
@@ -590,7 +590,6 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI
assertThat(size, equalTo(3));
}
- @Test
public void testGlobalOrdinalsGetRemovedOnceIndexReaderCloses() throws Exception {
fillExtendedMvSet();
refreshReader();
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java
index bc63ed9f18..73fdd79b10 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java
@@ -20,6 +20,7 @@
package org.elasticsearch.index.fielddata;
import com.carrotsearch.hppc.ObjectArrayList;
+
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.settings.Settings;
@@ -28,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -36,13 +36,11 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class BinaryDVFieldDataTests extends AbstractFieldDataTestCase {
-
@Override
protected boolean hasDocValues() {
return true;
}
- @Test
public void testDocValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("test")
.startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
index f02c286c60..171e48f9b4 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
@@ -20,6 +20,7 @@ package org.elasticsearch.index.fielddata;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
+
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.SortedSetDocValuesField;
@@ -41,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -54,16 +54,16 @@ import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.lessThan;
public class DuelFieldDataTests extends AbstractFieldDataTestCase {
-
@Override
protected FieldDataType getFieldDataType() {
return null;
}
- @Test
public void testDuelAllTypesSingleValue() throws Exception {
final String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -140,8 +140,6 @@ public class DuelFieldDataTests extends AbstractFieldDataTestCase {
}
}
-
- @Test
public void testDuelIntegers() throws Exception {
final String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -163,7 +161,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTestCase {
for (int j = 0; j < numValues; ++j) {
vals.add(randomByte());
}
-
+
numValues = vals.size();
int upto = 0;
for (Byte bb : vals) {
@@ -225,7 +223,6 @@ public class DuelFieldDataTests extends AbstractFieldDataTestCase {
}
- @Test
public void testDuelDoubles() throws Exception {
final String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -308,8 +305,6 @@ public class DuelFieldDataTests extends AbstractFieldDataTestCase {
}
-
- @Test
public void testDuelStrings() throws Exception {
Random random = getRandom();
int atLeast = scaledRandomIntBetween(200, 1500);
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java
index 393f481e17..adb511f1c8 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
@@ -42,7 +41,6 @@ public class FieldDataFilterIntegrationIT extends ESIntegTestCase {
return 0;
}
- @Test
public void testRegexpFilter() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test");
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -78,7 +76,7 @@ public class FieldDataFilterIntegrationIT extends ESIntegTestCase {
Terms nameAgg = aggs.get("name");
assertThat(nameAgg.getBuckets().size(), Matchers.equalTo(1));
assertThat(nameAgg.getBuckets().iterator().next().getKeyAsString(), Matchers.equalTo("bacon"));
-
+
Terms notFilteredAgg = aggs.get("not_filtered");
assertThat(notFilteredAgg.getBuckets().size(), Matchers.equalTo(2));
assertThat(notFilteredAgg.getBuckets().get(0).getKeyAsString(), Matchers.isOneOf("bacon", "bastards"));
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java
index 12aeb70df2..fc8a830f9c 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.fielddata;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -30,8 +29,6 @@ import static org.hamcrest.Matchers.greaterThan;
/**
*/
public class FieldDataLoadingIT extends ESIntegTestCase {
-
- @Test
public void testEagerFieldDataLoading() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties")
@@ -49,7 +46,6 @@ public class FieldDataLoadingIT extends ESIntegTestCase {
assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0l));
}
- @Test
public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java
index 4b9d0e1805..49cb414208 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java
@@ -24,21 +24,18 @@ import org.apache.lucene.document.StringField;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.RandomAccessOrds;
import org.elasticsearch.common.settings.Settings;
-import org.junit.Test;
import java.util.Random;
import static org.hamcrest.Matchers.equalTo;
public class FilterFieldDataTests extends AbstractFieldDataTestCase {
-
@Override
protected FieldDataType getFieldDataType() {
// TODO Auto-generated method stub
return null;
}
- @Test
public void testFilterByFrequency() throws Exception {
Random random = getRandom();
for (int i = 0; i < 1000; i++) {
@@ -61,7 +58,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
writer.forceMerge(1, true);
LeafReaderContext context = refreshReader();
String[] formats = new String[] { "paged_bytes"};
-
+
for (String format : formats) {
{
ifdService.clear();
@@ -84,7 +81,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
assertThat(1L, equalTo(bytesValues.getValueCount()));
assertThat(bytesValues.lookupOrd(0).utf8ToString(), equalTo("5"));
}
-
+
{
ifdService.clear(); // test # docs with value
FieldDataType fieldDataType = new FieldDataType("string", Settings.builder().put("format", format)
@@ -96,7 +93,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
assertThat(bytesValues.lookupOrd(0).utf8ToString(), equalTo("10"));
assertThat(bytesValues.lookupOrd(1).utf8ToString(), equalTo("100"));
}
-
+
{
ifdService.clear();
FieldDataType fieldDataType = new FieldDataType("string", Settings.builder().put("format", format)
@@ -108,7 +105,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
assertThat(bytesValues.lookupOrd(0).utf8ToString(), equalTo("10"));
assertThat(bytesValues.lookupOrd(1).utf8ToString(), equalTo("100"));
}
-
+
{
ifdService.clear();
FieldDataType fieldDataType = new FieldDataType("string", Settings.builder().put("format", format)
@@ -125,10 +122,8 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
}
}
-
- @Test
- public void testFilterByRegExp() throws Exception {
+ public void testFilterByRegExp() throws Exception {
int hundred = 0;
int ten = 0;
int five = 0;
@@ -182,6 +177,6 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase {
@Override
public void testEmpty() throws Exception {
- // No need to test empty usage here
+ assumeTrue("No need to test empty usage here", false);
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java
index f47b94d708..f9bb02e036 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java
@@ -29,7 +29,6 @@ import org.apache.lucene.document.StringField;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.Term;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -67,7 +66,6 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTestCase {
writer.deleteDocuments(new Term("_id", "1"));
}
- @Test
public void testOptimizeTypeLong() throws Exception {
Document d = new Document();
d.add(new StringField("_id", "1", Field.Store.NO));
@@ -81,8 +79,8 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTestCase {
IndexNumericFieldData indexFieldData = getForField("value");
AtomicNumericFieldData fieldData = indexFieldData.load(refreshReader());
- assertThat(getFirst(fieldData.getLongValues(), 0), equalTo((long) Integer.MAX_VALUE + 1l));
- assertThat(getFirst(fieldData.getLongValues(), 1), equalTo((long) Integer.MIN_VALUE - 1l));
+ assertThat(getFirst(fieldData.getLongValues(), 0), equalTo(Integer.MAX_VALUE + 1l));
+ assertThat(getFirst(fieldData.getLongValues(), 1), equalTo(Integer.MIN_VALUE - 1l));
}
private static long getFirst(SortedNumericDocValues values, int docId) {
@@ -92,14 +90,6 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTestCase {
return values.valueAt(0);
}
- private static double getFirst(SortedNumericDoubleValues values, int docId) {
- values.setDocument(docId);
- final int numValues = values.count();
- assertThat(numValues, is(1));
- return values.valueAt(0);
- }
-
- @Test
public void testDateScripts() throws Exception {
fillSingleValueAllSet();
IndexNumericFieldData indexFieldData = getForField("value");
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java
index 982f5e4d4e..230330dbbf 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java
@@ -19,14 +19,13 @@
package org.elasticsearch.index.fielddata;
-import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
import org.elasticsearch.index.mapper.MappedFieldType.Names;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
/** Returns an implementation based on paged bytes which doesn't implement WithOrdinals in order to visit different paths in the code,
* eg. BytesRefFieldComparatorSource makes decisions based on whether the field data implements WithOrdinals. */
@@ -79,9 +78,8 @@ public class NoOrdinalsStringFieldDataTests extends PagedBytesStringFieldDataTes
return hideOrdinals(super.getForField(fieldName));
}
- @Test
@Override
public void testTermsEnum() throws Exception {
- // We can't test this, since the returned IFD instance doesn't implement IndexFieldData.WithOrdinals
+ assumeTrue("We can't test this, since the returned IFD instance doesn't implement IndexFieldData.WithOrdinals", false);
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/ParentChildFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/ParentChildFieldDataTests.java
index b265988c33..eefe8c8918 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/ParentChildFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/ParentChildFieldDataTests.java
@@ -26,7 +26,12 @@ import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedDocValues;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.FieldDoc;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.common.compress.CompressedXContent;
@@ -36,7 +41,6 @@ import org.elasticsearch.index.mapper.internal.ParentFieldMapper;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.search.MultiValueMode;
import org.junit.Before;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -49,7 +53,6 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class ParentChildFieldDataTests extends AbstractFieldDataTestCase {
-
private final String parentType = "parent";
private final String childType = "child";
private final String grandChildType = "grand-child";
@@ -118,7 +121,6 @@ public class ParentChildFieldDataTests extends AbstractFieldDataTestCase {
return new SortedDocValuesField(ParentFieldMapper.joinField(parentType), new BytesRef(id));
}
- @Test
public void testGetBytesValues() throws Exception {
IndexFieldData indexFieldData = getForField(childType);
AtomicFieldData fieldData = indexFieldData.load(refreshReader());
@@ -160,7 +162,6 @@ public class ParentChildFieldDataTests extends AbstractFieldDataTestCase {
assertThat(bytesValues.count(), equalTo(0));
}
- @Test
public void testSorting() throws Exception {
IndexFieldData indexFieldData = getForField(childType);
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, true));
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java
index f855d3f9d7..655483fa31 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java
@@ -25,10 +25,15 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
import static org.hamcrest.Matchers.equalTo;
@@ -45,8 +50,6 @@ public class MultiOrdinalsTests extends ESTestCase {
return builder.build(settings.build());
}
-
- @Test
public void testRandomValues() throws IOException {
Random random = getRandom();
int numDocs = 100 + random.nextInt(1000);
@@ -182,7 +185,6 @@ public class MultiOrdinalsTests extends ESTestCase {
}
}
- @Test
public void testOrdinals() throws Exception {
int maxDoc = 7;
long maxOrds = 32;
@@ -227,7 +229,6 @@ public class MultiOrdinalsTests extends ESTestCase {
}
}
- @Test
public void testMultiValuesDocsWithOverlappingStorageArrays() throws Exception {
int maxDoc = 7;
long maxOrds = 15;
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/SingleOrdinalsTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/SingleOrdinalsTests.java
index 59be0f9a4f..3e0d5f6ad2 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/SingleOrdinalsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/SingleOrdinalsTests.java
@@ -23,19 +23,18 @@ import org.apache.lucene.index.RandomAccessOrds;
import org.apache.lucene.index.SortedDocValues;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.not;
/**
*/
public class SingleOrdinalsTests extends ESTestCase {
-
- @Test
public void testSvValues() throws IOException {
int numDocs = 1000000;
int numOrdinals = numDocs / 4;
@@ -61,7 +60,6 @@ public class SingleOrdinalsTests extends ESTestCase {
}
}
- @Test
public void testMvOrdinalsTrigger() throws IOException {
int numDocs = 1000000;
OrdinalsBuilder builder = new OrdinalsBuilder(numDocs);
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
index add7ee6a7f..b37392821a 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
@@ -23,21 +23,18 @@ import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.junit.Rule;
-import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.elasticsearch.test.VersionUtils.getFirstVersion;
import static org.elasticsearch.test.VersionUtils.getPreviousVersion;
import static org.elasticsearch.test.VersionUtils.randomVersionBetween;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasToString;
public class MapperServiceTests extends ESSingleNodeTestCase {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- @Test
public void testTypeNameStartsWithIllegalDot() {
expectedException.expect(MapperParsingException.class);
expectedException.expect(hasToString(containsString("mapping type name [.test-type] must not start with a '.'")));
@@ -53,7 +50,6 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
.actionGet();
}
- @Test
public void testThatLongTypeNameIsNotRejectedOnPreElasticsearchVersionTwo() {
String index = "text-index";
String field = "field";
@@ -71,7 +67,6 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
assertNotNull(response);
}
- @Test
public void testTypeNameTooLong() {
String index = "text-index";
String field = "field";
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/UidTests.java b/core/src/test/java/org/elasticsearch/index/mapper/UidTests.java
index d6a5c9f553..860c66863f 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/UidTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/UidTests.java
@@ -20,13 +20,10 @@ package org.elasticsearch.index.mapper;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class UidTests extends ESTestCase {
-
- @Test
public void testCreateAndSplitId() {
BytesRef createUid = Uid.createUidAsBytes("foo", "bar");
BytesRef[] splitUidIntoTypeAndId = Uid.splitUidIntoTypeAndId(createUid);
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java
index 0e3a04aa69..9e640972d3 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java
@@ -43,12 +43,10 @@ import org.elasticsearch.index.mapper.DocumentMapperParser;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.index.mapper.ParsedDocument;
-import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
-import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
+import org.elasticsearch.test.ESSingleNodeTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -57,9 +55,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
@@ -349,24 +347,39 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase {
assertThat(allEntries.fields(), hasItem("foo.bar"));
}
- @Test(expected = MapperParsingException.class)
public void testMisplacedTypeInRoot() throws IOException {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/misplaced_type_in_root.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ try {
+ createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters"));
+ assertThat(e.getMessage(), containsString("[type : string]"));
+ }
}
// related to https://github.com/elasticsearch/elasticsearch/issues/5864
- @Test(expected = MapperParsingException.class)
public void testMistypedTypeInRoot() throws IOException {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/mistyped_type_in_root.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ try {
+ createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters"));
+ assertThat(e.getMessage(), containsString("type=string"));
+ }
}
// issue https://github.com/elasticsearch/elasticsearch/issues/5864
- @Test(expected = MapperParsingException.class)
public void testMisplacedMappingAsRoot() throws IOException {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/misplaced_mapping_key_in_root.json");
- DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ try {
+ createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters"));
+ assertThat(e.getMessage(), containsString("type=string"));
+ }
}
// issue https://github.com/elasticsearch/elasticsearch/issues/5864
@@ -399,7 +412,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase {
mapping += "\"properties\":{}}" ;
createIndex("test").mapperService().documentMapperParser().parse("test", mapping);
}
-
+
public void testDocValuesNotAllowed() throws IOException {
String mapping = jsonBuilder().startObject().startObject("type")
.startObject("_all")
@@ -411,7 +424,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase {
} catch (MapperParsingException e) {
assertThat(e.getDetailedMessage(), containsString("[_all] is always tokenized and cannot have doc values"));
}
-
+
mapping = jsonBuilder().startObject().startObject("type")
.startObject("_all")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java
index d18acfe56a..05a0a03cc5 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java
@@ -23,13 +23,10 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class CustomBoostMappingTests extends ESSingleNodeTestCase {
-
- @Test
public void testCustomBoostValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("s_field").field("type", "string").endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java b/core/src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java
index 5c5ce7bdae..c9320e2da1 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java
@@ -26,15 +26,12 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.closeTo;
/**
*/
public class FieldLevelBoostTests extends ESSingleNodeTestCase {
-
- @Test
public void testFieldLevelBoost() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties")
.startObject("str_field").field("type", "string").endObject()
@@ -85,7 +82,6 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
assertThat((double) f.boost(), closeTo(9.0, 0.001));
}
- @Test
public void testInvalidFieldLevelBoost() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties")
.startObject("str_field").field("type", "string").endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java b/core/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java
index 89e186445d..1cfee0dd66 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java
@@ -24,14 +24,11 @@ import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
/**
*
*/
public class CamelCaseFieldNameTests extends ESSingleNodeTestCase {
-
- @Test
public void testCamelCaseFieldNameStaysAsIs() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject().string();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java
index 717823d9ff..10094ccd6d 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.core.CompletionFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Map;
@@ -35,8 +34,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
public class CompletionFieldMapperTests extends ESSingleNodeTestCase {
-
- @Test
public void testDefaultConfiguration() throws IOException {
String mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("completion")
@@ -53,7 +50,6 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase {
assertThat(completionFieldMapper.isStoringPayloads(), is(false));
}
- @Test
public void testThatSerializationIncludesAllElements() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("completion")
@@ -90,7 +86,6 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase {
assertThat(Integer.valueOf(configMap.get("max_input_length").toString()), is(14));
}
- @Test
public void testThatSerializationCombinesToOneAnalyzerFieldIfBothAreEqual() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("completion")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java b/core/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java
index fa2e1a1237..4dc017aa6b 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java
@@ -23,14 +23,11 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
public class CompoundTypesTests extends ESSingleNodeTestCase {
-
- @Test
public void testStringType() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java
index 5919c52bc3..1d6e72834c 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -37,9 +36,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class CopyToMapperIntegrationIT extends ESIntegTestCase {
-
-
- @Test
public void testDynamicTemplateCopyTo() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("test-idx")
@@ -56,7 +52,7 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase {
client().admin().indices().prepareRefresh("test-idx").execute().actionGet();
SubAggCollectionMode aggCollectionMode = randomFrom(SubAggCollectionMode.values());
-
+
SearchResponse response = client().prepareSearch("test-idx")
.setQuery(QueryBuilders.termQuery("even", true))
.addAggregation(AggregationBuilders.terms("test").field("test_field").size(recordCount * 2)
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java
index 419dde456d..301d6b13e3 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.core.LongFieldMapper;
import org.elasticsearch.index.mapper.core.StringFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.List;
@@ -54,9 +53,7 @@ import static org.hamcrest.Matchers.startsWith;
*
*/
public class CopyToMapperTests extends ESSingleNodeTestCase {
-
@SuppressWarnings("unchecked")
- @Test
public void testCopyToFieldsParsing() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("copy_test")
@@ -135,8 +132,6 @@ public class CopyToMapperTests extends ESSingleNodeTestCase {
assertThat(fieldMapper, instanceOf(LongFieldMapper.class));
}
- @SuppressWarnings("unchecked")
- @Test
public void testCopyToFieldsInnerObjectParsing() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -172,8 +167,6 @@ public class CopyToMapperTests extends ESSingleNodeTestCase {
}
- @SuppressWarnings("unchecked")
- @Test
public void testCopyToFieldsNonExistingInnerObjectParsing() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -198,9 +191,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testCopyToFieldMerge() throws Exception {
-
String mappingBefore = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("copy_test")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperIntegrationIT.java
index 613cdde97e..abca559553 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperIntegrationIT.java
@@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.core;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -31,7 +32,6 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,7 +39,10 @@ import java.util.Arrays;
import java.util.List;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
@ParametersFactory
@@ -65,8 +68,7 @@ public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
/**
* It is possible to get the token count in a search response.
*/
- @Test
- public void searchReturnsTokenCount() throws IOException {
+ public void testSearchReturnsTokenCount() throws IOException {
init();
assertSearchReturns(searchById("single"), "single");
@@ -80,8 +82,7 @@ public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
/**
* It is possible to search by token count.
*/
- @Test
- public void searchByTokenCount() throws IOException {
+ public void testSearchByTokenCount() throws IOException {
init();
assertSearchReturns(searchByNumericRange(4, 4).get(), "single");
@@ -94,8 +95,7 @@ public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
/**
* It is possible to search by token count.
*/
- @Test
- public void facetByTokenCount() throws IOException {
+ public void testFacetByTokenCount() throws IOException {
init();
String facetField = randomFrom(Arrays.asList(
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperTests.java
index 5a644e56f4..b1224d5c6c 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapperTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.DocumentMapperParser;
import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -41,7 +40,6 @@ import static org.hamcrest.Matchers.equalTo;
* Test for {@link TokenCountFieldMapper}.
*/
public class TokenCountFieldMapperTests extends ESSingleNodeTestCase {
- @Test
public void testMerge() throws IOException {
String stage1Mapping = XContentFactory.jsonBuilder().startObject()
.startObject("person")
@@ -77,7 +75,6 @@ public class TokenCountFieldMapperTests extends ESSingleNodeTestCase {
assertThat(((TokenCountFieldMapper) stage1.mappers().smartNameFieldMapper("tc")).analyzer(), equalTo("standard"));
}
- @Test
public void testCountPositions() throws IOException {
// We're looking to make sure that we:
Token t1 = new Token(); // Don't count tokens without an increment
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java
index 76383408ed..d07e617781 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
@@ -37,8 +36,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class GenericStoreDynamicTemplateTests extends ESSingleNodeTestCase {
-
- @Test
public void testSimple() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json");
IndexService index = createIndex("test");
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java
index 34c855f4f2..829730e68c 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java
@@ -24,10 +24,9 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldMapper;
-import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.ParseContext.Document;
+import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
@@ -37,8 +36,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class PathMatchDynamicTemplateTests extends ESSingleNodeTestCase {
-
- @Test
public void testSimple() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json");
IndexService index = createIndex("test");
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java
index 09358b5280..014f029580 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java
@@ -25,11 +25,13 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.IndexService;
-import org.elasticsearch.index.mapper.*;
+import org.elasticsearch.index.mapper.DocumentFieldMappers;
+import org.elasticsearch.index.mapper.DocumentMapper;
+import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.ParseContext.Document;
+import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
@@ -39,8 +41,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class SimpleDynamicTemplatesTests extends ESSingleNodeTestCase {
-
- @Test
public void testMatchTypeOnly() throws Exception {
XContentBuilder builder = JsonXContent.contentBuilder();
builder.startObject().startObject("person").startArray("dynamic_templates").startObject().startObject("test")
@@ -66,8 +66,6 @@ public class SimpleDynamicTemplatesTests extends ESSingleNodeTestCase {
}
-
- @Test
public void testSimple() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
IndexService index = createIndex("test");
@@ -124,7 +122,6 @@ public class SimpleDynamicTemplatesTests extends ESSingleNodeTestCase {
assertNotNull(fieldMapper);
}
- @Test
public void testSimpleWithXContentTraverse() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
IndexService index = createIndex("test");
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java
index 6d28f2daaf..2e763e2fd1 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java
@@ -26,20 +26,17 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import static org.hamcrest.Matchers.equalTo;
public class ExternalValuesMapperIntegrationIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(ExternalMapperPlugin.class);
}
- @Test
public void testExternalValues() throws Exception {
prepareCreate("test-idx").addMapping("type",
XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -84,7 +81,6 @@ public class ExternalValuesMapperIntegrationIT extends ESIntegTestCase {
assertThat(response.getHits().totalHits(), equalTo((long) 1));
}
- @Test
public void testExternalValuesWithMultifield() throws Exception {
prepareCreate("test-idx").addMapping("doc",
XContentFactory.jsonBuilder().startObject().startObject("doc").startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java
index bc808ab5b0..658217c70d 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@@ -32,8 +31,6 @@ import static org.hamcrest.Matchers.notNullValue;
/**
*/
public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
-
- @Test
public void testExternalValues() throws Exception {
MapperService mapperService = createIndex("test").mapperService();
mapperService.documentMapperParser().putRootTypeParser(ExternalMetadataMapper.CONTENT_TYPE,
@@ -72,7 +69,6 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
}
- @Test
public void testExternalValuesWithMultifield() throws Exception {
MapperService mapperService = createIndex("test").mapperService();
mapperService.documentMapperParser().putTypeParser(RegisterExternalTypes.EXTERNAL,
@@ -120,7 +116,6 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("field.field.raw").stringValue(), is("foo"));
}
- @Test
public void testExternalValuesWithMultifieldTwoLevels() throws Exception {
MapperService mapperService = createIndex("test").mapperService();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java
index 1c5a847c93..1892081095 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java
@@ -34,7 +34,6 @@ import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,12 +42,14 @@ import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.isIn;
+import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
- @Test
public void testLatLonValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
@@ -70,7 +71,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLatLonValuesWithGeohash() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject()
@@ -89,7 +89,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point.geohash"), equalTo(XGeoHashUtils.stringEncode(1.3, 1.2)));
}
- @Test
public void testLatLonInOneValueWithGeohash() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject()
@@ -108,7 +107,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point.geohash"), equalTo(XGeoHashUtils.stringEncode(1.3, 1.2)));
}
- @Test
public void testGeoHashIndexValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject()
@@ -127,7 +125,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point.geohash"), equalTo(XGeoHashUtils.stringEncode(1.3, 1.2)));
}
- @Test
public void testGeoHashValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
@@ -146,7 +143,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), notNullValue());
}
- @Test
public void testNormalizeLatLonValuesDefault() throws Exception {
// default to normalize
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -181,7 +177,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("-1.0,-179.0"));
}
- @Test
public void testValidateLatLonValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("coerce", false)
@@ -242,7 +237,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testNoValidateLatLonValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("coerce", false)
@@ -283,7 +277,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
.bytes());
}
- @Test
public void testLatLonValuesStored() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -305,7 +298,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testArrayLatLonValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -332,7 +324,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5"));
}
- @Test
public void testLatLonInOneValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
@@ -351,7 +342,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLatLonInOneValueStored() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -372,7 +362,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLatLonInOneValueArray() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -399,7 +388,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5"));
}
- @Test
public void testLonLatArray() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
@@ -418,7 +406,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLonLatArrayDynamic() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startArray("dynamic_templates").startObject()
@@ -439,7 +426,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLonLatArrayStored() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -460,7 +446,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLonLatArrayArrayStored() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject()
@@ -491,7 +476,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
/**
* Test that expected exceptions are thrown when creating a new index with deprecated options
*/
- @Test
public void testOptionDeprecation() throws Exception {
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
// test deprecation exceptions on newly created indexes
@@ -566,7 +550,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
/**
* Test backward compatibility
*/
- @Test
public void testBackwardCompatibleOptions() throws Exception {
// backward compatibility testing
Settings settings = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0,
@@ -618,7 +601,6 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
assertThat(parser.parse(mapping).mapping().toString(), containsString("\"coerce\":true"));
}
- @Test
public void testGeoPointMapperMerge() throws Exception {
String stage1Mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true)
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapperTests.java
index 26f7129e0a..c00bd3101a 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapperTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.DocumentMapperParser;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -41,8 +40,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.isIn;
public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
-
- @Test
public void testDefaultConfiguration() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -135,7 +132,6 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(coerce, equalTo(false));
}
- @Test
public void testGeohashConfiguration() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -158,7 +154,6 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getGrid().getMaxLevels(), equalTo(4));
}
- @Test
public void testQuadtreeConfiguration() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -182,8 +177,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getGrid().getMaxLevels(), equalTo(6));
assertThat(strategy.isPointsOnly(), equalTo(true));
}
-
- @Test
+
public void testLevelPrecisionConfiguration() throws IOException {
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
@@ -198,7 +192,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()
.endObject().endObject().string();
-
+
DocumentMapper defaultMapper = parser.parse(mapping);
FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -209,7 +203,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(QuadPrefixTree.class));
// 70m is more precise so it wins
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(70d)));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(70d)));
}
{
@@ -237,7 +231,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
// 70m is less precise so it loses
assertThat(strategy.getGrid().getMaxLevels(), equalTo(26));
}
-
+
{
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -259,9 +253,9 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
// 70m is more precise so it wins
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(70d)));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(70d)));
}
-
+
{
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -282,9 +276,9 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(70d)+1));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(70d)+1));
}
-
+
{
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -305,11 +299,10 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(QuadPrefixTree.class));
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(70d)+1));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(70d)+1));
}
}
- @Test
public void testPointsOnlyOption() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -330,7 +323,6 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.isPointsOnly(), equalTo(true));
}
- @Test
public void testLevelDefaults() throws IOException {
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
{
@@ -342,7 +334,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()
.endObject().endObject().string();
-
+
DocumentMapper defaultMapper = parser.parse(mapping);
FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));
@@ -353,9 +345,9 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(QuadPrefixTree.class));
/* 50m is default */
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(50d)));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.quadTreeLevelsForPrecision(50d)));
}
-
+
{
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -375,11 +367,10 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
assertThat(strategy.getDistErrPct(), equalTo(0.5));
assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
/* 50m is default */
- assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(50d)));
+ assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoUtils.geoHashLevelsForPrecision(50d)));
}
}
- @Test
public void testGeoShapeMapperMerge() throws Exception {
String stage1Mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("shape").field("type", "geo_shape").field("tree", "geohash").field("strategy", "recursive")
@@ -397,7 +388,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase {
// check correct conflicts
assertThat(mergeResult.hasConflicts(), equalTo(true));
assertThat(mergeResult.buildConflicts().length, equalTo(4));
- ArrayList conflicts = new ArrayList<>(Arrays.asList(mergeResult.buildConflicts()));
+ ArrayList<String> conflicts = new ArrayList<>(Arrays.asList(mergeResult.buildConflicts()));
assertThat("mapper [shape] has different [strategy]", isIn(conflicts));
assertThat("mapper [shape] has different [tree]", isIn(conflicts));
assertThat("mapper [shape] has different [tree_levels]", isIn(conflicts));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeohashMappingGeoPointTests.java b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeohashMappingGeoPointTests.java
index 6338f4b924..0e4da76eaf 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeohashMappingGeoPointTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeohashMappingGeoPointTests.java
@@ -26,16 +26,17 @@ import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
-
- @Test
public void testLatLonValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", false).endObject().endObject()
@@ -54,7 +55,6 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testLatLonInOneValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", false).endObject().endObject()
@@ -73,7 +73,6 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
}
- @Test
public void testGeoHashValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject()
@@ -93,7 +92,6 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
MatcherAssert.assertThat(doc.rootDoc().get("point"), notNullValue());
}
- @Test
public void testGeoHashPrecisionAsInteger() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).field("geohash_precision", 10).endObject().endObject()
@@ -105,7 +103,6 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
assertThat(geoPointFieldMapper.fieldType().geohashPrecision(), is(10));
}
- @Test
public void testGeoHashPrecisionAsLength() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).field("geohash_precision", "5m").endObject().endObject()
@@ -117,7 +114,6 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
assertThat(geoPointFieldMapper.fieldType().geohashPrecision(), is(10));
}
- @Test
public void testNullValue() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java
index 07d0940b3b..4245641fd8 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.containsString;
@@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class SimpleIpMappingTests extends ESSingleNodeTestCase {
-
- @Test
public void testSimpleMapping() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("ip").field("type", "ip").endObject().endObject()
@@ -57,12 +54,10 @@ public class SimpleIpMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("ip"), is("2130706433"));
}
- @Test
public void testThatValidIpCanBeConvertedToLong() throws Exception {
assertThat(IpFieldMapper.ipToLong("127.0.0.1"), is(2130706433L));
}
- @Test
public void testThatInvalidIpThrowsException() throws Exception {
try {
IpFieldMapper.ipToLong("127.0.011.1111111");
@@ -72,7 +67,6 @@ public class SimpleIpMappingTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testThatIpv6AddressThrowsException() throws Exception {
try {
IpFieldMapper.ipToLong("2001:db8:0:8d3:0:8a2e:70:7344");
@@ -82,7 +76,6 @@ public class SimpleIpMappingTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testIgnoreMalformedOption() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("field1")
.field("type", "ip").field("ignore_malformed", true).endObject().startObject("field2").field("type", "ip")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTests.java b/core/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTests.java
index 9aade61c5b..656599c503 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class DoubleIndexingDocTests extends ESSingleNodeTestCase {
-
- @Test
public void testDoubleIndexingSameDoc() throws Exception {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), Lucene.STANDARD_ANALYZER));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java b/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java
index 380e8e34d0..d67b97c3d8 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java
@@ -35,7 +35,6 @@ import org.elasticsearch.index.fieldvisitor.CustomFieldsVisitor;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@@ -47,8 +46,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class StoredNumericValuesTests extends ESSingleNodeTestCase {
-
- @Test
public void testBytesAndNumericRepresentation() throws Exception {
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java
index dc14ebecd5..e1efd405df 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java
@@ -40,19 +40,18 @@ import org.elasticsearch.index.mapper.core.StringFieldMapper;
import org.elasticsearch.index.mapper.core.TokenCountFieldMapper;
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
-import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
-import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.mapper.MapperBuilders.doc;
import static org.elasticsearch.index.mapper.MapperBuilders.rootObject;
import static org.elasticsearch.index.mapper.MapperBuilders.stringField;
+import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
+import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
@@ -61,15 +60,12 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class MultiFieldTests extends ESSingleNodeTestCase {
-
- @Test
- public void testMultiField_multiFieldType() throws Exception {
+ public void testMultiFieldMultiFieldType() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type.json");
testMultiField(mapping);
}
- @Test
- public void testMultiField_multiFields() throws Exception {
+ public void testMultiFieldMultiFields() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-fields.json");
testMultiField(mapping);
}
@@ -145,7 +141,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertThat(docMapper.mappers().getMapper("object1.multi1.string").fieldType().tokenized(), equalTo(false));
}
- @Test
public void testBuildThenParse() throws Exception {
IndexService indexService = createIndex("test");
Settings settings = indexService.settingsService().getSettings();
@@ -186,7 +181,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertEquals(IndexOptions.NONE, f.fieldType().indexOptions());
}
- @Test
public void testConvertMultiFieldNoDefaultField() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -256,7 +250,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertThat(docMapper.mappers().getMapper("age.stored").fieldType().tokenized(), equalTo(false));
}
- @Test
public void testConvertMultiFieldGeoPoint() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -353,7 +346,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
}
- @Test
public void testConvertMultiFieldCompletion() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -421,7 +413,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
}
- @Test
// The underlying order of the fields in multi fields in the mapping source should always be consistent, if not this
// can to unnecessary re-syncing of the mappings between the local instance and cluster state
public void testMultiFieldsInConsistentOrder() throws Exception {
@@ -451,12 +442,11 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertThat(field, equalTo(multiFieldNames[i++]));
}
}
-
- @Test
+
// The fielddata settings need to be the same after deserializing/re-serialsing, else unneccesary mapping sync's can be triggered
public void testMultiFieldsFieldDataSettingsInConsistentOrder() throws Exception {
final String MY_MULTI_FIELD = "multi_field";
-
+
// Possible fielddata settings
Map<String, Object> possibleSettings = new TreeMap<String, Object>();
possibleSettings.put("filter.frequency.min", 1);
@@ -466,7 +456,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
possibleSettings.put("foo", "bar");
possibleSettings.put("zetting", "zValue");
possibleSettings.put("aSetting", "aValue");
-
+
// Generate a mapping with the a random subset of possible fielddata settings
XContentBuilder builder = jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("my_field").field("type", "string").startObject("fields").startObject(MY_MULTI_FIELD)
@@ -476,8 +466,8 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
for(int i = randomIntBetween(0, possibleSettings.size()-1); i >= 0; --i)
builder.field(keys[i], possibleSettings.get(keys[i]));
builder.endObject().endObject().endObject().endObject().endObject().endObject().endObject();
-
- // Check the mapping remains identical when deserialed/re-serialsed
+
+ // Check the mapping remains identical when deserialed/re-serialsed
final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
DocumentMapper docMapper = parser.parse(builder.string());
DocumentMapper docMapper2 = parser.parse(docMapper.mappingSource().string());
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java
index 25b9f2b43b..20ef62291b 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java
@@ -27,20 +27,22 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Map;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
public class MultiFieldsIntegrationIT extends ESIntegTestCase {
-
- @Test
public void testMultiFields() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
@@ -98,7 +100,6 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testGeoPointMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
@@ -129,7 +130,6 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertThat(countResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testTokenCountMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
@@ -168,7 +168,6 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertThat(countResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testCompletionMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
@@ -194,7 +193,6 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertThat(countResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testIpMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java
index eec0002a6e..07671a2d4b 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java
@@ -28,19 +28,18 @@ import org.elasticsearch.index.mapper.DocumentMapperParser;
import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
-
- @Test
public void testMergeMultiField() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json");
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
@@ -112,7 +111,6 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
assertThat(docMapper.mappers().getMapper("name.not_indexed3"), notNullValue());
}
- @Test
public void testUpgradeFromMultiFieldTypeToMultiFields() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json");
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java
index 5ae90bd5a0..be27e9f83f 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java
@@ -26,15 +26,12 @@ import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
import org.elasticsearch.index.mapper.object.ObjectMapper;
import org.elasticsearch.index.mapper.object.ObjectMapper.Dynamic;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class NestedMappingTests extends ESSingleNodeTestCase {
-
- @Test
- public void emptyNested() throws Exception {
+ public void testEmptyNested() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").endObject()
.endObject().endObject().endObject().string();
@@ -60,8 +57,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().size(), equalTo(1));
}
- @Test
- public void singleNested() throws Exception {
+ public void testSingleNested() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").endObject()
.endObject().endObject().endObject().string();
@@ -108,8 +104,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().get(2).get("field"), equalTo("value"));
}
- @Test
- public void multiNested() throws Exception {
+ public void testMultiNested() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").startObject("properties")
.startObject("nested2").field("type", "nested")
@@ -160,8 +155,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().get(6).get("nested1.nested2.field2"), nullValue());
}
- @Test
- public void multiObjectAndNested1() throws Exception {
+ public void testMultiObjectAndNested1() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").startObject("properties")
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
@@ -212,8 +206,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().get(6).get("nested1.nested2.field2"), nullValue());
}
- @Test
- public void multiObjectAndNested2() throws Exception {
+ public void testMultiObjectAndNested2() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").field("include_in_parent", true).startObject("properties")
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
@@ -264,8 +257,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().get(6).getFields("nested1.nested2.field2").length, equalTo(4));
}
- @Test
- public void multiRootAndNested1() throws Exception {
+ public void testMultiRootAndNested1() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").startObject("properties")
.startObject("nested2").field("type", "nested").field("include_in_root", true)
@@ -316,8 +308,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
assertThat(doc.docs().get(6).getFields("nested1.nested2.field2").length, equalTo(4));
}
- @Test
- public void nestedArray_strict() throws Exception {
+ public void testNestedArrayStrict() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
.startObject("nested1").field("type", "nested").field("dynamic", "strict").startObject("properties")
.startObject("field1").field("type", "string")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java b/core/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java
index d7aa84c2df..fedb2d83d5 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java
@@ -22,19 +22,16 @@ package org.elasticsearch.index.mapper.null_value;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.IndexService;
+import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
/**
*/
public class NullValueTests extends ESSingleNodeTestCase {
-
- @Test
- public void testNullNull_Value() throws Exception {
+ public void testNullNullValue() throws Exception {
IndexService indexService = createIndex("test", Settings.settingsBuilder().build());
String[] typesToTest = {"integer", "long", "double", "float", "short", "date", "ip", "string", "boolean", "byte"};
@@ -57,9 +54,6 @@ public class NullValueTests extends ESSingleNodeTestCase {
} catch (MapperParsingException e) {
assertThat(e.getMessage(), equalTo("Property [null_value] cannot be null."));
}
-
}
-
-
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java b/core/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java
index 728152afdb..de2957cae3 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java
@@ -39,7 +39,6 @@ import org.elasticsearch.index.mapper.core.NumberFieldMapper;
import org.elasticsearch.index.mapper.core.StringFieldMapper;
import org.elasticsearch.index.mapper.string.SimpleStringMappingTests;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -52,8 +51,6 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class SimpleNumericTests extends ESSingleNodeTestCase {
-
- @Test
public void testNumericDetectionEnabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.field("numeric_detection", true)
@@ -79,7 +76,6 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertThat(mapper, instanceOf(DoubleFieldMapper.class));
}
- @Test
public void testNumericDetectionDefault() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject().string();
@@ -104,7 +100,6 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertThat(mapper, instanceOf(StringFieldMapper.class));
}
- @Test
public void testIgnoreMalformedOption() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -168,7 +163,6 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testCoerceOption() throws Exception {
String [] nonFractionNumericFieldTypes={"integer","long","short"};
//Test co-ercion policies on all non-fraction numerics
@@ -201,7 +195,7 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("noErrorCoerceField"), notNullValue());
//Default is ignore_malformed=true and coerce=true
assertThat(doc.rootDoc().getField("errorDefaultCoerce"), notNullValue());
-
+
//Test valid case of numbers passed as numbers
int validNumber=1;
doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
@@ -214,7 +208,7 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertEquals(validNumber,doc.rootDoc().getField("noErrorNoCoerceField").numericValue().intValue());
assertEquals(validNumber,doc.rootDoc().getField("noErrorCoerceField").numericValue().intValue());
assertEquals(validNumber,doc.rootDoc().getField("errorDefaultCoerce").numericValue().intValue());
-
+
//Test valid case of negative numbers passed as numbers
int validNegativeNumber=-1;
doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
@@ -227,7 +221,7 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertEquals(validNegativeNumber,doc.rootDoc().getField("noErrorNoCoerceField").numericValue().intValue());
assertEquals(validNegativeNumber,doc.rootDoc().getField("noErrorCoerceField").numericValue().intValue());
assertEquals(validNegativeNumber,doc.rootDoc().getField("errorDefaultCoerce").numericValue().intValue());
-
+
try {
defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
@@ -238,8 +232,8 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
} catch (MapperParsingException e) {
assertThat(e.getCause(), instanceOf(IllegalArgumentException.class));
}
-
-
+
+
//Test questionable case of floats passed to ints
float invalidJsonForInteger=1.9f;
int coercedFloatValue=1; //This is what the JSON parser will do to a float - truncate not round
@@ -254,7 +248,7 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertEquals(coercedFloatValue,doc.rootDoc().getField("noErrorCoerceField").numericValue().intValue());
//Default is ignore_malformed=true and coerce=true
assertEquals(coercedFloatValue,doc.rootDoc().getField("errorDefaultCoerce").numericValue().intValue());
-
+
try {
defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
@@ -266,8 +260,8 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
}
}
}
-
-
+
+
public void testDocValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -346,9 +340,8 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertEquals(DocValuesType.SORTED_NUMERIC, SimpleStringMappingTests.docValuesType(doc, "nested.double"));
}
}
-
+
/** Test default precision step for autodetected numeric types */
- @Test
public void testPrecisionStepDefaultsDetected() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.field("numeric_detection", true)
@@ -364,17 +357,16 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
.field("date", "2010-01-01")
.endObject()
.bytes());
-
+
assertEquals(1, doc.docs().size());
Document luceneDoc = doc.docs().get(0);
-
+
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("long"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("double"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("date"));
}
-
+
/** Test default precision step for numeric types */
- @Test
public void testPrecisionStepDefaultsMapped() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -402,12 +394,12 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
.startObject("ip")
.field("type", "ip")
.endObject()
-
+
.endObject()
.endObject().endObject().string();
DocumentMapper mapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
-
+
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("int", "100")
@@ -420,24 +412,23 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
.field("ip", "255.255.255.255")
.endObject()
.bytes());
-
+
assertEquals(1, doc.docs().size());
Document luceneDoc = doc.docs().get(0);
-
+
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("long"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("double"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("date"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_64_BIT, luceneDoc.getField("ip"));
-
+
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_32_BIT, luceneDoc.getField("int"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_32_BIT, luceneDoc.getField("float"));
-
+
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_16_BIT, luceneDoc.getField("short"));
assertPrecisionStepEquals(NumberFieldMapper.Defaults.PRECISION_STEP_8_BIT, luceneDoc.getField("byte"));
}
-
+
/** Test precision step set to silly explicit values */
- @Test
public void testPrecisionStepExplicit() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -473,12 +464,12 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
.field("type", "ip")
.field("precision_step", "2")
.endObject()
-
+
.endObject()
.endObject().endObject().string();
DocumentMapper mapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
-
+
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("int", "100")
@@ -491,10 +482,10 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
.field("ip", "255.255.255.255")
.endObject()
.bytes());
-
+
assertEquals(1, doc.docs().size());
Document luceneDoc = doc.docs().get(0);
-
+
assertPrecisionStepEquals(1, luceneDoc.getField("int"));
assertPrecisionStepEquals(2, luceneDoc.getField("float"));
assertPrecisionStepEquals(1, luceneDoc.getField("long"));
@@ -505,18 +496,18 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
assertPrecisionStepEquals(2, luceneDoc.getField("ip"));
}
-
+
/** checks precisionstep on both the fieldtype and the tokenstream */
private static void assertPrecisionStepEquals(int expected, IndexableField field) throws IOException {
assertNotNull(field);
assertThat(field, instanceOf(Field.class));
-
+
// check fieldtype's precisionstep
assertEquals(expected, ((Field)field).fieldType().numericPrecisionStep());
-
+
// check the tokenstream actually used by the indexer
TokenStream ts = field.tokenStream(null, null);
- assertThat(ts, instanceOf(NumericTokenStream.class));
+ assertThat(ts, instanceOf(NumericTokenStream.class));
assertEquals(expected, ((NumericTokenStream)ts).getPrecisionStep());
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java
index f2b0b19af5..b13fcc8ed9 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -33,8 +32,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class NullValueObjectMappingTests extends ESSingleNodeTestCase {
-
- @Test
public void testNullValueObject() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("obj1").field("type", "object").endObject().endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java
index ee604e006b..917ee9806e 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java
@@ -24,13 +24,12 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
+
+import static org.hamcrest.Matchers.containsString;
/**
*/
public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
-
- @Test
public void testDifferentInnerObjectTokenFailure() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.endObject().endObject().string();
@@ -56,7 +55,6 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testEmptyArrayProperties() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startArray("properties").endArray()
@@ -64,8 +62,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
createIndex("test").mapperService().documentMapperParser().parse(mapping);
}
- @Test
- public void emptyFieldsArrayMultiFieldsTest() throws Exception {
+ public void testEmptyFieldsArrayMultiFields() throws Exception {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("tweet")
@@ -83,8 +80,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
createIndex("test").mapperService().documentMapperParser().parse(mapping);
}
- @Test(expected = MapperParsingException.class)
- public void fieldsArrayMultiFieldsShouldThrowExceptionTest() throws Exception {
+ public void testFieldsArrayMultiFieldsShouldThrowException() throws Exception {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("tweet")
@@ -101,11 +97,16 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
.endObject()
.endObject()
.string();
- createIndex("test").mapperService().documentMapperParser().parse(mapping);
+ try {
+ createIndex("test").mapperService().documentMapperParser().parse(mapping);
+ fail("Expected MapperParsingException");
+ } catch(MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("expected map for property [fields]"));
+ assertThat(e.getMessage(), containsString("but got a class java.util.ArrayList"));
+ }
}
- @Test
- public void emptyFieldsArrayTest() throws Exception {
+ public void testEmptyFieldsArray() throws Exception {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("tweet")
@@ -119,8 +120,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
createIndex("test").mapperService().documentMapperParser().parse(mapping);
}
- @Test(expected = MapperParsingException.class)
- public void fieldsWithFilledArrayShouldThrowExceptionTest() throws Exception {
+ public void testFieldsWithFilledArrayShouldThrowException() throws Exception {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("tweet")
@@ -133,11 +133,15 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase {
.endObject()
.endObject()
.string();
- createIndex("test").mapperService().documentMapperParser().parse(mapping);
+ try {
+ createIndex("test").mapperService().documentMapperParser().parse(mapping);
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("Expected map for property [fields]"));
+ }
}
- @Test
- public void fieldPropertiesArrayTest() throws Exception {
+ public void testFieldPropertiesArray() throws Exception {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("tweet")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java
index 06ef922e94..2582562c03 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.path;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -33,8 +32,6 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class PathMapperTests extends ESSingleNodeTestCase {
-
- @Test
public void testPathMapping() throws IOException {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/path/test-mapping.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java
index d89ae84e3a..edd1f0f4a4 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java
@@ -19,28 +19,32 @@
package org.elasticsearch.index.mapper.simple;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.mapper.*;
-import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.index.IndexService;
+import org.elasticsearch.index.mapper.DocumentMapper;
+import org.elasticsearch.index.mapper.DocumentMapperParser;
+import org.elasticsearch.index.mapper.MapperParsingException;
+import org.elasticsearch.index.mapper.ParseContext.Document;
+import org.elasticsearch.index.mapper.Uid;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
+import static org.elasticsearch.index.mapper.MapperBuilders.doc;
+import static org.elasticsearch.index.mapper.MapperBuilders.object;
+import static org.elasticsearch.index.mapper.MapperBuilders.rootObject;
+import static org.elasticsearch.index.mapper.MapperBuilders.stringField;
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
-import static org.elasticsearch.index.mapper.MapperBuilders.*;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
public class SimpleMapperTests extends ESSingleNodeTestCase {
-
- @Test
public void testSimpleMapper() throws Exception {
IndexService indexService = createIndex("test");
Settings settings = indexService.settingsService().getSettings();
@@ -54,31 +58,22 @@ public class SimpleMapperTests extends ESSingleNodeTestCase {
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay"));
-// System.out.println("Document: " + doc);
-// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
doc = docMapper.parse("test", "person", "1", json).rootDoc();
-// System.out.println("Document: " + doc);
-// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
}
- @Test
public void testParseToJsonAndParse() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
DocumentMapper docMapper = parser.parse(mapping);
String builtMapping = docMapper.mappingSource().string();
-// System.out.println(builtMapping);
// reparse it
DocumentMapper builtDocMapper = parser.parse(builtMapping);
BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json"));
Document doc = builtDocMapper.parse("test", "person", "1", json).rootDoc();
assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1")));
assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay"));
-// System.out.println("Document: " + doc);
-// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
}
- @Test
public void testSimpleParser() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -89,11 +84,8 @@ public class SimpleMapperTests extends ESSingleNodeTestCase {
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1")));
assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay"));
-// System.out.println("Document: " + doc);
-// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
}
- @Test
public void testSimpleParserNoTypeNoId() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -101,11 +93,8 @@ public class SimpleMapperTests extends ESSingleNodeTestCase {
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1")));
assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay"));
-// System.out.println("Document: " + doc);
-// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
}
- @Test
public void testAttributes() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
@@ -118,7 +107,6 @@ public class SimpleMapperTests extends ESSingleNodeTestCase {
assertThat((String) builtDocMapper.meta().get("param1"), equalTo("value1"));
}
- @Test
public void testNoDocumentSent() throws Exception {
IndexService indexService = createIndex("test");
Settings settings = indexService.settingsService().getSettings();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java
index 56c188b7aa..7c1875be55 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -39,7 +38,6 @@ import static org.hamcrest.Matchers.equalTo;
public class CompressSourceMappingTests extends ESSingleNodeTestCase {
Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
- @Test
public void testCompressDisabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_source").field("compress", false).endObject()
@@ -55,7 +53,6 @@ public class CompressSourceMappingTests extends ESSingleNodeTestCase {
assertThat(CompressorFactory.isCompressed(new BytesArray(bytes)), equalTo(false));
}
- @Test
public void testCompressEnabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_source").field("compress", true).endObject()
@@ -72,7 +69,6 @@ public class CompressSourceMappingTests extends ESSingleNodeTestCase {
assertThat(CompressorFactory.isCompressed(new BytesArray(bytes)), equalTo(true));
}
- @Test
public void testCompressThreshold() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_source").field("compress_threshold", "200b").endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
index a54b63d753..3dfd2b4d2c 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
@@ -47,7 +47,6 @@ import org.elasticsearch.index.mapper.core.StringFieldMapper.Builder;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.VersionUtils;
import org.junit.Before;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Map;
@@ -61,7 +60,6 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class SimpleStringMappingTests extends ESSingleNodeTestCase {
-
private static Settings DOC_VALUES_SETTINGS = Settings.builder().put(FieldDataType.FORMAT_KEY, FieldDataType.DOC_VALUES_FORMAT_VALUE).build();
IndexService indexService;
@@ -73,7 +71,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
parser = indexService.mapperService().documentMapperParser();
}
- @Test
public void testLimit() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "string").field("ignore_above", 5).endObject().endObject()
@@ -134,7 +131,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
assertEquals(expected, doc.rootDoc().getField("field").fieldType());
}
- @Test
public void testDefaultsForAnalyzed() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "string").endObject().endObject()
@@ -153,7 +149,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
assertParseIdemPotent(fieldType, defaultMapper);
}
- @Test
public void testDefaultsForNotAnalyzed() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "string").field("index", "not_analyzed").endObject().endObject()
@@ -218,7 +213,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
assertParseIdemPotent(fieldType, defaultMapper);
}
- @Test
public void testSearchQuoteAnalyzerSerialization() throws Exception {
// Cases where search_quote_analyzer should not be added to the mapping.
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -294,7 +288,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
return result;
}
- @Test
public void testTermVectors() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -480,7 +473,6 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
return DocValuesType.NONE;
}
- @Test
public void testDisableNorms() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "string").endObject().endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java
index e51b6a61d5..df9cc10d8c 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java
@@ -37,10 +37,15 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.json.JsonXContent;
-import org.elasticsearch.index.mapper.*;
+import org.elasticsearch.index.mapper.DocumentMapper;
+import org.elasticsearch.index.mapper.DocumentMapperParser;
+import org.elasticsearch.index.mapper.MappedFieldType;
+import org.elasticsearch.index.mapper.MapperParsingException;
+import org.elasticsearch.index.mapper.MergeResult;
+import org.elasticsearch.index.mapper.ParsedDocument;
+import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -55,14 +60,20 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.elasticsearch.test.VersionUtils.randomVersionBetween;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.isIn;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
/**
*/
public class TimestampMappingTests extends ESSingleNodeTestCase {
Settings BWC_SETTINGS = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
- @Test
public void testSimpleDisabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -76,7 +87,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("_timestamp"), equalTo(null));
}
- @Test
public void testEnabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", "yes").endObject()
@@ -94,7 +104,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("_timestamp").tokenStream(docMapper.mappers().indexAnalyzer(), null), notNullValue());
}
- @Test
public void testDefaultValues() throws Exception {
for (Version version : Arrays.asList(V_1_5_0, V_2_0_0_beta1, randomVersion(random()))) {
for (String mapping : Arrays.asList(
@@ -114,7 +123,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testBackcompatSetValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -132,7 +140,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(docMapper.timestampFieldMapper().fieldType().hasDocValues(), equalTo(true));
}
- @Test
public void testThatDisablingDuringMergeIsWorking() throws Exception {
String enabledMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", true).endObject()
@@ -150,7 +157,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(enabledMapper.timestampFieldMapper().enabled(), is(false));
}
- @Test // issue 3174
+ // issue 3174
public void testThatSerializationWorksCorrectlyForIndexField() throws Exception {
String enabledMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", true).field("store", "yes").field("index", "no").endObject()
@@ -171,7 +178,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(timestampConfiguration.get("index").toString(), is("no"));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testBackcompatPathMissingDefaultValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -199,7 +206,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampDefaultValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -225,7 +232,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(delay, lessThanOrEqualTo(60000L));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testBackcompatPathMissingDefaultToEpochValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -251,7 +258,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(request.timestamp(), is(MappingMetaData.Timestamp.parseStringTimestamp("1970-01-01", Joda.forPattern("YYYY-MM-dd"), Version.CURRENT)));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampMissingDefaultToEpochValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -276,7 +283,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(request.timestamp(), is(MappingMetaData.Timestamp.parseStringTimestamp("1970-01-01", Joda.forPattern("YYYY-MM-dd"), Version.CURRENT)));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testBackcompatPathMissingNowDefaultValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -305,7 +312,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(delay, lessThanOrEqualTo(60000L));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampMissingNowDefaultValue() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -333,7 +340,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(delay, lessThanOrEqualTo(60000L));
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testPathMissingWithForcedNullDefaultShouldFail() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -350,7 +357,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testBackcompatPathMissingShouldFail() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -378,7 +385,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampMissingWithForcedNullDefaultShouldFail() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -395,7 +402,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampDefaultAndIgnore() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -413,7 +420,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
+ // Issue 4718: was throwing a TimestampParsingException: failed to parse timestamp [null]
public void testTimestampMissingShouldNotFail() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -440,7 +447,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(delay, lessThanOrEqualTo(60000L));
}
- @Test
public void testDefaultTimestampStream() throws IOException {
// Testing null value for default timestamp
{
@@ -494,7 +500,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testMergingFielddataLoadingWorks() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", randomBoolean()).startObject("fielddata").field("loading", "lazy").field("format", "doc_values").endObject().field("store", "yes").endObject()
@@ -515,7 +520,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(docMapper.timestampFieldMapper().fieldType().fieldDataType().getFormat(indexSettings), equalTo("array"));
}
- @Test
public void testParsingNotDefaultTwiceDoesNotChangeMapping() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp")
@@ -529,7 +533,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(docMapper.mappingSource().string(), equalTo(mapping));
}
- @Test
public void testBackcompatParsingTwiceDoesNotChangeTokenizeValue() throws Exception {
String[] index_options = {"no", "analyzed", "not_analyzed"};
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -551,7 +554,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(tokenized, equalTo(docMapper.timestampFieldMapper().fieldType().tokenized()));
}
- @Test
public void testMergingConflicts() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", true)
@@ -593,7 +595,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(docMapper.timestampFieldMapper().fieldType().fieldDataType().getFormat(indexSettings), equalTo("doc_values"));
}
- @Test
public void testBackcompatMergingConflictsForIndexValues() throws Exception {
List<String> indexValues = new ArrayList<>();
indexValues.add("analyzed");
@@ -633,7 +634,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
/**
* Test for issue #9223
*/
- @Test
public void testInitMappers() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject()
.startObject("type")
@@ -646,7 +646,6 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
new MappingMetaData(new CompressedXContent(mapping));
}
- @Test
public void testBackcompatMergePaths() throws Exception {
String[] possiblePathValues = {"some_path", "anotherPath", null};
DocumentMapperParser parser = createIndex("test", BWC_SETTINGS).mapperService().documentMapperParser();
@@ -681,7 +680,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
assertThat(mergeResult.buildConflicts()[0], containsString(conflict));
}
}
-
+
public void testBackcompatDocValuesSerialization() throws Exception {
// default
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
@@ -726,7 +725,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
.endObject().endObject().endObject().string();
assertDocValuesSerialization(mapping);
}
-
+
void assertDocValuesSerialization(String mapping) throws Exception {
DocumentMapperParser parser = createIndex("test_doc_values", BWC_SETTINGS).mapperService().documentMapperParser();
DocumentMapper docMapper = parser.parse(mapping);
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java
index b9f7a98878..7802e86681 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java
@@ -31,11 +31,16 @@ import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.mapper.*;
-import org.elasticsearch.index.mapper.internal.TTLFieldMapper;
import org.elasticsearch.index.IndexService;
+import org.elasticsearch.index.mapper.DocumentMapper;
+import org.elasticsearch.index.mapper.DocumentMapperParser;
+import org.elasticsearch.index.mapper.MapperParsingException;
+import org.elasticsearch.index.mapper.MergeMappingException;
+import org.elasticsearch.index.mapper.MergeResult;
+import org.elasticsearch.index.mapper.ParsedDocument;
+import org.elasticsearch.index.mapper.SourceToParse;
+import org.elasticsearch.index.mapper.internal.TTLFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -45,7 +50,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class TTLMappingTests extends ESSingleNodeTestCase {
- @Test
public void testSimpleDisabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -59,7 +63,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("_ttl"), equalTo(null));
}
- @Test
public void testEnabled() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_ttl").field("enabled", "yes").endObject()
@@ -77,7 +80,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().getField("_ttl").tokenStream(docMapper.mappers().indexAnalyzer(), null), notNullValue());
}
- @Test
public void testDefaultValues() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
@@ -86,8 +88,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(docMapper.TTLFieldMapper().fieldType().indexOptions(), equalTo(TTLFieldMapper.Defaults.TTL_FIELD_TYPE.indexOptions()));
}
-
- @Test
public void testSetValuesBackcompat() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_ttl")
@@ -101,7 +101,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
}
- @Test
public void testThatEnablingTTLFieldOnMergeWorks() throws Exception {
String mappingWithoutTtl = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").field("field").startObject().field("type", "string").endObject().endObject()
@@ -124,7 +123,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(mapperWithoutTtl.TTLFieldMapper().enabled(), equalTo(true));
}
- @Test
public void testThatChangingTTLKeepsMapperEnabled() throws Exception {
String mappingWithTtl = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_ttl")
@@ -150,7 +148,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(initialMapper.TTLFieldMapper().enabled(), equalTo(true));
}
- @Test
public void testThatDisablingTTLReportsConflict() throws Exception {
String mappingWithTtl = getMappingWithTtlEnabled().string();
String mappingWithTtlDisabled = getMappingWithTtlDisabled().string();
@@ -164,7 +161,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(initialMapper.TTLFieldMapper().enabled(), equalTo(true));
}
- @Test
public void testThatDisablingTTLReportsConflictOnCluster() throws Exception {
String mappingWithTtl = getMappingWithTtlEnabled().string();
String mappingWithTtlDisabled = getMappingWithTtlDisabled().string();
@@ -180,7 +176,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(mappingsBeforeUpdateResponse.getMappings().get("testindex").get("type").source(), equalTo(mappingsAfterUpdateResponse.getMappings().get("testindex").get("type").source()));
}
- @Test
public void testThatEnablingTTLAfterFirstDisablingWorks() throws Exception {
String mappingWithTtl = getMappingWithTtlEnabled().string();
String withTtlDisabled = getMappingWithTtlDisabled().string();
@@ -192,7 +187,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(mappingsAfterUpdateResponse.getMappings().get("testindex").get("type").sourceAsMap().get("_ttl").toString(), equalTo("{enabled=true}"));
}
- @Test
public void testNoConflictIfNothingSetAndDisabledLater() throws Exception {
IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type");
XContentBuilder mappingWithTtlDisabled = getMappingWithTtlDisabled("7d");
@@ -200,7 +194,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertFalse(mergeResult.hasConflicts());
}
- @Test
public void testNoConflictIfNothingSetAndEnabledLater() throws Exception {
IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type");
XContentBuilder mappingWithTtlEnabled = getMappingWithTtlEnabled("7d");
@@ -208,7 +201,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertFalse(mergeResult.hasConflicts());
}
- @Test
public void testMergeWithOnlyDefaultSet() throws Exception {
XContentBuilder mappingWithTtlEnabled = getMappingWithTtlEnabled("7d");
IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type", mappingWithTtlEnabled);
@@ -219,7 +211,6 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":true,\"default\":360000},\"properties\":{\"field\":{\"type\":\"string\"}}}}")));
}
- @Test
public void testMergeWithOnlyDefaultSetTtlDisabled() throws Exception {
XContentBuilder mappingWithTtlEnabled = getMappingWithTtlDisabled("7d");
IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type", mappingWithTtlEnabled);
@@ -232,9 +223,7 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":false},\"properties\":{\"field\":{\"type\":\"string\"}}}}")));
}
- @Test
public void testThatSimulatedMergingLeavesStateUntouched() throws Exception {
-
//check if default ttl changed when simulate set to true
XContentBuilder mappingWithTtl = getMappingWithTtlEnabled("6d");
IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type", mappingWithTtl);
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java b/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java
index 21ee96522c..26d710b137 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -31,8 +30,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
-
- @Test
public void testNoLevel() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -51,7 +48,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testTypeLevel() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -70,7 +66,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("type.inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testNoLevelWithFieldTypeAsValue() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -91,7 +86,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testTypeLevelWithFieldTypeAsValue() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -112,7 +106,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("type.inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testNoLevelWithFieldTypeAsObject() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -133,7 +126,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
}
- @Test
public void testTypeLevelWithFieldTypeAsObject() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -154,7 +146,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("type.inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -175,7 +166,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("type.inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -196,7 +186,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("type.inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
@@ -218,7 +207,6 @@ public class ParseDocumentTypeLevelsTests extends ESSingleNodeTestCase {
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
}
- @Test
public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java b/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java
index f67547586b..d99efee682 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java
@@ -23,14 +23,11 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.DocumentMapperParser;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
// TODO: move this test...it doesn't need to be by itself
public class ParseMappingTypeLevelTests extends ESSingleNodeTestCase {
-
- @Test
public void testTypeLevel() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("_timestamp").field("enabled", true).endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java
index 4ae039a361..bf97cec3c4 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java
@@ -26,32 +26,27 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.MergeMappingException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
-import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class UpdateMappingOnClusterIT extends ESIntegTestCase {
-
private static final String INDEX = "index";
private static final String TYPE = "type";
-
- @Test
- public void test_all_enabled() throws Exception {
+ public void testAllEnabled() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("mappings").startObject(TYPE).startObject("_all").field("enabled", "false").endObject().endObject().endObject().endObject();
XContentBuilder mappingUpdate = jsonBuilder().startObject().startObject("_all").field("enabled", "true").endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
String errorMessage = "[_all] enabled is false now encountering true";
testConflict(mapping.string(), mappingUpdate.string(), errorMessage);
}
- @Test
- public void test_all_conflicts() throws Exception {
+ public void testAllConflicts() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/update/all_mapping_create_index.json");
String mappingUpdate = copyToStringFromClasspath("/org/elasticsearch/index/mapper/update/all_mapping_update_with_conflicts.json");
String[] errorMessage = {"[_all] enabled is true now encountering false",
@@ -67,9 +62,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
testConflict(mapping, mappingUpdate, errorMessage);
}
-
- @Test
- public void test_all_with_default() throws Exception {
+ public void testAllWithDefault() throws Exception {
String defaultMapping = jsonBuilder().startObject().startObject("_default_")
.startObject("_all")
.field("enabled", false)
@@ -115,8 +108,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
}
- @Test
- public void test_doc_valuesInvalidMapping() throws Exception {
+ public void testDocValuesInvalidMapping() throws Exception {
String mapping = jsonBuilder().startObject().startObject("mappings").startObject(TYPE).startObject("_all").startObject("fielddata").field("format", "doc_values").endObject().endObject().endObject().endObject().endObject().string();
try {
prepareCreate(INDEX).setSource(mapping).get();
@@ -126,8 +118,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
}
}
- @Test
- public void test_doc_valuesInvalidMappingOnUpdate() throws Exception {
+ public void testDocValuesInvalidMappingOnUpdate() throws Exception {
String mapping = jsonBuilder().startObject().startObject(TYPE).startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().string();
prepareCreate(INDEX).addMapping(TYPE, mapping).get();
String mappingUpdate = jsonBuilder().startObject().startObject(TYPE).startObject("_all").startObject("fielddata").field("format", "doc_values").endObject().endObject().endObject().endObject().string();
@@ -143,7 +134,6 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
}
// checks if the setting for timestamp and size are kept even if disabled
- @Test
public void testDisabledSizeTimestampIndexDoNotLooseMappings() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/update/default_mapping_with_disabled_root_types.json");
prepareCreate(INDEX).addMapping(TYPE, mapping).get();
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java
index c10dc3b1de..5149ab1057 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java
@@ -26,12 +26,11 @@ import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperService;
-import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.LinkedHashMap;
@@ -41,38 +40,32 @@ import static org.hamcrest.CoreMatchers.equalTo;
public class UpdateMappingTests extends ESSingleNodeTestCase {
-
- @Test
- public void test_all_enabled_after_disabled() throws Exception {
+ public void testAllEnabledAfterDisabled() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().endObject();
XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate);
}
- @Test
- public void test_all_disabled_after_enabled() throws Exception {
+ public void testAllDisabledAfterEnabled() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().endObject();
XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate);
}
- @Test
- public void test_all_disabled_after_default_enabled() throws Exception {
+ public void testAllDisabledAfterDefaultEnabled() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("some_text").field("type", "string").endObject().endObject().endObject();
XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate);
}
- @Test
- public void test_all_enabled_after_enabled() throws Exception {
+ public void testAllEnabledAfterEnabled() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().endObject();
XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().endObject();
testNoConflictWhileMergingAndMappingChanged(mapping, mappingUpdate, expectedMapping);
}
- @Test
- public void test_all_disabled_after_disabled() throws Exception {
+ public void testAllDisabledAfterDisabled() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().endObject();
XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject();
XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().endObject();
@@ -114,7 +107,6 @@ public class UpdateMappingTests extends ESSingleNodeTestCase {
assertThat(mappingAfterUpdate, equalTo(mappingBeforeUpdate));
}
- @Test
public void testIndexFieldParsingBackcompat() throws IOException {
IndexService indexService = createIndex("test", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build());
XContentBuilder indexMapping = XContentFactory.jsonBuilder();
@@ -132,7 +124,6 @@ public class UpdateMappingTests extends ESSingleNodeTestCase {
assertThat(documentMapper.indexMapper().enabled(), equalTo(enabled));
}
- @Test
public void testTimestampParsing() throws IOException {
IndexService indexService = createIndex("test", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build());
XContentBuilder indexMapping = XContentFactory.jsonBuilder();
@@ -158,7 +149,6 @@ public class UpdateMappingTests extends ESSingleNodeTestCase {
assertTrue(documentMapper.timestampFieldMapper().fieldType().stored());
}
- @Test
public void testSizeTimestampIndexParsing() throws IOException {
IndexService indexService = createIndex("test", Settings.settingsBuilder().build());
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/update/default_mapping_with_disabled_root_types.json");
@@ -168,7 +158,6 @@ public class UpdateMappingTests extends ESSingleNodeTestCase {
assertThat(documentMapper.mappingSource().string(), equalTo(mapping));
}
- @Test
public void testDefaultApplied() throws IOException {
createIndex("test1", Settings.settingsBuilder().build());
createIndex("test2", Settings.settingsBuilder().build());
diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java
index f8a6673085..281293811f 100644
--- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java
@@ -91,7 +91,6 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
@@ -310,7 +309,6 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
* Generic test that creates new query from the test query and checks both for equality
* and asserts equality on the two queries.
*/
- @Test
public void testFromXContent() throws IOException {
QB testQuery = createTestQueryBuilder();
assertParsedQuery(testQuery.toString(), testQuery);
@@ -366,7 +364,6 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
* Test creates the {@link Query} from the {@link QueryBuilder} under test and delegates the
* assertions being made on the result to the implementing subclass.
*/
- @Test
public void testToQuery() throws IOException {
QueryShardContext context = createShardContext();
context.setAllowUnmappedFields(true);
@@ -450,7 +447,6 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
/**
* Test serialization and deserialization of the test query.
*/
- @Test
public void testSerialization() throws IOException {
QB testQuery = createTestQueryBuilder();
assertSerialization(testQuery);
@@ -474,7 +470,6 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
}
}
- @Test
public void testEqualsAndHashcode() throws IOException {
QB firstQuery = createTestQueryBuilder();
assertFalse("query is equal to null", firstQuery.equals(null));
diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java
index adab170127..161e7582bb 100644
--- a/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java
@@ -21,13 +21,10 @@ package org.elasticsearch.index.query;
import com.fasterxml.jackson.core.io.JsonStringEncoder;
-import org.junit.Test;
-
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractTermQueryTestCase<QB extends BaseTermQueryBuilder<QB>> extends AbstractQueryTestCase<QB> {
-
@Override
protected final QB doCreateTestQueryBuilder() {
String fieldName = null;
@@ -75,7 +72,6 @@ public abstract class AbstractTermQueryTestCase<QB extends BaseTermQueryBuilder<
protected abstract QB createQueryBuilder(String fieldName, Object value);
- @Test
public void testIllegalArguments() throws QueryShardException {
try {
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java
index 68e739c11d..04f07a9428 100644
--- a/core/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/BoolQueryBuilderTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.*;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.*;
@@ -32,7 +31,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilder> {
-
@Override
protected BoolQueryBuilder doCreateTestQueryBuilder() {
BoolQueryBuilder query = new BoolQueryBuilder();
@@ -146,7 +144,6 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
return alternateVersions;
}
- @Test
public void testIllegalArguments() {
BoolQueryBuilder booleanQuery = new BoolQueryBuilder();
@@ -176,7 +173,6 @@ public class BoolQueryBuilderTests extends AbstractQueryTestCase<BoolQueryBuilde
}
// https://github.com/elasticsearch/elasticsearch/issues/7240
- @Test
public void testEmptyBooleanQuery() throws Exception {
String query = jsonBuilder().startObject().startObject("bool").endObject().endObject().string();
Query parsedQuery = parseQuery(query).toQuery(createShardContext());
diff --git a/core/src/test/java/org/elasticsearch/index/query/BoostingQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/BoostingQueryBuilderTests.java
index 57fab99d51..17610f244a 100644
--- a/core/src/test/java/org/elasticsearch/index/query/BoostingQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/BoostingQueryBuilderTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.queries.BoostingQuery;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
@@ -48,7 +47,6 @@ public class BoostingQueryBuilderTests extends AbstractQueryTestCase<BoostingQue
}
}
- @Test
public void testIllegalArguments() {
try {
new BoostingQueryBuilder(null, new MatchAllQueryBuilder());
diff --git a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java
index 04f8437d0a..cfe22843c9 100644
--- a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
@@ -46,7 +45,7 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
}
if (randomBoolean()) {
- query.cutoffFrequency((float) randomIntBetween(1, 10));
+ query.cutoffFrequency(randomIntBetween(1, 10));
}
if (randomBoolean()) {
@@ -85,7 +84,6 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
assertThat(extendedCommonTermsQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo(queryBuilder.lowFreqMinimumShouldMatch()));
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
@@ -106,7 +104,6 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
}
}
- @Test
public void testNoTermsFromQueryString() throws IOException {
CommonTermsQueryBuilder builder = new CommonTermsQueryBuilder(STRING_FIELD_NAME, "");
QueryShardContext context = createShardContext();
@@ -114,7 +111,6 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
assertNull(builder.toQuery(context));
}
- @Test
public void testCommonTermsQuery1() throws IOException {
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/commonTerms-query1.json");
Query parsedQuery = parseQuery(query).toQuery(createShardContext());
@@ -124,7 +120,6 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("2"));
}
- @Test
public void testCommonTermsQuery2() throws IOException {
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/commonTerms-query2.json");
Query parsedQuery = parseQuery(query).toQuery(createShardContext());
@@ -134,7 +129,6 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("5<20%"));
}
- @Test
public void testCommonTermsQuery3() throws IOException {
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/commonTerms-query3.json");
Query parsedQuery = parseQuery(query).toQuery(createShardContext());
@@ -144,7 +138,7 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("2"));
}
- @Test // see #11730
+ // see #11730
public void testCommonTermsQuery4() throws IOException {
boolean disableCoord = randomBoolean();
Query parsedQuery = parseQuery(commonTermsQuery("field", "text").disableCoord(disableCoord).buildAsBytes()).toQuery(createShardContext());
@@ -152,5 +146,4 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
assertThat(ectQuery.isCoordDisabled(), equalTo(disableCoord));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java
index d339a5d623..8430e11a96 100644
--- a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java
@@ -21,12 +21,10 @@ package org.elasticsearch.index.query;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
public class CommonTermsQueryParserTests extends ESSingleNodeTestCase {
- @Test
public void testWhenParsedQueryIsNullNoNullPointerExceptionIsThrown() throws IOException {
final String index = "test-index";
final String type = "test-type";
diff --git a/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java
index 2bafc95774..44bcbee27b 100644
--- a/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java
@@ -22,15 +22,14 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.ParsingException;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.containsString;
public class ConstantScoreQueryBuilderTests extends AbstractQueryTestCase<ConstantScoreQueryBuilder> {
-
/**
* @return a {@link ConstantScoreQueryBuilder} with random boost between 0.1f and 2.0f
*/
@@ -54,13 +53,16 @@ public class ConstantScoreQueryBuilderTests extends AbstractQueryTestCase<Consta
/**
* test that missing "filter" element causes {@link ParsingException}
*/
- @Test(expected=ParsingException.class)
public void testFilterElement() throws IOException {
String queryString = "{ \"" + ConstantScoreQueryBuilder.NAME + "\" : {}";
- parseQuery(queryString);
+ try {
+ parseQuery(queryString);
+ fail("Expected ParsingException");
+ } catch (ParsingException e) {
+ assertThat(e.getMessage(), containsString("requires a 'filter' element"));
+ }
}
- @Test
public void testIllegalArguments() {
try {
new ConstantScoreQueryBuilder(null);
diff --git a/core/src/test/java/org/elasticsearch/index/query/DisMaxQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/DisMaxQueryBuilderTests.java
index 0dac9c99c0..3c6efd4935 100644
--- a/core/src/test/java/org/elasticsearch/index/query/DisMaxQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/DisMaxQueryBuilderTests.java
@@ -23,16 +23,20 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.DisjunctionMaxQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBuilder> {
-
/**
* @return a {@link DisMaxQueryBuilder} with random inner queries
*/
@@ -84,7 +88,6 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
/**
* test `null`return value for missing inner queries
*/
- @Test
public void testNoInnerQueries() throws IOException {
DisMaxQueryBuilder disMaxBuilder = new DisMaxQueryBuilder();
assertNull(disMaxBuilder.toQuery(createShardContext()));
@@ -95,7 +98,6 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
* Those should be ignored upstream. To test this, we use inner {@link ConstantScoreQueryBuilder}
* with empty inner filter.
*/
- @Test
public void testInnerQueryReturnsNull() throws IOException {
String queryString = "{ \"" + ConstantScoreQueryBuilder.NAME + "\" : { \"filter\" : { } } }";
QueryBuilder<?> innerQueryBuilder = parseQuery(queryString);
@@ -103,7 +105,6 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
assertNull(disMaxBuilder.toQuery(createShardContext()));
}
- @Test
public void testIllegalArguments() {
DisMaxQueryBuilder disMaxQuery = new DisMaxQueryBuilder();
try {
@@ -114,7 +115,6 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
}
}
- @Test
public void testToQueryInnerPrefixQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String queryAsString = "{\n" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java
index 92523bb99f..1464822ffd 100644
--- a/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java
@@ -25,7 +25,6 @@ import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.index.mapper.object.ObjectMapper;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -34,7 +33,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBuilder> {
-
@Override
protected ExistsQueryBuilder doCreateTestQueryBuilder() {
String fieldPattern;
@@ -80,7 +78,6 @@ public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBu
}
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java
index 64724d28b0..5dd9263e91 100644
--- a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.FieldMaskingSpanQuery;
import org.elasticsearch.index.mapper.MappedFieldType;
-import org.junit.Test;
import java.io.IOException;
@@ -30,7 +29,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class FieldMaskingSpanQueryBuilderTests extends AbstractQueryTestCase<FieldMaskingSpanQueryBuilder> {
-
@Override
protected FieldMaskingSpanQueryBuilder doCreateTestQueryBuilder() {
String fieldName;
@@ -56,7 +54,6 @@ public class FieldMaskingSpanQueryBuilderTests extends AbstractQueryTestCase<Fie
assertThat(fieldMaskingSpanQuery.getMaskedQuery(), equalTo(queryBuilder.innerQuery().toQuery(context)));
}
- @Test
public void testIllegalArguments() {
try {
new FieldMaskingSpanQueryBuilder(null, "maskedField");
diff --git a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java
index 13fdb9563e..c7787860c0 100644
--- a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java
@@ -26,7 +26,6 @@ import org.apache.lucene.search.Query;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.unit.Fuzziness;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
@@ -66,7 +65,6 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase<FuzzyQueryBuil
}
}
- @Test
public void testIllegalArguments() {
try {
new FuzzyQueryBuilder(null, "text");
@@ -90,7 +88,6 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase<FuzzyQueryBuil
}
}
- @Test
public void testUnsupportedFuzzinessForStringType() throws IOException {
QueryShardContext context = createShardContext();
context.setAllowUnmappedFields(true);
@@ -106,7 +103,6 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase<FuzzyQueryBuil
}
}
- @Test
public void testToQueryWithStringField() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -128,7 +124,6 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase<FuzzyQueryBuil
assertThat(fuzzyQuery.getBoost(), equalTo(2.0f));
}
- @Test
public void testToQueryWithNumericField() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java
index c138ad0e31..fb385124f3 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java
@@ -21,22 +21,28 @@ package org.elasticsearch.index.query;
import com.spatial4j.core.io.GeohashUtils;
import com.spatial4j.core.shape.Rectangle;
-import org.apache.lucene.search.*;
+
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.ConstantScoreQuery;
+import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.search.Query;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.geo.GeoUtils;
import org.elasticsearch.index.search.geo.InMemoryGeoBoundingBoxQuery;
import org.elasticsearch.test.geo.RandomShapeGenerator;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBoundingBoxQueryBuilder> {
/** Randomly generate either NaN or one of the two infinity values. */
private static Double[] brokenDoubles = {Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY};
-
+
@Override
protected GeoBoundingBoxQueryBuilder doCreateTestQueryBuilder() {
GeoBoundingBoxQueryBuilder builder = new GeoBoundingBoxQueryBuilder(GEO_POINT_FIELD_NAME);
@@ -48,7 +54,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
switch (path) {
case 0:
builder.setCorners(
- new GeoPoint(box.getMaxY(), box.getMinX()),
+ new GeoPoint(box.getMaxY(), box.getMinX()),
new GeoPoint(box.getMinY(), box.getMaxX()));
break;
case 1:
@@ -80,38 +86,51 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
return builder;
}
- @Test(expected = IllegalArgumentException.class)
public void testValidationNullFieldname() {
- new GeoBoundingBoxQueryBuilder(null);
+ try {
+ new GeoBoundingBoxQueryBuilder(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Field name must not be empty."));
+ }
}
-
- @Test(expected = IllegalArgumentException.class)
public void testValidationNullType() {
GeoBoundingBoxQueryBuilder qb = new GeoBoundingBoxQueryBuilder("teststring");
- qb.type((GeoExecType) null);
+ try {
+ qb.type((GeoExecType) null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Type is not allowed to be null."));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testValidationNullTypeString() {
GeoBoundingBoxQueryBuilder qb = new GeoBoundingBoxQueryBuilder("teststring");
- qb.type((String) null);
+ try {
+ qb.type((String) null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("cannot parse type from null string"));
+ }
}
- @Test
@Override
public void testToQuery() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
super.testToQuery();
}
-
- @Test(expected = QueryShardException.class)
+
public void testExceptionOnMissingTypes() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length == 0);
- super.testToQuery();
+ try {
+ super.testToQuery();
+ fail("Expected IllegalArgumentException");
+ } catch (QueryShardException e) {
+ assertThat(e.getMessage(), is("failed to find geo_point field [mapped_geo_point]"));
+ }
}
- @Test
public void testBrokenCoordinateCannotBeSet() {
PointTester[] testers = { new TopTester(), new LeftTester(), new BottomTester(), new RightTester() };
@@ -128,7 +147,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
}
}
- @Test
public void testBrokenCoordinateCanBeSetWithIgnoreMalformed() {
PointTester[] testers = { new TopTester(), new LeftTester(), new BottomTester(), new RightTester() };
@@ -140,8 +158,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
}
}
-
- @Test
public void testValidation() {
PointTester[] testers = { new TopTester(), new LeftTester(), new BottomTester(), new RightTester() };
@@ -183,7 +199,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
}
}
- @Test(expected = IllegalArgumentException.class)
public void testTopBottomCannotBeFlipped() {
GeoBoundingBoxQueryBuilder builder = createTestQueryBuilder();
double top = builder.topLeft().getLat();
@@ -192,11 +207,15 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
double right = builder.bottomRight().getLon();
assumeTrue("top should not be equal to bottom for flip check", top != bottom);
- System.out.println("top: " + top + " bottom: " + bottom);
- builder.setValidationMethod(GeoValidationMethod.STRICT).setCorners(bottom, left, top, right);
+ logger.info("top: {} bottom: {}", top, bottom);
+ try {
+ builder.setValidationMethod(GeoValidationMethod.STRICT).setCorners(bottom, left, top, right);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("top is below bottom corner:"));
+ }
}
- @Test
public void testTopBottomCanBeFlippedOnIgnoreMalformed() {
GeoBoundingBoxQueryBuilder builder = createTestQueryBuilder();
double top = builder.topLeft().getLat();
@@ -208,19 +227,17 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
builder.setValidationMethod(GeoValidationMethod.IGNORE_MALFORMED).setCorners(bottom, left, top, right);
}
- @Test
public void testLeftRightCanBeFlipped() {
GeoBoundingBoxQueryBuilder builder = createTestQueryBuilder();
double top = builder.topLeft().getLat();
double left = builder.topLeft().getLon();
double bottom = builder.bottomRight().getLat();
double right = builder.bottomRight().getLon();
-
+
builder.setValidationMethod(GeoValidationMethod.IGNORE_MALFORMED).setCorners(top, right, bottom, left);
builder.setValidationMethod(GeoValidationMethod.STRICT).setCorners(top, right, bottom, left);
}
- @Test
public void testNormalization() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
GeoBoundingBoxQueryBuilder qb = createTestQueryBuilder();
@@ -243,9 +260,8 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
}
}
}
-
- @Test
- public void checkStrictnessDefault() {
+
+ public void testStrictnessDefault() {
assertFalse("Someone changed the default for coordinate validation - were the docs changed as well?", GeoValidationMethod.DEFAULT_LENIENT_PARSING);
}
@@ -311,7 +327,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
public class RightTester extends PointTester {
public RightTester() {
super(randomDoubleBetween(GeoUtils.MAX_LON, Double.MAX_VALUE, true));
- }
+ }
@Override
public void fillIn(double coordinate, GeoBoundingBoxQueryBuilder qb) {
@@ -319,7 +335,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
}
}
- @Test
public void testParsingAndToQuery1() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -333,7 +348,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
assertGeoBoundingBoxQuery(query);
}
- @Test
public void testParsingAndToQuery2() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -353,7 +367,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
assertGeoBoundingBoxQuery(query);
}
- @Test
public void testParsingAndToQuery3() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -367,7 +380,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
assertGeoBoundingBoxQuery(query);
}
- @Test
public void testParsingAndToQuery4() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -381,7 +393,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
assertGeoBoundingBoxQuery(query);
}
- @Test
public void testParsingAndToQuery5() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -395,7 +406,6 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
assertGeoBoundingBoxQuery(query);
}
- @Test
public void testParsingAndToQuery6() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -410,7 +420,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase<GeoBo
"}\n";
assertGeoBoundingBoxQuery(query);
}
-
+
private void assertGeoBoundingBoxQuery(String query) throws IOException {
Query parsedQuery = parseQuery(query).toQuery(createShardContext());
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java
index 691204921e..edb2b65293 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
import org.elasticsearch.test.geo.RandomShapeGenerator;
-import org.junit.Test;
import java.io.IOException;
@@ -152,7 +151,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
* explicitly mapped
*/
@Override
- @Test
public void testToQuery() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
super.testToQuery();
@@ -176,7 +174,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertThat(geoQuery.maxInclusiveDistance(), closeTo(distance, Math.abs(distance) / 1000));
}
- @Test
public void testParsingAndToQuery1() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -191,7 +188,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery2() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -203,7 +199,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery3() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -215,7 +210,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery4() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -227,7 +221,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery5() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -243,7 +236,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery6() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -259,7 +251,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery7() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -280,7 +271,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertThat(filter.maxInclusiveDistance(), closeTo(DistanceUnit.DEFAULT.convert(0.012, DistanceUnit.MILES), 0.00001));
}
- @Test
public void testParsingAndToQuery8() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -301,7 +291,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertThat(filter.maxInclusiveDistance(), closeTo(DistanceUnit.KILOMETERS.convert(12, DistanceUnit.MILES), 0.00001));
}
- @Test
public void testParsingAndToQuery9() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -317,7 +306,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery10() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -333,7 +321,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery11() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -348,7 +335,6 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
assertGeoDistanceRangeQuery(query);
}
- @Test
public void testParsingAndToQuery12() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java
index 19e48aa41a..2165507d82 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java
@@ -25,13 +25,13 @@ import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.geo.GeoUtils;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanceRangeQueryBuilder> {
@@ -145,69 +145,101 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
* explicitly mapped
*/
@Override
- @Test
public void testToQuery() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
super.testToQuery();
}
- @Test(expected=IllegalArgumentException.class)
public void testNullFieldName() {
- if (randomBoolean()) {
- new GeoDistanceRangeQueryBuilder(null, new GeoPoint());
- } else {
- new GeoDistanceRangeQueryBuilder("", new GeoPoint());
+ try {
+ if (randomBoolean()) {
+ new GeoDistanceRangeQueryBuilder(null, new GeoPoint());
+ } else {
+ new GeoDistanceRangeQueryBuilder("", new GeoPoint());
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("fieldName must not be null"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testNoPoint() {
- if (randomBoolean()) {
- new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, (GeoPoint) null);
- } else {
- new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, (String) null);
+ try {
+ if (randomBoolean()) {
+ new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, (GeoPoint) null);
+ } else {
+ new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, (String) null);
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("point must not be null"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidFrom() {
GeoDistanceRangeQueryBuilder builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, new GeoPoint());
- if (randomBoolean()) {
- builder.from((String) null);
- } else {
- builder.from((Number) null);
+ try {
+ if (randomBoolean()) {
+ builder.from((String) null);
+ } else {
+ builder.from((Number) null);
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("[from] must not be null"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidTo() {
GeoDistanceRangeQueryBuilder builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, new GeoPoint());
- if (randomBoolean()) {
- builder.to((String) null);
- } else {
- builder.to((Number) null);
+ try {
+ if (randomBoolean()) {
+ builder.to((String) null);
+ } else {
+ builder.to((Number) null);
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("[to] must not be null"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidOptimizeBBox() {
GeoDistanceRangeQueryBuilder builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, new GeoPoint());
if (randomBoolean()) {
- builder.optimizeBbox(null);
+ try {
+ builder.optimizeBbox(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("optimizeBbox must not be null"));
+ }
} else {
- builder.optimizeBbox("foo");
+ try {
+ builder.optimizeBbox("foo");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("optimizeBbox must be one of [none, memory, indexed]"));
+ }
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidGeoDistance() {
GeoDistanceRangeQueryBuilder builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, new GeoPoint());
- builder.geoDistance(null);
+ try {
+ builder.geoDistance(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("geoDistance calculation mode must not be null"));
+ }
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidDistanceUnit() {
GeoDistanceRangeQueryBuilder builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, new GeoPoint());
- builder.unit(null);
+ try {
+ builder.unit(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("distance unit must not be null"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java
index e49d15d751..eb9da71385 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.search.geo.GeoPolygonQuery;
import org.elasticsearch.test.geo.RandomShapeGenerator;
import org.elasticsearch.test.geo.RandomShapeGenerator.ShapeType;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -42,9 +41,9 @@ import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygonQueryBuilder> {
-
@Override
protected GeoPolygonQueryBuilder doCreateTestQueryBuilder() {
List<GeoPoint> polygon = randomPolygon(randomIntBetween(4, 50));
@@ -105,36 +104,51 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
return polygonPoints;
}
- @Test(expected = IllegalArgumentException.class)
public void testNullFieldName() {
- new GeoPolygonQueryBuilder(null, randomPolygon(5));
+ try {
+ new GeoPolygonQueryBuilder(null, randomPolygon(5));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("fieldName must not be null"));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testEmptyPolygon() {
- if (randomBoolean()) {
- new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, new ArrayList<GeoPoint>());
- } else {
- new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, null);
+ try {
+ if (randomBoolean()) {
+ new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, new ArrayList<GeoPoint>());
+ } else {
+ new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, null);
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("polygon must not be null or empty"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidClosedPolygon() {
List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(0, 90));
points.add(new GeoPoint(90, 90));
points.add(new GeoPoint(0, 90));
- new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, points);
-
+ try {
+ new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, points);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("too few points defined for geo_polygon query"));
+ }
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidOpenPolygon() {
List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(0, 90));
points.add(new GeoPoint(90, 90));
- new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, points);
+ try {
+ new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, points);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("too few points defined for geo_polygon query"));
+ }
}
public void testDeprecatedXContent() throws IOException {
@@ -160,7 +174,6 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
}
}
- @Test
public void testParsingAndToQueryParsingExceptions() throws IOException {
String[] brokenFiles = new String[]{
"/org/elasticsearch/index/query/geo_polygon_exception_1.json",
@@ -180,7 +193,6 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
}
}
- @Test
public void testParsingAndToQuery1() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -197,7 +209,6 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
assertGeoPolygonQuery(query);
}
- @Test
public void testParsingAndToQuery2() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -223,7 +234,6 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
assertGeoPolygonQuery(query);
}
- @Test
public void testParsingAndToQuery3() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -240,7 +250,6 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
assertGeoPolygonQuery(query);
}
- @Test
public void testParsingAndToQuery4() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java
index 0a2034d98d..3280ef2679 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java
@@ -36,13 +36,13 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.get.GetResult;
import org.elasticsearch.test.geo.RandomShapeGenerator;
import org.junit.After;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQueryBuilder> {
@@ -140,13 +140,16 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
super.testToQuery();
}
- @Test(expected = IllegalArgumentException.class)
public void testNoFieldName() throws Exception {
ShapeBuilder shape = RandomShapeGenerator.createShapeWithin(getRandom(), null);
- new GeoShapeQueryBuilder(null, shape);
+ try {
+ new GeoShapeQueryBuilder(null, shape);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("fieldName is required"));
+ }
}
- @Test
public void testNoShape() throws IOException {
try {
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, (ShapeBuilder) null);
@@ -156,24 +159,35 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
}
}
- @Test(expected = IllegalArgumentException.class)
public void testNoIndexedShape() throws IOException {
- new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, null, "type");
+ try {
+ new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, null, "type");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("either shapeBytes or indexedShapeId and indexedShapeType are required"));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testNoIndexedShapeType() throws IOException {
- new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, "id", null);
+ try {
+ new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, "id", null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("indexedShapeType is required if indexedShapeId is specified"));
+ }
}
- @Test(expected=IllegalArgumentException.class)
public void testNoRelation() throws IOException {
ShapeBuilder shape = RandomShapeGenerator.createShapeWithin(getRandom(), null);
GeoShapeQueryBuilder builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape);
- builder.relation(null);
+ try {
+ builder.relation(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("No Shape Relation defined"));
+ }
}
- @Test
public void testInvalidRelation() throws IOException {
ShapeBuilder shape = RandomShapeGenerator.createShapeWithin(getRandom(), null);
GeoShapeQueryBuilder builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape);
@@ -194,7 +208,7 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
}
}
- @Test // see #3878
+ // see #3878
public void testThatXContentSerializationInsideOfArrayWorks() throws Exception {
EnvelopeBuilder envelopeBuilder = ShapeBuilder.newEnvelope().topLeft(0, 0).bottomRight(10, 10);
GeoShapeQueryBuilder geoQuery = QueryBuilders.geoShapeQuery("searchGeometry", envelopeBuilder);
diff --git a/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java
index 022c2e1125..afacce87bd 100644
--- a/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java
@@ -30,12 +30,13 @@ import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
import org.elasticsearch.index.query.GeohashCellQuery.Builder;
import org.elasticsearch.test.geo.RandomShapeGenerator;
-import org.junit.Test;
import java.io.IOException;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
public class GeohashCellQueryBuilderTests extends AbstractQueryTestCase<Builder> {
@@ -84,31 +85,42 @@ public class GeohashCellQueryBuilderTests extends AbstractQueryTestCase<Builder>
super.testToQuery();
}
- @Test(expected=IllegalArgumentException.class)
public void testNullField() {
- if (randomBoolean()) {
- new Builder(null, new GeoPoint());
- } else {
- new Builder("", new GeoPoint());
+ try {
+ if (randomBoolean()) {
+ new Builder(null, new GeoPoint());
+ } else {
+ new Builder("", new GeoPoint());
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("fieldName must not be null"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testNullGeoPoint() {
- if (randomBoolean()) {
- new Builder(GEO_POINT_FIELD_NAME, (GeoPoint) null);
- } else {
- new Builder(GEO_POINT_FIELD_NAME, "");
+ try {
+ if (randomBoolean()) {
+ new Builder(GEO_POINT_FIELD_NAME, (GeoPoint) null);
+ } else {
+ new Builder(GEO_POINT_FIELD_NAME, "");
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("geohash or point must be defined"));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testInvalidPrecision() {
GeohashCellQuery.Builder builder = new Builder(GEO_POINT_FIELD_NAME, new GeoPoint());
- builder.precision(-1);
+ try {
+ builder.precision(-1);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("precision must be greater than 0"));
+ }
}
- @Test
public void testLocationParsing() throws IOException {
Point point = RandomShapeGenerator.xRandomPoint(getRandom());
Builder pointTestBuilder = new GeohashCellQuery.Builder("pin", new GeoPoint(point.getY(), point.getX()));
diff --git a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryParserTests.java
index bdf7efbbab..7be9a6c74f 100644
--- a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryParserTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryParserTests.java
@@ -20,51 +20,52 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
public class HasChildQueryParserTests extends ESTestCase {
-
- @Test
- public void minFromString() {
+ public void testMinFromString() {
assertThat("fromString(min) != MIN", ScoreMode.Min, equalTo(HasChildQueryParser.parseScoreMode("min")));
}
- @Test
- public void maxFromString() {
+ public void testMaxFromString() {
assertThat("fromString(max) != MAX", ScoreMode.Max, equalTo(HasChildQueryParser.parseScoreMode("max")));
}
- @Test
- public void avgFromString() {
+ public void testAvgFromString() {
assertThat("fromString(avg) != AVG", ScoreMode.Avg, equalTo(HasChildQueryParser.parseScoreMode("avg")));
}
- @Test
- public void sumFromString() {
+ public void testSumFromString() {
assertThat("fromString(total) != SUM", ScoreMode.Total, equalTo(HasChildQueryParser.parseScoreMode("total")));
}
- @Test
- public void noneFromString() {
+ public void testNoneFromString() {
assertThat("fromString(none) != NONE", ScoreMode.None, equalTo(HasChildQueryParser.parseScoreMode("none")));
}
/**
* Should throw {@link IllegalArgumentException} instead of NPE.
*/
- @Test(expected = IllegalArgumentException.class)
- public void nullFromString_throwsException() {
- HasChildQueryParser.parseScoreMode(null);
+ public void testThatNullFromStringThrowsException() {
+ try {
+ HasChildQueryParser.parseScoreMode(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("No score mode for child query [null] found"));
+ }
}
/**
* Failure should not change (and the value should never match anything...).
*/
- @Test(expected = IllegalArgumentException.class)
- public void unrecognizedFromString_throwsException() {
- HasChildQueryParser.parseScoreMode("unrecognized value");
+ public void testThatUnrecognizedFromStringThrowsException() {
+ try {
+ HasChildQueryParser.parseScoreMode("unrecognized value");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("No score mode for child query [unrecognized value] found"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java
index 665b4b08ae..a88a57394a 100644
--- a/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java
@@ -25,7 +25,6 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.ParsingException;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -33,16 +32,21 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
public class IdsQueryBuilderTests extends AbstractQueryTestCase<IdsQueryBuilder> {
-
/**
- * check that parser throws exception on missing values field
+ * Check that parser throws exception on missing values field.
*/
- @Test(expected=ParsingException.class)
public void testIdsNotProvided() throws IOException {
String noIdsFieldQuery = "{\"ids\" : { \"type\" : \"my_type\" }";
- parseQuery(noIdsFieldQuery);
+ try {
+ parseQuery(noIdsFieldQuery);
+ fail("Expected ParsingException");
+ } catch (ParsingException e) {
+ assertThat(e.getMessage(), containsString("no ids values provided"));
+ }
}
@Override
@@ -138,9 +142,14 @@ public class IdsQueryBuilderTests extends AbstractQueryTestCase<IdsQueryBuilder>
}
}
- @Test(expected= ParsingException.class) // see #7686.
+ // see #7686.
public void testIdsQueryWithInvalidValues() throws Exception {
String query = "{ \"ids\": { \"values\": [[1]] } }";
- parseQuery(query);
+ try {
+ parseQuery(query);
+ fail("Expected ParsingException");
+ } catch (ParsingException e) {
+ assertThat(e.getMessage(), is("Illegal value for id, expecting a string or number, got: START_ARRAY"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/IndicesQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/IndicesQueryBuilderTests.java
index 8db4317a58..6be5cce953 100644
--- a/core/src/test/java/org/elasticsearch/index/query/IndicesQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/IndicesQueryBuilderTests.java
@@ -20,7 +20,6 @@
package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
@@ -68,7 +67,6 @@ public class IndicesQueryBuilderTests extends AbstractQueryTestCase<IndicesQuery
//nothing to do here, boost check is already included in equality check done as part of doAssertLuceneQuery above
}
- @Test
public void testIllegalArguments() {
try {
new IndicesQueryBuilder(null, "index");
diff --git a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java
index f9da80d97d..45b508b151 100644
--- a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java
@@ -20,24 +20,29 @@
package org.elasticsearch.index.query;
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.search.MatchQuery;
import org.elasticsearch.index.search.MatchQuery.ZeroTermsQuery;
-import org.junit.Test;
import java.io.IOException;
import java.util.Locale;
import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class MatchQueryBuilderTests extends AbstractQueryTestCase<MatchQueryBuilder> {
-
@Override
protected MatchQueryBuilder doCreateTestQueryBuilder() {
String fieldName = randomFrom(STRING_FIELD_NAME, BOOLEAN_FIELD_NAME, INT_FIELD_NAME,
@@ -228,10 +233,14 @@ public class MatchQueryBuilderTests extends AbstractQueryTestCase<MatchQueryBuil
}
}
- @Test(expected = QueryShardException.class)
public void testBadAnalyzer() throws IOException {
MatchQueryBuilder matchQuery = new MatchQueryBuilder("fieldName", "text");
matchQuery.analyzer("bogusAnalyzer");
- matchQuery.toQuery(createShardContext());
+ try {
+ matchQuery.toQuery(createShardContext());
+ fail("Expected QueryShardException");
+ } catch (QueryShardException e) {
+ assertThat(e.getMessage(), containsString("analyzer [bogusAnalyzer] not found"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/MissingQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MissingQueryBuilderTests.java
index 0314ca957a..0a66d7a315 100644
--- a/core/src/test/java/org/elasticsearch/index/query/MissingQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/MissingQueryBuilderTests.java
@@ -20,10 +20,11 @@
package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
+import static org.hamcrest.Matchers.containsString;
+
public class MissingQueryBuilderTests extends AbstractQueryTestCase<MissingQueryBuilder> {
@Override
@@ -43,10 +44,10 @@ public class MissingQueryBuilderTests extends AbstractQueryTestCase<MissingQuery
@Override
protected void doAssertLuceneQuery(MissingQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
- //too many mapping dependent cases to test, we don't want to end up duplication the toQuery method
+ // too many mapping dependent cases to test, we don't want to end up
+ // duplication the toQuery method
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
@@ -74,10 +75,14 @@ public class MissingQueryBuilderTests extends AbstractQueryTestCase<MissingQuery
}
}
- @Test(expected = QueryShardException.class)
public void testBothNullValueAndExistenceFalse() throws IOException {
QueryShardContext context = createShardContext();
context.setAllowUnmappedFields(true);
- MissingQueryBuilder.newFilter(context, "field", false, false);
+ try {
+ MissingQueryBuilder.newFilter(context, "field", false, false);
+ fail("Expected QueryShardException");
+ } catch (QueryShardException e) {
+ assertThat(e.getMessage(), containsString("missing must have either existence, or null_value"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
index 7e9f97d76a..663e37ed97 100644
--- a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
@@ -42,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -244,19 +243,26 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
}
}
- @Test(expected=IllegalArgumentException.class)
public void testValidateEmptyFields() {
- new MoreLikeThisQueryBuilder(new String[0], new String[]{"likeText"}, null);
+ try {
+ new MoreLikeThisQueryBuilder(new String[0], new String[]{"likeText"}, null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("requires 'fields' to be specified"));
+ }
}
- @Test(expected=IllegalArgumentException.class)
public void testValidateEmptyLike() {
String[] likeTexts = randomBoolean() ? null : new String[0];
Item[] likeItems = randomBoolean() ? null : new Item[0];
- new MoreLikeThisQueryBuilder(likeTexts, likeItems);
+ try {
+ new MoreLikeThisQueryBuilder(likeTexts, likeItems);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("requires either 'like' texts or items to be specified"));
+ }
}
- @Test
public void testUnsupportedFields() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String unsupportedField = randomFrom(INT_FIELD_NAME, DOUBLE_FIELD_NAME, DATE_FIELD_NAME);
@@ -270,7 +276,6 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
}
}
- @Test
public void testMoreLikeThisBuilder() throws Exception {
Query parsedQuery = parseQuery(moreLikeThisQuery(new String[]{"name.first", "name.last"}, new String[]{"something"}, null).minTermFreq(1).maxQueryTerms(12).buildAsBytes()).toQuery(createShardContext());
assertThat(parsedQuery, instanceOf(MoreLikeThisQuery.class));
@@ -281,7 +286,6 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
assertThat(mltQuery.getMaxQueryTerms(), equalTo(12));
}
- @Test
public void testItemSerialization() throws IOException {
Item expectedItem = generateRandomItem();
BytesStreamOutput output = new BytesStreamOutput();
@@ -290,7 +294,6 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
assertEquals(expectedItem, newItem);
}
- @Test
public void testItemFromXContent() throws IOException {
Item expectedItem = generateRandomItem();
String json = expectedItem.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).string();
diff --git a/core/src/test/java/org/elasticsearch/index/query/MultiMatchQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MultiMatchQueryBuilderTests.java
index 8014597a4c..796ac225c9 100644
--- a/core/src/test/java/org/elasticsearch/index/query/MultiMatchQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/MultiMatchQueryBuilderTests.java
@@ -21,11 +21,17 @@ package org.elasticsearch.index.query;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MatchNoDocsQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.elasticsearch.common.lucene.all.AllTermQuery;
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
import org.elasticsearch.index.search.MatchQuery;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -34,7 +40,9 @@ import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.multiMatchQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBooleanSubQuery;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.either;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatchQueryBuilder> {
@@ -126,7 +134,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
.or(instanceOf(MatchNoDocsQuery.class)).or(instanceOf(PhraseQuery.class)));
}
- @Test
public void testIllegaArguments() {
try {
new MultiMatchQueryBuilder(null, "field");
@@ -162,7 +169,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
//we delegate boost checks to specific boost tests below
}
- @Test
public void testToQueryBoost() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
QueryShardContext shardContext = createShardContext();
@@ -180,7 +186,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
assertThat(query.getBoost(), equalTo(10f));
}
- @Test
public void testToQueryMultipleTermsBooleanQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = multiMatchQuery("test1 test2").field(STRING_FIELD_NAME).useDisMax(false).toQuery(createShardContext());
@@ -191,7 +196,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
assertThat(assertBooleanSubQuery(query, TermQuery.class, 1).getTerm(), equalTo(new Term(STRING_FIELD_NAME, "test2")));
}
- @Test
public void testToQueryMultipleFieldsBooleanQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = multiMatchQuery("test").field(STRING_FIELD_NAME).field(STRING_FIELD_NAME_2).useDisMax(false).toQuery(createShardContext());
@@ -202,7 +206,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
assertThat(assertBooleanSubQuery(query, TermQuery.class, 1).getTerm(), equalTo(new Term(STRING_FIELD_NAME_2, "test")));
}
- @Test
public void testToQueryMultipleFieldsDisMaxQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = multiMatchQuery("test").field(STRING_FIELD_NAME).field(STRING_FIELD_NAME_2).useDisMax(true).toQuery(createShardContext());
@@ -213,7 +216,6 @@ public class MultiMatchQueryBuilderTests extends AbstractQueryTestCase<MultiMatc
assertThat(((TermQuery) disjuncts.get(1)).getTerm(), equalTo(new Term(STRING_FIELD_NAME_2, "test")));
}
- @Test
public void testToQueryFieldsWildcard() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = multiMatchQuery("test").field("mapped_str*").useDisMax(false).toQuery(createShardContext());
diff --git a/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java
index 0299068a91..fde284a45d 100644
--- a/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java
@@ -27,7 +27,10 @@ import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.compress.CompressedXContent;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.fielddata.IndexFieldDataService;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.support.QueryInnerHits;
@@ -36,7 +39,6 @@ import org.elasticsearch.search.fetch.innerhits.InnerHitsContext;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.TestSearchContext;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -161,7 +163,6 @@ public class NestedQueryBuilderTests extends AbstractQueryTestCase<NestedQueryBu
assertEquals(tqb.values(), Arrays.asList("a", "b"));
}
- @Test
public void testValidate() {
try {
new NestedQueryBuilder(null, EmptyQueryBuilder.PROTOTYPE);
diff --git a/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java
index 7d7a3a4cfe..7466f2d8e7 100644
--- a/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java
@@ -23,7 +23,6 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -54,7 +53,6 @@ public class PrefixQueryBuilderTests extends AbstractQueryTestCase<PrefixQueryBu
assertThat(prefixQuery.getPrefix().text(), equalTo(queryBuilder.value()));
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
@@ -75,7 +73,6 @@ public class PrefixQueryBuilderTests extends AbstractQueryTestCase<PrefixQueryBu
}
}
- @Test
public void testBlendedRewriteMethod() throws IOException {
for (String rewrite : Arrays.asList("top_terms_blended_freqs_10", "topTermsBlendedFreqs10")) {
Query parsedQuery = parseQuery(prefixQuery("field", "val").rewrite(rewrite).buildAsBytes()).toQuery(createShardContext());
diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
index 8001c06eb8..88cc951752 100644
--- a/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.Fil
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,8 +38,51 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.elasticsearch.index.query.QueryBuilders.*;
-import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.boostingQuery;
+import static org.elasticsearch.index.query.QueryBuilders.commonTermsQuery;
+import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.disMaxQuery;
+import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
+import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.fuzzyQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoDistanceRangeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoHashCellQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoPolygonQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
+import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
+import static org.elasticsearch.index.query.QueryBuilders.idsQuery;
+import static org.elasticsearch.index.query.QueryBuilders.indicesQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
+import static org.elasticsearch.index.query.QueryBuilders.missingQuery;
+import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery;
+import static org.elasticsearch.index.query.QueryBuilders.multiMatchQuery;
+import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
+import static org.elasticsearch.index.query.QueryBuilders.prefixQuery;
+import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
+import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.regexpQuery;
+import static org.elasticsearch.index.query.QueryBuilders.scriptQuery;
+import static org.elasticsearch.index.query.QueryBuilders.simpleQueryStringQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanContainingQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanFirstQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanMultiTermQueryBuilder;
+import static org.elasticsearch.index.query.QueryBuilders.spanNearQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanNotQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanOrQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery;
+import static org.elasticsearch.index.query.QueryBuilders.spanWithinQuery;
+import static org.elasticsearch.index.query.QueryBuilders.templateQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
+import static org.elasticsearch.index.query.QueryBuilders.typeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.exponentialDecayFunction;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction;
/**
* If one of the following tests doesn't compile make sure to not only fix the compilation error here
@@ -50,7 +92,6 @@ import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.
* documented in the java api query dsl part of our reference guide.
* */
public class QueryDSLDocumentationTests extends ESTestCase {
- @Test
public void testBool() {
boolQuery()
.must(termQuery("content", "test1"))
@@ -60,24 +101,20 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.filter(termQuery("content", "test5"));
}
- @Test
public void testBoosting() {
boostingQuery(termQuery("name","kimchy"), termQuery("name","dadoonet"))
.negativeBoost(0.2f);
}
- @Test
public void testCommonTerms() {
commonTermsQuery("name", "kimchy");
}
- @Test
public void testConstantScore() {
constantScoreQuery(termQuery("name","kimchy"))
.boost(2.0f);
}
- @Test
public void testDisMax() {
disMaxQuery()
.add(termQuery("name", "kimchy"))
@@ -86,12 +123,10 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.tieBreaker(0.7f);
}
- @Test
public void testExists() {
existsQuery("name");
}
- @Test
public void testFunctionScore() {
FilterFunctionBuilder[] functions = {
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
@@ -103,17 +138,14 @@ public class QueryDSLDocumentationTests extends ESTestCase {
functionScoreQuery(functions);
}
- @Test
public void testFuzzy() {
fuzzyQuery("name", "kimchy");
}
- @Test
public void testGeoBoundingBox() {
geoBoundingBoxQuery("pin.location").setCorners(40.73, -74.1, 40.717, -73.99);
}
- @Test
public void testGeoDistance() {
geoDistanceQuery("pin.location")
.point(40, -70)
@@ -122,7 +154,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.geoDistance(GeoDistance.ARC);
}
- @Test
public void testGeoDistanceRange() {
geoDistanceRangeQuery("pin.location", new GeoPoint(40, -70)) // TODO check why I need the point here but not above
.from("200km")
@@ -133,7 +164,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.geoDistance(GeoDistance.ARC);
}
- @Test
public void testGeoPolygon() {
List<GeoPoint> points = new ArrayList<GeoPoint>();
points.add(new GeoPoint(40, -70));
@@ -142,7 +172,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
geoPolygonQuery("pin.location", points);
}
- @Test
public void testGeoShape() throws IOException {
GeoShapeQueryBuilder qb = geoShapeQuery(
"pin.location",
@@ -163,7 +192,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.indexedShapePath("location");
}
- @Test
public void testGeoHashCell() {
geoHashCellQuery("pin.location",
new GeoPoint(13.4080, 52.5186))
@@ -171,7 +199,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.precision(3);
}
- @Test
public void testHasChild() {
hasChildQuery(
"blog_tag",
@@ -179,7 +206,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
);
}
- @Test
public void testHasParent() {
hasParentQuery(
"blog",
@@ -187,7 +213,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
);
}
- @Test
public void testIds() {
idsQuery("my_type", "type2")
.addIds("1", "4", "100");
@@ -195,7 +220,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
idsQuery().addIds("1", "4", "100");
}
- @Test
public void testIndices() {
indicesQuery(
termQuery("tag", "wow"),
@@ -208,22 +232,18 @@ public class QueryDSLDocumentationTests extends ESTestCase {
).noMatchQuery("all");
}
- @Test
public void testMatchAll() {
matchAllQuery();
}
- @Test
public void testMatch() {
matchQuery("name", "kimchy elasticsearch");
}
- @Test
public void testMissing() {
missingQuery("user", true, true);
}
- @Test
public void testMLT() {
String[] fields = {"name.first", "name.last"};
String[] texts = {"text like this one"};
@@ -234,12 +254,10 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.maxQueryTerms(12);
}
- @Test
public void testMultiMatch() {
multiMatchQuery("kimchy elasticsearch", "user", "message");
}
- @Test
public void testNested() {
nestedQuery(
"obj1",
@@ -250,17 +268,14 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.scoreMode(ScoreMode.Avg);
}
- @Test
public void testPrefix() {
prefixQuery("brand", "heine");
}
- @Test
public void testQueryString() {
queryStringQuery("+kimchy -elasticsearch");
}
- @Test
public void testRange() {
rangeQuery("price")
.from(5)
@@ -273,12 +288,10 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.lt("20");
}
- @Test
public void testRegExp() {
regexpQuery("name.first", "s.*y");
}
- @Test
public void testScript() {
scriptQuery(
new Script("doc['num1'].value > 1")
@@ -296,12 +309,10 @@ public class QueryDSLDocumentationTests extends ESTestCase {
}
- @Test
public void testSimpleQueryString() {
simpleQueryStringQuery("+kimchy -elasticsearch");
}
- @Test
public void testSpanContaining() {
spanContainingQuery(
spanNearQuery(spanTermQuery("field1","bar"), 5)
@@ -310,7 +321,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
spanTermQuery("field1","foo"));
}
- @Test
public void testSpanFirst() {
spanFirstQuery(
spanTermQuery("user", "kimchy"),
@@ -318,12 +328,10 @@ public class QueryDSLDocumentationTests extends ESTestCase {
);
}
- @Test
public void testSpanMultiTerm() {
spanMultiTermQueryBuilder(prefixQuery("user", "ki"));
}
- @Test
public void testSpanNear() {
spanNearQuery(spanTermQuery("field","value1"), 12)
.clause(spanTermQuery("field","value2"))
@@ -332,25 +340,21 @@ public class QueryDSLDocumentationTests extends ESTestCase {
.collectPayloads(false);
}
- @Test
public void testSpanNot() {
spanNotQuery(spanTermQuery("field","value1"),
spanTermQuery("field","value2"));
}
- @Test
public void testSpanOr() {
spanOrQuery(spanTermQuery("field","value1"))
.clause(spanTermQuery("field","value2"))
.clause(spanTermQuery("field","value3"));
}
- @Test
public void testSpanTerm() {
spanTermQuery("user", "kimchy");
}
- @Test
public void testSpanWithin() {
spanWithinQuery(
spanNearQuery(spanTermQuery("field1", "bar"), 5)
@@ -359,7 +363,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
spanTermQuery("field1", "foo"));
}
- @Test
public void testTemplate() {
templateQuery(
"gender_template",
@@ -367,22 +370,18 @@ public class QueryDSLDocumentationTests extends ESTestCase {
new HashMap<>());
}
- @Test
public void testTerm() {
termQuery("name", "kimchy");
}
- @Test
public void testTerms() {
termsQuery("tags", "blue", "pill");
}
- @Test
public void testType() {
typeQuery("my_type");
}
- @Test
public void testWildcard() {
wildcardQuery("user", "k?mch*");
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryFilterBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryFilterBuilderTests.java
index 15075b3092..d98dbd0cbb 100644
--- a/core/src/test/java/org/elasticsearch/index/query/QueryFilterBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/QueryFilterBuilderTests.java
@@ -21,11 +21,12 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.Query;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.nullValue;
@SuppressWarnings("deprecation")
public class QueryFilterBuilderTests extends AbstractQueryTestCase<QueryFilterBuilder> {
@@ -56,7 +57,6 @@ public class QueryFilterBuilderTests extends AbstractQueryTestCase<QueryFilterBu
/**
* test that wrapping an inner filter that returns <tt>null</tt> also returns <tt>null</tt> to pass on upwards
*/
- @Test
public void testInnerQueryReturnsNull() throws IOException {
// create inner filter
String queryString = "{ \"constant_score\" : { \"filter\" : {} } }";
@@ -66,7 +66,6 @@ public class QueryFilterBuilderTests extends AbstractQueryTestCase<QueryFilterBu
assertNull(queryFilterQuery.toQuery(createShardContext()));
}
- @Test
public void testValidate() {
try {
new QueryFilterBuilder(null);
diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
index 1b85a26c5a..00b139039c 100644
--- a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
@@ -20,12 +20,20 @@
package org.elasticsearch.index.query;
import org.apache.lucene.index.Term;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MatchNoDocsQuery;
+import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RegexpQuery;
+import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
import org.elasticsearch.common.lucene.all.AllTermQuery;
import org.hamcrest.Matchers;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.io.IOException;
import java.util.List;
@@ -35,7 +43,8 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBool
import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.containsString;
public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStringQueryBuilder> {
@@ -145,7 +154,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
}
}
- @Test
public void testIllegalArguments() {
try {
new QueryStringQueryBuilder(null);
@@ -155,13 +163,11 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
}
}
- @Test
public void testToQueryMatchAllQuery() throws Exception {
Query query = queryStringQuery("*:*").toQuery(createShardContext());
assertThat(query, instanceOf(MatchAllDocsQuery.class));
}
- @Test
public void testToQueryTermQuery() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test").defaultField(STRING_FIELD_NAME).toQuery(createShardContext());
@@ -170,7 +176,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(termQuery.getTerm(), equalTo(new Term(STRING_FIELD_NAME, "test")));
}
- @Test
public void testToQueryPhraseQuery() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("\"term1 term2\"").defaultField(STRING_FIELD_NAME).phraseSlop(3).toQuery(createShardContext());
@@ -185,7 +190,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(phraseQuery.getSlop(), equalTo(3));
}
- @Test
public void testToQueryBoosts() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
QueryShardContext shardContext = createShardContext();
@@ -221,7 +225,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(boostQuery.getBoost(), equalTo(6.0f));
}
- @Test
public void testToQueryMultipleTermsBooleanQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test1 test2").field(STRING_FIELD_NAME).useDisMax(false).toQuery(createShardContext());
@@ -232,7 +235,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(assertBooleanSubQuery(query, TermQuery.class, 1).getTerm(), equalTo(new Term(STRING_FIELD_NAME, "test2")));
}
- @Test
public void testToQueryMultipleFieldsBooleanQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test").field(STRING_FIELD_NAME).field(STRING_FIELD_NAME_2).useDisMax(false).toQuery(createShardContext());
@@ -243,7 +245,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(assertBooleanSubQuery(query, TermQuery.class, 1).getTerm(), equalTo(new Term(STRING_FIELD_NAME_2, "test")));
}
- @Test
public void testToQueryMultipleFieldsDisMaxQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test").field(STRING_FIELD_NAME).field(STRING_FIELD_NAME_2).useDisMax(true).toQuery(createShardContext());
@@ -254,7 +255,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(((TermQuery) disjuncts.get(1)).getTerm(), equalTo(new Term(STRING_FIELD_NAME_2, "test")));
}
- @Test
public void testToQueryFieldsWildcard() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test").field("mapped_str*").useDisMax(false).toQuery(createShardContext());
@@ -265,7 +265,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat(assertBooleanSubQuery(query, TermQuery.class, 1).getTerm(), equalTo(new Term(STRING_FIELD_NAME_2, "test")));
}
- @Test
public void testToQueryDisMaxQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("test").field(STRING_FIELD_NAME, 2.2f).field(STRING_FIELD_NAME_2).useDisMax(true).toQuery(createShardContext());
@@ -278,7 +277,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertThat((double) disjuncts.get(1).getBoost(), closeTo(1, 0.01));
}
- @Test
public void testToQueryRegExpQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("/foo*bar/").defaultField(STRING_FIELD_NAME).maxDeterminizedStates(5000).toQuery(createShardContext());
@@ -287,23 +285,25 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
assertTrue(regexpQuery.toString().contains("/foo*bar/"));
}
- @Test(expected = TooComplexToDeterminizeException.class)
public void testToQueryRegExpQueryTooComplex() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
- queryStringQuery("/[ac]*a[ac]{50,200}/").defaultField(STRING_FIELD_NAME).toQuery(createShardContext());
+ try {
+ queryStringQuery("/[ac]*a[ac]{50,200}/").defaultField(STRING_FIELD_NAME).toQuery(createShardContext());
+ fail("Expected TooComplexToDeterminizeException");
+ } catch (TooComplexToDeterminizeException e) {
+ assertThat(e.getMessage(), containsString("Determinizing [ac]*"));
+ assertThat(e.getMessage(), containsString("would result in more than 10000 states"));
+ }
}
- @Test
public void testToQueryNumericRangeQuery() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = queryStringQuery("12~0.2").defaultField(INT_FIELD_NAME).toQuery(createShardContext());
NumericRangeQuery fuzzyQuery = (NumericRangeQuery) query;
assertThat(fuzzyQuery.getMin().longValue(), equalTo(12l));
assertThat(fuzzyQuery.getMax().longValue(), equalTo(12l));
-
}
- @Test
public void testTimezone() throws Exception {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String queryAsString = "{\n" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java
index 14c1d4f3f4..0eabedeeff 100644
--- a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java
@@ -26,14 +26,17 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.lucene.BytesRefs;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuilder> {
@@ -126,7 +129,6 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
}
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
@@ -166,25 +168,31 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
/**
* Specifying a timezone together with a numeric range query should throw an exception.
*/
- @Test(expected=QueryShardException.class)
public void testToQueryNonDateWithTimezone() throws QueryShardException, IOException {
RangeQueryBuilder query = new RangeQueryBuilder(INT_FIELD_NAME);
query.from(1).to(10).timeZone("UTC");
- query.toQuery(createShardContext());
+ try {
+ query.toQuery(createShardContext());
+ fail("Expected QueryShardException");
+ } catch (QueryShardException e) {
+ assertThat(e.getMessage(), containsString("[range] time_zone can not be applied"));
+ }
}
/**
* Specifying a timezone together with an unmapped field should throw an exception.
*/
- @Test(expected=QueryShardException.class)
public void testToQueryUnmappedWithTimezone() throws QueryShardException, IOException {
RangeQueryBuilder query = new RangeQueryBuilder("bogus_field");
query.from(1).to(10).timeZone("UTC");
- query.toQuery(createShardContext());
+ try {
+ query.toQuery(createShardContext());
+ fail("Expected QueryShardException");
+ } catch (QueryShardException e) {
+ assertThat(e.getMessage(), containsString("[range] time_zone can not be applied"));
+ }
}
-
- @Test
public void testToQueryNumericField() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query parsedQuery = rangeQuery(INT_FIELD_NAME).from(23).to(54).includeLower(true).includeUpper(false).toQuery(createShardContext());
@@ -198,7 +206,6 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
assertThat(rangeQuery.includesMax(), equalTo(false));
}
- @Test
public void testDateRangeQueryFormat() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
// We test 01/01/2012 from gte and 2030 for lt
@@ -240,7 +247,6 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
}
}
- @Test
public void testDateRangeBoundaries() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String query = "{\n" +
@@ -284,7 +290,6 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
assertFalse(rangeQuery.includesMax());
}
- @Test
public void testDateRangeQueryTimezone() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
long startDate = System.currentTimeMillis();
diff --git a/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
index 4649decc76..526fbc009b 100644
--- a/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.RegexpQuery;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -63,7 +62,6 @@ public class RegexpQueryBuilderTests extends AbstractQueryTestCase<RegexpQueryBu
assertThat(regexpQuery.getField(), equalTo(queryBuilder.fieldName()));
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
index 87384f78d8..6077fe8086 100644
--- a/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
@@ -23,7 +23,6 @@ import org.apache.lucene.search.Query;
import org.elasticsearch.script.MockScriptEngine;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@@ -32,7 +31,6 @@ import java.util.Map;
import static org.hamcrest.Matchers.instanceOf;
public class ScriptQueryBuilderTests extends AbstractQueryTestCase<ScriptQueryBuilder> {
-
@Override
protected ScriptQueryBuilder doCreateTestQueryBuilder() {
String script = "5";
@@ -45,7 +43,6 @@ public class ScriptQueryBuilderTests extends AbstractQueryTestCase<ScriptQueryBu
assertThat(query, instanceOf(ScriptQueryBuilder.ScriptQuery.class));
}
- @Test
public void testIllegalConstructorArg() {
try {
new ScriptQueryBuilder(null);
diff --git a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java
index 2ca9441986..480517bd70 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java
@@ -29,7 +29,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -96,7 +95,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
return result;
}
- @Test
public void testDefaults() {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
@@ -127,7 +125,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
assertEquals("Wrong default default locale field.", Locale.ROOT, SimpleQueryStringBuilder.DEFAULT_LOCALE);
}
- @Test
public void testDefaultNullLocale() {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
qb.locale(null);
@@ -135,7 +132,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
qb.locale());
}
- @Test
public void testDefaultNullComplainFlags() {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
qb.flags((SimpleQueryStringFlag[]) null);
@@ -143,7 +139,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
qb.flags());
}
- @Test
public void testDefaultEmptyComplainFlags() {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
qb.flags(new SimpleQueryStringFlag[]{});
@@ -151,7 +146,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
qb.flags());
}
- @Test
public void testDefaultNullComplainOp() {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
qb.defaultOperator(null);
@@ -160,7 +154,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
}
// Check operator handling, and default field handling.
- @Test
public void testDefaultOperatorHandling() throws IOException {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.").field(STRING_FIELD_NAME);
QueryShardContext shardContext = createShardContext();
@@ -180,7 +173,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
assertThat(shouldClauses(boolQuery), is(4));
}
- @Test
public void testIllegalConstructorArg() {
try {
new SimpleQueryStringBuilder(null);
@@ -190,41 +182,60 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
}
}
- @Test(expected = IllegalArgumentException.class)
public void testFieldCannotBeNull() {
SimpleQueryStringBuilder qb = createTestQueryBuilder();
- qb.field(null);
+ try {
+ qb.field(null);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("supplied field is null or empty."));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testFieldCannotBeNullAndWeighted() {
SimpleQueryStringBuilder qb = createTestQueryBuilder();
- qb.field(null, AbstractQueryBuilder.DEFAULT_BOOST);
+ try {
+ qb.field(null, AbstractQueryBuilder.DEFAULT_BOOST);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("supplied field is null or empty."));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testFieldCannotBeEmpty() {
SimpleQueryStringBuilder qb = createTestQueryBuilder();
- qb.field("");
+ try {
+ qb.field("");
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("supplied field is null or empty."));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testFieldCannotBeEmptyAndWeighted() {
SimpleQueryStringBuilder qb = createTestQueryBuilder();
- qb.field("", AbstractQueryBuilder.DEFAULT_BOOST);
+ try {
+ qb.field("", AbstractQueryBuilder.DEFAULT_BOOST);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("supplied field is null or empty."));
+ }
}
/**
* The following should fail fast - never silently set the map containing
* fields and weights to null but refuse to accept null instead.
* */
- @Test(expected = NullPointerException.class)
public void testFieldsCannotBeSetToNull() {
SimpleQueryStringBuilder qb = createTestQueryBuilder();
- qb.fields(null);
+ try {
+ qb.fields(null);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException e) {
+ assertThat(e.getMessage(), is("fields cannot be null"));
+ }
}
- @Test
public void testDefaultFieldParsing() throws IOException {
QueryParseContext context = createParseContext();
String query = randomAsciiOfLengthBetween(1, 10).toLowerCase(Locale.ROOT);
@@ -312,7 +323,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
//instead of trying to reparse the query and guess what the boost should be, we delegate boost checks to specific boost tests below
}
-
private int shouldClauses(BooleanQuery query) {
int result = 0;
for (BooleanClause c : query.clauses()) {
@@ -323,7 +333,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
return result;
}
- @Test
public void testToQueryBoost() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
QueryShardContext shardContext = createShardContext();
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanContainingQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanContainingQueryBuilderTests.java
index ff5882a6fa..2e519750bd 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanContainingQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanContainingQueryBuilderTests.java
@@ -21,14 +21,12 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanContainingQuery;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanContainingQueryBuilderTests extends AbstractQueryTestCase<SpanContainingQueryBuilder> {
-
@Override
protected SpanContainingQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(2);
@@ -40,7 +38,6 @@ public class SpanContainingQueryBuilderTests extends AbstractQueryTestCase<SpanC
assertThat(query, instanceOf(SpanContainingQuery.class));
}
- @Test
public void testIllegalArguments() {
try {
new SpanContainingQueryBuilder(null, SpanTermQueryBuilder.PROTOTYPE);
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanFirstQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanFirstQueryBuilderTests.java
index 325db416be..204bb795df 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanFirstQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanFirstQueryBuilderTests.java
@@ -24,7 +24,6 @@ import org.apache.lucene.search.spans.SpanFirstQuery;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.junit.Test;
import java.io.IOException;
@@ -32,7 +31,6 @@ import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanFirstQueryBuilderTests extends AbstractQueryTestCase<SpanFirstQueryBuilder> {
-
@Override
protected SpanFirstQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(1);
@@ -47,9 +45,7 @@ public class SpanFirstQueryBuilderTests extends AbstractQueryTestCase<SpanFirstQ
/**
* test exception on missing `end` and `match` parameter in parser
*/
- @Test
public void testParseEnd() throws IOException {
-
{
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
@@ -66,7 +62,6 @@ public class SpanFirstQueryBuilderTests extends AbstractQueryTestCase<SpanFirstQ
assertTrue(e.getMessage().contains("spanFirst must have [end] set"));
}
}
-
{
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java
index 7c9e50abf5..ba6030f280 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper;
-import org.junit.Test;
import java.io.IOException;
@@ -30,7 +29,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase<SpanMultiTermQueryBuilder> {
-
@Override
protected SpanMultiTermQueryBuilder doCreateTestQueryBuilder() {
MultiTermQueryBuilder multiTermQueryBuilder = RandomQueryBuilder.createMultiTermQuery(random());
@@ -46,7 +44,6 @@ public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase<SpanMu
assertThat(spanMultiTermQueryWrapper.getWrappedQuery(), equalTo(new SpanMultiTermQueryWrapper<>((MultiTermQuery)multiTermQuery).getWrappedQuery()));
}
- @Test
public void testIllegalArgument() {
try {
new SpanMultiTermQueryBuilder(null);
@@ -62,7 +59,6 @@ public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase<SpanMu
* This is currently the case for {@link RangeQueryBuilder} when the target field is mapped
* to a date.
*/
- @Test
public void testUnsupportedInnerQueryType() throws IOException {
QueryShardContext context = createShardContext();
// test makes only sense if we have at least one type registered with date field mapping
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanNearQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanNearQueryBuilderTests.java
index 02dcddb663..6560bfcc0a 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanNearQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanNearQueryBuilderTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
-import org.junit.Test;
import java.io.IOException;
import java.util.Iterator;
@@ -31,7 +30,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQueryBuilder> {
-
@Override
protected SpanNearQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(randomIntBetween(1, 6));
@@ -57,7 +55,6 @@ public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQue
}
}
- @Test
public void testIllegalArguments() {
try {
new SpanNearQueryBuilder(null, 1);
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanNotQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanNotQueryBuilderTests.java
index 1b711f19dd..6c8418644b 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanNotQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanNotQueryBuilderTests.java
@@ -24,16 +24,16 @@ import org.apache.lucene.search.spans.SpanNotQuery;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.index.query.QueryBuilders.spanNearQuery;
import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQueryBuilder> {
-
@Override
protected SpanNotQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(2);
@@ -60,7 +60,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
assertThat(spanNotQuery.getInclude(), equalTo(queryBuilder.includeQuery().toQuery(context)));
}
- @Test
public void testIllegalArgument() {
try {
new SpanNotQueryBuilder(null, SpanTermQueryBuilder.PROTOTYPE);
@@ -76,7 +75,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
}
}
- @Test
public void testDist() {
SpanNotQueryBuilder builder = new SpanNotQueryBuilder(new SpanTermQueryBuilder("name1", "value1"), new SpanTermQueryBuilder("name2", "value2"));
assertThat(builder.pre(), equalTo(0));
@@ -89,7 +87,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
assertThat(builder.post(), equalTo(4));
}
- @Test
public void testPrePost() {
SpanNotQueryBuilder builder = new SpanNotQueryBuilder(new SpanTermQueryBuilder("name1", "value1"), new SpanTermQueryBuilder("name2", "value2"));
assertThat(builder.pre(), equalTo(0));
@@ -105,7 +102,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
/**
* test correct parsing of `dist` parameter, this should create builder with pre/post set to same value
*/
- @Test
public void testParseDist() throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
@@ -128,9 +124,7 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
/**
* test exceptions for three types of broken json, missing include / exclude and both dist and pre/post specified
*/
- @Test
public void testParserExceptions() throws IOException {
-
{
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
@@ -148,7 +142,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
assertThat("ParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [include]"));
}
}
-
{
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
@@ -167,7 +160,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
assertThat("ParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [exclude]"));
}
}
-
{
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanOrQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanOrQueryBuilderTests.java
index eaa70354ba..c40680aee6 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanOrQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanOrQueryBuilderTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
-import org.junit.Test;
import java.io.IOException;
import java.util.Iterator;
@@ -31,7 +30,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanOrQueryBuilderTests extends AbstractQueryTestCase<SpanOrQueryBuilder> {
-
@Override
protected SpanOrQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(randomIntBetween(1, 6));
@@ -53,7 +51,6 @@ public class SpanOrQueryBuilderTests extends AbstractQueryTestCase<SpanOrQueryBu
}
}
- @Test
public void testIllegalArguments() {
try {
new SpanOrQueryBuilder(null);
diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanWithinQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanWithinQueryBuilderTests.java
index 87b2380f62..0e4d7f9215 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SpanWithinQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SpanWithinQueryBuilderTests.java
@@ -21,14 +21,12 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanWithinQuery;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SpanWithinQueryBuilderTests extends AbstractQueryTestCase<SpanWithinQueryBuilder> {
-
@Override
protected SpanWithinQueryBuilder doCreateTestQueryBuilder() {
SpanTermQueryBuilder[] spanTermQueries = new SpanTermQueryBuilderTests().createSpanTermQueryBuilders(2);
@@ -40,7 +38,6 @@ public class SpanWithinQueryBuilderTests extends AbstractQueryTestCase<SpanWithi
assertThat(query, instanceOf(SpanWithinQuery.class));
}
- @Test
public void testIllegalArguments() {
try {
new SpanWithinQueryBuilder(null, SpanTermQueryBuilder.PROTOTYPE);
diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java
index 62a04c447e..3039cc1110 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.script.Template;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -59,7 +58,6 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
assertEquals(templateBase.toQuery(context), query);
}
- @Test
public void testIllegalArgument() {
try {
new TemplateQueryBuilder(null);
@@ -74,7 +72,6 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
//no-op boost is checked already above as part of doAssertLuceneQuery as we rely on lucene equals impl
}
- @Test
public void testJSONGeneration() throws IOException {
Map<String, Object> vars = new HashMap<>();
vars.put("template", "filled");
@@ -89,7 +86,6 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
content.string());
}
- @Test
public void testRawEscapedTemplate() throws IOException {
String expectedTemplateString = "{\"match_{{template}}\": {}}\"";
String query = "{\"template\": {\"query\": \"{\\\"match_{{template}}\\\": {}}\\\"\",\"params\" : {\"template\" : \"all\"}}}";
@@ -100,7 +96,6 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
assertParsedQuery(query, expectedBuilder);
}
- @Test
public void testRawTemplate() throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
@@ -115,5 +110,4 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
XContentType.JSON, params));
assertParsedQuery(query, expectedBuilder);
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryIT.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryIT.java
index 71dd323f1f..c4951640cc 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryIT.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryIT.java
@@ -38,7 +38,6 @@ import org.elasticsearch.script.mustache.MustacheScriptEngineService;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -51,6 +50,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -76,7 +76,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
.put("path.conf", this.getDataPath("config")).build();
}
- @Test
public void testTemplateInBody() throws IOException {
Map<String, Object> vars = new HashMap<>();
vars.put("template", "all");
@@ -88,7 +87,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertHitCount(sr, 2);
}
- @Test
public void testTemplateInBodyWithSize() throws IOException {
String request = "{\n" +
" \"size\":0," +
@@ -113,7 +111,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertThat(sr.getHits().hits().length, equalTo(0));
}
- @Test
public void testTemplateWOReplacementInBody() throws IOException {
Map<String, Object> vars = new HashMap<>();
@@ -124,7 +121,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertHitCount(sr, 2);
}
- @Test
public void testTemplateInFile() {
Map<String, Object> vars = new HashMap<>();
vars.put("template", "all");
@@ -136,7 +132,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertHitCount(sr, 2);
}
- @Test
public void testRawFSTemplate() throws IOException {
Map<String, Object> params = new HashMap<>();
params.put("template", "all");
@@ -145,7 +140,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertHitCount(sr, 2);
}
- @Test
public void testSearchRequestTemplateSource() throws Exception {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("_all");
@@ -163,7 +157,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
}
}
- @Test
// Releates to #6318
public void testSearchRequestFail() throws Exception {
SearchRequest searchRequest = new SearchRequest();
@@ -183,7 +176,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().hits().length, equalTo(1));
}
- @Test
public void testThatParametersCanBeSet() throws Exception {
index("test", "type", "1", jsonBuilder().startObject().field("theField", "foo").endObject());
index("test", "type", "2", jsonBuilder().startObject().field("theField", "foo 2").endObject());
@@ -211,7 +203,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1);
}
- @Test
public void testSearchTemplateQueryFromFile() throws Exception {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("_all");
@@ -225,7 +216,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
/**
* Test that template can be expressed as a single escaped string.
*/
- @Test
public void testTemplateQueryAsEscapedString() throws Exception {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("_all");
@@ -240,7 +230,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
* Test that template can contain conditional clause. In this case it is at
* the beginning of the string.
*/
- @Test
public void testTemplateQueryAsEscapedStringStartingWithConditionalClause() throws Exception {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("_all");
@@ -256,7 +245,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
* Test that template can contain conditional clause. In this case it is at
* the end of the string.
*/
- @Test
public void testTemplateQueryAsEscapedStringWithConditionalClauseAtEnd() throws Exception {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("_all");
@@ -268,7 +256,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().hits().length, equalTo(1));
}
- @Test(expected = SearchPhaseExecutionException.class)
public void testIndexedTemplateClient() throws Exception {
createIndex(ScriptService.SCRIPT_INDEX);
ensureGreen(ScriptService.SCRIPT_INDEX);
@@ -323,14 +310,18 @@ public class TemplateQueryIT extends ESIntegTestCase {
getResponse = client().prepareGetIndexedScript(MustacheScriptEngineService.NAME, "testTemplate").get();
assertFalse(getResponse.isExists());
- client().prepareSearch("test")
- .setTypes("type")
- .setTemplate(
- new Template("/template_index/mustache/1000", ScriptType.INDEXED, MustacheScriptEngineService.NAME, null,
- templateParams)).get();
+ try {
+ client().prepareSearch("test")
+ .setTypes("type")
+ .setTemplate(
+ new Template("/template_index/mustache/1000", ScriptType.INDEXED, MustacheScriptEngineService.NAME, null,
+ templateParams)).get();
+ fail("Expected SearchPhaseExecutionException");
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getCause().getMessage(), containsString("Illegal index script format"));
+ }
}
- @Test
public void testIndexedTemplate() throws Exception {
createIndex(ScriptService.SCRIPT_INDEX);
ensureGreen(ScriptService.SCRIPT_INDEX);
@@ -441,7 +432,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
}
// Relates to #10397
- @Test
public void testIndexedTemplateOverwrite() throws Exception {
createIndex("testindex");
ensureGreen("testindex");
@@ -487,8 +477,6 @@ public class TemplateQueryIT extends ESIntegTestCase {
}
}
-
- @Test
public void testIndexedTemplateWithArray() throws Exception {
createIndex(ScriptService.SCRIPT_INDEX);
ensureGreen(ScriptService.SCRIPT_INDEX);
diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java
index 985fbfde89..4e2c43a8e0 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java
@@ -53,11 +53,12 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Proxy;
+import static org.hamcrest.Matchers.containsString;
+
/**
* Test parsing and executing a template request.
*/
@@ -120,7 +121,6 @@ public class TemplateQueryParserTests extends ESTestCase {
terminate(injector.getInstance(ThreadPool.class));
}
- @Test
public void testParser() throws IOException {
String templateString = "{" + "\"query\":{\"match_{{template}}\": {}}," + "\"params\":{\"template\":\"all\"}" + "}";
@@ -133,7 +133,6 @@ public class TemplateQueryParserTests extends ESTestCase {
assertTrue("Parsing template query failed.", query instanceof MatchAllDocsQuery);
}
- @Test
public void testParseTemplateAsSingleStringWithConditionalClause() throws IOException {
String templateString = "{" + " \"inline\" : \"{ \\\"match_{{#use_it}}{{template}}{{/use_it}}\\\":{} }\"," + " \"params\":{"
+ " \"template\":\"all\"," + " \"use_it\": true" + " }" + "}";
@@ -150,7 +149,6 @@ public class TemplateQueryParserTests extends ESTestCase {
* expressed as a single string but still it expects only the query
* specification (thus this test should fail with specific exception).
*/
- @Test(expected = ParsingException.class)
public void testParseTemplateFailsToParseCompleteQueryAsSingleString() throws IOException {
String templateString = "{" + " \"inline\" : \"{ \\\"size\\\": \\\"{{size}}\\\", \\\"query\\\":{\\\"match_all\\\":{}}}\","
+ " \"params\":{" + " \"size\":2" + " }\n" + "}";
@@ -159,10 +157,14 @@ public class TemplateQueryParserTests extends ESTestCase {
context.reset(templateSourceParser);
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
- parser.fromXContent(context.parseContext()).toQuery(context);
+ try {
+ parser.fromXContent(context.parseContext()).toQuery(context);
+ fail("Expected ParsingException");
+ } catch (ParsingException e) {
+ assertThat(e.getMessage(), containsString("query malformed, no field after start_object"));
+ }
}
- @Test
public void testParserCanExtractTemplateNames() throws Exception {
String templateString = "{ \"file\": \"storedTemplate\" ,\"params\":{\"template\":\"all\" } } ";
diff --git a/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java
index f79e249ac9..42de6bf016 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java
@@ -25,15 +25,14 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.index.mapper.MappedFieldType;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.Matchers.is;
public class TermQueryBuilderTests extends AbstractTermQueryTestCase<TermQueryBuilder> {
-
/**
* @return a TermQuery with random field name and value, optional random boost and queryname
*/
@@ -56,13 +55,17 @@ public class TermQueryBuilderTests extends AbstractTermQueryTestCase<TermQueryBu
}
}
- @Test(expected = ParsingException.class)
public void testTermArray() throws IOException {
String queryAsString = "{\n" +
" \"term\": {\n" +
" \"age\": [34, 35]\n" +
" }\n" +
"}";
- parseQuery(queryAsString);
+ try {
+ parseQuery(queryAsString);
+ fail("Expected ParsingException");
+ } catch (ParsingException e) {
+ assertThat(e.getMessage(), is("[term] query does not support array of values"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java
index b810d6be2b..d326beacd2 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java
@@ -39,15 +39,17 @@ import org.elasticsearch.index.get.GetResult;
import org.elasticsearch.indices.cache.query.terms.TermsLookup;
import org.hamcrest.Matchers;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuilder> {
-
private List<Object> randomTerms;
private String termsPath;
@@ -128,21 +130,28 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
assertEquals(expectedTerms + " vs. " + booleanTerms, expectedTerms, booleanTerms);
}
- @Test(expected=IllegalArgumentException.class)
public void testEmtpyFieldName() {
- if (randomBoolean()) {
- new TermsQueryBuilder(null, "term");
- } else {
- new TermsQueryBuilder("", "term");
+ try {
+ if (randomBoolean()) {
+ new TermsQueryBuilder(null, "term");
+ } else {
+ new TermsQueryBuilder("", "term");
+ }
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("field name cannot be null."));
}
}
- @Test(expected=IllegalArgumentException.class)
public void testEmtpyTermsLookup() {
- new TermsQueryBuilder("field", (TermsLookup) null);
+ try {
+ new TermsQueryBuilder("field", (TermsLookup) null);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("No value or termsLookup specified for terms query"));
+ }
}
- @Test
public void testNullValues() {
try {
switch (randomInt(6)) {
@@ -174,7 +183,6 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
}
}
- @Test(expected=IllegalArgumentException.class)
public void testBothValuesAndLookupSet() throws IOException {
String query = "{\n" +
" \"terms\": {\n" +
@@ -190,7 +198,12 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
" }\n" +
" }\n" +
"}";
- QueryBuilder termsQueryBuilder = parseQuery(query);
+ try {
+ parseQuery(query);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Both values and termsLookup specified for terms query"));
+ }
}
public void testDeprecatedXContent() throws IOException {
@@ -289,7 +302,6 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
}
}
- @Test
public void testTermsQueryWithMultipleFields() throws IOException {
String query = XContentFactory.jsonBuilder().startObject()
.startObject("terms").array("foo", 123).array("bar", 456).endObject()
diff --git a/core/src/test/java/org/elasticsearch/index/query/TypeQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TypeQueryBuilderTests.java
index af5c63c1e2..1940a50503 100644
--- a/core/src/test/java/org/elasticsearch/index/query/TypeQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/TypeQueryBuilderTests.java
@@ -23,11 +23,12 @@ import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
public class TypeQueryBuilderTests extends AbstractQueryTestCase<TypeQueryBuilder> {
@@ -48,7 +49,6 @@ public class TypeQueryBuilderTests extends AbstractQueryTestCase<TypeQueryBuilde
assertThat(termQuery.getTerm().text(), equalTo(queryBuilder.type()));
}
- @Test
public void testIllegalArgument() {
try {
new TypeQueryBuilder((String) null);
diff --git a/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java
index 83f274ec9f..572bfec72a 100644
--- a/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.WildcardQuery;
-import org.junit.Test;
import java.io.IOException;
@@ -56,7 +55,6 @@ public class WildcardQueryBuilderTests extends AbstractQueryTestCase<WildcardQue
assertThat(wildcardQuery.getTerm().text(), equalTo(queryBuilder.value()));
}
- @Test
public void testIllegalArguments() {
try {
if (randomBoolean()) {
@@ -77,7 +75,6 @@ public class WildcardQueryBuilderTests extends AbstractQueryTestCase<WildcardQue
}
}
- @Test
public void testEmptyValue() throws IOException {
QueryShardContext context = createShardContext();
context.setAllowUnmappedFields(true);
diff --git a/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java
index ea04b79a6e..0cd3020857 100644
--- a/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.junit.Test;
import java.io.IOException;
@@ -69,7 +68,6 @@ public class WrapperQueryBuilderTests extends AbstractQueryTestCase<WrapperQuery
//no-op boost is checked already above as part of doAssertLuceneQuery as we rely on lucene equals impl
}
- @Test
public void testIllegalArgument() {
try {
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
index 58193ab40d..69aeb824d4 100644
--- a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
@@ -20,14 +20,26 @@
package org.elasticsearch.index.query.functionscore;
import com.fasterxml.jackson.core.JsonParseException;
+
import org.apache.lucene.index.Term;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.elasticsearch.common.ParsingException;
-import org.elasticsearch.common.lucene.search.function.*;
+import org.elasticsearch.common.lucene.search.function.CombineFunction;
+import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction;
+import org.elasticsearch.common.lucene.search.function.FiltersFunctionScoreQuery;
+import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
+import org.elasticsearch.common.lucene.search.function.WeightFactorFunction;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.index.query.*;
+import org.elasticsearch.index.query.AbstractQueryBuilder;
+import org.elasticsearch.index.query.AbstractQueryTestCase;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.index.query.QueryShardContext;
+import org.elasticsearch.index.query.RandomQueryBuilder;
+import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionBuilder;
import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionBuilder;
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionBuilder;
@@ -39,7 +51,6 @@ import org.elasticsearch.script.MockScriptEngine;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@@ -49,7 +60,12 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.nullValue;
public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<FunctionScoreQueryBuilder> {
@@ -180,7 +196,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
super.testToQuery();
}
- @Test
public void testIllegalArguments() {
try {
new FunctionScoreQueryBuilder((QueryBuilder<?>)null);
@@ -274,7 +289,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testParseFunctionsArray() throws IOException {
String functionScoreQuery = "{\n" +
" \"function_score\":{\n" +
@@ -359,7 +373,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testParseSingleFunction() throws IOException {
String functionScoreQuery = "{\n" +
" \"function_score\":{\n" +
@@ -407,7 +420,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testProperErrorMessageWhenTwoFunctionsDefinedInQueryBody() throws IOException {
//without a functions array, we support only a single function, weight can't be associated with the function either.
String functionScoreQuery = "{\n" +
@@ -426,7 +438,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testProperErrorMessageWhenTwoFunctionsDefinedInFunctionsArray() throws IOException {
String functionScoreQuery = "{\n" +
" \"function_score\":{\n" +
@@ -457,7 +468,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testProperErrorMessageWhenMissingFunction() throws IOException {
String functionScoreQuery = "{\n" +
" \"function_score\":{\n" +
@@ -480,7 +490,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test
public void testWeight1fStillProducesWeightFunction() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
String queryString = jsonBuilder().startObject()
@@ -515,7 +524,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
assertThat(weightFactorFunction.getScoreFunction(), instanceOf(FieldValueFactorFunction.class));
}
- @Test
public void testProperErrorMessagesForMisplacedWeightsAndFunctions() throws IOException {
String query = jsonBuilder().startObject().startObject("function_score")
.startArray("functions")
@@ -543,13 +551,16 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
}
}
- @Test(expected = JsonParseException.class)
- public void ensureMalformedThrowsException() throws IOException {
- parseQuery(copyToStringFromClasspath("/org/elasticsearch/index/query/faulty-function-score-query.json"));
+ public void testMalformedThrowsException() throws IOException {
+ try {
+ parseQuery(copyToStringFromClasspath("/org/elasticsearch/index/query/faulty-function-score-query.json"));
+ fail("Expected JsonParseException");
+ } catch (JsonParseException e) {
+ assertThat(e.getMessage(), containsString("Unexpected character ('{"));
+ }
}
- @Test
- public void testCustomWeightFactorQueryBuilder_withFunctionScore() throws IOException {
+ public void testCustomWeightFactorQueryBuilderWithFunctionScore() throws IOException {
Query parsedQuery = parseQuery(functionScoreQuery(termQuery("name.last", "banon"), ScoreFunctionBuilders.weightFactorFunction(1.3f)).buildAsBytes()).toQuery(createShardContext());
assertThat(parsedQuery, instanceOf(FunctionScoreQuery.class));
FunctionScoreQuery functionScoreQuery = (FunctionScoreQuery) parsedQuery;
@@ -557,8 +568,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
assertThat((double) ((WeightFactorFunction) functionScoreQuery.getFunction()).getWeight(), closeTo(1.3, 0.001));
}
- @Test
- public void testCustomWeightFactorQueryBuilder_withFunctionScoreWithoutQueryGiven() throws IOException {
+ public void testCustomWeightFactorQueryBuilderWithFunctionScoreWithoutQueryGiven() throws IOException {
Query parsedQuery = parseQuery(functionScoreQuery(ScoreFunctionBuilders.weightFactorFunction(1.3f)).buildAsBytes()).toQuery(createShardContext());
assertThat(parsedQuery, instanceOf(FunctionScoreQuery.class));
FunctionScoreQuery functionScoreQuery = (FunctionScoreQuery) parsedQuery;
@@ -566,7 +576,6 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
assertThat((double) ((WeightFactorFunction) functionScoreQuery.getFunction()).getWeight(), closeTo(1.3, 0.001));
}
- @Test
public void testFieldValueFactorFactorArray() throws IOException {
// don't permit an array of factors
String querySource = "{" +
diff --git a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java
index 11d6ebcce7..21667e9ffb 100644
--- a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java
@@ -23,15 +23,39 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.SortedNumericDocValues;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.Weight;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.lucene.search.function.*;
+import org.elasticsearch.common.lucene.search.function.CombineFunction;
+import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction;
+import org.elasticsearch.common.lucene.search.function.FiltersFunctionScoreQuery;
+import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
+import org.elasticsearch.common.lucene.search.function.LeafScoreFunction;
+import org.elasticsearch.common.lucene.search.function.RandomScoreFunction;
+import org.elasticsearch.common.lucene.search.function.ScoreFunction;
+import org.elasticsearch.common.lucene.search.function.WeightFactorFunction;
import org.elasticsearch.index.Index;
-import org.elasticsearch.index.fielddata.*;
+import org.elasticsearch.index.fielddata.AtomicFieldData;
+import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
+import org.elasticsearch.index.fielddata.FieldDataType;
+import org.elasticsearch.index.fielddata.IndexFieldData;
+import org.elasticsearch.index.fielddata.IndexNumericFieldData;
+import org.elasticsearch.index.fielddata.ScriptDocValues;
+import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
+import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionBuilder;
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionBuilder;
@@ -40,7 +64,6 @@ import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -261,7 +284,6 @@ public class FunctionScoreTests extends ESTestCase {
dir.close();
}
- @Test
public void testExplainFunctionScoreQuery() throws IOException {
Explanation functionExplanation = getFunctionScoreExplanation(searcher, RANDOM_SCORE_FUNCTION);
@@ -307,7 +329,6 @@ public class FunctionScoreTests extends ESTestCase {
assertThat(randomExplanation.getDetails()[0].getDescription(), equalTo(functionExpl));
}
- @Test
public void testExplainFiltersFunctionScoreQuery() throws IOException {
Explanation functionExplanation = getFiltersFunctionScoreExplanation(searcher, RANDOM_SCORE_FUNCTION);
checkFiltersFunctionScoreExplanation(functionExplanation, "random score function (seed: 0)", 0);
@@ -437,8 +458,7 @@ public class FunctionScoreTests extends ESTestCase {
}
}
- @Test
- public void simpleWeightedFunctionsTest() throws IOException, ExecutionException, InterruptedException {
+ public void testSimpleWeightedFunction() throws IOException, ExecutionException, InterruptedException {
int numFunctions = randomIntBetween(1, 3);
float[] weights = randomFloats(numFunctions);
double[] scores = randomDoubles(numFunctions);
@@ -534,8 +554,7 @@ public class FunctionScoreTests extends ESTestCase {
assertThat(explainedScore / scoreWithWeight, is(1f));
}
- @Test
- public void checkWeightOnlyCreatesBoostFunction() throws IOException {
+ public void testWeightOnlyCreatesBoostFunction() throws IOException {
FunctionScoreQuery filtersFunctionScoreQueryWithWeights = new FunctionScoreQuery(new MatchAllDocsQuery(), new WeightFactorFunction(2), 0.0f, CombineFunction.MULTIPLY, 100);
TopDocs topDocsWithWeights = searcher.search(filtersFunctionScoreQueryWithWeights, 1);
float score = topDocsWithWeights.scoreDocs[0].score;
diff --git a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java
index c015052ffb..fc0328c1b1 100644
--- a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java
+++ b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.util.Collection;
@@ -39,12 +38,12 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitC
import static org.hamcrest.Matchers.instanceOf;
public class CustomQueryParserIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(DummyQueryParserPlugin.class);
}
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -59,12 +58,10 @@ public class CustomQueryParserIT extends ESIntegTestCase {
return cluster().numDataNodes();
}
- @Test
public void testCustomDummyQuery() {
assertHitCount(client().prepareSearch("index").setQuery(new DummyQueryParserPlugin.DummyQueryBuilder()).get(), 1l);
}
- @Test
public void testCustomDummyQueryWithinBooleanQuery() {
assertHitCount(client().prepareSearch("index").setQuery(new BoolQueryBuilder().must(new DummyQueryParserPlugin.DummyQueryBuilder())).get(), 1l);
}
@@ -74,7 +71,7 @@ public class CustomQueryParserIT extends ESIntegTestCase {
return indicesService.indexServiceSafe("index").queryParserService();
}
- @Test //see #11120
+ //see #11120
public void testConstantScoreParsesFilter() throws Exception {
IndexQueryParserService queryParser = queryParser();
Query q = constantScoreQuery(new DummyQueryParserPlugin.DummyQueryBuilder()).toQuery(queryParser.getShardContext());
@@ -83,7 +80,7 @@ public class CustomQueryParserIT extends ESIntegTestCase {
assertEquals(true, ((DummyQueryParserPlugin.DummyQuery) inner).isFilter);
}
- @Test //see #11120
+ //see #11120
public void testBooleanParsesFilter() throws Exception {
IndexQueryParserService queryParser = queryParser();
// single clause, serialized as inner object
diff --git a/core/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java b/core/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java
index 27046a9bfe..d82cddcae6 100644
--- a/core/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/geo/GeoPointParsingTests.java
@@ -28,17 +28,15 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.geo.RandomGeoGenerator;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.is;
public class GeoPointParsingTests extends ESTestCase {
static double TOLERANCE = 1E-5;
- @Test
public void testGeoPointReset() throws IOException {
double lat = 1 + randomDouble() * 89;
double lon = 1 + randomDouble() * 179;
@@ -59,7 +57,6 @@ public class GeoPointParsingTests extends ESTestCase {
assertPointsEqual(point.reset(0, 0), point2.reset(0, 0));
}
- @Test
public void testEqualsHashCodeContract() {
// generate a random geopoint
final GeoPoint x = RandomGeoGenerator.randomPoint(random());
@@ -89,7 +86,6 @@ public class GeoPointParsingTests extends ESTestCase {
assertFalse(x.hashCode() == a.hashCode());
}
- @Test
public void testGeoPointParsing() throws IOException {
GeoPoint randomPt = RandomGeoGenerator.randomPoint(random());
@@ -106,8 +102,7 @@ public class GeoPointParsingTests extends ESTestCase {
assertCloseTo(point, randomPt.lat(), randomPt.lon());
}
- // Based on issue5390
- @Test(expected = ElasticsearchParseException.class)
+ // Based on #5390
public void testInvalidPointEmbeddedObject() throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.startObject();
@@ -119,10 +114,14 @@ public class GeoPointParsingTests extends ESTestCase {
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
parser.nextToken();
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testInvalidPointLatHashMix() throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.startObject();
@@ -132,10 +131,14 @@ public class GeoPointParsingTests extends ESTestCase {
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
parser.nextToken();
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field must be either lat/lon or geohash"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testInvalidPointLonHashMix() throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.startObject();
@@ -145,10 +148,14 @@ public class GeoPointParsingTests extends ESTestCase {
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
parser.nextToken();
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field must be either lat/lon or geohash"));
+ }
}
- @Test(expected = ElasticsearchParseException.class)
public void testInvalidField() throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.startObject();
@@ -158,7 +165,12 @@ public class GeoPointParsingTests extends ESTestCase {
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
parser.nextToken();
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]"));
+ }
}
private static XContentParser objectLatLon(double lat, double lon) throws IOException {
@@ -204,5 +216,4 @@ public class GeoPointParsingTests extends ESTestCase {
assertEquals(point.lat(), lat, TOLERANCE);
assertEquals(point.lon(), lon, TOLERANCE);
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java b/core/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java
index bf5b7f9260..81c8371319 100644
--- a/core/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/geo/GeoUtilsTests.java
@@ -21,6 +21,7 @@ package org.elasticsearch.index.search.geo;
import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.distance.DistanceUtils;
+
import org.apache.lucene.spatial.prefix.tree.Cell;
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
@@ -33,21 +34,25 @@ import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentParser.Token;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.not;
public class GeoUtilsTests extends ESTestCase {
-
private static final char[] BASE_32 = {'0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
private static final double MAX_ACCEPTABLE_ERROR = 0.000000001;
- @Test
public void testGeohashCellWidth() {
double equatorialDistance = 2 * Math.PI * 6378137.0;
assertThat(GeoUtils.geoHashCellWidth(0), equalTo(equatorialDistance));
@@ -65,7 +70,6 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.geoHashCellWidth(12), equalTo(equatorialDistance / 1073741824));
}
- @Test
public void testGeohashCellHeight() {
double polarDistance = Math.PI * 6356752.314245;
assertThat(GeoUtils.geoHashCellHeight(0), equalTo(polarDistance));
@@ -83,7 +87,6 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.geoHashCellHeight(12), equalTo(polarDistance / 1073741824));
}
- @Test
public void testGeohashCellSize() {
double equatorialDistance = 2 * Math.PI * 6378137.0;
double polarDistance = Math.PI * 6356752.314245;
@@ -112,7 +115,6 @@ public class GeoUtilsTests extends ESTestCase {
equalTo(Math.sqrt(Math.pow(polarDistance / 1073741824, 2) + Math.pow(equatorialDistance / 1073741824, 2))));
}
- @Test
public void testGeoHashLevelsForPrecision() {
for (int i = 0; i < 100; i++) {
double precision = randomDouble() * 100;
@@ -121,7 +123,6 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
public void testGeoHashLevelsForPrecision_String() {
for (int i = 0; i < 100; i++) {
double precision = randomDouble() * 100;
@@ -131,7 +132,6 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
public void testQuadTreeCellWidth() {
double equatorialDistance = 2 * Math.PI * 6378137.0;
assertThat(GeoUtils.quadTreeCellWidth(0), equalTo(equatorialDistance));
@@ -149,7 +149,6 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.quadTreeCellWidth(12), equalTo(equatorialDistance / 4096));
}
- @Test
public void testQuadTreeCellHeight() {
double polarDistance = Math.PI * 6356752.314245;
assertThat(GeoUtils.quadTreeCellHeight(0), equalTo(polarDistance));
@@ -167,7 +166,6 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.quadTreeCellHeight(12), equalTo(polarDistance / 4096));
}
- @Test
public void testQuadTreeCellSize() {
double equatorialDistance = 2 * Math.PI * 6378137.0;
double polarDistance = Math.PI * 6356752.314245;
@@ -192,7 +190,6 @@ public class GeoUtilsTests extends ESTestCase {
equalTo(Math.sqrt(Math.pow(polarDistance / 4096, 2) + Math.pow(equatorialDistance / 4096, 2))));
}
- @Test
public void testQuadTreeLevelsForPrecision() {
for (int i = 0; i < 100; i++) {
double precision = randomDouble() * 100;
@@ -201,8 +198,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testQuadTreeLevelsForPrecision_String() {
+ public void testQuadTreeLevelsForPrecisionString() {
for (int i = 0; i < 100; i++) {
double precision = randomDouble() * 100;
String precisionString = precision + "m";
@@ -211,16 +207,14 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizeLat_inNormalRange() {
+ public void testNormalizeLatInNormalRange() {
for (int i = 0; i < 100; i++) {
double testValue = (randomDouble() * 180.0) - 90.0;
assertThat(GeoUtils.normalizeLat(testValue), closeTo(testValue, MAX_ACCEPTABLE_ERROR));
}
}
- @Test
- public void testNormalizeLat_outsideNormalRange() {
+ public void testNormalizeLatOutsideNormalRange() {
for (int i = 0; i < 100; i++) {
double normalisedValue = (randomDouble() * 180.0) - 90.0;
int shift = (randomBoolean() ? 1 : -1) * randomIntBetween(1, 10000);
@@ -230,8 +224,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizeLat_Huge() {
+ public void testNormalizeLatHuge() {
assertThat(GeoUtils.normalizeLat(-18000000000091.0), equalTo(GeoUtils.normalizeLat(-091.0)));
assertThat(GeoUtils.normalizeLat(-18000000000090.0), equalTo(GeoUtils.normalizeLat(-090.0)));
assertThat(GeoUtils.normalizeLat(-18000000000089.0), equalTo(GeoUtils.normalizeLat(-089.0)));
@@ -246,8 +239,7 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.normalizeLat(+18000000000091.0), equalTo(GeoUtils.normalizeLat(+091.0)));
}
- @Test
- public void testNormalizeLat_edgeCases() {
+ public void testNormalizeLatEdgeCases() {
assertThat(GeoUtils.normalizeLat(Double.POSITIVE_INFINITY), equalTo(Double.NaN));
assertThat(GeoUtils.normalizeLat(Double.NEGATIVE_INFINITY), equalTo(Double.NaN));
assertThat(GeoUtils.normalizeLat(Double.NaN), equalTo(Double.NaN));
@@ -260,16 +252,14 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.normalizeLat(90.0), equalTo(90.0));
}
- @Test
- public void testNormalizeLon_inNormalRange() {
+ public void testNormalizeLonInNormalRange() {
for (int i = 0; i < 100; i++) {
double testValue = (randomDouble() * 360.0) - 180.0;
assertThat(GeoUtils.normalizeLon(testValue), closeTo(testValue, MAX_ACCEPTABLE_ERROR));
}
}
- @Test
- public void testNormalizeLon_outsideNormalRange() {
+ public void testNormalizeLonOutsideNormalRange() {
for (int i = 0; i < 100; i++) {
double normalisedValue = (randomDouble() * 360.0) - 180.0;
double testValue = normalisedValue + ((randomBoolean() ? 1 : -1) * 360.0 * randomIntBetween(1, 10000));
@@ -277,8 +267,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizeLon_Huge() {
+ public void testNormalizeLonHuge() {
assertThat(GeoUtils.normalizeLon(-36000000000181.0), equalTo(GeoUtils.normalizeLon(-181.0)));
assertThat(GeoUtils.normalizeLon(-36000000000180.0), equalTo(GeoUtils.normalizeLon(-180.0)));
assertThat(GeoUtils.normalizeLon(-36000000000179.0), equalTo(GeoUtils.normalizeLon(-179.0)));
@@ -293,8 +282,7 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.normalizeLon(+36000000000181.0), equalTo(GeoUtils.normalizeLon(+181.0)));
}
- @Test
- public void testNormalizeLon_edgeCases() {
+ public void testNormalizeLonEdgeCases() {
assertThat(GeoUtils.normalizeLon(Double.POSITIVE_INFINITY), equalTo(Double.NaN));
assertThat(GeoUtils.normalizeLon(Double.NEGATIVE_INFINITY), equalTo(Double.NaN));
assertThat(GeoUtils.normalizeLon(Double.NaN), equalTo(Double.NaN));
@@ -307,8 +295,7 @@ public class GeoUtilsTests extends ESTestCase {
assertThat(GeoUtils.normalizeLon(180.0), equalTo(180.0));
}
- @Test
- public void testNormalizePoint_inNormalRange() {
+ public void testNormalizePointInNormalRange() {
for (int i = 0; i < 100; i++) {
double testLat = (randomDouble() * 180.0) - 90.0;
double testLon = (randomDouble() * 360.0) - 180.0;
@@ -317,8 +304,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizePoint_outsideNormalRange() {
+ public void testNormalizePointOutsideNormalRange() {
for (int i = 0; i < 100; i++) {
double normalisedLat = (randomDouble() * 180.0) - 90.0;
double normalisedLon = (randomDouble() * 360.0) - 180.0;
@@ -337,8 +323,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizePoint_outsideNormalRange_withOptions() {
+ public void testNormalizePointOutsideNormalRange_withOptions() {
for (int i = 0; i < 100; i++) {
boolean normalize = randomBoolean();
double normalisedLat = (randomDouble() * 180.0) - 90.0;
@@ -367,8 +352,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testNormalizePoint_Huge() {
+ public void testNormalizePointHuge() {
assertNormalizedPoint(new GeoPoint(-18000000000091.0, -36000000000181.0), new GeoPoint(-089.0, -001.0));
assertNormalizedPoint(new GeoPoint(-18000000000090.0, -36000000000180.0), new GeoPoint(-090.0, +180.0));
assertNormalizedPoint(new GeoPoint(-18000000000089.0, -36000000000179.0), new GeoPoint(-089.0, -179.0));
@@ -384,8 +368,7 @@ public class GeoUtilsTests extends ESTestCase {
}
- @Test
- public void testNormalizePoint_edgeCases() {
+ public void testNormalizePointEdgeCases() {
assertNormalizedPoint(new GeoPoint(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY), new GeoPoint(Double.NaN, Double.NaN));
assertNormalizedPoint(new GeoPoint(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY), new GeoPoint(Double.NaN, Double.NaN));
assertNormalizedPoint(new GeoPoint(Double.NaN, Double.NaN), new GeoPoint(Double.NaN, Double.NaN));
@@ -398,7 +381,6 @@ public class GeoUtilsTests extends ESTestCase {
assertNormalizedPoint(new GeoPoint(90.0, 180.0), new GeoPoint(90.0, 180.0));
}
- @Test
public void testParseGeoPoint() throws IOException {
for (int i = 0; i < 100; i++) {
double lat = randomDouble() * 180 - 90 + randomIntBetween(-1000, 1000) * 180;
@@ -430,8 +412,7 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test
- public void testParseGeoPoint_geohash() throws IOException {
+ public void testParseGeoPointGeohash() throws IOException {
for (int i = 0; i < 100; i++) {
int geoHashLength = randomIntBetween(1, XGeoHashUtils.PRECISION);
StringBuilder geohashBuilder = new StringBuilder(geoHashLength);
@@ -455,62 +436,85 @@ public class GeoUtilsTests extends ESTestCase {
}
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_geohashWrongType() throws IOException {
- BytesReference jsonBytes = jsonBuilder().startObject().field("geohash", 1.0).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ public void testParseGeoPointGeohashWrongType() throws IOException {
+ BytesReference jsonBytes = jsonBuilder().startObject().field("geohash", 1.0).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("geohash must be a string"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_LatNoLon() throws IOException {
- double lat = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ public void testParseGeoPointLatNoLon() throws IOException {
+ double lat = 0.0;
+ BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field [lon] missing"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_LonNoLat() throws IOException {
- double lon = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().field("lon", lon).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ public void testParseGeoPointLonNoLat() throws IOException {
+ double lon = 0.0;
+ BytesReference jsonBytes = jsonBuilder().startObject().field("lon", lon).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field [lat] missing"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_LonWrongType() throws IOException {
- double lat = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).field("lon", false).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ public void testParseGeoPointLonWrongType() throws IOException {
+ double lat = 0.0;
+ BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).field("lon", false).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("longitude must be a number"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_LatWrongType() throws IOException {
- double lon = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().field("lat", false).field("lon", lon).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ public void testParseGeoPointLatWrongType() throws IOException {
+ double lon = 0.0;
+ BytesReference jsonBytes = jsonBuilder().startObject().field("lat", false).field("lon", lon).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("latitude must be a number"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_ExtraField() throws IOException {
+ public void testParseGeoPointExtraField() throws IOException {
double lat = 0.0;
double lon = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).field("lon", lon).field("foo", true).endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- parser.nextToken();
+ BytesReference jsonBytes = jsonBuilder().startObject().field("lat", lat).field("lon", lon).field("foo", true).endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ parser.nextToken();
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("field must be either [lat], [lon] or [geohash]"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_LonLatGeoHash() throws IOException {
+ public void testParseGeoPointLonLatGeoHash() throws IOException {
double lat = 0.0;
double lon = 0.0;
String geohash = "abcd";
@@ -518,45 +522,62 @@ public class GeoUtilsTests extends ESTestCase {
.bytes();
XContentParser parser = XContentHelper.createParser(jsonBytes);
parser.nextToken();
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), containsString("field must be either lat/lon or geohash"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_ArrayTooManyValues() throws IOException {
- double lat = 0.0;
- double lon = 0.0;
- double elev = 0.0;
- BytesReference jsonBytes = jsonBuilder().startObject().startArray("foo").value(lon).value(lat).value(elev).endArray().endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- while (parser.currentToken() != Token.START_ARRAY) {
- parser.nextToken();
- }
+ public void testParseGeoPointArrayTooManyValues() throws IOException {
+ double lat = 0.0;
+ double lon = 0.0;
+ double elev = 0.0;
+ BytesReference jsonBytes = jsonBuilder().startObject().startArray("foo").value(lon).value(lat).value(elev).endArray().endObject()
+ .bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ while (parser.currentToken() != Token.START_ARRAY) {
+ parser.nextToken();
+ }
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("only two values allowed"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_ArrayWrongType() throws IOException {
- double lat = 0.0;
- boolean lon = false;
- BytesReference jsonBytes = jsonBuilder().startObject().startArray("foo").value(lon).value(lat).endArray().endObject().bytes();
- XContentParser parser = XContentHelper.createParser(jsonBytes);
- while (parser.currentToken() != Token.START_ARRAY) {
- parser.nextToken();
- }
+ public void testParseGeoPointArrayWrongType() throws IOException {
+ double lat = 0.0;
+ boolean lon = false;
+ BytesReference jsonBytes = jsonBuilder().startObject().startArray("foo").value(lon).value(lat).endArray().endObject().bytes();
+ XContentParser parser = XContentHelper.createParser(jsonBytes);
+ while (parser.currentToken() != Token.START_ARRAY) {
+ parser.nextToken();
+ }
+ try {
GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("numeric value expected"));
+ }
}
- @Test(expected=ElasticsearchParseException.class)
- public void testParseGeoPoint_InvalidType() throws IOException {
+ public void testParseGeoPointInvalidType() throws IOException {
BytesReference jsonBytes = jsonBuilder().startObject().field("foo", 5).endObject().bytes();
XContentParser parser = XContentHelper.createParser(jsonBytes);
while (parser.currentToken() != Token.VALUE_NUMBER) {
parser.nextToken();
}
- GeoUtils.parseGeoPoint(parser);
+ try {
+ GeoUtils.parseGeoPoint(parser);
+ fail("Expected ElasticsearchParseException");
+ } catch (ElasticsearchParseException e) {
+ assertThat(e.getMessage(), is("geo_point expected"));
+ }
}
- @Test
public void testPrefixTreeCellSizes() {
assertThat(GeoUtils.EARTH_SEMI_MAJOR_AXIS, equalTo(DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM * 1000));
assertThat(GeoUtils.quadTreeCellWidth(0), lessThanOrEqualTo(GeoUtils.EARTH_EQUATOR));
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java b/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
index 426edf84c6..297875b6ad 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
@@ -42,7 +42,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -53,8 +52,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldDataTestCase {
-
- @Test
public void testNestedSorting() throws Exception {
List<Document> docs = new ArrayList<>();
Document document = new Document();
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java b/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
index da4eddffa0..49af5f0b82 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
@@ -50,7 +50,6 @@ import org.elasticsearch.index.fielddata.NoOrdinalsStringFieldDataTests;
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData;
import org.elasticsearch.search.MultiValueMode;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -62,13 +61,11 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class NestedSortingTests extends AbstractFieldDataTestCase {
-
@Override
protected FieldDataType getFieldDataType() {
return new FieldDataType("string", Settings.builder().put("format", "paged_bytes"));
}
- @Test
public void testDuel() throws Exception {
final int numDocs = scaledRandomIntBetween(100, 1000);
for (int i = 0; i < numDocs; ++i) {
@@ -122,7 +119,6 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
return searcher.search(query, n, sort);
}
- @Test
public void testNestedSorting() throws Exception {
List<Document> docs = new ArrayList<>();
Document document = new Document();
diff --git a/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java b/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
index 3ac624c25e..8821f0b9e7 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
@@ -19,12 +19,11 @@
package org.elasticsearch.index.shard;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import static org.hamcrest.Matchers.equalTo;
@@ -34,10 +33,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class CommitPointsTests extends ESTestCase {
-
private final ESLogger logger = Loggers.getLogger(CommitPointsTests.class);
- @Test
public void testCommitPointXContent() throws Exception {
ArrayList<CommitPoint.FileInfo> indexFiles = new ArrayList<>();
indexFiles.add(new CommitPoint.FileInfo("file1", "file1_p", 100, "ck1"));
diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
index baf4ee6077..c73420aaa4 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
@@ -20,8 +20,16 @@ package org.elasticsearch.index.shard;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.index.*;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.FieldFilterLeafReader;
+import org.apache.lucene.index.FilterDirectoryReader;
+import org.apache.lucene.index.IndexCommit;
+import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.Constants;
@@ -41,8 +49,12 @@ import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.SnapshotId;
import org.elasticsearch.cluster.node.DiscoveryNode;
-import org.elasticsearch.cluster.routing.*;
-import org.elasticsearch.common.ParsingException;
+import org.elasticsearch.cluster.routing.RestoreSource;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingHelper;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
+import org.elasticsearch.cluster.routing.TestShardRouting;
+import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
@@ -68,7 +80,11 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.flush.FlushStats;
import org.elasticsearch.index.indexing.IndexingOperationListener;
import org.elasticsearch.index.indexing.ShardIndexingService;
-import org.elasticsearch.index.mapper.*;
+import org.elasticsearch.index.mapper.MappedFieldType;
+import org.elasticsearch.index.mapper.Mapping;
+import org.elasticsearch.index.mapper.ParseContext;
+import org.elasticsearch.index.mapper.ParsedDocument;
+import org.elasticsearch.index.mapper.Uid;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.index.settings.IndexSettingsService;
import org.elasticsearch.index.snapshots.IndexShardRepository;
@@ -81,7 +97,6 @@ import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.test.DummyShardLock;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -95,19 +110,23 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
import static org.hamcrest.Matchers.equalTo;
/**
* Simple unit-test IndexShard related operations.
*/
public class IndexShardTests extends ESSingleNodeTestCase {
-
public void testFlushOnDeleteSetting() throws Exception {
boolean initValue = randomBoolean();
createIndex("test", settingsBuilder().put(IndexShard.INDEX_FLUSH_ON_CLOSE, initValue).build());
@@ -153,7 +172,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testLockTryingToDelete() throws Exception {
createIndex("test");
ensureGreen();
@@ -300,7 +318,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
- @Test
public void testDeleteIndexDecreasesCounter() throws InterruptedException, ExecutionException, IOException {
assertAcked(client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get());
ensureGreen("test");
@@ -317,7 +334,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testIndexShardCounter() throws InterruptedException, ExecutionException, IOException {
assertAcked(client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get());
ensureGreen("test");
@@ -334,7 +350,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
assertEquals(0, indexShard.getOperationsCount());
}
- @Test
public void testMarkAsInactiveTriggersSyncedFlush() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test")
.setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0));
@@ -720,6 +735,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
CyclicBarrier barrier = new CyclicBarrier(numThreads + 1);
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread() {
+ @Override
public void run() {
try {
barrier.await();
@@ -1036,7 +1052,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
private static class FieldMaskingReader extends FilterDirectoryReader {
-
private final String field;
public FieldMaskingReader(String field, DirectoryReader in) throws IOException {
super(in, new SubReaderWrapper() {
diff --git a/core/src/test/java/org/elasticsearch/index/shard/MergePolicySettingsTests.java b/core/src/test/java/org/elasticsearch/index/shard/MergePolicySettingsTests.java
index 0f6b2bd8d9..76051d70d0 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/MergePolicySettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/MergePolicySettingsTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.settings.IndexSettingsService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -34,12 +33,9 @@ import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.hamcrest.Matchers.equalTo;
public class MergePolicySettingsTests extends ESTestCase {
-
protected final ShardId shardId = new ShardId(new Index("index"), 1);
- @Test
public void testCompoundFileSettings() throws IOException {
-
assertThat(new MergePolicyConfig(logger, EMPTY_SETTINGS).getMergePolicy().getNoCFSRatio(), equalTo(0.1));
assertThat(new MergePolicyConfig(logger, build(true)).getMergePolicy().getNoCFSRatio(), equalTo(1.0));
assertThat(new MergePolicyConfig(logger, build(0.5)).getMergePolicy().getNoCFSRatio(), equalTo(0.5));
@@ -58,7 +54,6 @@ public class MergePolicySettingsTests extends ESTestCase {
assertTrue(mp.getMergePolicy() instanceof NoMergePolicy);
}
- @Test
public void testUpdateSettings() throws IOException {
{
IndexSettingsService service = new IndexSettingsService(new Index("test"), EMPTY_SETTINGS);
diff --git a/core/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java b/core/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java
index 32d2019089..0d653c0810 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java
@@ -18,23 +18,21 @@
*/
package org.elasticsearch.index.shard;
-import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
-import java.util.Set;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
/**
*/
public class ShardPathTests extends ESTestCase {
-
public void testLoadShardPath() throws IOException {
try (final NodeEnvironment env = newNodeEnvironment(settingsBuilder().build())) {
Settings.Builder builder = settingsBuilder().put(IndexMetaData.SETTING_INDEX_UUID, "0xDEADBEEF");
@@ -52,7 +50,6 @@ public class ShardPathTests extends ESTestCase {
}
}
- @Test(expected = IllegalStateException.class)
public void testFailLoadShardPathOnMultiState() throws IOException {
try (final NodeEnvironment env = newNodeEnvironment(settingsBuilder().build())) {
Settings.Builder builder = settingsBuilder().put(IndexMetaData.SETTING_INDEX_UUID, "0xDEADBEEF");
@@ -63,10 +60,12 @@ public class ShardPathTests extends ESTestCase {
int id = randomIntBetween(1, 10);
ShardStateMetaData.FORMAT.write(new ShardStateMetaData(id, true, "0xDEADBEEF"), id, paths);
ShardPath.loadShardPath(logger, env, shardId, settings);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("more than one shard state found"));
}
}
- @Test(expected = IllegalStateException.class)
public void testFailLoadShardPathIndexUUIDMissmatch() throws IOException {
try (final NodeEnvironment env = newNodeEnvironment(settingsBuilder().build())) {
Settings.Builder builder = settingsBuilder().put(IndexMetaData.SETTING_INDEX_UUID, "foobar");
@@ -77,13 +76,20 @@ public class ShardPathTests extends ESTestCase {
int id = randomIntBetween(1, 10);
ShardStateMetaData.FORMAT.write(new ShardStateMetaData(id, true, "0xDEADBEEF"), id, path);
ShardPath.loadShardPath(logger, env, shardId, settings);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("expected: foobar on shard path"));
}
}
- @Test(expected = IllegalArgumentException.class)
public void testIllegalCustomDataPath() {
final Path path = createTempDir().resolve("foo").resolve("0");
- new ShardPath(true, path, path, "foo", new ShardId("foo", 0));
+ try {
+ new ShardPath(true, path, path, "foo", new ShardId("foo", 0));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("shard state path must be different to the data path when using custom data paths"));
+ }
}
public void testValidCtor() {
diff --git a/core/src/test/java/org/elasticsearch/index/similarity/SimilarityTests.java b/core/src/test/java/org/elasticsearch/index/similarity/SimilarityTests.java
index 28f5e5c62f..965916284a 100644
--- a/core/src/test/java/org/elasticsearch/index/similarity/SimilarityTests.java
+++ b/core/src/test/java/org/elasticsearch/index/similarity/SimilarityTests.java
@@ -19,13 +19,22 @@
package org.elasticsearch.index.similarity;
-import org.apache.lucene.search.similarities.*;
+import org.apache.lucene.search.similarities.AfterEffectL;
+import org.apache.lucene.search.similarities.BM25Similarity;
+import org.apache.lucene.search.similarities.BasicModelG;
+import org.apache.lucene.search.similarities.DFRSimilarity;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.DistributionSPL;
+import org.apache.lucene.search.similarities.IBSimilarity;
+import org.apache.lucene.search.similarities.LMDirichletSimilarity;
+import org.apache.lucene.search.similarities.LMJelinekMercerSimilarity;
+import org.apache.lucene.search.similarities.LambdaTTF;
+import org.apache.lucene.search.similarities.NormalizationH2;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -33,15 +42,12 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class SimilarityTests extends ESSingleNodeTestCase {
-
- @Test
public void testResolveDefaultSimilarities() {
SimilarityService similarityService = createIndex("foo").similarityService();
assertThat(similarityService.getSimilarity("default").get(), instanceOf(DefaultSimilarity.class));
assertThat(similarityService.getSimilarity("BM25").get(), instanceOf(BM25Similarity.class));
}
- @Test
public void testResolveSimilaritiesFromMapping_default() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -61,7 +67,6 @@ public class SimilarityTests extends ESSingleNodeTestCase {
assertThat(similarity.getDiscountOverlaps(), equalTo(false));
}
- @Test
public void testResolveSimilaritiesFromMapping_bm25() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -85,7 +90,6 @@ public class SimilarityTests extends ESSingleNodeTestCase {
assertThat(similarity.getDiscountOverlaps(), equalTo(false));
}
- @Test
public void testResolveSimilaritiesFromMapping_DFR() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -111,7 +115,6 @@ public class SimilarityTests extends ESSingleNodeTestCase {
assertThat(((NormalizationH2) similarity.getNormalization()).getC(), equalTo(3f));
}
- @Test
public void testResolveSimilaritiesFromMapping_IB() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -137,7 +140,6 @@ public class SimilarityTests extends ESSingleNodeTestCase {
assertThat(((NormalizationH2) similarity.getNormalization()).getC(), equalTo(3f));
}
- @Test
public void testResolveSimilaritiesFromMapping_LMDirichlet() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
@@ -157,7 +159,6 @@ public class SimilarityTests extends ESSingleNodeTestCase {
assertThat(similarity.getMu(), equalTo(3000f));
}
- @Test
public void testResolveSimilaritiesFromMapping_LMJelinekMercer() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java
index cd1b05f152..650388c5f0 100644
--- a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java
+++ b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java
@@ -22,11 +22,14 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Version;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.unit.ByteSizeValue;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo.Fields;
import org.elasticsearch.index.store.StoreFileMetaData;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo.Fields;
-import org.junit.Test;
import java.io.IOException;
@@ -37,8 +40,6 @@ import static org.hamcrest.Matchers.is;
/**
*/
public class FileInfoTests extends ESTestCase {
-
- @Test
public void testToFromXContent() throws IOException {
final int iters = scaledRandomIntBetween(1, 10);
for (int iter = 0; iter < iters; iter++) {
@@ -71,7 +72,6 @@ public class FileInfoTests extends ESTestCase {
}
}
- @Test
public void testInvalidFieldsInFromXContent() throws IOException {
final int iters = scaledRandomIntBetween(1, 10);
for (int iter = 0; iter < iters; iter++) {
diff --git a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java
index e9deadb9d0..38fc17c777 100644
--- a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java
+++ b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java
@@ -19,18 +19,20 @@
package org.elasticsearch.index.snapshots.blobstore;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
+
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Random;
import static org.hamcrest.Matchers.equalTo;
public class SlicedInputStreamTests extends ESTestCase {
-
- @Test
- public void readRandom() throws IOException {
+ public void testReadRandom() throws IOException {
int parts = randomIntBetween(1, 20);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int numWriteOps = scaledRandomIntBetween(1000, 10000);
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
index 17e677a88f..b9282ea2db 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
@@ -19,7 +19,6 @@
package org.elasticsearch.index.store;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
-import java.nio.charset.StandardCharsets;
import org.apache.lucene.index.CheckIndex;
import org.apache.lucene.index.IndexFileNames;
@@ -65,8 +64,8 @@ import org.elasticsearch.indices.recovery.RecoveryTarget;
import org.elasticsearch.monitor.fs.FsInfo;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.snapshots.SnapshotState;
-import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.CorruptionUtils;
+import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.store.MockFSDirectoryService;
import org.elasticsearch.test.transport.MockTransportService;
@@ -74,11 +73,11 @@ import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -111,7 +110,6 @@ import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
public class CorruptedFileIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
@@ -133,7 +131,6 @@ public class CorruptedFileIT extends ESIntegTestCase {
/**
* Tests that we can actually recover from a corruption on the primary given that we have replica shards around.
*/
- @Test
public void testCorruptFileAndRecover() throws ExecutionException, InterruptedException, IOException {
int numDocs = scaledRandomIntBetween(100, 1000);
// have enough space for 3 copies
@@ -201,7 +198,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
@Override
public void afterIndexShardClosed(ShardId sid, @Nullable IndexShard indexShard, @IndexSettings Settings indexSettings) {
if (indexShard != null) {
- Store store = ((IndexShard) indexShard).store();
+ Store store = indexShard.store();
store.incRef();
try {
if (!Lucene.indexExists(store.directory()) && indexShard.state() == IndexShardState.STARTED) {
@@ -246,7 +243,6 @@ public class CorruptedFileIT extends ESIntegTestCase {
* Tests corruption that happens on a single shard when no replicas are present. We make sure that the primary stays unassigned
* and all other replicas for the healthy shards happens
*/
- @Test
public void testCorruptPrimaryNoReplica() throws ExecutionException, InterruptedException, IOException {
int numDocs = scaledRandomIntBetween(100, 1000);
internalCluster().ensureAtLeastNumDataNodes(2);
@@ -375,7 +371,6 @@ public class CorruptedFileIT extends ESIntegTestCase {
* Tests corruption that happens on the network layer and that the primary does not get affected by corruption that happens on the way
* to the replica. The file on disk stays uncorrupted
*/
- @Test
public void testCorruptionOnNetworkLayer() throws ExecutionException, InterruptedException {
int numDocs = scaledRandomIntBetween(100, 1000);
internalCluster().ensureAtLeastNumDataNodes(2);
@@ -474,7 +469,6 @@ public class CorruptedFileIT extends ESIntegTestCase {
* TODO once checksum verification on snapshotting is implemented this test needs to be fixed or split into several
* parts... We should also corrupt files on the actual snapshot and check that we don't restore the corrupted shard.
*/
- @Test
public void testCorruptFileThenSnapshotAndRestore() throws ExecutionException, InterruptedException, IOException {
int numDocs = scaledRandomIntBetween(100, 1000);
internalCluster().ensureAtLeastNumDataNodes(2);
@@ -529,7 +523,6 @@ public class CorruptedFileIT extends ESIntegTestCase {
* nodes, so that replica won't be sneaky and allocated on a node that doesn't have a corrupted
* replica.
*/
- @Test
public void testReplicaCorruption() throws Exception {
int numDocs = scaledRandomIntBetween(100, 1000);
internalCluster().ensureAtLeastNumDataNodes(2);
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
index c5158b782e..653a7d04e9 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
@@ -20,6 +20,7 @@
package org.elasticsearch.index.store;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
@@ -37,7 +38,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.engine.MockEngineSupport;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
-import org.junit.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -62,7 +62,6 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ESIntegTestCase.ClusterScope(scope= ESIntegTestCase.Scope.SUITE, numDataNodes = 0)
public class CorruptedTranslogIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
// we really need local GW here since this also checks for corruption etc.
@@ -70,7 +69,6 @@ public class CorruptedTranslogIT extends ESIntegTestCase {
return pluginList(MockTransportService.TestPlugin.class);
}
- @Test
@TestLogging("index.translog:TRACE,index.gateway:TRACE")
public void testCorruptTranslogFiles() throws Exception {
internalCluster().startNodesAsync(1, Settings.EMPTY).get();
@@ -153,12 +151,12 @@ public class CorruptedTranslogIT extends ESIntegTestCase {
ByteBuffer bb = ByteBuffer.wrap(new byte[1]);
raf.read(bb);
bb.flip();
-
+
// corrupt
byte oldValue = bb.get(0);
byte newValue = (byte) (oldValue + 1);
bb.put(0, newValue);
-
+
// rewrite
raf.position(filePointer);
raf.write(bb);
diff --git a/core/src/test/java/org/elasticsearch/index/store/DirectoryUtilsTests.java b/core/src/test/java/org/elasticsearch/index/store/DirectoryUtilsTests.java
index 04ae4676fe..57265872c4 100644
--- a/core/src/test/java/org/elasticsearch/index/store/DirectoryUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/store/DirectoryUtilsTests.java
@@ -18,20 +18,23 @@
*/
package org.elasticsearch.index.store;
-import org.apache.lucene.store.*;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.FileSwitchDirectory;
+import org.apache.lucene.store.FilterDirectory;
+import org.apache.lucene.store.RAMDirectory;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
public class DirectoryUtilsTests extends ESTestCase {
-
- @Test
public void testGetLeave() throws IOException {
Path file = createTempDir();
final int iters = scaledRandomIntBetween(10, 100);
diff --git a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java
index 91d17f4503..cc3c786806 100644
--- a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java
@@ -26,15 +26,17 @@ import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.bulk.TransportShardBulkAction;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.ConnectTransportException;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.Collection;
@@ -45,7 +47,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
@@ -60,7 +64,7 @@ public class ExceptionRetryIT extends ESIntegTestCase {
@Override
protected void beforeIndexDeletion() {
// a write operation might still be in flight when the test has finished
- // so we should not check the operation counter here
+ // so we should not check the operation counter here
}
/**
@@ -68,7 +72,6 @@ public class ExceptionRetryIT extends ESIntegTestCase {
* If auto generated ids are used this must not lead to duplicate ids
* see https://github.com/elasticsearch/elasticsearch/issues/8788
*/
- @Test
public void testRetryDueToExceptionOnNetworkLayer() throws ExecutionException, InterruptedException, IOException {
final AtomicBoolean exceptionThrown = new AtomicBoolean(false);
int numDocs = scaledRandomIntBetween(100, 1000);
diff --git a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java
index 123e4e01bc..7e8186157a 100644
--- a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java
+++ b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java
@@ -73,7 +73,6 @@ import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData;
import org.elasticsearch.test.DummyShardLock;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -107,8 +106,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class StoreTests extends ESTestCase {
-
- @Test
public void testRefCount() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -162,7 +159,6 @@ public class StoreTests extends ESTestCase {
}
}
- @Test
public void testVerifyingIndexOutput() throws IOException {
Directory dir = newDirectory();
IndexOutput output = dir.createOutput("foo.bar", IOContext.DEFAULT);
@@ -276,7 +272,6 @@ public class StoreTests extends ESTestCase {
}
}
- @Test
public void testVerifyingIndexOutputWithBogusInput() throws IOException {
Directory dir = newDirectory();
int length = scaledRandomIntBetween(10, 1024);
@@ -359,7 +354,6 @@ public class StoreTests extends ESTestCase {
// The test currently fails because the segment infos and the index don't
// agree on the oldest version of a segment. We should fix this test by
// switching to a static bw index
- @Test
public void testWriteLegacyChecksums() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -444,7 +438,6 @@ public class StoreTests extends ESTestCase {
}
- @Test
public void testNewChecksums() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -504,7 +497,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
- @Test
public void testMixedChecksums() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -596,7 +588,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
- @Test
public void testRenameFile() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random(), false);
@@ -713,7 +704,6 @@ public class StoreTests extends ESTestCase {
}
- @Test
public void testVerifyingIndexInput() throws IOException {
Directory dir = newDirectory();
IndexOutput output = dir.createOutput("foo.bar", IOContext.DEFAULT);
@@ -843,7 +833,6 @@ public class StoreTests extends ESTestCase {
* Legacy indices without lucene CRC32 did never write or calculate checksums for segments_N files
* but for other files
*/
- @Test
public void testRecoveryDiffWithLegacyCommit() {
Map<String, StoreFileMetaData> metaDataMap = new HashMap<>();
metaDataMap.put("segments_1", new StoreFileMetaData("segments_1", 50, null, null, new BytesRef(new byte[]{1})));
@@ -855,8 +844,6 @@ public class StoreTests extends ESTestCase {
assertEquals(recoveryDiff.toString(), recoveryDiff.different.size(), 2);
}
-
- @Test
public void testRecoveryDiff() throws IOException, InterruptedException {
int numDocs = 2 + random().nextInt(100);
List<Document> docs = new ArrayList<>();
@@ -1001,7 +988,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
- @Test
public void testCleanupFromSnapshot() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -1111,7 +1097,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
- @Test
public void testCleanUpWithLegacyChecksums() throws IOException {
Map<String, StoreFileMetaData> metaDataMap = new HashMap<>();
metaDataMap.put("segments_1", new StoreFileMetaData("segments_1", 50, null, null, new BytesRef(new byte[]{1})));
@@ -1158,7 +1143,6 @@ public class StoreTests extends ESTestCase {
assertEquals(count.get(), 1);
}
- @Test
public void testStoreStats() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -1217,9 +1201,7 @@ public class StoreTests extends ESTestCase {
return numNonExtra;
}
- @Test
public void testMetadataSnapshotStreaming() throws Exception {
-
Store.MetadataSnapshot outMetadataSnapshot = createMetaDataSnapshot();
org.elasticsearch.Version targetNodeVersion = randomVersion(random());
@@ -1253,7 +1235,6 @@ public class StoreTests extends ESTestCase {
return new Store.MetadataSnapshot(unmodifiableMap(storeFileMetaDataMap), unmodifiableMap(commitUserData), 0);
}
- @Test
public void testUserDataRead() throws IOException {
final ShardId shardId = new ShardId(new Index("index"), 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random());
@@ -1288,7 +1269,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
- @Test
public void testStreamStoreFilesMetaData() throws Exception {
Store.MetadataSnapshot metadataSnapshot = createMetaDataSnapshot();
TransportNodesListShardStoreMetaData.StoreFilesMetaData outStoreFileMetaData = new TransportNodesListShardStoreMetaData.StoreFilesMetaData(randomBoolean(), new ShardId("test", 0),metadataSnapshot);
diff --git a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
index 02d5279abb..68c19d56e5 100644
--- a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
+++ b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
@@ -32,7 +32,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder;
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
@@ -41,19 +40,20 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
/**
*/
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SuggestStatsIT extends ESIntegTestCase {
-
@Override
protected int numberOfReplicas() {
return 0;
}
- @Test
public void testSimpleStats() throws Exception {
// clear all stats first
client().admin().indices().prepareStats().clear().execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
index 0b3e12dd9c..49a6f42b08 100644
--- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
+++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
@@ -20,21 +20,19 @@
package org.elasticsearch.index.translog;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.ByteArrayDataOutput;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
@@ -45,25 +43,39 @@ import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.EOFException;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
-import java.nio.file.*;
-import java.util.*;
-import java.util.concurrent.*;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
/**
*
@@ -182,7 +194,6 @@ public class TranslogTests extends ESTestCase {
return string;
}
- @Test
public void testRead() throws IOException {
Translog.Location loc1 = translog.add(new Translog.Index("test", "1", new byte[]{1}));
Translog.Location loc2 = translog.add(new Translog.Index("test", "2", new byte[]{2}));
@@ -209,7 +220,6 @@ public class TranslogTests extends ESTestCase {
}
}
- @Test
public void testSimpleOperations() throws IOException {
ArrayList<Translog.Operation> ops = new ArrayList<>();
Translog.Snapshot snapshot = translog.newSnapshot();
@@ -272,7 +282,6 @@ public class TranslogTests extends ESTestCase {
return stats;
}
- @Test
public void testStats() throws IOException {
final long firstOperationPosition = translog.getFirstOperationPosition();
TranslogStats stats = stats();
@@ -336,7 +345,6 @@ public class TranslogTests extends ESTestCase {
}
}
- @Test
public void testSnapshot() {
ArrayList<Translog.Operation> ops = new ArrayList<>();
Translog.Snapshot snapshot = translog.newSnapshot();
@@ -363,7 +371,6 @@ public class TranslogTests extends ESTestCase {
snapshot1.close();
}
- @Test
public void testSnapshotWithNewTranslog() throws IOException {
ArrayList<Translog.Operation> ops = new ArrayList<>();
Translog.Snapshot snapshot = translog.newSnapshot();
@@ -401,8 +408,7 @@ public class TranslogTests extends ESTestCase {
}
}
- @Test
- public void deleteOnSnapshotRelease() throws Exception {
+ public void testDeleteOnSnapshotRelease() throws Exception {
ArrayList<Translog.Operation> firstOps = new ArrayList<>();
addToTranslogAndList(translog, firstOps, new Translog.Index("test", "1", new byte[]{1}));
@@ -457,7 +463,6 @@ public class TranslogTests extends ESTestCase {
}
- @Test
public void testConcurrentWritesWithVaryingSize() throws Throwable {
final int opsPerThread = randomIntBetween(10, 200);
int threadCount = 2 + randomInt(5);
@@ -543,7 +548,6 @@ public class TranslogTests extends ESTestCase {
}
- @Test
public void testTranslogChecksums() throws Exception {
List<Translog.Location> locations = new ArrayList<>();
@@ -567,7 +571,6 @@ public class TranslogTests extends ESTestCase {
assertThat("at least one corruption was caused and caught", corruptionsCaught.get(), greaterThanOrEqualTo(1));
}
- @Test
public void testTruncatedTranslogs() throws Exception {
List<Translog.Location> locations = new ArrayList<>();
@@ -634,8 +637,6 @@ public class TranslogTests extends ESTestCase {
return new Term("_uid", id);
}
-
- @Test
public void testVerifyTranslogIsNotDeleted() throws IOException {
assertFileIsPresent(translog, 1);
translog.add(new Translog.Index("test", "1", new byte[]{1}));
@@ -655,7 +656,6 @@ public class TranslogTests extends ESTestCase {
}
/** Tests that concurrent readers and writes maintain view and snapshot semantics */
- @Test
public void testConcurrentWriteViewsAndSnapshot() throws Throwable {
final Thread[] writers = new Thread[randomIntBetween(1, 10)];
final Thread[] readers = new Thread[randomIntBetween(1, 10)];
diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java
index 283124d09e..68f26c504f 100644
--- a/core/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java
+++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.index.translog;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.channels.FileChannel;
@@ -36,8 +35,6 @@ import static org.hamcrest.Matchers.equalTo;
* Tests for reading old and new translog files
*/
public class TranslogVersionTests extends ESTestCase {
-
- @Test
public void testV0LegacyTranslogVersion() throws Exception {
Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v0.binary");
assertThat("test file should exist", Files.exists(translogFile), equalTo(true));
@@ -62,7 +59,6 @@ public class TranslogVersionTests extends ESTestCase {
}
}
- @Test
public void testV1ChecksummedTranslogVersion() throws Exception {
Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1.binary");
assertThat("test file should exist", Files.exists(translogFile), equalTo(true));
@@ -95,7 +91,6 @@ public class TranslogVersionTests extends ESTestCase {
}
}
- @Test
public void testCorruptedTranslogs() throws Exception {
try {
Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1-corrupted-magic.binary");
@@ -135,7 +130,6 @@ public class TranslogVersionTests extends ESTestCase {
}
- @Test
public void testTruncatedTranslog() throws Exception {
try {
Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1-truncated.binary");
diff --git a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
index 1c914c10c0..f4a70a2afa 100644
--- a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
+++ b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.indices.InvalidIndexNameException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -44,12 +43,10 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
*
*/
public class IndexActionIT extends ESIntegTestCase {
-
/**
* This test tries to simulate load while creating an index and indexing documents
* while the index is being created.
*/
- @Test
public void testAutoGenerateIdNoDuplicates() throws Exception {
int numberOfIterations = scaledRandomIntBetween(10, 50);
for (int i = 0; i < numberOfIterations; i++) {
@@ -92,7 +89,6 @@ public class IndexActionIT extends ESIntegTestCase {
}
}
- @Test
public void testCreatedFlag() throws Exception {
createIndex("test");
ensureGreen();
@@ -110,7 +106,6 @@ public class IndexActionIT extends ESIntegTestCase {
}
- @Test
public void testCreatedFlagWithFlush() throws Exception {
createIndex("test");
ensureGreen();
@@ -126,7 +121,6 @@ public class IndexActionIT extends ESIntegTestCase {
assertTrue(indexResponse.isCreated());
}
- @Test
public void testCreatedFlagParallelExecution() throws Exception {
createIndex("test");
ensureGreen();
@@ -159,7 +153,6 @@ public class IndexActionIT extends ESIntegTestCase {
terminate(threadPool);
}
- @Test
public void testCreatedFlagWithExternalVersioning() throws Exception {
createIndex("test");
ensureGreen();
@@ -169,7 +162,6 @@ public class IndexActionIT extends ESIntegTestCase {
assertTrue(indexResponse.isCreated());
}
- @Test
public void testCreateFlagWithBulk() {
createIndex("test");
ensureGreen();
@@ -181,7 +173,6 @@ public class IndexActionIT extends ESIntegTestCase {
assertTrue(indexResponse.isCreated());
}
- @Test
public void testCreateIndexWithLongName() {
int min = MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES + 1;
int max = MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES * 2;
diff --git a/core/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java b/core/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
index 8fe2bf01ca..1f4e7c6702 100644
--- a/core/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
+++ b/core/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
@@ -31,8 +31,8 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
-import org.junit.Test;
import java.util.Set;
import java.util.stream.Collectors;
@@ -46,7 +46,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
@@ -59,8 +58,6 @@ import static org.hamcrest.Matchers.nullValue;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class IndexLifecycleActionIT extends ESIntegTestCase {
-
- @Test
public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
Settings settings = settingsBuilder()
.put(SETTING_NUMBER_OF_SHARDS, 11)
diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java b/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
index bf3b84e4d4..9ea4e38f86 100644
--- a/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
@@ -38,7 +38,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.List;
import java.util.Map;
@@ -64,8 +63,6 @@ import static org.hamcrest.Matchers.hasSize;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class IndicesLifecycleListenerIT extends ESIntegTestCase {
-
- @Test
public void testBeforeIndexAddedToCluster() throws Exception {
String node1 = internalCluster().startNode();
String node2 = internalCluster().startNode();
@@ -113,7 +110,6 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
* Tests that if an *index* structure creation fails on relocation to a new node, the shard
* is not stuck but properly failed.
*/
- @Test
public void testIndexShardFailedOnRelocation() throws Throwable {
String node1 = internalCluster().startNode();
client().admin().indices().prepareCreate("index1").setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).get();
@@ -133,9 +129,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
assertThat(state.nodes().resolveNode(shard.get(0).currentNodeId()).getName(), Matchers.equalTo(node1));
}
- @Test
public void testIndexStateShardChanged() throws Throwable {
-
//start with a single node
String node1 = internalCluster().startNode();
IndexShardStateChangeListener stateChangeListenerNode1 = new IndexShardStateChangeListener();
diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java b/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java
index 9f9ed46f69..037e9b974f 100644
--- a/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.concurrent.atomic.AtomicInteger;
@@ -33,15 +32,12 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
public class IndicesLifecycleListenerSingleNodeTests extends ESSingleNodeTestCase {
-
@Override
protected boolean resetNodeAfterTest() {
return true;
}
- @Test
public void testCloseDeleteCallback() throws Throwable {
-
final AtomicInteger counter = new AtomicInteger(1);
assertAcked(client().admin().indices().prepareCreate("test")
.setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0));
@@ -86,5 +82,5 @@ public class IndicesLifecycleListenerSingleNodeTests extends ESSingleNodeTestCas
assertAcked(client().admin().indices().prepareDelete("test").get());
assertEquals(7, counter.get());
}
-
+
}
diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
index 11c9dba91d..c959ba164e 100644
--- a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
@@ -54,7 +54,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.suggest.SuggestBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@@ -65,9 +64,7 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
-
- @Test
- public void testSpecifiedIndexUnavailable_multipleIndices() throws Exception {
+ public void testSpecifiedIndexUnavailableMultipleIndices() throws Exception {
createIndex("test1");
ensureYellow();
@@ -158,8 +155,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(getSettings("test1", "test2").setIndicesOptions(options), false);
}
- @Test
- public void testSpecifiedIndexUnavailable_singleIndexThatIsClosed() throws Exception {
+ public void testSpecifiedIndexUnavailableSingleIndexThatIsClosed() throws Exception {
assertAcked(prepareCreate("test1"));
// we need to wait until all shards are allocated since recovery from
// gateway will fail unless the majority of the replicas was allocated
@@ -235,8 +231,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(getSettings("test1").setIndicesOptions(options), false);
}
- @Test
- public void testSpecifiedIndexUnavailable_singleIndex() throws Exception {
+ public void testSpecifiedIndexUnavailableSingleIndex() throws Exception {
IndicesOptions options = IndicesOptions.strictExpandOpenAndForbidClosed();
verify(search("test1").setIndicesOptions(options), true);
verify(msearch(options, "test1"), true);
@@ -301,8 +296,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(getSettings("test1").setIndicesOptions(options), false);
}
- @Test
- public void testSpecifiedIndexUnavailable_snapshotRestore() throws Exception {
+ public void testSpecifiedIndexUnavailableSnapshotRestore() throws Exception {
createIndex("test1");
ensureGreen("test1");
waitForRelocation();
@@ -332,7 +326,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(restore("snap3", "test1", "test2").setIndicesOptions(options), false);
}
- @Test
public void testWildcardBehaviour() throws Exception {
// Verify defaults for wildcards, when specifying no indices (*, _all, /)
String[] indices = Strings.EMPTY_ARRAY;
@@ -448,8 +441,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(getSettings(indices).setIndicesOptions(options), false);
}
- @Test
- public void testWildcardBehaviour_snapshotRestore() throws Exception {
+ public void testWildcardBehaviourSnapshotRestore() throws Exception {
createIndex("foobar");
ensureGreen("foobar");
waitForRelocation();
@@ -480,8 +472,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(restore("snap3", "foo*", "baz*").setIndicesOptions(options), true);
}
- @Test
- public void testAllMissing_lenient() throws Exception {
+ public void testAllMissingLenient() throws Exception {
createIndex("test1");
client().prepareIndex("test1", "type", "1").setSource("k", "v").setRefresh(true).execute().actionGet();
SearchResponse response = client().prepareSearch("test2")
@@ -503,8 +494,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertHitCount(response, 1l);
}
- @Test
- public void testAllMissing_strict() throws Exception {
+ public void testAllMissingStrict() throws Exception {
createIndex("test1");
ensureYellow();
try {
@@ -527,9 +517,8 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
client().prepareSearch().setQuery(matchAllQuery()).execute().actionGet();
}
- @Test
// For now don't handle closed indices
- public void testCloseApi_specifiedIndices() throws Exception {
+ public void testCloseApiSpecifiedIndices() throws Exception {
createIndex("test1", "test2");
ensureGreen();
verify(search("test1", "test2"), false);
@@ -545,8 +534,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(search("t*"), false);
}
- @Test
- public void testCloseApi_wildcards() throws Exception {
+ public void testCloseApiWildcards() throws Exception {
createIndex("foo", "foobar", "bar", "barbaz");
ensureGreen();
@@ -562,7 +550,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
verify(client().admin().indices().prepareOpen("_all"), true);
}
- @Test
public void testDeleteIndex() throws Exception {
createIndex("foobar");
ensureYellow();
@@ -573,8 +560,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareExists("foobar").get().isExists(), equalTo(false));
}
- @Test
- public void testDeleteIndex_wildcard() throws Exception {
+ public void testDeleteIndexWildcard() throws Exception {
verify(client().admin().indices().prepareDelete("_all"), false);
createIndex("foo", "foobar", "bar", "barbaz");
@@ -595,7 +581,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareExists("barbaz").get().isExists(), equalTo(false));
}
- @Test
public void testPutWarmer() throws Exception {
createIndex("foobar");
ensureYellow();
@@ -604,8 +589,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
- @Test
- public void testPutWarmer_wildcard() throws Exception {
+ public void testPutWarmerWildcard() throws Exception {
createIndex("foo", "foobar", "bar", "barbaz");
ensureYellow();
@@ -625,7 +609,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
- @Test
public void testPutAlias() throws Exception {
createIndex("foobar");
ensureYellow();
@@ -634,8 +617,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
- @Test
- public void testPutAlias_wildcard() throws Exception {
+ public void testPutAliasWildcard() throws Exception {
createIndex("foo", "foobar", "bar", "barbaz");
ensureYellow();
@@ -653,7 +635,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
- @Test
public void testDeleteWarmer() throws Exception {
SearchSourceBuilder source = new SearchSourceBuilder();
source.query(QueryBuilders.matchAllQuery());
@@ -667,8 +648,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareGetWarmers("foobar").setWarmers("test1").get().getWarmers().size(), equalTo(0));
}
- @Test
- public void testDeleteWarmer_wildcard() throws Exception {
+ public void testDeleteWarmerWildcard() throws Exception {
verify(client().admin().indices().prepareDeleteWarmer().setIndices("_all").setNames("test1"), true);
SearchSourceBuilder source = new SearchSourceBuilder();
@@ -695,7 +675,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareGetWarmers("barbaz").setWarmers("test1").get().getWarmers().size(), equalTo(0));
}
- @Test
public void testPutMapping() throws Exception {
verify(client().admin().indices().preparePutMapping("foo").setType("type1").setSource("field", "type=string"), true);
verify(client().admin().indices().preparePutMapping("_all").setType("type1").setSource("field", "type=string"), true);
@@ -727,7 +706,6 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz").get("type4"), notNullValue());
}
- @Test
public void testUpdateSettings() throws Exception {
verify(client().admin().indices().prepareUpdateSettings("foo").setSettings(Settings.builder().put("a", "b")), true);
verify(client().admin().indices().prepareUpdateSettings("_all").setSettings(Settings.builder().put("a", "b")), true);
diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
index 208922b885..4130cf5ad8 100644
--- a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -45,13 +44,11 @@ import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
@ESBackcompatTestCase.CompatibilityVersion(version = Version.V_1_2_0_ID) // we throw an exception if we create an index with _field_names that is 1.3
public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(DummyAnalysisPlugin.class);
}
- @Test
public void testThatPreBuiltAnalyzersAreNotClosedOnIndexClose() throws Exception {
Map<PreBuiltAnalyzers, List<Version>> loadedAnalyzers = new HashMap<>();
List<String> indexNames = new ArrayList<>();
@@ -121,7 +118,6 @@ public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
* Test case for #5030: Upgrading analysis plugins fails
* See https://github.com/elasticsearch/elasticsearch/issues/5030
*/
- @Test
public void testThatPluginAnalyzersCanBeUpdated() throws Exception {
final XContentBuilder mapping = jsonBuilder().startObject()
.startObject("type")
diff --git a/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java b/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
index a9de21b22f..9f4f2b58e7 100644
--- a/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
@@ -24,24 +24,25 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequestBuilder;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.rest.action.admin.indices.analyze.RestAnalyzeAction;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
/**
*
*/
public class AnalyzeActionIT extends ESIntegTestCase {
-
- @Test
- public void simpleAnalyzerTests() throws Exception {
+ public void testSimpleAnalyzerTests() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen();
@@ -70,9 +71,8 @@ public class AnalyzeActionIT extends ESIntegTestCase {
assertThat(token.getPosition(), equalTo(3));
}
}
-
- @Test
- public void analyzeNumericField() throws IOException {
+
+ public void testAnalyzeNumericField() throws IOException {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "long", "type=long", "double", "type=double"));
ensureGreen("test");
@@ -90,9 +90,7 @@ public class AnalyzeActionIT extends ESIntegTestCase {
}
}
- @Test
- public void analyzeWithNoIndex() throws Exception {
-
+ public void testAnalyzeWithNoIndex() throws Exception {
AnalyzeResponse analyzeResponse = client().admin().indices().prepareAnalyze("THIS IS A TEST").setAnalyzer("simple").get();
assertThat(analyzeResponse.getTokens().size(), equalTo(4));
@@ -120,9 +118,7 @@ public class AnalyzeActionIT extends ESIntegTestCase {
}
- @Test
- public void analyzeWithCharFilters() throws Exception {
-
+ public void testAnalyzeWithCharFilters() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(settingsBuilder().put(indexSettings())
.put("index.analysis.char_filter.custom_mapping.type", "mapping")
@@ -152,8 +148,7 @@ public class AnalyzeActionIT extends ESIntegTestCase {
assertThat(token.getTerm(), equalTo("fish"));
}
- @Test
- public void analyzerWithFieldOrTypeTests() throws Exception {
+ public void testAnalyzerWithFieldOrTypeTests() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen();
@@ -173,7 +168,7 @@ public class AnalyzeActionIT extends ESIntegTestCase {
}
}
- @Test // issue #5974
+ // issue #5974
public void testThatStandardAndDefaultAnalyzersAreSame() throws Exception {
AnalyzeResponse response = client().admin().indices().prepareAnalyze("this is a test").setAnalyzer("standard").get();
assertTokens(response, "this", "is", "a", "test");
@@ -196,7 +191,6 @@ public class AnalyzeActionIT extends ESIntegTestCase {
return randomBoolean() ? "test" : "alias";
}
- @Test
public void testParseXContentForAnalyzeReuqest() throws Exception {
BytesReference content = XContentFactory.jsonBuilder()
.startObject()
@@ -215,7 +209,6 @@ public class AnalyzeActionIT extends ESIntegTestCase {
assertThat(analyzeRequest.tokenFilters(), equalTo(new String[]{"lowercase"}));
}
- @Test
public void testParseXContentForAnalyzeRequestWithInvalidJsonThrowsException() throws Exception {
AnalyzeRequest analyzeRequest = new AnalyzeRequest("for test");
@@ -228,7 +221,6 @@ public class AnalyzeActionIT extends ESIntegTestCase {
}
}
- @Test
public void testParseXContentForAnalyzeRequestWithUnknownParamThrowsException() throws Exception {
AnalyzeRequest analyzeRequest = new AnalyzeRequest("for test");
BytesReference invalidContent =XContentFactory.jsonBuilder()
@@ -246,9 +238,7 @@ public class AnalyzeActionIT extends ESIntegTestCase {
}
}
- @Test
- public void analyzerWithMultiValues() throws Exception {
-
+ public void testAnalyzerWithMultiValues() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceIT.java b/core/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceIT.java
index 96fc85ad85..722a4ebde8 100644
--- a/core/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceIT.java
@@ -27,9 +27,9 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
-import org.junit.Test;
-import static org.elasticsearch.indices.analysis.HunspellService.*;
+import static org.elasticsearch.indices.analysis.HunspellService.HUNSPELL_IGNORE_CASE;
+import static org.elasticsearch.indices.analysis.HunspellService.HUNSPELL_LAZY_LOAD;
import static org.hamcrest.Matchers.notNullValue;
/**
@@ -37,8 +37,6 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ClusterScope(scope= Scope.TEST, numDataNodes=0)
public class HunspellServiceIT extends ESIntegTestCase {
-
- @Test
public void testLocaleDirectoryWithNodeLevelConfig() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("path.conf", getDataPath("/indices/analyze/conf_dir"))
@@ -52,7 +50,6 @@ public class HunspellServiceIT extends ESIntegTestCase {
assertIgnoreCase(true, dictionary);
}
- @Test
public void testLocaleDirectoryWithLocaleSpecificConfig() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("path.conf", getDataPath("/indices/analyze/conf_dir"))
@@ -75,7 +72,6 @@ public class HunspellServiceIT extends ESIntegTestCase {
assertIgnoreCase(true, dictionary);
}
- @Test
public void testDicWithNoAff() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("path.conf", getDataPath("/indices/analyze/no_aff_conf_dir"))
@@ -94,7 +90,6 @@ public class HunspellServiceIT extends ESIntegTestCase {
}
}
- @Test
public void testDicWithTwoAffs() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("path.conf", getDataPath("/indices/analyze/two_aff_conf_dir"))
diff --git a/core/src/test/java/org/elasticsearch/indices/cache/query/terms/TermsLookupTests.java b/core/src/test/java/org/elasticsearch/indices/cache/query/terms/TermsLookupTests.java
index 6474547cf2..bf0394988b 100644
--- a/core/src/test/java/org/elasticsearch/indices/cache/query/terms/TermsLookupTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/cache/query/terms/TermsLookupTests.java
@@ -22,13 +22,12 @@ package org.elasticsearch.indices.cache.query.terms;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-public class TermsLookupTests extends ESTestCase {
+import static org.hamcrest.Matchers.containsString;
- @Test
+public class TermsLookupTests extends ESTestCase {
public void testTermsLookup() {
String index = randomAsciiOfLengthBetween(1, 10);
String type = randomAsciiOfLengthBetween(1, 10);
@@ -44,23 +43,28 @@ public class TermsLookupTests extends ESTestCase {
assertEquals(routing, termsLookup.routing());
}
- @Test(expected=IllegalArgumentException.class)
public void testIllegalArguments() {
String type = randomAsciiOfLength(5);
String id = randomAsciiOfLength(5);
String path = randomAsciiOfLength(5);
switch (randomIntBetween(0, 2)) {
case 0:
- type = null; break;
+ type = null;
+ break;
case 1:
- id = null; break;
+ id = null;
+ break;
case 2:
- path = null; break;
+ path = null;
+ break;
+ }
+ try {
+ new TermsLookup(null, type, id, path);
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("[terms] query lookup element requires specifying"));
}
- new TermsLookup(null, type, id, path);
}
- @Test
public void testSerialization() throws IOException {
TermsLookup termsLookup = randomTermsLookup();
try (BytesStreamOutput output = new BytesStreamOutput()) {
diff --git a/core/src/test/java/org/elasticsearch/indices/exists/indices/IndicesExistsIT.java b/core/src/test/java/org/elasticsearch/indices/exists/indices/IndicesExistsIT.java
index 199f4b6f77..38bea16f83 100644
--- a/core/src/test/java/org/elasticsearch/indices/exists/indices/IndicesExistsIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/exists/indices/IndicesExistsIT.java
@@ -23,16 +23,15 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.hamcrest.Matchers.equalTo;
public class IndicesExistsIT extends ESIntegTestCase {
-
- @Test
// Indices exists never throws IndexMissingException, the indices options control its behaviour (return true or false)
public void testIndicesExists() throws Exception {
assertThat(client().admin().indices().prepareExists("foo").get().isExists(), equalTo(false));
@@ -51,7 +50,6 @@ public class IndicesExistsIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareExists("_all").get().isExists(), equalTo(true));
}
- @Test
public void testIndicesExistsWithBlocks() {
createIndex("ro");
ensureYellow();
diff --git a/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsIT.java b/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsIT.java
index ffb2e2e186..407ee6fbc4 100644
--- a/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsIT.java
@@ -24,20 +24,19 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
public class TypesExistsIT extends ESIntegTestCase {
-
- @Test
public void testSimple() throws Exception {
Client client = client();
client.admin().indices().prepareCreate("test1")
@@ -76,7 +75,6 @@ public class TypesExistsIT extends ESIntegTestCase {
assertThat(response.isExists(), equalTo(false));
}
- @Test
public void testTypesExistsWithBlocks() throws IOException {
assertAcked(prepareCreate("ro").addMapping("type1", jsonBuilder().startObject().startObject("type1").endObject().endObject()));
ensureGreen("ro");
diff --git a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
index 5e0fde7b67..aa8c9f18c0 100644
--- a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
@@ -31,7 +31,6 @@ import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -47,8 +46,6 @@ import static org.hamcrest.Matchers.emptyIterable;
import static org.hamcrest.Matchers.equalTo;
public class FlushIT extends ESIntegTestCase {
-
- @Test
public void testWaitIfOngoing() throws InterruptedException {
createIndex("test");
ensureGreen("test");
@@ -210,7 +207,6 @@ public class FlushIT extends ESIntegTestCase {
}
}
- @Test
public void testUnallocatedShardsDoesNotHang() throws InterruptedException {
// create an index but disallow allocation
prepareCreate("test").setSettings(Settings.builder().put("index.routing.allocation.include._name", "nonexistent")).get();
@@ -222,5 +218,4 @@ public class FlushIT extends ESIntegTestCase {
assertThat(shardsResult.size(), equalTo(numShards));
assertThat(shardsResult.get(0).failureReason(), equalTo("no active shards"));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
index f9d597cdc6..0946d51a45 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.List;
@@ -32,17 +31,15 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.emptyIterable;
@ESIntegTestCase.ClusterScope(randomDynamicTemplates = false) // this test takes a long time to delete the idx if all fields are eager loading
public class ConcurrentDynamicTemplateIT extends ESIntegTestCase {
-
private final String mappingType = "test-mapping";
- @Test // see #3544
+ // see #3544
public void testConcurrentDynamicMapping() throws Exception {
final String fieldName = "field";
final String mapping = "{ \"" + mappingType + "\": {" +
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
index 504d9a5840..2f4970ef4f 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
@@ -25,12 +25,15 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_METADATA_BLOCK;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@@ -41,25 +44,20 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ClusterScope(randomDynamicTemplates = false)
public class SimpleGetMappingsIT extends ESIntegTestCase {
-
- @Test
- public void getMappingsWhereThereAreNone() {
+ public void testGetMappingsWhereThereAreNone() {
createIndex("index");
GetMappingsResponse response = client().admin().indices().prepareGetMappings().execute().actionGet();
assertThat(response.mappings().containsKey("index"), equalTo(true));
assertThat(response.mappings().get("index").size(), equalTo(0));
}
-
private XContentBuilder getMappingForType(String type) throws IOException {
return jsonBuilder().startObject().startObject(type).startObject("properties")
.startObject("field1").field("type", "string").endObject()
.endObject().endObject().endObject();
}
-
- @Test
- public void simpleGetMappings() throws Exception {
+ public void testSimpleGetMappings() throws Exception {
client().admin().indices().prepareCreate("indexa")
.addMapping("typeA", getMappingForType("typeA"))
.addMapping("typeB", getMappingForType("typeB"))
@@ -146,7 +144,6 @@ public class SimpleGetMappingsIT extends ESIntegTestCase {
assertThat(response.mappings().get("indexb").get("Btype"), notNullValue());
}
- @Test
public void testGetMappingsWithBlocks() throws IOException {
client().admin().indices().prepareCreate("test")
.addMapping("typeA", getMappingForType("typeA"))
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
index b706db0088..305688b3a6 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
@@ -35,7 +35,6 @@ import org.elasticsearch.index.mapper.MergeMappingException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,16 +43,23 @@ import java.util.Map;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.not;
@ClusterScope(randomDynamicTemplates = false)
public class UpdateMappingIntegrationIT extends ESIntegTestCase {
-
- @Test
- public void dynamicUpdates() throws Exception {
+ public void testDynamicUpdates() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(
settingsBuilder()
@@ -87,8 +93,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
}
}
- @Test
- public void updateMappingWithoutType() throws Exception {
+ public void testUpdateMappingWithoutType() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(
settingsBuilder()
@@ -109,8 +114,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
equalTo("{\"doc\":{\"properties\":{\"body\":{\"type\":\"string\"},\"date\":{\"type\":\"integer\"}}}}"));
}
- @Test
- public void updateMappingWithoutTypeMultiObjects() throws Exception {
+ public void testUpdateMappingWithoutTypeMultiObjects() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(
settingsBuilder()
@@ -130,9 +134,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
equalTo("{\"doc\":{\"properties\":{\"date\":{\"type\":\"integer\"}}}}"));
}
- @Test(expected = MergeMappingException.class)
- public void updateMappingWithConflicts() throws Exception {
-
+ public void testUpdateMappingWithConflicts() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(
settingsBuilder()
@@ -142,29 +144,33 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
.execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
- PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
- .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}")
- .execute().actionGet();
-
- assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
+ try {
+ client().admin().indices().preparePutMapping("test").setType("type")
+ .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}").execute().actionGet();
+ fail("Expected MergeMappingException");
+ } catch (MergeMappingException e) {
+ assertThat(e.getMessage(), containsString("mapper [body] of different type"));
+ }
}
- @Test(expected = MergeMappingException.class)
- public void updateMappingWithNormsConflicts() throws Exception {
+ public void testUpdateMappingWithNormsConflicts() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": false }}}}}")
.execute().actionGet();
- PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
- .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": true }}}}}")
- .execute().actionGet();
+ try {
+ client().admin().indices().preparePutMapping("test").setType("type")
+ .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": true }}}}}").execute()
+ .actionGet();
+ fail("Expected MergeMappingException");
+ } catch (MergeMappingException e) {
+ assertThat(e.getMessage(), containsString("mapper [body] has different [omit_norms]"));
+ }
}
/*
Second regression test for https://github.com/elasticsearch/elasticsearch/issues/3381
*/
- @Test
- public void updateMappingNoChanges() throws Exception {
-
+ public void testUpdateMappingNoChanges() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(
settingsBuilder()
@@ -183,9 +189,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
}
@SuppressWarnings("unchecked")
- @Test
- public void updateDefaultMappingSettings() throws Exception {
-
+ public void testUpdateDefaultMappingSettings() throws Exception {
logger.info("Creating index with _default_ mappings");
client().admin().indices().prepareCreate("test").addMapping(MapperService.DEFAULT_MAPPING,
JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING)
@@ -245,8 +249,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
}
- @Test
- public void updateMappingConcurrently() throws Throwable {
+ public void testUpdateMappingConcurrently() throws Throwable {
createIndex("test1", "test2");
// This is important. The test assumes all nodes are aware of all indices. Due to initializing shard throttling
@@ -312,7 +315,6 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
}
- @Test
public void testPutMappingsWithBlocks() throws Exception {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerIT.java b/core/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerIT.java
index e14cc22664..4013031fd3 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerIT.java
@@ -24,21 +24,17 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.concurrent.EsExecutors;
-import org.elasticsearch.index.engine.EngineConfig;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class IndexingMemoryControllerIT extends ESIntegTestCase {
-
private long getIWBufferSize(String indexName) {
return client().admin().indices().prepareStats(indexName).get().getTotal().getSegments().getIndexWriterMaxMemoryInBytes();
}
- @Test
public void testIndexBufferPushedToEngine() throws InterruptedException {
createNode(Settings.builder().put(IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING, "100000h",
IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING, "32mb",
@@ -68,7 +64,6 @@ public class IndexingMemoryControllerIT extends ESIntegTestCase {
}
- @Test
public void testInactivePushedToShard() throws InterruptedException {
createNode(Settings.builder().put(IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING, "100ms",
IndexingMemoryController.SHARD_INACTIVE_INTERVAL_TIME_SETTING, "100ms",
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
index 4992b9f72d..3398839b90 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +38,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
/** Tests for the noop breakers, which are non-dynamic settings */
@ESIntegTestCase.ClusterScope(scope= ESIntegTestCase.Scope.SUITE, numDataNodes=0)
public class CircuitBreakerNoopIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
@@ -52,7 +50,6 @@ public class CircuitBreakerNoopIT extends ESIntegTestCase {
.build();
}
- @Test
public void testNoopRequestBreaker() throws Exception {
assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))));
Client client = client();
@@ -70,7 +67,6 @@ public class CircuitBreakerNoopIT extends ESIntegTestCase {
// no exception because the breaker is a noop
}
- @Test
public void testNoopFielddataBreaker() throws Exception {
assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))));
Client client = client();
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
index 4ffe6361cb..fcd94d9958 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
@@ -38,7 +38,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -60,7 +59,6 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
*/
@ClusterScope(scope = TEST, randomDynamicTemplates = false)
public class CircuitBreakerServiceIT extends ESIntegTestCase {
-
/** Reset all breaker settings back to their defaults */
private void reset() {
logger.info("--> resetting breaker settings");
@@ -100,7 +98,6 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
return false;
}
- @Test
public void testMemoryBreaker() throws Exception {
if (noopBreakerUsed()) {
logger.info("--> noop breakers used, skipping test");
@@ -142,7 +139,6 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
assertThat(breaks, greaterThanOrEqualTo(1));
}
- @Test
public void testRamAccountingTermsEnum() throws Exception {
if (noopBreakerUsed()) {
logger.info("--> noop breakers used, skipping test");
@@ -196,7 +192,6 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
* Test that a breaker correctly redistributes to a different breaker, in
* this case, the fielddata breaker borrows space from the request breaker
*/
- @Test
public void testParentChecking() throws Exception {
if (noopBreakerUsed()) {
logger.info("--> noop breakers used, skipping test");
@@ -256,7 +251,6 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
}
}
- @Test
public void testRequestBreaker() throws Exception {
if (noopBreakerUsed()) {
logger.info("--> noop breakers used, skipping test");
@@ -307,7 +301,6 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
}, 30, TimeUnit.SECONDS);
}
- @Test
public void testCustomCircuitBreakerRegistration() throws Exception {
Iterable<CircuitBreakerService> serviceIter = internalCluster().getInstances(CircuitBreakerService.class);
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerUnitTests.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerUnitTests.java
index 013bc718ec..741ea30525 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerUnitTests.java
@@ -26,20 +26,20 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
/**
* Unit tests for the circuit breaker
*/
public class CircuitBreakerUnitTests extends ESTestCase {
-
public static long pctBytes(String percentString) {
return Settings.EMPTY.getAsMemory("", percentString).bytes();
}
- @Test
public void testBreakerSettingsValidationWithValidSettings() {
// parent: {:limit 70}, fd: {:limit 50}, request: {:limit 20}
BreakerSettings fd = new BreakerSettings(CircuitBreaker.FIELDDATA, pctBytes("50%"), 1.0);
@@ -52,7 +52,6 @@ public class CircuitBreakerUnitTests extends ESTestCase {
HierarchyCircuitBreakerService.validateSettings(new BreakerSettings[]{fd, request});
}
- @Test
public void testBreakerSettingsValidationNegativeOverhead() {
// parent: {:limit 70}, fd: {:limit 50}, request: {:limit 20}
BreakerSettings fd = new BreakerSettings(CircuitBreaker.FIELDDATA, pctBytes("50%"), -0.1);
@@ -66,7 +65,6 @@ public class CircuitBreakerUnitTests extends ESTestCase {
}
}
- @Test
public void testRegisterCustomBreaker() throws Exception {
CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new NodeSettingsService(Settings.EMPTY));
String customName = "custom";
@@ -78,5 +76,4 @@ public class CircuitBreakerUnitTests extends ESTestCase {
assertThat(breaker, instanceOf(CircuitBreaker.class));
assertThat(breaker.getName(), is(customName));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
index 4f0bd600be..d9a114a276 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
@@ -41,7 +41,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.engine.MockEngineSupport;
import org.elasticsearch.test.engine.MockEngineSupportModule;
import org.elasticsearch.test.engine.ThrowingLeafReaderWrapper;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -57,13 +56,11 @@ import static org.hamcrest.Matchers.equalTo;
* Tests for the circuit breaker while random exceptions are happening
*/
public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(RandomExceptionDirectoryReaderWrapper.TestPlugin.class);
}
- @Test
public void testBreakerWithRandomExceptions() throws IOException, InterruptedException, ExecutionException {
for (NodeStats node : client().admin().cluster().prepareNodesStats()
.clear().setBreaker(true).execute().actionGet().getNodes()) {
diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
index 0bab80ae4c..883d04e818 100644
--- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
@@ -49,6 +49,7 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.store.MockFSDirectoryService;
@@ -59,7 +60,6 @@ import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -70,7 +70,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.arrayWithSize;
@@ -158,8 +157,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
.get().isAcknowledged());
}
- @Test
- public void gatewayRecoveryTest() throws Exception {
+ public void testGatewayRecovery() throws Exception {
logger.info("--> start nodes");
String node = internalCluster().startNode();
@@ -184,8 +182,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
validateIndexRecoveryState(recoveryState.getIndex());
}
- @Test
- public void gatewayRecoveryTestActiveOnly() throws Exception {
+ public void testGatewayRecoveryTestActiveOnly() throws Exception {
logger.info("--> start nodes");
internalCluster().startNode();
@@ -202,8 +199,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
assertThat(recoveryStates.size(), equalTo(0)); // Should not expect any responses back
}
- @Test
- public void replicaRecoveryTest() throws Exception {
+ public void testReplicaRecovery() throws Exception {
logger.info("--> start node A");
String nodeA = internalCluster().startNode();
@@ -243,9 +239,8 @@ public class IndexRecoveryIT extends ESIntegTestCase {
validateIndexRecoveryState(nodeBRecoveryState.getIndex());
}
- @Test
@TestLogging("indices.recovery:TRACE")
- public void rerouteRecoveryTest() throws Exception {
+ public void testRerouteRecovery() throws Exception {
logger.info("--> start node A");
final String nodeA = internalCluster().startNode();
@@ -433,8 +428,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
validateIndexRecoveryState(nodeCRecoveryStates.get(0).getIndex());
}
- @Test
- public void snapshotRecoveryTest() throws Exception {
+ public void testSnapshotRecovery() throws Exception {
logger.info("--> start node A");
String nodeA = internalCluster().startNode();
@@ -528,8 +522,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
assertThat(indexState.recoveredBytesPercent(), lessThanOrEqualTo(100.0f));
}
- @Test
- public void disconnectsWhileRecoveringTest() throws Exception {
+ public void testDisconnectsWhileRecovering() throws Exception {
final String indexName = "test";
final Settings nodeSettings = Settings.builder()
.put(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK, "100ms")
diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java
index 3a571a6d91..fea8f0fdf1 100644
--- a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java
@@ -26,9 +26,14 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.index.shard.ShardId;
-import org.elasticsearch.indices.recovery.RecoveryState.*;
+import org.elasticsearch.indices.recovery.RecoveryState.File;
+import org.elasticsearch.indices.recovery.RecoveryState.Index;
+import org.elasticsearch.indices.recovery.RecoveryState.Stage;
+import org.elasticsearch.indices.recovery.RecoveryState.Timer;
+import org.elasticsearch.indices.recovery.RecoveryState.Translog;
+import org.elasticsearch.indices.recovery.RecoveryState.Type;
+import org.elasticsearch.indices.recovery.RecoveryState.VerifyIndex;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -38,12 +43,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.test.VersionUtils.randomVersion;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class RecoveryStateTests extends ESTestCase {
-
abstract class Streamer<T extends Streamable> extends Thread {
-
private T lastRead;
final private AtomicBoolean shouldStop;
final private T source;
@@ -485,7 +495,6 @@ public class RecoveryStateTests extends ESTestCase {
}
}
- @Test
public void testConcurrentModificationIndexFileDetailsMap() throws InterruptedException {
final Index index = new Index();
final AtomicBoolean stop = new AtomicBoolean(false);
@@ -496,6 +505,7 @@ public class RecoveryStateTests extends ESTestCase {
}
};
Thread modifyThread = new Thread() {
+ @Override
public void run() {
for (int i = 0; i < 1000; i++) {
index.addFileDetail(randomAsciiOfLength(10), 100, true);
@@ -510,7 +520,6 @@ public class RecoveryStateTests extends ESTestCase {
assertThat(readWriteIndex.error.get(), equalTo(null));
}
- @Test
public void testFileHashCodeAndEquals() {
File f = new File("foo", randomIntBetween(0, 100), randomBoolean());
File anotherFile = new File(f.name(), f.length(), f.reused());
@@ -526,6 +535,5 @@ public class RecoveryStateTests extends ESTestCase {
assertFalse(f.equals(anotherFile));
}
}
-
}
}
diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java
index 4df825704d..4ad298e39a 100644
--- a/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java
@@ -27,20 +27,16 @@ import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.nullValue;
/**
*/
public class StartRecoveryRequestTests extends ESTestCase {
-
- @Test
public void testSerialization() throws Exception {
Version targetNodeVersion = randomVersion(random());
StartRecoveryRequest outRequest = new StartRecoveryRequest(
diff --git a/core/src/test/java/org/elasticsearch/indices/settings/GetSettingsBlocksIT.java b/core/src/test/java/org/elasticsearch/indices/settings/GetSettingsBlocksIT.java
index 357e87f069..a2a7c5fb49 100644
--- a/core/src/test/java/org/elasticsearch/indices/settings/GetSettingsBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/settings/GetSettingsBlocksIT.java
@@ -22,19 +22,19 @@ package org.elasticsearch.indices.settings;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
public class GetSettingsBlocksIT extends ESIntegTestCase {
-
- @Test
public void testGetSettingsWithBlocks() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(Settings.settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java b/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
index 4dd9b967b8..01c740c161 100644
--- a/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
@@ -26,7 +26,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -39,14 +38,12 @@ import static org.hamcrest.Matchers.equalTo;
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
-
@Override
protected int maximumNumberOfReplicas() {
return 1;
}
- @Test
- public void simpleUpdateNumberOfReplicasIT() throws Exception {
+ public void testSimpleUpdateNumberOfReplicas() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test", 2));
logger.info("Running Cluster Health");
@@ -122,7 +119,6 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
}
}
- @Test
public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
internalCluster().ensureAtMostNumDataNodes(2);
logger.info("--> creating index test with auto expand replicas");
@@ -178,7 +174,6 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries));
}
- @Test
public void testAutoExpandNumberReplicas1ToData() throws IOException {
logger.info("--> creating index test with auto expand replicas");
internalCluster().ensureAtMostNumDataNodes(2);
@@ -234,7 +229,6 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries));
}
- @Test
public void testAutoExpandNumberReplicas2() {
logger.info("--> creating index test with auto expand replicas set to 0-2");
assertAcked(prepareCreate("test", 3, settingsBuilder().put("auto_expand_replicas", "0-2")));
@@ -267,7 +261,6 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 4));
}
- @Test
public void testUpdateWithInvalidNumberOfReplicas() {
createIndex("test");
try {
diff --git a/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java b/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
index cd7241bc9b..afd3bdefaa 100644
--- a/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
@@ -23,7 +23,6 @@ import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
-import org.elasticsearch.index.shard.MergeSchedulerConfig;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
@@ -33,21 +32,24 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.shard.MergePolicyConfig;
+import org.elasticsearch.index.shard.MergeSchedulerConfig;
import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class UpdateSettingsIT extends ESIntegTestCase {
-
- @Test
public void testOpenCloseUpdateSettings() throws Exception {
createIndex("test");
try {
@@ -119,7 +121,6 @@ public class UpdateSettingsIT extends ESIntegTestCase {
assertThat(getSettingsResponse.getSetting("test", "index.cache.filter.type"), equalTo("none"));
}
- @Test
public void testEngineGCDeletesSetting() throws InterruptedException {
createIndex("test");
client().prepareIndex("test", "type", "1").setSource("f", 1).get(); // set version to 1
@@ -137,9 +138,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
// #6626: make sure we can update throttle settings and the changes take effect
- @Test
public void testUpdateThrottleSettings() {
-
// No throttling at first, only 1 non-replicated shard, force lots of merging:
assertAcked(prepareCreate("test")
.setSettings(Settings.builder()
@@ -214,7 +213,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
logger.info("test: disable merge throttling");
-
+
// Now updates settings to disable merge throttling
client()
.admin()
@@ -271,9 +270,6 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
private static class MockAppender extends AppenderSkeleton {
- public boolean sawIndexWriterMessage;
- public boolean sawFlushDeletes;
- public boolean sawMergeThreadPaused;
public boolean sawUpdateMaxThreadCount;
public boolean sawUpdateAutoThrottle;
@@ -282,8 +278,6 @@ public class UpdateSettingsIT extends ESIntegTestCase {
String message = event.getMessage().toString();
if (event.getLevel() == Level.TRACE &&
event.getLoggerName().endsWith("lucene.iw")) {
- sawFlushDeletes |= message.contains("IW: apply all deletes during flush");
- sawMergeThreadPaused |= message.contains("CMS: pause thread");
}
if (event.getLevel() == Level.INFO && message.contains("updating [index.merge.scheduler.max_thread_count] from [10000] to [1]")) {
sawUpdateMaxThreadCount = true;
@@ -303,9 +297,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
}
- @Test
public void testUpdateAutoThrottleSettings() {
-
MockAppender mockAppender = new MockAppender();
Logger rootLogger = Logger.getRootLogger();
Level savedLevel = rootLogger.getLevel();
@@ -347,9 +339,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
// #6882: make sure we can change index.merge.scheduler.max_thread_count live
- @Test
public void testUpdateMergeMaxThreadCount() {
-
MockAppender mockAppender = new MockAppender();
Logger rootLogger = Logger.getRootLogger();
Level savedLevel = rootLogger.getLevel();
@@ -379,7 +369,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
.put(MergeSchedulerConfig.MAX_THREAD_COUNT, "1")
)
.get();
-
+
// Make sure we log the change:
assertTrue(mockAppender.sawUpdateMaxThreadCount);
@@ -393,7 +383,6 @@ public class UpdateSettingsIT extends ESIntegTestCase {
}
}
- @Test
public void testUpdateSettingsWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java b/core/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
index daebe71ac5..326c5bb22e 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
@@ -26,17 +26,14 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(scope= Scope.TEST, numDataNodes =2)
public class CloseIndexDisableCloseAllIT extends ESIntegTestCase {
-
- @Test
// Combined multiple tests into one, because cluster scope is test.
// The cluster scope is test b/c we can't clear cluster settings.
public void testCloseAllRequiresName() {
diff --git a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
index 5556b674aa..e17b2a5c7b 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
@@ -34,20 +34,25 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
public class OpenCloseIndexIT extends ESIntegTestCase {
-
- @Test
public void testSimpleCloseOpen() {
Client client = client();
createIndex("test1");
@@ -63,28 +68,39 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1");
}
- @Test(expected = IndexNotFoundException.class)
public void testSimpleCloseMissingIndex() {
Client client = client();
- client.admin().indices().prepareClose("test1").execute().actionGet();
+ try {
+ client.admin().indices().prepareClose("test1").execute().actionGet();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test(expected = IndexNotFoundException.class)
public void testSimpleOpenMissingIndex() {
Client client = client();
- client.admin().indices().prepareOpen("test1").execute().actionGet();
+ try {
+ client.admin().indices().prepareOpen("test1").execute().actionGet();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test(expected = IndexNotFoundException.class)
public void testCloseOneMissingIndex() {
Client client = client();
createIndex("test1");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
- client.admin().indices().prepareClose("test1", "test2").execute().actionGet();
+ try {
+ client.admin().indices().prepareClose("test1", "test2").execute().actionGet();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
public void testCloseOneMissingIndexIgnoreMissing() {
Client client = client();
createIndex("test1");
@@ -96,16 +112,19 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsClosed("test1");
}
- @Test(expected = IndexNotFoundException.class)
public void testOpenOneMissingIndex() {
Client client = client();
createIndex("test1");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
- client.admin().indices().prepareOpen("test1", "test2").execute().actionGet();
+ try {
+ client.admin().indices().prepareOpen("test1", "test2").execute().actionGet();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
public void testOpenOneMissingIndexIgnoreMissing() {
Client client = client();
createIndex("test1");
@@ -117,7 +136,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1");
}
- @Test
public void testCloseOpenMultipleIndices() {
Client client = client();
createIndex("test1", "test2", "test3");
@@ -138,7 +156,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1", "test2", "test3");
}
- @Test
public void testCloseOpenWildcard() {
Client client = client();
createIndex("test1", "test2", "a");
@@ -155,7 +172,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1", "test2", "a");
}
- @Test
public void testCloseOpenAll() {
Client client = client();
createIndex("test1", "test2", "test3");
@@ -171,7 +187,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1", "test2", "test3");
}
- @Test
public void testCloseOpenAllWildcard() {
Client client = client();
createIndex("test1", "test2", "test3");
@@ -187,31 +202,46 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1", "test2", "test3");
}
- @Test(expected = ActionRequestValidationException.class)
public void testCloseNoIndex() {
Client client = client();
- client.admin().indices().prepareClose().execute().actionGet();
+ try {
+ client.admin().indices().prepareClose().execute().actionGet();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("index is missing"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
public void testCloseNullIndex() {
Client client = client();
- client.admin().indices().prepareClose((String[])null).execute().actionGet();
+ try {
+ client.admin().indices().prepareClose((String[])null).execute().actionGet();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("index is missing"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
public void testOpenNoIndex() {
Client client = client();
- client.admin().indices().prepareOpen().execute().actionGet();
+ try {
+ client.admin().indices().prepareOpen().execute().actionGet();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("index is missing"));
+ }
}
- @Test(expected = ActionRequestValidationException.class)
public void testOpenNullIndex() {
Client client = client();
- client.admin().indices().prepareOpen((String[])null).execute().actionGet();
+ try {
+ client.admin().indices().prepareOpen((String[])null).execute().actionGet();
+ fail("Expected ActionRequestValidationException");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("index is missing"));
+ }
}
- @Test
public void testOpenAlreadyOpenedIndex() {
Client client = client();
createIndex("test1");
@@ -224,7 +254,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1");
}
- @Test
public void testCloseAlreadyClosedIndex() {
Client client = client();
createIndex("test1");
@@ -242,7 +271,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsClosed("test1");
}
- @Test
public void testSimpleCloseOpenAlias() {
Client client = client();
createIndex("test1");
@@ -261,7 +289,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertIndexIsOpened("test1");
}
- @Test
public void testCloseOpenAliasMultipleIndices() {
Client client = client();
createIndex("test1", "test2");
@@ -299,7 +326,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
}
}
- @Test
public void testOpenCloseWithDocs() throws IOException, ExecutionException, InterruptedException {
String mapping = XContentFactory.jsonBuilder().
startObject().
@@ -335,7 +361,6 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
assertHitCount(searchResponse, docs);
}
- @Test
public void testOpenCloseIndexWithBlocks() {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
index dbdfc2be84..1dc9e0268b 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
@@ -54,7 +54,6 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.disruption.BlockClusterStateProcessing;
import org.elasticsearch.test.junit.annotations.TestLogging;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -76,7 +75,6 @@ import static org.hamcrest.Matchers.instanceOf;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0)
@ESIntegTestCase.SuppressLocalMode
public class RareClusterStateIT extends ESIntegTestCase {
-
@Override
protected int numberOfShards() {
return 1;
@@ -87,7 +85,6 @@ public class RareClusterStateIT extends ESIntegTestCase {
return 0;
}
- @Test
public void testUnassignedShardAndEmptyNodesInRoutingTable() throws Exception {
internalCluster().startNode();
createIndex("a");
@@ -106,7 +103,6 @@ public class RareClusterStateIT extends ESIntegTestCase {
allocator.allocateUnassigned(routingAllocation);
}
- @Test
@TestLogging("gateway:TRACE")
public void testAssignmentWithJustAddedNodes() throws Exception {
internalCluster().startNode();
@@ -171,9 +167,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
});
}
-
- @Test
- @TestLogging(value = "cluster.service:TRACE")
+ @TestLogging("cluster.service:TRACE")
public void testDeleteCreateInOneBulk() throws Exception {
internalCluster().startNodesAsync(2, Settings.builder()
.put(DiscoveryModule.DISCOVERY_TYPE_KEY, "zen")
diff --git a/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
index 73f53accc4..ad64e4a3d5 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
@@ -35,7 +35,6 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
@@ -46,10 +45,8 @@ import static org.hamcrest.Matchers.nullValue;
*/
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SimpleIndexStateIT extends ESIntegTestCase {
-
private final ESLogger logger = Loggers.getLogger(SimpleIndexStateIT.class);
- @Test
public void testSimpleOpenClose() {
logger.info("--> creating test index");
createIndex("test");
@@ -100,7 +97,6 @@ public class SimpleIndexStateIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
}
- @Test
public void testFastCloseAfterCreateDoesNotClose() {
logger.info("--> creating test index that cannot be allocated");
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder()
@@ -135,9 +131,7 @@ public class SimpleIndexStateIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
}
- @Test
public void testConsistencyAfterIndexCreationFailure() {
-
logger.info("--> deleting test index....");
try {
client().admin().indices().prepareDelete("test").get();
@@ -157,5 +151,4 @@ public class SimpleIndexStateIT extends ESIntegTestCase {
CreateIndexResponse response = client().admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("number_of_shards", 1)).get();
assertThat(response.isAcknowledged(), equalTo(true));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java
index d40ebf57a4..a42ac5e879 100644
--- a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java
@@ -19,10 +19,6 @@
package org.elasticsearch.indices.stats;
-import org.elasticsearch.index.VersionType;
-import org.elasticsearch.index.cache.IndexCacheModule;
-import org.elasticsearch.index.engine.VersionConflictEngineException;
-import org.elasticsearch.index.shard.MergeSchedulerConfig;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.Version;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
@@ -39,19 +35,22 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
+import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.VersionType;
+import org.elasticsearch.index.cache.IndexCacheModule;
import org.elasticsearch.index.cache.query.QueryCacheStats;
+import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.shard.MergePolicyConfig;
+import org.elasticsearch.index.shard.MergeSchedulerConfig;
import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.io.IOException;
import java.util.EnumSet;
@@ -73,7 +72,6 @@ import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.SUITE, numDataNodes = 2, numClientNodes = 0, randomDynamicTemplates = false)
@SuppressCodecs("*") // requires custom completion format
public class IndexStatsIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
//Filter/Query cache is cleaned periodically, default is 60s, so make sure it runs often. Thread.sleep for 60s is bad
@@ -84,7 +82,6 @@ public class IndexStatsIT extends ESIntegTestCase {
.build();
}
- @Test
public void testFieldDataStats() {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 2)).execute().actionGet();
ensureGreen();
@@ -129,7 +126,6 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testClearAllCaches() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(Settings.settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2))
@@ -186,7 +182,6 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0l));
}
- @Test
public void testQueryCache() throws Exception {
assertAcked(client().admin().indices().prepareCreate("idx").setSettings(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED, true).get());
ensureGreen();
@@ -277,9 +272,7 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l));
}
-
- @Test
- public void nonThrottleStats() throws Exception {
+ public void testNonThrottleStats() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(Settings.builder()
.put(IndexStore.INDEX_STORE_THROTTLE_TYPE, "merge")
@@ -311,8 +304,7 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(stats.getPrimaries().getIndexing().getTotal().getThrottleTimeInMillis(), equalTo(0l));
}
- @Test
- public void throttleStats() throws Exception {
+ public void testThrottleStats() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(Settings.builder()
.put(IndexStore.INDEX_STORE_THROTTLE_TYPE, "merge")
@@ -361,8 +353,7 @@ public class IndexStatsIT extends ESIntegTestCase {
logger.info("test: test done");
}
- @Test
- public void simpleStats() throws Exception {
+ public void testSimpleStats() throws Exception {
createIndex("test1", "test2");
ensureGreen();
@@ -491,7 +482,6 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(stats.getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(3L));
}
- @Test
public void testMergeStats() {
createIndex("test1");
@@ -528,7 +518,6 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(stats.getTotal().getMerge().getTotal(), greaterThan(0l));
}
- @Test
public void testSegmentsStats() {
assertAcked(prepareCreate("test1", 2, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))));
ensureGreen();
@@ -555,7 +544,6 @@ public class IndexStatsIT extends ESIntegTestCase {
assertThat(stats.getTotal().getSegments().getMemoryInBytes(), greaterThan(0l));
}
- @Test
public void testAllFlags() throws Exception {
// rely on 1 replica for this tests
createIndex("test1");
@@ -617,7 +605,6 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testEncodeDecodeCommonStats() throws IOException {
CommonStatsFlags flags = new CommonStatsFlags();
Flag[] values = CommonStatsFlags.Flag.values();
@@ -661,7 +648,6 @@ public class IndexStatsIT extends ESIntegTestCase {
}
}
- @Test
public void testFlagOrdinalOrder() {
Flag[] flags = new Flag[]{Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh,
Flag.QueryCache, Flag.FieldData, Flag.Docs, Flag.Warmer, Flag.Percolate, Flag.Completion, Flag.Segments,
@@ -673,9 +659,7 @@ public class IndexStatsIT extends ESIntegTestCase {
}
}
- @Test
public void testMultiIndex() throws Exception {
-
createIndex("test1");
createIndex("test2");
@@ -714,9 +698,7 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testFieldDataFieldsParam() throws Exception {
-
createIndex("test1");
ensureGreen();
@@ -761,9 +743,7 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testCompletionFieldsParam() throws Exception {
-
assertAcked(prepareCreate("test1")
.addMapping(
"bar",
@@ -808,9 +788,7 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testGroupsParam() throws Exception {
-
createIndex("test1");
ensureGreen();
@@ -844,9 +822,7 @@ public class IndexStatsIT extends ESIntegTestCase {
}
- @Test
public void testTypesParam() throws Exception {
-
createIndex("test1");
createIndex("test2");
diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
index 8562b0991c..b56e3ad364 100644
--- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
@@ -27,7 +27,13 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.IndexRoutingTable;
+import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
+import org.elasticsearch.cluster.routing.RoutingNode;
+import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
+import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider;
@@ -44,13 +50,17 @@ import org.elasticsearch.indices.recovery.RecoverySource;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.disruption.BlockClusterStateProcessing;
import org.elasticsearch.test.disruption.SingleNodeDisruption;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.ConnectTransportException;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.nio.file.Files;
@@ -63,7 +73,6 @@ import java.util.concurrent.TimeUnit;
import static java.lang.Thread.sleep;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -72,7 +81,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class IndicesStoreIntegrationIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) { // simplify this and only use a single data path
return Settings.settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put("path.data", "")
@@ -94,8 +102,7 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
// so we cannot check state consistency of this cluster
}
- @Test
- public void indexCleanup() throws Exception {
+ public void testIndexCleanup() throws Exception {
final String masterNode = internalCluster().startNode(Settings.builder().put("node.data", false));
final String node_1 = internalCluster().startNode(Settings.builder().put("node.master", false));
final String node_2 = internalCluster().startNode(Settings.builder().put("node.master", false));
@@ -164,9 +171,8 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
}
- @Test
/* Test that shard is deleted in case ShardActiveRequest after relocation and next incoming cluster state is an index delete. */
- public void shardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted() throws Exception {
+ public void testShardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted() throws Exception {
final String node_1 = internalCluster().startNode();
logger.info("--> creating index [test] with one shard and on replica");
assertAcked(prepareCreate("test").setSettings(
@@ -226,8 +232,7 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
assertThat(Files.exists(indexDirectory(node_2, "test")), equalTo(false));
}
- @Test
- public void shardsCleanup() throws Exception {
+ public void testShardsCleanup() throws Exception {
final String node_1 = internalCluster().startNode();
final String node_2 = internalCluster().startNode();
logger.info("--> creating index [test] with one shard and on replica");
@@ -286,8 +291,6 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
assertThat(waitForShardDeletion(node_4, "test", 0), equalTo(false));
}
-
- @Test
@TestLogging("cluster.service:TRACE")
public void testShardActiveElsewhereDoesNotDeleteAnother() throws Exception {
InternalTestCluster.Async<String> masterFuture = internalCluster().startNodeAsync(
@@ -367,7 +370,6 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
}
- @Test
public void testShardActiveElseWhere() throws Exception {
List<String> nodes = internalCluster().startNodesAsync(2).get();
diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java
index 890b94d158..ec6a3b3849 100644
--- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java
@@ -26,12 +26,14 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
+import org.elasticsearch.cluster.routing.TestShardRouting;
+import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@@ -39,12 +41,10 @@ import java.util.Set;
import static org.elasticsearch.Version.CURRENT;
import static org.elasticsearch.test.VersionUtils.randomVersion;
-import static org.hamcrest.Matchers.is;
/**
*/
public class IndicesStoreTests extends ESTestCase {
-
private final static ShardRoutingState[] NOT_STARTED_STATES;
static {
@@ -63,8 +63,7 @@ public class IndicesStoreTests extends ESTestCase {
indicesStore = new IndicesStore();
}
- @Test
- public void testShardCanBeDeleted_noShardRouting() throws Exception {
+ public void testShardCanBeDeletedNoShardRouting() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -75,8 +74,7 @@ public class IndicesStoreTests extends ESTestCase {
assertFalse(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
- @Test
- public void testShardCanBeDeleted_noShardStarted() throws Exception {
+ public void testShardCanBeDeletedNoShardStarted() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -103,8 +101,7 @@ public class IndicesStoreTests extends ESTestCase {
assertFalse(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
- @Test
- public void testShardCanBeDeleted_shardExistsLocally() throws Exception {
+ public void testShardCanBeDeletedShardExistsLocally() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -126,8 +123,7 @@ public class IndicesStoreTests extends ESTestCase {
assertFalse(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
- @Test
- public void testShardCanBeDeleted_nodeNotInList() throws Exception {
+ public void testShardCanBeDeletedNodeNotInList() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -147,8 +143,7 @@ public class IndicesStoreTests extends ESTestCase {
assertFalse(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
- @Test
- public void testShardCanBeDeleted_nodeVersion() throws Exception {
+ public void testShardCanBeDeletedNodeVersion() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -169,8 +164,7 @@ public class IndicesStoreTests extends ESTestCase {
assertTrue(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
- @Test
- public void testShardCanBeDeleted_relocatingNode() throws Exception {
+ public void testShardCanBeDeletedRelocatingNode() throws Exception {
int numShards = randomIntBetween(1, 7);
int numReplicas = randomInt(2);
@@ -194,5 +188,4 @@ public class IndicesStoreTests extends ESTestCase {
// shard exist on other node (abc and def)
assertTrue(indicesStore.shardCanBeDeleted(clusterState.build(), routingTable.build()));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java
index c1c41cf6c3..c46c038529 100644
--- a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResp
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.io.IOException;
@@ -33,8 +32,6 @@ import static org.hamcrest.Matchers.hasSize;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndexTemplateBlocksIT extends ESIntegTestCase {
-
- @Test
public void testIndexTemplatesWithBlocks() throws IOException {
// creates a simple index template
client().admin().indices().preparePutTemplate("template_blocks")
diff --git a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java
index f67e12095f..ee0f874808 100644
--- a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java
@@ -26,12 +26,10 @@ import org.elasticsearch.cluster.metadata.IndexTemplateFilter;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.util.Collection;
@@ -41,13 +39,11 @@ import static org.hamcrest.core.IsNull.notNullValue;
@ClusterScope(scope = Scope.SUITE)
public class IndexTemplateFilteringIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(TestPlugin.class);
}
- @Test
public void testTemplateFiltering() throws Exception {
client().admin().indices().preparePutTemplate("template1")
.setTemplate("test*")
@@ -70,7 +66,6 @@ public class IndexTemplateFilteringIT extends ESIntegTestCase {
assertThat(metadata.get("type2"), notNullValue());
}
-
public static class TestFilter implements IndexTemplateFilter {
@Override
public boolean apply(CreateIndexClusterStateUpdateRequest request, IndexTemplateMetaData template) {
diff --git a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
index 1084d4d27d..b9da71d75a 100644
--- a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
@@ -29,15 +29,14 @@ import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
+import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.common.ParsingException;
import org.elasticsearch.indices.IndexTemplateAlreadyExistsException;
import org.elasticsearch.indices.InvalidAliasNameException;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -64,9 +63,7 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class SimpleIndexTemplateIT extends ESIntegTestCase {
-
- @Test
- public void simpleIndexTemplateTests() throws Exception {
+ public void testSimpleIndexTemplateTests() throws Exception {
// clean all templates setup by the framework.
client().admin().indices().prepareDeleteTemplate("*").get();
@@ -139,7 +136,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).field("field2").value().toString(), equalTo("value 2"));
}
- @Test
public void testDeleteIndexTemplate() throws Exception {
final int existingTemplates = admin().cluster().prepareState().execute().actionGet().getState().metaData().templates().size();
logger.info("--> put template_1 and template_2");
@@ -186,7 +182,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(admin().cluster().prepareState().execute().actionGet().getState().metaData().templates().size(), equalTo(0));
}
- @Test
public void testThatGetIndexTemplatesWorks() throws Exception {
logger.info("--> put template_1");
client().admin().indices().preparePutTemplate("template_1")
@@ -210,7 +205,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(getTemplate2Response.getIndexTemplates(), hasSize(0));
}
- @Test
public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
logger.info("--> put template_1");
client().admin().indices().preparePutTemplate("template_1")
@@ -271,7 +265,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(templateNames, containsInAnyOrder("template_1", "template_2"));
}
- @Test
public void testThatInvalidGetIndexTemplatesFails() throws Exception {
logger.info("--> get template null");
testExpectActionRequestValidationException((String[])null);
@@ -292,7 +285,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
"get template with " + Arrays.toString(names));
}
- @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/8802")
public void testBrokenMapping() throws Exception {
// clean all templates setup by the framework.
@@ -320,7 +312,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testInvalidSettings() throws Exception {
// clean all templates setup by the framework.
client().admin().indices().prepareDeleteTemplate("*").get();
@@ -398,7 +389,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(types, containsInAnyOrder("typeX", "typeY", "typeZ"));
}
- @Test
public void testIndexTemplateWithAliasesInSource() {
client().admin().indices().preparePutTemplate("template_1")
.setSource("{\n" +
@@ -434,7 +424,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).type(), equalTo("type2"));
}
- @Test
public void testIndexTemplateWithAliasesSource() {
client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -473,7 +462,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).type(), equalTo("type2"));
}
- @Test
public void testDuplicateAlias() throws Exception {
client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -487,9 +475,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(response.getIndexTemplates().get(0).getAliases().get("my_alias").filter().string(), containsString("\"value1\""));
}
- @Test
public void testAliasInvalidFilterValidJson() throws Exception {
-
//invalid filter but valid json: put index template works fine, fails during index creation
client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -510,9 +496,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testAliasInvalidFilterInvalidJson() throws Exception {
-
//invalid json: put index template fails
PutIndexTemplateRequestBuilder putIndexTemplateRequestBuilder = client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -528,9 +512,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
assertThat(response.getIndexTemplates().size(), equalTo(0));
}
- @Test
public void testAliasNameExistingIndex() throws Exception {
-
createIndex("index");
client().admin().indices().preparePutTemplate("template_1")
@@ -545,7 +527,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testAliasEmptyName() throws Exception {
PutIndexTemplateRequestBuilder putIndexTemplateRequestBuilder = client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -559,7 +540,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testAliasWithMultipleIndexRoutings() throws Exception {
PutIndexTemplateRequestBuilder putIndexTemplateRequestBuilder = client().admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
@@ -573,7 +553,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testMultipleAliasesPrecedence() throws Exception {
client().admin().indices().preparePutTemplate("template1")
.setTemplate("*")
@@ -611,7 +590,6 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
}
}
- @Test
public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exception {
// Indexing into a should succeed, because the field mapping for field 'field' is defined in the test mapping.
client().admin().indices().preparePutTemplate("template1")
diff --git a/core/src/test/java/org/elasticsearch/indices/warmer/GatewayIndicesWarmerIT.java b/core/src/test/java/org/elasticsearch/indices/warmer/GatewayIndicesWarmerIT.java
index 1c1b193986..7c5a154ebc 100644
--- a/core/src/test/java/org/elasticsearch/indices/warmer/GatewayIndicesWarmerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/warmer/GatewayIndicesWarmerIT.java
@@ -28,11 +28,10 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster.RestartCallback;
import org.hamcrest.Matchers;
-import org.junit.Test;
-import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -40,12 +39,9 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(numDataNodes =0, scope= Scope.TEST)
public class GatewayIndicesWarmerIT extends ESIntegTestCase {
-
private final ESLogger logger = Loggers.getLogger(GatewayIndicesWarmerIT.class);
- @Test
public void testStatePersistence() throws Exception {
-
logger.info("--> starting 1 nodes");
internalCluster().startNode();
diff --git a/core/src/test/java/org/elasticsearch/indices/warmer/IndicesWarmerBlocksIT.java b/core/src/test/java/org/elasticsearch/indices/warmer/IndicesWarmerBlocksIT.java
index 0ee4ab6329..62bac50b0a 100644
--- a/core/src/test/java/org/elasticsearch/indices/warmer/IndicesWarmerBlocksIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/warmer/IndicesWarmerBlocksIT.java
@@ -21,17 +21,23 @@ package org.elasticsearch.indices.warmer;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
+
import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersResponse;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Arrays;
import java.util.List;
-import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_METADATA_BLOCK;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_READ_BLOCK;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_READ_ONLY_BLOCK;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
+import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.metadata.MetaData.CLUSTER_READ_ONLY_BLOCK;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
@@ -39,8 +45,6 @@ import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesWarmerBlocksIT extends ESIntegTestCase {
-
- @Test
public void testPutWarmerWithBlocks() {
createIndex("test-blocks");
ensureGreen("test-blocks");
@@ -91,7 +95,6 @@ public class IndicesWarmerBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testGetWarmerWithBlocks() {
createIndex("test-blocks");
ensureGreen("test-blocks");
@@ -124,7 +127,6 @@ public class IndicesWarmerBlocksIT extends ESIntegTestCase {
}
}
- @Test
public void testDeleteWarmerWithBlocks() {
createIndex("test-blocks");
ensureGreen("test-blocks");
diff --git a/core/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerIT.java b/core/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerIT.java
index 82e08588b5..8470020f82 100644
--- a/core/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.search.warmer.IndexWarmerMissingException;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.List;
@@ -44,9 +43,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
public class SimpleIndicesWarmerIT extends ESIntegTestCase {
-
- @Test
- public void simpleWarmerTests() {
+ public void testSimpleWarmers() {
createIndex("test");
ensureGreen();
@@ -99,8 +96,7 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
assertThat(getWarmersResponse.getWarmers().size(), equalTo(0));
}
- @Test
- public void templateWarmer() {
+ public void testTtemplateWarmer() {
client().admin().indices().preparePutTemplate("template_1")
.setSource("{\n" +
" \"template\" : \"*\",\n" +
@@ -129,8 +125,7 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "2").setSource("field", "value2").setRefresh(true).execute().actionGet();
}
- @Test
- public void createIndexWarmer() {
+ public void testCreateIndexWarmer() {
assertAcked(prepareCreate("test")
.setSource("{\n" +
" \"warmers\" : {\n" +
@@ -154,8 +149,7 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "2").setSource("field", "value2").setRefresh(true).execute().actionGet();
}
- @Test
- public void deleteNonExistentIndexWarmerTest() {
+ public void testDeleteNonExistentIndexWarmer() {
createIndex("test");
try {
client().admin().indices().prepareDeleteWarmer().setIndices("test").setNames("foo").execute().actionGet();
@@ -165,8 +159,8 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
}
}
- @Test // issue 8991
- public void deleteAllIndexWarmerDoesNotThrowWhenNoWarmers() {
+ // issue 8991
+ public void testDeleteAllIndexWarmerDoesNotThrowWhenNoWarmers() {
createIndex("test");
DeleteWarmerResponse deleteWarmerResponse = client().admin().indices().prepareDeleteWarmer()
.setIndices("test").setNames("_all").execute().actionGet();
@@ -177,8 +171,7 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
assertThat(deleteWarmerResponse.isAcknowledged(), equalTo(true));
}
- @Test
- public void deleteIndexWarmerTest() {
+ public void testDeleteIndexWarmerTest() {
createIndex("test");
ensureGreen();
@@ -201,8 +194,8 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
assertThat(getWarmersResponse.warmers().size(), equalTo(0));
}
- @Test // issue 3246
- public void ensureThatIndexWarmersCanBeChangedOnRuntime() throws Exception {
+ // issue 3246
+ public void testEnsureThatIndexWarmersCanBeChangedOnRuntime() throws Exception {
createIndex("test");
ensureGreen();
@@ -224,8 +217,7 @@ public class SimpleIndicesWarmerIT extends ESIntegTestCase {
assertThat(getWarmerRuns(), equalTo(warmerRunsAfterDisabling));
}
- @Test
- public void gettingAllWarmersUsingAllAndWildcardsShouldWork() throws Exception {
+ public void testGettingAllWarmersUsingAllAndWildcardsShouldWork() throws Exception {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java b/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java
index 7716bf7300..b661e78532 100644
--- a/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java
+++ b/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java
@@ -29,18 +29,18 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
public class SimpleMgetIT extends ESIntegTestCase {
-
- @Test
public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException {
createIndex("test");
ensureYellow();
@@ -74,7 +74,6 @@ public class SimpleMgetIT extends ESIntegTestCase {
}
- @Test
public void testThatParentPerDocumentIsSupported() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.addMapping("test", jsonBuilder()
@@ -106,7 +105,6 @@ public class SimpleMgetIT extends ESIntegTestCase {
}
@SuppressWarnings("unchecked")
- @Test
public void testThatSourceFilteringIsSupported() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureYellow();
@@ -146,7 +144,6 @@ public class SimpleMgetIT extends ESIntegTestCase {
}
}
- @Test
public void testThatRoutingPerDocumentIsSupported() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.builder()
diff --git a/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java
index 383bd0c891..26a56529e0 100644
--- a/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java
@@ -22,15 +22,14 @@ package org.elasticsearch.monitor.fs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.isEmptyOrNullString;
+import static org.hamcrest.Matchers.not;
public class FsProbeTests extends ESTestCase {
-
- @Test
public void testFsInfo() throws IOException {
try (NodeEnvironment env = newNodeEnvironment()) {
FsProbe probe = new FsProbe(Settings.EMPTY, env);
diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmStatsTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmStatsTests.java
index 011edcb5b7..d0b1d54171 100644
--- a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmStatsTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmStatsTests.java
@@ -22,17 +22,17 @@ package org.elasticsearch.monitor.jvm;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
public class JvmStatsTests extends ESTestCase {
-
- @Test
public void testJvmStats() throws IOException {
JvmStats stats = JvmStats.jvmStats();
assertNotNull(stats);
diff --git a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java
index 6b8818a493..4d1dde5f17 100644
--- a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java
@@ -21,15 +21,18 @@ package org.elasticsearch.monitor.os;
import org.apache.lucene.util.Constants;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class OsProbeTests extends ESTestCase {
-
OsProbe probe = OsProbe.getInstance();
- @Test
public void testOsInfo() {
OsInfo info = probe.osInfo();
assertNotNull(info);
@@ -40,7 +43,6 @@ public class OsProbeTests extends ESTestCase {
assertThat(info.getAvailableProcessors(), equalTo(Runtime.getRuntime().availableProcessors()));
}
- @Test
public void testOsStats() {
OsStats stats = probe.osStats();
assertNotNull(stats);
diff --git a/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java
index 18b5f7a7e1..181932513d 100644
--- a/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java
@@ -22,16 +22,19 @@ package org.elasticsearch.monitor.process;
import org.apache.lucene.util.Constants;
import org.elasticsearch.bootstrap.BootstrapInfo;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.monitor.jvm.JvmInfo.jvmInfo;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class ProcessProbeTests extends ESTestCase {
-
ProcessProbe probe = ProcessProbe.getInstance();
- @Test
public void testProcessInfo() {
ProcessInfo info = probe.processInfo();
assertNotNull(info);
@@ -40,7 +43,6 @@ public class ProcessProbeTests extends ESTestCase {
assertThat(info.isMlockall(), equalTo(BootstrapInfo.isMemoryLocked()));
}
- @Test
public void testProcessStats() {
ProcessStats stats = probe.processStats();
assertNotNull(stats);
diff --git a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
index 406cf68a98..5ae598ff2d 100644
--- a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
+++ b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
@@ -24,28 +24,25 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.client.Requests.nodesInfoRequest;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
/**
*
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleNodesInfoIT extends ESIntegTestCase {
-
static final class Fields {
static final String SITE_PLUGIN = "dummy";
static final String SITE_PLUGIN_DESCRIPTION = "This is a description for a dummy test site plugin.";
static final String SITE_PLUGIN_VERSION = "0.0.7-BOND-SITE";
}
-
- @Test
public void testNodesInfos() throws Exception {
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
final String node_1 = nodesIds.get(0);
diff --git a/core/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationIT.java b/core/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationIT.java
index 3e2d0e70d9..49d22b87bf 100644
--- a/core/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationIT.java
@@ -22,7 +22,6 @@ package org.elasticsearch.operateAllIndices;
import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@@ -31,8 +30,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class DestructiveOperationsIntegrationIT extends ESIntegTestCase {
-
- @Test
// One test for test performance, since cluster scope is test
// The cluster scope is test b/c we can't clear cluster settings.
public void testDestructiveOperations() throws Exception {
diff --git a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java
index e6282d803b..a0751dffac 100644
--- a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java
+++ b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.rest.client.http.HttpDeleteWithEntity;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
import static org.hamcrest.Matchers.is;
@@ -39,7 +38,6 @@ import static org.hamcrest.Matchers.is;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 1)
public class DetailedErrorsDisabledIT extends ESIntegTestCase {
-
// Build our cluster settings
@Override
protected Settings nodeSettings(int nodeOrdinal) {
@@ -50,7 +48,6 @@ public class DetailedErrorsDisabledIT extends ESIntegTestCase {
.build();
}
- @Test
public void testThatErrorTraceParamReturns400() throws Exception {
// Make the HTTP request
HttpResponse response = new HttpRequestBuilder(HttpClients.createDefault())
diff --git a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsEnabledIT.java b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsEnabledIT.java
index 050d88c2f3..935b4e21ad 100644
--- a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsEnabledIT.java
+++ b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsEnabledIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.rest.client.http.HttpDeleteWithEntity;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
@@ -39,8 +38,6 @@ import static org.hamcrest.Matchers.not;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 1)
public class DetailedErrorsEnabledIT extends ESIntegTestCase {
-
- // Build our cluster settings
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
@@ -49,7 +46,6 @@ public class DetailedErrorsEnabledIT extends ESIntegTestCase {
.build();
}
- @Test
public void testThatErrorTraceWorksByDefault() throws Exception {
// Make the HTTP request
HttpResponse response = new HttpRequestBuilder(HttpClients.createDefault())
diff --git a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java
index 4a6b835c83..b11f24377a 100644
--- a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Random;
import java.util.Set;
@@ -41,15 +40,19 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.percolator.PercolatorTestUtil.convertFromTextArray;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.arrayContaining;
+import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.emptyArray;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class ConcurrentPercolatorIT extends ESIntegTestCase {
-
- @Test
public void testSimpleConcurrentPercolator() throws Exception {
// We need to index a document / define mapping, otherwise field1 doesn't get reconized as number field.
// If we don't do this, then 'test2' percolate query gets parsed as a TermQuery and not a RangeQuery.
@@ -144,7 +147,6 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase {
assertThat(assertionError + " should be null", assertionError, nullValue());
}
- @Test
public void testConcurrentAddingAndPercolating() throws Exception {
assertAcked(prepareCreate("index").addMapping("type", "field1", "type=string", "field2", "type=string"));
ensureGreen();
@@ -291,7 +293,6 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase {
assertThat(exceptionsHolder.isEmpty(), equalTo(true));
}
- @Test
public void testConcurrentAddingAndRemovingWhilePercolating() throws Exception {
assertAcked(prepareCreate("index").addMapping("type", "field1", "type=string"));
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java
index 2eb763959f..7674ef83b5 100644
--- a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java
@@ -26,27 +26,33 @@ import org.elasticsearch.action.percolate.PercolateSourceBuilder;
import org.elasticsearch.client.Requests;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
-import static org.elasticsearch.common.xcontent.XContentFactory.*;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.percolator.PercolatorTestUtil.convertFromTextArray;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertMatchCount;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.arrayContaining;
+import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
public class MultiPercolatorIT extends ESIntegTestCase {
-
- @Test
public void testBasics() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string"));
ensureGreen();
@@ -116,7 +122,6 @@ public class MultiPercolatorIT extends ESIntegTestCase {
assertThat(item.getErrorMessage(), containsString("document missing"));
}
- @Test
public void testWithRouting() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string"));
ensureGreen();
@@ -195,7 +200,6 @@ public class MultiPercolatorIT extends ESIntegTestCase {
assertThat(item.getErrorMessage(), containsString("document missing"));
}
- @Test
public void testExistingDocsOnly() throws Exception {
createIndex("test");
@@ -265,7 +269,6 @@ public class MultiPercolatorIT extends ESIntegTestCase {
assertThat(response.items()[numPercolateRequest].getResponse().getMatches().length, equalTo(numQueries));
}
- @Test
public void testWithDocsOnly() throws Exception {
createIndex("test");
ensureGreen();
@@ -338,8 +341,6 @@ public class MultiPercolatorIT extends ESIntegTestCase {
assertThat(response.items()[numPercolateRequest].getResponse().getMatches().length, equalTo(numQueries));
}
-
- @Test
public void testNestedMultiPercolation() throws IOException {
initNestedIndexAndPercolation();
MultiPercolateRequestBuilder mpercolate= client().prepareMultiPercolate();
diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorBackwardsCompatibilityIT.java
index f250e9231f..8254932c30 100644
--- a/core/src/test/java/org/elasticsearch/percolator/PercolatorBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorBackwardsCompatibilityIT.java
@@ -23,9 +23,8 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.percolate.PercolateResponse;
import org.elasticsearch.action.percolate.PercolateSourceBuilder;
import org.elasticsearch.index.percolator.PercolatorException;
-import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.index.query.QueryShardException;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@@ -36,8 +35,6 @@ import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class PercolatorBackwardsCompatibilityIT extends ESIntegTestCase {
-
- @Test
public void testPercolatorUpgrading() throws Exception {
// Simulates an index created on an node before 1.4.0 where the field resolution isn't strict.
assertAcked(prepareCreate("test")
@@ -53,7 +50,7 @@ public class PercolatorBackwardsCompatibilityIT extends ESIntegTestCase {
PercolateResponse response = client().preparePercolate().setIndices("test").setDocumentType("type")
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("field1", "value"))
.get();
- assertMatchCount(response, (long) numDocs);
+ assertMatchCount(response, numDocs);
// After upgrade indices, indices created before the upgrade allow that queries refer to fields not available in mapping
client().prepareIndex("test", PercolatorService.TYPE_NAME)
diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsIT.java
index c1326845b4..85783e3d45 100644
--- a/core/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsIT.java
@@ -31,7 +31,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -51,8 +50,6 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class PercolatorFacetsAndAggregationsIT extends ESIntegTestCase {
-
- @Test
// Just test the integration with facets and aggregations, not the facet and aggregation functionality!
public void testFacetsAndAggregations() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string", "field2", "type=string"));
@@ -115,7 +112,6 @@ public class PercolatorFacetsAndAggregationsIT extends ESIntegTestCase {
}
}
- @Test
// Just test the integration with facets and aggregations, not the facet and aggregation functionality!
public void testAggregationsAndPipelineAggregations() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string", "field2", "type=string"));
@@ -188,7 +184,6 @@ public class PercolatorFacetsAndAggregationsIT extends ESIntegTestCase {
}
}
- @Test
public void testSignificantAggs() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -199,7 +194,6 @@ public class PercolatorFacetsAndAggregationsIT extends ESIntegTestCase {
assertNoFailures(response);
}
- @Test
public void testSingleShardAggregations() throws Exception {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("SETTING_NUMBER_OF_SHARDS", 1))
.addMapping("type", "field1", "type=string", "field2", "type=string"));
diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java
index 306b140428..f627e0217e 100644
--- a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java
@@ -50,27 +50,59 @@ import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableSet;
+import java.util.Set;
+import java.util.TreeSet;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
import static org.elasticsearch.common.settings.Settings.builder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.common.xcontent.XContentFactory.*;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
+import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
+import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.fieldValueFactorFunction;
import static org.elasticsearch.percolator.PercolatorTestUtil.convertFromTextArray;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertMatchCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.arrayContaining;
+import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.emptyArray;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class PercolatorIT extends ESIntegTestCase {
-
- @Test
public void testSimple1() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -149,7 +181,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testSimple2() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=long,doc_values=true"));
ensureGreen();
@@ -201,7 +232,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("test1"));
}
- @Test
public void testPercolateQueriesWithRouting() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 2))
@@ -243,8 +273,7 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response.getMatches(), arrayWithSize(50));
}
- @Test
- public void storePeroclateQueriesOnRecreatedIndex() throws Exception {
+ public void testStorePeroclateQueriesOnRecreatedIndex() throws Exception {
createIndex("test");
ensureGreen();
@@ -273,9 +302,8 @@ public class PercolatorIT extends ESIntegTestCase {
.execute().actionGet();
}
- @Test
// see #2814
- public void percolateCustomAnalyzer() throws Exception {
+ public void testPercolateCustomAnalyzer() throws Exception {
Builder builder = builder();
builder.put("index.analysis.analyzer.lwhitespacecomma.tokenizer", "whitespacecomma");
builder.putArray("index.analysis.analyzer.lwhitespacecomma.filter", "lowercase");
@@ -312,8 +340,7 @@ public class PercolatorIT extends ESIntegTestCase {
}
- @Test
- public void createIndexAndThenRegisterPercolator() throws Exception {
+ public void testCreateIndexAndThenRegisterPercolator() throws Exception {
prepareCreate("test")
.addMapping("type1", "field1", "type=string")
.get();
@@ -363,8 +390,7 @@ public class PercolatorIT extends ESIntegTestCase {
assertHitCount(countResponse, 0l);
}
- @Test
- public void multiplePercolators() throws Exception {
+ public void testMultiplePercolators() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string"));
ensureGreen();
@@ -404,8 +430,7 @@ public class PercolatorIT extends ESIntegTestCase {
}
- @Test
- public void dynamicAddingRemovingQueries() throws Exception {
+ public void testDynamicAddingRemovingQueries() throws Exception {
assertAcked(
prepareCreate("test")
.addMapping("type1", "field1", "type=string")
@@ -479,7 +504,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(percolate.getMatches(), emptyArray());
}
- @Test
public void testPercolateStatistics() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -564,7 +588,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(percolateSumTime, greaterThan(0l));
}
- @Test
public void testPercolatingExistingDocs() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -638,7 +661,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(3).type(), equalTo("type"));
}
- @Test
public void testPercolatingExistingDocs_routing() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -704,7 +726,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("4"));
}
- @Test
public void testPercolatingExistingDocs_versionCheck() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -765,7 +786,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4"));
}
- @Test
public void testPercolateMultipleIndicesAndAliases() throws Exception {
createIndex("test1", "test2");
ensureGreen();
@@ -843,7 +863,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testPercolateWithAliasFilter() throws Exception {
assertAcked(prepareCreate("my-index")
.addMapping(PercolatorService.TYPE_NAME, "a", "type=string,index=not_analyzed")
@@ -921,7 +940,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response.getCount(), equalTo(0l));
}
- @Test
public void testCountPercolation() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -990,7 +1008,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testCountPercolatingExistingDocs() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -1052,7 +1069,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response.getMatches(), nullValue());
}
- @Test
public void testPercolateSizingWithQueryAndFilter() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -1141,7 +1157,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testPercolateScoreAndSorting() throws Exception {
createIndex("my-index");
ensureGreen();
@@ -1231,7 +1246,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testPercolateSortingWithNoSize() throws Exception {
createIndex("my-index");
ensureGreen();
@@ -1269,8 +1283,7 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
- public void testPercolateSorting_unsupportedField() throws Exception {
+ public void testPercolateSortingUnsupportedField() throws Exception {
client().admin().indices().prepareCreate("my-index")
.addMapping("my-type", "field", "type=string")
.addMapping(PercolatorService.TYPE_NAME, "level", "type=integer", "query", "type=object,enabled=false")
@@ -1297,7 +1310,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response.getShardFailures()[0].reason(), containsString("Only _score desc is supported"));
}
- @Test
public void testPercolateOnEmptyIndex() throws Exception {
client().admin().indices().prepareCreate("my-index").execute().actionGet();
ensureGreen();
@@ -1311,7 +1323,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertMatchCount(response, 0l);
}
- @Test
public void testPercolateNotEmptyIndexButNoRefresh() throws Exception {
client().admin().indices().prepareCreate("my-index")
.setSettings(settingsBuilder().put("index.refresh_interval", -1))
@@ -1331,7 +1342,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertMatchCount(response, 0l);
}
- @Test
public void testPercolatorWithHighlighting() throws Exception {
StringBuilder fieldMapping = new StringBuilder("type=string")
.append(",store=").append(randomBoolean());
@@ -1547,8 +1557,7 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(matches[4].getHighlightFields().get("field1").fragments()[0].string(), equalTo("The quick brown <em>fox</em> jumps over the lazy dog"));
}
- @Test
- public void percolateNonMatchingConstantScoreQuery() throws Exception {
+ public void testPercolateNonMatchingConstantScoreQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("doc", "message", "type=string"));
ensureGreen();
@@ -1572,7 +1581,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertMatchCount(percolate, 0l);
}
- @Test
public void testNestedPercolation() throws IOException {
initNestedIndexAndPercolation();
PercolateResponse response = client().preparePercolate().setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc(getNotMatchingNestedDoc())).setIndices("nestedindex").setDocumentType("company").get();
@@ -1582,8 +1590,7 @@ public class PercolatorIT extends ESIntegTestCase {
assertEquals(response.getMatches()[0].getId().string(), "Q");
}
- @Test
- public void makeSureNonNestedDocumentDoesNotTriggerAssertion() throws IOException {
+ public void testNonNestedDocumentDoesNotTriggerAssertion() throws IOException {
initNestedIndexAndPercolation();
XContentBuilder doc = jsonBuilder();
doc.startObject();
@@ -1592,7 +1599,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertNoFailures(response);
}
- @Test
public void testNestedPercolationOnExistingDoc() throws IOException {
initNestedIndexAndPercolation();
client().prepareIndex("nestedindex", "company", "notmatching").setSource(getNotMatchingNestedDoc()).get();
@@ -1605,7 +1611,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertEquals(response.getMatches()[0].getId().string(), "Q");
}
- @Test
public void testPercolationWithDynamicTemplates() throws Exception {
assertAcked(prepareCreate("idx").addMapping("type", jsonBuilder().startObject().startObject("type")
.field("dynamic", false)
@@ -1662,7 +1667,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(percolateResponse.getMatches()[0].getId().string(), equalTo("2"));
}
- @Test
public void testUpdateMappingDynamicallyWhilePercolating() throws Exception {
createIndex("test");
ensureSearchable();
@@ -1691,7 +1695,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(((Map<String, String>) properties.get("field2")).get("type"), equalTo("string"));
}
- @Test
public void testDontReportDeletedPercolatorDocs() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
ensureGreen();
@@ -1714,7 +1717,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1"));
}
- @Test
public void testAddQueryWithNoMapping() throws Exception {
client().admin().indices().prepareCreate("test").get();
ensureGreen();
@@ -1738,7 +1740,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testPercolatorQueryWithNowRange() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("my-type", "timestamp", "type=date,format=epoch_millis")
@@ -1798,7 +1799,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
// issue
- @Test
public void testNestedDocFilter() throws IOException {
String mapping = "{\n" +
" \"doc\": {\n" +
@@ -1935,7 +1935,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertMatchCount(response, 3l);
}
- @Test
public void testMapUnmappedFieldAsString() throws IOException{
// If index.percolator.map_unmapped_fields_as_string is set to true, unmapped field is mapped as an analyzed string.
Settings.Builder settings = Settings.settingsBuilder()
@@ -1954,7 +1953,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response1.getMatches(), arrayWithSize(1));
}
- @Test
public void testFailNicelyWithInnerHits() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject()
.startObject("mapping")
@@ -1982,7 +1980,6 @@ public class PercolatorIT extends ESIntegTestCase {
}
}
- @Test
public void testParentChild() throws Exception {
// We don't fail p/c queries, but those queries are unusable because only a single document can be provided in
// the percolate api
@@ -1993,7 +1990,6 @@ public class PercolatorIT extends ESIntegTestCase {
.execute().actionGet();
}
- @Test
public void testPercolateDocumentWithParentField() throws Exception {
assertAcked(prepareCreate("index").addMapping("child", "_parent", "type=parent").addMapping("parent"));
client().prepareIndex("index", PercolatorService.TYPE_NAME, "1")
@@ -2009,7 +2005,6 @@ public class PercolatorIT extends ESIntegTestCase {
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
}
- @Test
public void testFilterByNow() throws Exception {
client().prepareIndex("index", PercolatorService.TYPE_NAME, "1")
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).field("created", "2015-07-10T14:41:54+0000").endObject())
@@ -2024,6 +2019,5 @@ public class PercolatorIT extends ESIntegTestCase {
.get();
assertMatchCount(response, 1);
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java
index 935b5f8260..db66069584 100644
--- a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java
@@ -33,7 +33,8 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -47,8 +48,6 @@ import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.percolator.PercolatorTestUtil.convertFromTextArray;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertMatchCount;
@@ -61,13 +60,11 @@ import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0)
public class RecoveryPercolatorIT extends ESIntegTestCase {
-
@Override
protected int numberOfShards() {
return 1;
}
- @Test
public void testRestartNodePercolator1() throws Exception {
internalCluster().startNode();
assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string").addMapping(PercolatorService.TYPE_NAME, "color", "type=string"));
@@ -104,7 +101,6 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
assertThat(percolate.getMatches(), arrayWithSize(1));
}
- @Test
public void testRestartNodePercolator2() throws Exception {
internalCluster().startNode();
assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string").addMapping(PercolatorService.TYPE_NAME, "color", "type=string"));
@@ -176,7 +172,6 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
assertThat(percolate.getMatches(), arrayWithSize(1));
}
- @Test
public void testLoadingPercolateQueriesDuringCloseAndOpen() throws Exception {
internalCluster().startNode();
internalCluster().startNode();
@@ -223,13 +218,11 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
assertThat(response.getMatches()[0].getId().string(), equalTo("100"));
}
- @Test
- public void testSinglePercolator_recovery() throws Exception {
+ public void testSinglePercolatorRecovery() throws Exception {
percolatorRecovery(false);
}
- @Test
- public void testMultiPercolator_recovery() throws Exception {
+ public void testMultiPercolatorRecovery() throws Exception {
percolatorRecovery(true);
}
diff --git a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java
index 7fbedca044..4b4d4a8423 100644
--- a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java
+++ b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@@ -48,7 +47,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class TTLPercolatorIT extends ESIntegTestCase {
-
private static final long PURGE_INTERVAL = 200;
@Override
@@ -63,7 +61,6 @@ public class TTLPercolatorIT extends ESIntegTestCase {
.build();
}
- @Test
public void testPercolatingWithTimeToLive() throws Exception {
final Client client = client();
ensureGreen();
@@ -155,8 +152,6 @@ public class TTLPercolatorIT extends ESIntegTestCase {
assertThat(percolateResponse.getMatches(), emptyArray());
}
-
- @Test
public void testEnsureTTLDoesNotCreateIndex() throws IOException, InterruptedException {
ensureGreen();
client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder()
@@ -207,8 +202,5 @@ public class TTLPercolatorIT extends ESIntegTestCase {
client().admin().indices().prepareCreate("test")
.addMapping("type1", typeMapping)
.execute().actionGet();
-
-
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluggableTransportModuleIT.java b/core/src/test/java/org/elasticsearch/plugins/PluggableTransportModuleIT.java
index a6ac6bf1c6..7831b7ca99 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluggableTransportModuleIT.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluggableTransportModuleIT.java
@@ -25,26 +25,30 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.DiscoveryModule;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.transport.AssertingLocalTransport;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.Transport;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportModule;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
/**
*
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 2)
public class PluggableTransportModuleIT extends ESIntegTestCase {
-
public static final AtomicInteger SENT_REQUEST_COUNTER = new AtomicInteger(0);
@Override
@@ -65,7 +69,6 @@ public class PluggableTransportModuleIT extends ESIntegTestCase {
return pluginList(CountingSentRequestsPlugin.class);
}
- @Test
public void testThatPluginFunctionalityIsLoadedWithoutConfiguration() throws Exception {
for (Transport transport : internalCluster().getInstances(Transport.class)) {
assertThat(transport, instanceOf(CountingAssertingLocalTransport.class));
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
index 27379dfa83..ba94b12f52 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
@@ -205,7 +205,7 @@ public class PluginInfoTests extends ESTestCase {
PluginInfo.readFromProperties(pluginDir);
fail("expected bogus elasticsearch version exception");
} catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().contains("version needs to contain major, minor and revision"));
+ assertTrue(e.getMessage().contains("version needs to contain major, minor, and revision"));
}
}
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginManagerCliTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginManagerCliTests.java
index f21609a5d5..f16f9981d9 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluginManagerCliTests.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluginManagerCliTests.java
@@ -21,19 +21,18 @@ package org.elasticsearch.plugins;
import org.elasticsearch.common.cli.CliTool;
import org.elasticsearch.common.cli.CliToolTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Path;
-import static org.elasticsearch.common.cli.CliTool.ExitStatus.OK_AND_EXIT;
import static org.elasticsearch.common.cli.CliTool.ExitStatus.IO_ERROR;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.common.cli.CliTool.ExitStatus.OK_AND_EXIT;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
public class PluginManagerCliTests extends CliToolTestCase {
-
- @Test
public void testHelpWorks() throws IOException {
CliToolTestCase.CaptureOutputTerminal terminal = new CliToolTestCase.CaptureOutputTerminal();
assertThat(new PluginManagerCliParser(terminal).execute(args("--help")), is(OK_AND_EXIT));
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java
index 81c834ab9a..8814a2110b 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
-import org.junit.Test;
import java.io.IOException;
import java.net.URL;
@@ -44,13 +43,11 @@ import static org.hamcrest.Matchers.is;
*
*/
public class PluginManagerUnitTests extends ESTestCase {
-
@After
public void cleanSystemProperty() {
System.clearProperty(PluginManager.PROPERTY_SUPPORT_STAGING_URLS);
}
- @Test
public void testThatConfigDirectoryCanBeOutsideOfElasticsearchHomeDirectory() throws IOException {
String pluginName = randomAsciiOfLength(10);
Path homeFolder = createTempDir();
@@ -68,7 +65,6 @@ public class PluginManagerUnitTests extends ESTestCase {
assertEquals(configDirPath, expectedDirPath);
}
- @Test
public void testSimplifiedNaming() throws IOException {
String pluginName = randomAsciiOfLength(10);
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
@@ -93,7 +89,6 @@ public class PluginManagerUnitTests extends ESTestCase {
assertThat(iterator.hasNext(), is(false));
}
- @Test
public void testOfficialPluginName() throws IOException {
String randomPluginName = randomFrom(new ArrayList<>(PluginManager.OFFICIAL_PLUGINS));
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName);
@@ -119,7 +114,6 @@ public class PluginManagerUnitTests extends ESTestCase {
assertThat(iterator.hasNext(), is(false));
}
- @Test
public void testGithubPluginName() throws IOException {
String user = randomAsciiOfLength(6);
String pluginName = randomAsciiOfLength(10);
@@ -129,7 +123,6 @@ public class PluginManagerUnitTests extends ESTestCase {
assertThat(handle.urls().get(0).toExternalForm(), is(new URL("https", "github.com", "/" + user + "/" + pluginName + "/" + "archive/master.zip").toExternalForm()));
}
- @Test
public void testDownloadHelperChecksums() throws Exception {
// Sanity check to make sure the checksum functions never change how they checksum things
assertEquals("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
diff --git a/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java b/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java
index d9580854c1..5d7b8068fe 100644
--- a/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java
+++ b/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java
@@ -22,14 +22,13 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.responseheader.TestResponseHeaderPlugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
import java.util.Collection;
import static org.elasticsearch.rest.RestStatus.OK;
import static org.elasticsearch.rest.RestStatus.UNAUTHORIZED;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus;
import static org.hamcrest.Matchers.equalTo;
@@ -38,7 +37,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class ResponseHeaderPluginIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
@@ -52,7 +50,6 @@ public class ResponseHeaderPluginIT extends ESIntegTestCase {
return pluginList(TestResponseHeaderPlugin.class);
}
- @Test
public void testThatSettingHeadersWorks() throws Exception {
ensureGreen();
HttpResponse response = httpClient().method("GET").path("/_protected").execute();
@@ -63,5 +60,4 @@ public class ResponseHeaderPluginIT extends ESIntegTestCase {
assertThat(authResponse, hasStatus(OK));
assertThat(authResponse.getHeaders().get("Secret"), equalTo("granted"));
}
-
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java b/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java
index 6e62fd9e67..4609ec16df 100644
--- a/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java
+++ b/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java
@@ -25,9 +25,9 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -35,8 +35,10 @@ import java.util.List;
import java.util.Locale;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.rest.RestStatus.*;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
+import static org.elasticsearch.rest.RestStatus.FORBIDDEN;
+import static org.elasticsearch.rest.RestStatus.MOVED_PERMANENTLY;
+import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
+import static org.elasticsearch.rest.RestStatus.OK;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus;
import static org.hamcrest.Matchers.containsString;
@@ -45,8 +47,6 @@ import static org.hamcrest.Matchers.containsString;
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class SitePluginIT extends ESIntegTestCase {
-
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Path pluginDir = getDataPath("/org/elasticsearch/test_plugins");
@@ -57,13 +57,13 @@ public class SitePluginIT extends ESIntegTestCase {
.build();
}
+ @Override
public HttpRequestBuilder httpClient() {
RequestConfig.Builder builder = RequestConfig.custom().setRedirectsEnabled(false);
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(builder.build()).build();
return new HttpRequestBuilder(httpClient).httpTransport(internalCluster().getDataNodeInstance(HttpServerTransport.class));
}
- @Test
public void testRedirectSitePlugin() throws Exception {
// We use an HTTP Client to test redirection
HttpResponse response = httpClient().method("GET").path("/_plugin/dummy").execute();
@@ -79,7 +79,6 @@ public class SitePluginIT extends ESIntegTestCase {
/**
* Test direct access to an existing file (index.html)
*/
- @Test
public void testAnyPage() throws Exception {
HttpResponse response = httpClient().path("/_plugin/dummy/index.html").execute();
assertThat(response, hasStatus(OK));
@@ -89,7 +88,6 @@ public class SitePluginIT extends ESIntegTestCase {
/**
* Test normalizing of path
*/
- @Test
public void testThatPathsAreNormalized() throws Exception {
// more info: https://www.owasp.org/index.php/Path_Traversal
List<String> notFoundUris = new ArrayList<>();
@@ -118,7 +116,6 @@ public class SitePluginIT extends ESIntegTestCase {
* Test case for #4845: https://github.com/elasticsearch/elasticsearch/issues/4845
* Serving _site plugins do not pick up on index.html for sub directories
*/
- @Test
public void testWelcomePageInSubDirs() throws Exception {
HttpResponse response = httpClient().path("/_plugin/subdir/dir/").execute();
assertThat(response, hasStatus(OK));
diff --git a/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java b/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java
index ed3062620b..1cde90d698 100644
--- a/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java
+++ b/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
import java.nio.file.Path;
@@ -39,7 +38,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus;
@ClusterScope(scope = SUITE, numDataNodes = 1)
public class SitePluginRelativePathConfigIT extends ESIntegTestCase {
-
private final Path root = PathUtils.get(".").toAbsolutePath().getRoot();
@Override
@@ -60,7 +58,6 @@ public class SitePluginRelativePathConfigIT extends ESIntegTestCase {
.build();
}
- @Test
public void testThatRelativePathsDontAffectPlugins() throws Exception {
HttpResponse response = httpClient().method("GET").path("/_plugin/dummy/").execute();
assertThat(response, hasStatus(OK));
@@ -83,6 +80,7 @@ public class SitePluginRelativePathConfigIT extends ESIntegTestCase {
return sb.toString();
}
+ @Override
public HttpRequestBuilder httpClient() {
CloseableHttpClient httpClient = HttpClients.createDefault();
return new HttpRequestBuilder(httpClient).httpTransport(internalCluster().getDataNodeInstance(HttpServerTransport.class));
diff --git a/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java b/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java
index 4ce213cbc3..cab052a1b0 100644
--- a/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java
+++ b/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java
@@ -27,10 +27,9 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
/**
@@ -38,7 +37,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitC
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0.0)
public class FullRollingRestartIT extends ESIntegTestCase {
-
protected void assertTimeout(ClusterHealthRequestBuilder requestBuilder) {
ClusterHealthResponse clusterHealth = requestBuilder.get();
if (clusterHealth.isTimedOut()) {
@@ -52,7 +50,6 @@ public class FullRollingRestartIT extends ESIntegTestCase {
return 1;
}
- @Test
public void testFullRollingRestart() throws Exception {
Settings settings = Settings.builder().put(ZenDiscovery.SETTING_JOIN_TIMEOUT, "30s").build();
internalCluster().startNode(settings);
diff --git a/core/src/test/java/org/elasticsearch/recovery/RecoveriesCollectionTests.java b/core/src/test/java/org/elasticsearch/recovery/RecoveriesCollectionTests.java
index 5a5f3163a4..4cad0b2bf0 100644
--- a/core/src/test/java/org/elasticsearch/recovery/RecoveriesCollectionTests.java
+++ b/core/src/test/java/org/elasticsearch/recovery/RecoveriesCollectionTests.java
@@ -34,7 +34,6 @@ import org.elasticsearch.indices.recovery.RecoveryStatus;
import org.elasticsearch.indices.recovery.RecoveryTarget;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.threadpool.ThreadPool;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
@@ -46,7 +45,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
public class RecoveriesCollectionTests extends ESSingleNodeTestCase {
-
final static RecoveryTarget.RecoveryListener listener = new RecoveryTarget.RecoveryListener() {
@Override
public void onRecoveryDone(RecoveryState state) {
@@ -59,7 +57,6 @@ public class RecoveriesCollectionTests extends ESSingleNodeTestCase {
}
};
- @Test
public void testLastAccessTimeUpdate() throws Exception {
createIndex();
final RecoveriesCollection collection = new RecoveriesCollection(logger, getInstanceFromNode(ThreadPool.class));
@@ -79,7 +76,6 @@ public class RecoveriesCollectionTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testRecoveryTimeout() throws InterruptedException {
createIndex();
final RecoveriesCollection collection = new RecoveriesCollection(logger, getInstanceFromNode(ThreadPool.class));
@@ -106,7 +102,6 @@ public class RecoveriesCollectionTests extends ESSingleNodeTestCase {
}
- @Test
public void testRecoveryCancellationNoPredicate() throws Exception {
createIndex();
final RecoveriesCollection collection = new RecoveriesCollection(logger, getInstanceFromNode(ThreadPool.class));
@@ -122,7 +117,6 @@ public class RecoveriesCollectionTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testRecoveryCancellationPredicate() throws Exception {
createIndex();
final RecoveriesCollection collection = new RecoveriesCollection(logger, getInstanceFromNode(ThreadPool.class));
diff --git a/core/src/test/java/org/elasticsearch/recovery/RecoverySettingsTests.java b/core/src/test/java/org/elasticsearch/recovery/RecoverySettingsTests.java
index a722e3ab02..b0288042ec 100644
--- a/core/src/test/java/org/elasticsearch/recovery/RecoverySettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/recovery/RecoverySettingsTests.java
@@ -22,18 +22,15 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.concurrent.TimeUnit;
public class RecoverySettingsTests extends ESSingleNodeTestCase {
-
@Override
protected boolean resetNodeAfterTest() {
return true;
}
- @Test
public void testAllSettingsAreDynamicallyUpdatable() {
innerTestSettings(RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE, randomIntBetween(1, 200), ByteSizeUnit.BYTES, new Validator() {
@Override
diff --git a/core/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java b/core/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
index 29eb8266d1..8c0c7347a1 100644
--- a/core/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
+++ b/core/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
@@ -32,7 +32,6 @@ import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.index.translog.TranslogConfig;
import org.elasticsearch.test.BackgroundIndexer;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@@ -47,11 +46,9 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitC
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
-
private final ESLogger logger = Loggers.getLogger(RecoveryWhileUnderLoadIT.class);
- @Test
- public void recoverWhileUnderLoadAllocateReplicasTest() throws Exception {
+ public void testRecoverWhileUnderLoadAllocateReplicasTest() throws Exception {
logger.info("--> creating test index ...");
int numberOfShards = numberOfShards();
assertAcked(prepareCreate("test", 1, settingsBuilder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 1).put(TranslogConfig.INDEX_TRANSLOG_DURABILITY, Translog.Durabilty.ASYNC)));
@@ -104,8 +101,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
}
}
- @Test
- public void recoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() throws Exception {
+ public void testRecoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() throws Exception {
logger.info("--> creating test index ...");
int numberOfShards = numberOfShards();
assertAcked(prepareCreate("test", 1, settingsBuilder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 1).put(TranslogConfig.INDEX_TRANSLOG_DURABILITY, Translog.Durabilty.ASYNC)));
@@ -156,8 +152,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
}
}
- @Test
- public void recoverWhileUnderLoadWithReducedAllowedNodes() throws Exception {
+ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception {
logger.info("--> creating test index ...");
int numberOfShards = numberOfShards();
assertAcked(prepareCreate("test", 2, settingsBuilder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 1).put(TranslogConfig.INDEX_TRANSLOG_DURABILITY, Translog.Durabilty.ASYNC)));
@@ -226,8 +221,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
}
}
- @Test
- public void recoverWhileRelocating() throws Exception {
+ public void testRecoverWhileRelocating() throws Exception {
final int numShards = between(2, 10);
final int numReplicas = 0;
logger.info("--> creating test index ...");
diff --git a/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java b/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java
index 2eea223e29..5f99f80ce5 100644
--- a/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java
+++ b/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java
@@ -21,6 +21,7 @@ package org.elasticsearch.recovery;
import com.carrotsearch.hppc.IntHashSet;
import com.carrotsearch.hppc.procedures.IntProcedure;
+
import org.apache.lucene.index.IndexFileNames;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -51,10 +52,14 @@ import org.elasticsearch.search.SearchHits;
import org.elasticsearch.test.BackgroundIndexer;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.Transport;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.nio.file.FileVisitResult;
@@ -71,10 +76,11 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
/**
*/
@@ -88,7 +94,6 @@ public class RelocationIT extends ESIntegTestCase {
return pluginList(MockTransportService.TestPlugin.class);
}
- @Test
public void testSimpleRelocationNoIndexing() {
logger.info("--> starting [node1] ...");
final String node_1 = internalCluster().startNode();
@@ -136,7 +141,6 @@ public class RelocationIT extends ESIntegTestCase {
assertThat(client().prepareSearch("test").setSize(0).execute().actionGet().getHits().totalHits(), equalTo(20l));
}
- @Test
public void testRelocationWhileIndexingRandom() throws Exception {
int numberOfRelocations = scaledRandomIntBetween(1, rarely() ? 10 : 4);
int numberOfReplicas = randomBoolean() ? 0 : 1;
@@ -245,7 +249,6 @@ public class RelocationIT extends ESIntegTestCase {
}
}
- @Test
public void testRelocationWhileRefreshing() throws Exception {
int numberOfRelocations = scaledRandomIntBetween(1, rarely() ? 10 : 4);
int numberOfReplicas = randomBoolean() ? 0 : 1;
@@ -345,7 +348,6 @@ public class RelocationIT extends ESIntegTestCase {
}
}
- @Test
public void testCancellationCleansTempFiles() throws Exception {
final String indexName = "test";
diff --git a/core/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java b/core/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java
index d19117e1d2..26291b7ac9 100644
--- a/core/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java
@@ -24,15 +24,16 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import static org.elasticsearch.client.Requests.*;
+import static org.elasticsearch.client.Requests.flushRequest;
+import static org.elasticsearch.client.Requests.getRequest;
+import static org.elasticsearch.client.Requests.indexRequest;
+import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
public class SimpleRecoveryIT extends ESIntegTestCase {
-
@Override
public Settings indexSettings() {
return settingsBuilder().put(super.indexSettings()).put(recoverySettings()).build();
@@ -47,7 +48,6 @@ public class SimpleRecoveryIT extends ESIntegTestCase {
return 1;
}
- @Test
public void testSimpleRecovery() throws Exception {
assertAcked(prepareCreate("test", 1).execute().actionGet());
diff --git a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java
index 25347fa1fa..df0f905e89 100644
--- a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java
@@ -37,8 +37,10 @@ import org.elasticsearch.indices.recovery.RecoveryTarget;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
-import org.junit.Test;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
@@ -56,7 +58,6 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ESIntegTestCase.ClusterScope(numDataNodes = 2, numClientNodes = 0, scope = ESIntegTestCase.Scope.TEST)
@SuppressCodecs("*") // test relies on exact file extensions
public class TruncatedRecoveryIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder()
@@ -76,7 +77,6 @@ public class TruncatedRecoveryIT extends ESIntegTestCase {
* we just throw an exception to make sure the recovery fails and we leave some half baked files on the target.
* Later we allow full recovery to ensure we can still recover and don't run into corruptions.
*/
- @Test
public void testCancelRecoveryAndResume() throws Exception {
NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get();
List<NodeStats> dataNodeStats = new ArrayList<>();
diff --git a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
index 76d08eadc8..0a40da3403 100644
--- a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
@@ -28,19 +28,20 @@ import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.transport.RemoteTransportException;
-import org.junit.Test;
import java.io.FileNotFoundException;
import java.io.IOException;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
/**
*
*/
public class BytesRestResponseTests extends ESTestCase {
- @Test
public void testWithHeaders() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = randomBoolean() ? new DetailedExceptionRestChannel(request) : new SimpleExceptionRestChannel(request);
@@ -52,7 +53,6 @@ public class BytesRestResponseTests extends ESTestCase {
assertThat(response.getHeaders().get("n2"), contains("v21", "v22"));
}
- @Test
public void testSimpleExceptionMessage() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = new SimpleExceptionRestChannel(request);
@@ -66,7 +66,6 @@ public class BytesRestResponseTests extends ESTestCase {
assertThat(text, not(containsString("error_trace")));
}
- @Test
public void testDetailedExceptionMessage() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = new DetailedExceptionRestChannel(request);
@@ -78,7 +77,6 @@ public class BytesRestResponseTests extends ESTestCase {
assertThat(text, containsString("{\"type\":\"file_not_found_exception\",\"reason\":\"/foo/bar\"}"));
}
- @Test
public void testNonElasticsearchExceptionIsNotShownAsSimpleMessage() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = new SimpleExceptionRestChannel(request);
@@ -92,7 +90,6 @@ public class BytesRestResponseTests extends ESTestCase {
assertThat(text, containsString("\"error\":\"No ElasticsearchException found\""));
}
- @Test
public void testErrorTrace() throws Exception {
RestRequest request = new FakeRestRequest();
request.params().put("error_trace", "true");
@@ -123,7 +120,6 @@ public class BytesRestResponseTests extends ESTestCase {
}
}
- @Test
public void testNullThrowable() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = new SimpleExceptionRestChannel(request);
@@ -134,7 +130,6 @@ public class BytesRestResponseTests extends ESTestCase {
assertThat(text, not(containsString("error_trace")));
}
- @Test
public void testConvert() throws IOException {
RestRequest request = new FakeRestRequest();
RestChannel channel = new DetailedExceptionRestChannel(request);
diff --git a/core/src/test/java/org/elasticsearch/rest/CorsRegexDefaultIT.java b/core/src/test/java/org/elasticsearch/rest/CorsRegexDefaultIT.java
index fa7eccd665..2b7533cae1 100644
--- a/core/src/test/java/org/elasticsearch/rest/CorsRegexDefaultIT.java
+++ b/core/src/test/java/org/elasticsearch/rest/CorsRegexDefaultIT.java
@@ -22,9 +22,10 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
/**
*
@@ -38,7 +39,6 @@ public class CorsRegexDefaultIT extends ESIntegTestCase {
.put(super.nodeSettings(nodeOrdinal)).build();
}
- @Test
public void testCorsSettingDefaultBehaviourDoesNotReturnAnything() throws Exception {
String corsValue = "http://localhost:9200";
HttpResponse response = httpClient().method("GET").path("/").addHeader("User-Agent", "Mozilla Bar").addHeader("Origin", corsValue).execute();
@@ -48,7 +48,6 @@ public class CorsRegexDefaultIT extends ESIntegTestCase {
assertThat(response.getHeaders(), not(hasKey("Access-Control-Allow-Credentials")));
}
- @Test
public void testThatOmittingCorsHeaderDoesNotReturnAnything() throws Exception {
HttpResponse response = httpClient().method("GET").path("/").execute();
diff --git a/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java b/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java
index d0e0282f2c..3828ae0ad7 100644
--- a/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java
+++ b/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java
@@ -23,16 +23,16 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.rest.client.http.HttpResponse;
-import org.junit.Test;
-import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN;
import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_CREDENTIALS;
+import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN;
import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ENABLED;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
/**
*
@@ -53,7 +53,6 @@ public class CorsRegexIT extends ESIntegTestCase {
.build();
}
- @Test
public void testThatRegularExpressionWorksOnMatch() throws Exception {
String corsValue = "http://localhost:9200";
HttpResponse response = httpClient().method("GET").path("/").addHeader("User-Agent", "Mozilla Bar").addHeader("Origin", corsValue).execute();
@@ -66,34 +65,29 @@ public class CorsRegexIT extends ESIntegTestCase {
assertThat(response.getHeaders().get("Access-Control-Allow-Credentials"), is("true"));
}
- @Test
public void testThatRegularExpressionReturnsNullOnNonMatch() throws Exception {
HttpResponse response = httpClient().method("GET").path("/").addHeader("User-Agent", "Mozilla Bar").addHeader("Origin", "http://evil-host:9200").execute();
assertResponseWithOriginheader(response, "null");
}
- @Test
public void testThatSendingNoOriginHeaderReturnsNoAccessControlHeader() throws Exception {
HttpResponse response = httpClient().method("GET").path("/").addHeader("User-Agent", "Mozilla Bar").execute();
assertThat(response.getStatusCode(), is(200));
assertThat(response.getHeaders(), not(hasKey("Access-Control-Allow-Origin")));
}
- @Test
public void testThatRegularExpressionIsNotAppliedWithoutCorrectBrowserOnMatch() throws Exception {
HttpResponse response = httpClient().method("GET").path("/").execute();
assertThat(response.getStatusCode(), is(200));
assertThat(response.getHeaders(), not(hasKey("Access-Control-Allow-Origin")));
}
- @Test
public void testThatPreFlightRequestWorksOnMatch() throws Exception {
String corsValue = "http://localhost:9200";
HttpResponse response = httpClient().method("OPTIONS").path("/").addHeader("User-Agent", "Mozilla Bar").addHeader("Origin", corsValue).execute();
assertResponseWithOriginheader(response, corsValue);
}
- @Test
public void testThatPreFlightRequestReturnsNullOnNonMatch() throws Exception {
HttpResponse response = httpClient().method("OPTIONS").path("/").addHeader("User-Agent", "Mozilla Bar").addHeader("Origin", "http://evil-host:9200").execute();
assertResponseWithOriginheader(response, "null");
diff --git a/core/src/test/java/org/elasticsearch/rest/HeadersAndContextCopyClientTests.java b/core/src/test/java/org/elasticsearch/rest/HeadersAndContextCopyClientTests.java
index b099f97ddf..2a8299226c 100644
--- a/core/src/test/java/org/elasticsearch/rest/HeadersAndContextCopyClientTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/HeadersAndContextCopyClientTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -53,7 +52,6 @@ import static org.hamcrest.Matchers.is;
public class HeadersAndContextCopyClientTests extends ESTestCase {
- @Test
public void testRegisterRelevantHeaders() throws InterruptedException {
final RestController restController = new RestController(Settings.EMPTY);
@@ -91,7 +89,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
assertThat(relevantHeaders, equalTo(headersArray));
}
- @Test
public void testCopyHeadersRequest() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
@@ -137,7 +134,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
}
}
- @Test
public void testCopyHeadersClusterAdminRequest() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
@@ -183,7 +179,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
}
}
- @Test
public void testCopyHeadersIndicesAdminRequest() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
@@ -229,7 +224,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
}
}
- @Test
public void testCopyHeadersRequestBuilder() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
@@ -270,7 +264,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
}
}
- @Test
public void testCopyHeadersClusterAdminRequestBuilder() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
@@ -310,7 +303,6 @@ public class HeadersAndContextCopyClientTests extends ESTestCase {
}
}
- @Test
public void testCopyHeadersIndicesAdminRequestBuilder() {
Map<String, String> transportHeaders = randomHeaders(randomIntBetween(0, 10));
Map<String, String> restHeaders = randomHeaders(randomIntBetween(0, 10));
diff --git a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
index 5760c28416..b66d00cd6a 100644
--- a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -42,8 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.CoreMatchers.equalTo;
public class RestFilterChainTests extends ESTestCase {
-
- @Test
public void testRestFilters() throws InterruptedException {
RestController restController = new RestController(Settings.EMPTY);
@@ -120,7 +117,6 @@ public class RestFilterChainTests extends ESTestCase {
}
}
- @Test
public void testTooManyContinueProcessing() throws InterruptedException {
final int additionalContinueCount = randomInt(10);
diff --git a/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java b/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java
index 12bbef4735..8e60b28f37 100644
--- a/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java
@@ -22,18 +22,16 @@ package org.elasticsearch.rest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
/**
*
*/
public class RestRequestTests extends ESTestCase {
-
- @Test
public void testContext() throws Exception {
int count = randomInt(10);
Request request = new Request();
diff --git a/core/src/test/java/org/elasticsearch/rest/action/support/RestTableTests.java b/core/src/test/java/org/elasticsearch/rest/action/support/RestTableTests.java
index 237c62d93c..161668dba0 100644
--- a/core/src/test/java/org/elasticsearch/rest/action/support/RestTableTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/action/support/RestTableTests.java
@@ -23,13 +23,14 @@ import org.elasticsearch.common.Table;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.elasticsearch.rest.action.support.RestTable.buildDisplayHeaders;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.not;
public class RestTableTests extends ESTestCase {
@@ -51,7 +52,6 @@ public class RestTableTests extends ESTestCase {
table.endHeaders();
}
- @Test
public void testThatDisplayHeadersSupportWildcards() throws Exception {
restRequest.params().put("h", "bulk*");
List<RestTable.DisplayHeader> headers = buildDisplayHeaders(table, restRequest);
@@ -61,7 +61,6 @@ public class RestTableTests extends ESTestCase {
assertThat(headerNames, not(hasItem("unmatched")));
}
- @Test
public void testThatDisplayHeadersAreNotAddedTwice() throws Exception {
restRequest.params().put("h", "nonexistent,bulk*,bul*");
List<RestTable.DisplayHeader> headers = buildDisplayHeaders(table, restRequest);
diff --git a/core/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java b/core/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java
index c095b8d625..e60a120ff1 100644
--- a/core/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.rest.util;
import org.elasticsearch.rest.support.RestUtils;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Locale;
@@ -35,7 +34,6 @@ import static org.hamcrest.Matchers.*;
*/
public class RestUtilsTests extends ESTestCase {
- @Test
public void testDecodeQueryString() {
Map<String, String> params = new HashMap<>();
@@ -62,7 +60,6 @@ public class RestUtilsTests extends ESTestCase {
assertThat(params.size(), equalTo(0));
}
- @Test
public void testDecodeQueryStringEdgeCases() {
Map<String, String> params = new HashMap<>();
@@ -123,7 +120,6 @@ public class RestUtilsTests extends ESTestCase {
assertThat(params.get("p1"), equalTo("v1"));
}
- @Test
public void testCorsSettingIsARegex() {
assertCorsSettingRegex("/foo/", Pattern.compile("foo"));
assertCorsSettingRegex("/.*/", Pattern.compile(".*"));
diff --git a/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
index 2d823292e5..2740dd7324 100644
--- a/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
+++ b/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
@@ -23,7 +23,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class AliasResolveRoutingIT extends ESIntegTestCase {
-
- @Test
public void testResolveIndexRouting() throws Exception {
createIndex("test1");
createIndex("test2");
@@ -78,8 +75,6 @@ public class AliasResolveRoutingIT extends ESIntegTestCase {
}
}
-
- @Test
public void testResolveSearchRouting() throws Exception {
createIndex("test1");
createIndex("test2");
diff --git a/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java
index 5538def5c0..9fc6bcfb73 100644
--- a/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java
+++ b/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.cluster.metadata.AliasAction.newAddAliasAction;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -40,7 +39,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
return 2;
}
- @Test
public void testAliasCrudRouting() throws Exception {
createIndex("test");
ensureGreen();
@@ -102,7 +100,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
}
}
- @Test
public void testAliasSearchRouting() throws Exception {
createIndex("test");
ensureGreen();
@@ -197,7 +194,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
}
- @Test
public void testAliasSearchRoutingWithTwoIndices() throws Exception {
createIndex("test-a");
createIndex("test-b");
@@ -258,7 +254,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
to the other indices (without routing) were not taken into account in PlainOperationRouting#searchShards.
That affected the number of shards that we executed the search on, thus some documents were missing in the search results.
*/
- @Test
public void testAliasSearchRoutingWithConcreteAndAliasedIndices_issue2682() throws Exception {
createIndex("index", "index_2");
ensureGreen();
@@ -284,7 +279,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
That could cause returning 1, which led to forcing the QUERY_AND_FETCH mode.
As a result, (size * number of hit shards) results were returned and no reduce phase was taking place.
*/
- @Test
public void testAliasSearchRoutingWithConcreteAndAliasedIndices_issue3268() throws Exception {
createIndex("index", "index_2");
ensureGreen();
@@ -305,7 +299,6 @@ public class AliasRoutingIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
}
- @Test
public void testIndexingAliasesOverTime() throws Exception {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
index 9998234770..f386e829c6 100644
--- a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.watcher.ResourceWatcherService;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -45,8 +44,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class NativeScriptTests extends ESTestCase {
-
- @Test
public void testNativeScript() throws InterruptedException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
Settings settings = Settings.settingsBuilder()
@@ -69,7 +66,6 @@ public class NativeScriptTests extends ESTestCase {
terminate(injector.getInstance(ThreadPool.class));
}
- @Test
public void testFineGrainedSettingsDontAffectNativeScripts() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
Settings.Builder builder = Settings.settingsBuilder();
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java b/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
index c7d3a52bf7..a43589fe21 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
@@ -21,15 +21,14 @@ package org.elasticsearch.script;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
-public class ScriptContextRegistryTests extends ESTestCase {
+import static org.hamcrest.Matchers.containsString;
- @Test
+public class ScriptContextRegistryTests extends ESTestCase {
public void testValidateCustomScriptContextsOperation() throws IOException {
for (final String rejectedContext : ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS) {
try {
@@ -42,7 +41,6 @@ public class ScriptContextRegistryTests extends ESTestCase {
}
}
- @Test
public void testValidateCustomScriptContextsPluginName() throws IOException {
for (final String rejectedContext : ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS) {
try {
@@ -55,28 +53,34 @@ public class ScriptContextRegistryTests extends ESTestCase {
}
}
- @Test(expected = IllegalArgumentException.class)
public void testValidateCustomScriptContextsEmptyPluginName() throws IOException {
- new ScriptContext.Plugin(randomBoolean() ? null : "", "test");
+ try {
+ new ScriptContext.Plugin(randomBoolean() ? null : "", "test");
+ fail("Expected exception");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("plugin name cannot be empty"));
+ }
}
- @Test(expected = IllegalArgumentException.class)
public void testValidateCustomScriptContextsEmptyOperation() throws IOException {
- new ScriptContext.Plugin("test", randomBoolean() ? null : "");
+ try {
+ new ScriptContext.Plugin("test", randomBoolean() ? null : "");
+ fail("Expected exception");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("operation name cannot be empty"));
+ }
}
- @Test
public void testDuplicatedPluginScriptContexts() throws IOException {
try {
//try to register a prohibited script context
new ScriptContextRegistry(Arrays.asList(new ScriptContext.Plugin("testplugin", "test"), new ScriptContext.Plugin("testplugin", "test")));
fail("ScriptContextRegistry initialization should have failed");
} catch(IllegalArgumentException e) {
- assertThat(e.getMessage(), Matchers.containsString("script context [testplugin_test] cannot be registered twice"));
+ assertThat(e.getMessage(), containsString("script context [testplugin_test] cannot be registered twice"));
}
}
- @Test
public void testNonDuplicatedPluginScriptContexts() throws IOException {
new ScriptContextRegistry(Arrays.asList(new ScriptContext.Plugin("testplugin1", "test"), new ScriptContext.Plugin("testplugin2", "test")));
}
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
index e3fba013fc..0edaedbb28 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
@@ -30,6 +30,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import static org.hamcrest.Matchers.containsString;
+
public class ScriptContextTests extends ESTestCase {
private static final String PLUGIN_NAME = "testplugin";
@@ -59,7 +61,7 @@ public class ScriptContextTests extends ESTestCase {
scriptService.compile(script, new ScriptContext.Plugin(PLUGIN_NAME, "custom_globally_disabled_op"), contextAndHeaders);
fail("script compilation should have been rejected");
} catch (ScriptException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("scripts of type [" + scriptType + "], operation [" + PLUGIN_NAME + "_custom_globally_disabled_op] and lang [" + MockScriptEngine.NAME + "] are disabled"));
+ assertThat(e.getMessage(), containsString("scripts of type [" + scriptType + "], operation [" + PLUGIN_NAME + "_custom_globally_disabled_op] and lang [" + MockScriptEngine.NAME + "] are disabled"));
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
index 4fdfbb09e5..71a41750c9 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
@@ -21,7 +21,6 @@ package org.elasticsearch.script;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.ScriptService.ScriptType;
@@ -34,7 +33,6 @@ import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ExecutionException;
-import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = Scope.SUITE, numDataNodes = 3)
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java b/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java
index e38c9930d5..38ab78bff4 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.Collections;
import java.util.HashMap;
@@ -41,6 +40,7 @@ import static java.util.Collections.unmodifiableSet;
import static org.elasticsearch.common.util.set.Sets.newHashSet;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.Matchers.containsString;
// TODO: this needs to be a base test class, and all scripting engines extend it
public class ScriptModesTests extends ESTestCase {
@@ -102,21 +102,23 @@ public class ScriptModesTests extends ESTestCase {
}
}
- @Test
public void testDefaultSettings() {
this.scriptModes = new ScriptModes(scriptEngines, scriptContextRegistry, Settings.EMPTY);
assertScriptModesAllOps(ScriptMode.ON, ALL_LANGS, ScriptType.FILE);
assertScriptModesAllOps(ScriptMode.SANDBOX, ALL_LANGS, ScriptType.INDEXED, ScriptType.INLINE);
}
- @Test(expected = IllegalArgumentException.class)
public void testMissingSetting() {
assertAllSettingsWereChecked = false;
this.scriptModes = new ScriptModes(scriptEngines, scriptContextRegistry, Settings.EMPTY);
- scriptModes.getScriptMode("non_existing", randomFrom(ScriptType.values()), randomFrom(scriptContexts));
+ try {
+ scriptModes.getScriptMode("non_existing", randomFrom(ScriptType.values()), randomFrom(scriptContexts));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("not found for lang [non_existing]"));
+ }
}
- @Test
public void testScriptTypeGenericSettings() {
int randomInt = randomIntBetween(1, ScriptType.values().length - 1);
Set<ScriptType> randomScriptTypesSet = new HashSet<>();
@@ -149,7 +151,6 @@ public class ScriptModesTests extends ESTestCase {
}
}
- @Test
public void testScriptContextGenericSettings() {
int randomInt = randomIntBetween(1, scriptContexts.length - 1);
Set<ScriptContext> randomScriptContextsSet = new HashSet<>();
@@ -177,7 +178,6 @@ public class ScriptModesTests extends ESTestCase {
assertScriptModes(ScriptMode.SANDBOX, ALL_LANGS, new ScriptType[]{ScriptType.INDEXED, ScriptType.INLINE}, complementOf);
}
- @Test
public void testConflictingScriptTypeAndOpGenericSettings() {
ScriptContext scriptContext = randomFrom(scriptContexts);
Settings.Builder builder = Settings.builder().put(ScriptModes.SCRIPT_SETTINGS_PREFIX + scriptContext.getKey(), randomFrom(DISABLE_VALUES))
@@ -190,7 +190,6 @@ public class ScriptModesTests extends ESTestCase {
assertScriptModes(ScriptMode.SANDBOX, ALL_LANGS, new ScriptType[]{ScriptType.INLINE}, complementOf);
}
- @Test
public void testInteractionBetweenGenericAndEngineSpecificSettings() {
Settings.Builder builder = Settings.builder().put("script.inline", randomFrom(DISABLE_VALUES))
.put(specificEngineOpSettings(MustacheScriptEngineService.NAME, ScriptType.INLINE, ScriptContext.Standard.AGGS), randomFrom(ENABLE_VALUES))
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java b/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java
index 85dc650c6a..c3c80c5085 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java
@@ -30,17 +30,22 @@ import org.elasticsearch.script.Script.ScriptParseException;
import org.elasticsearch.script.ScriptParameterParser.ScriptParameterValue;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
-
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static java.util.Collections.singleton;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
public class ScriptParameterParserTests extends ESTestCase {
-
- @Test
public void testTokenDefaultInline() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"script\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -61,7 +66,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenDefaultFile() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"script_file\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -84,7 +88,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenDefaultIndexed() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"script_id\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -107,7 +110,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenDefaultNotFound() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"bar\" }"));
Token token = parser.nextToken();
@@ -121,7 +123,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenSingleParameter() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -136,7 +137,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenSingleParameterFile() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_file\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -151,7 +151,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenSingleParameterIndexed() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_id\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -166,7 +165,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceInlineFile() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"scriptValue\", \"foo_file\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -183,10 +181,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceInlineIndexed() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"scriptValue\", \"foo_id\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -203,10 +205,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceFileInline() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_file\" : \"scriptValue\", \"foo\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -223,10 +229,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceFileIndexed() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_file\" : \"scriptValue\", \"foo_id\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -243,10 +253,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceIndexedInline() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_id\" : \"scriptValue\", \"foo\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -263,10 +277,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testTokenSingleParameterDelcaredTwiceIndexedFile() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo_id\" : \"scriptValue\", \"foo_file\" : \"scriptValue\" }"));
Token token = parser.nextToken();
@@ -283,10 +301,14 @@ public class ScriptParameterParserTests extends ESTestCase {
while (token != Token.VALUE_STRING) {
token = parser.nextToken();
}
- paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.token(parser.currentName(), parser.currentToken(), parser, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test
public void testTokenMultipleParameters() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"fooScriptValue\", \"bar_file\" : \"barScriptValue\", \"baz_id\" : \"bazScriptValue\" }"));
Set<String> parameters = new HashSet<>();
@@ -335,7 +357,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenMultipleParametersWithLang() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"fooScriptValue\", \"bar_file\" : \"barScriptValue\", \"lang\" : \"myLang\", \"baz_id\" : \"bazScriptValue\" }"));
Set<String> parameters = new HashSet<>();
@@ -395,7 +416,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), equalTo("myLang"));
}
- @Test
public void testTokenMultipleParametersNotFound() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"other\" : \"scriptValue\" }"));
Set<String> parameters = new HashSet<>();
@@ -423,7 +443,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenMultipleParametersSomeNotFound() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"fooScriptValue\", \"other_file\" : \"barScriptValue\", \"baz_id\" : \"bazScriptValue\" }"));
Set<String> parameters = new HashSet<>();
@@ -480,7 +499,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testTokenMultipleParametersWrongType() throws IOException {
XContentParser parser = XContentHelper.createParser(new BytesArray("{ \"foo\" : \"fooScriptValue\", \"bar_file\" : \"barScriptValue\", \"baz_id\" : \"bazScriptValue\" }"));
Set<String> parameters = new HashSet<>();
@@ -503,13 +521,15 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test(expected=IllegalArgumentException.class)
public void testReservedParameters() {
- Set<String> parameterNames = Collections.singleton("lang");
- new ScriptParameterParser(parameterNames );
+ try {
+ new ScriptParameterParser(singleton("lang"));
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("lang is reserved"));
+ }
}
- @Test
public void testConfigDefaultInline() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("script", "scriptValue");
@@ -534,7 +554,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigDefaultFile() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("script_file", "scriptValue");
@@ -553,7 +572,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigDefaultIndexed() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("script_id", "scriptValue");
@@ -572,7 +590,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigDefaultIndexedNoRemove() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("script_id", "scriptValue");
@@ -593,7 +610,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat((String) config.get("scriptId"), equalTo("scriptValue"));
}
- @Test
public void testConfigDefaultNotFound() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "bar");
@@ -606,7 +622,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat((String) config.get("foo"), equalTo("bar"));
}
- @Test
public void testConfigSingleParameter() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "scriptValue");
@@ -619,7 +634,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigSingleParameterFile() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo_file", "scriptValue");
@@ -632,7 +646,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigSingleParameterIndexed() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo_id", "scriptValue");
@@ -645,7 +658,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceInlineFile() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo", "scriptValue");
@@ -653,10 +665,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceInlineIndexed() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo", "scriptValue");
@@ -664,10 +680,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceFileInline() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo_file", "scriptValue");
@@ -675,10 +695,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceFileIndexed() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo_file", "scriptValue");
@@ -686,10 +710,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceIndexedInline() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo_id", "scriptValue");
@@ -697,10 +725,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigSingleParameterDelcaredTwiceIndexedFile() throws IOException {
Map<String, Object> config = new LinkedHashMap<>();
config.put("foo_id", "scriptValue");
@@ -708,10 +740,14 @@ public class ScriptParameterParserTests extends ESTestCase {
Set<String> parameters = Collections.singleton("foo");
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test
public void testConfigMultipleParameters() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -738,7 +774,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigMultipleParametersWithLang() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -766,7 +801,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(config.isEmpty(), equalTo(true));
}
- @Test
public void testConfigMultipleParametersWithLangNoRemove() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -798,7 +832,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat((String) config.get("lang"), equalTo("myLang"));
}
- @Test
public void testConfigMultipleParametersNotFound() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("other", "scriptValue");
@@ -825,7 +858,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat((String) config.get("other"), equalTo("scriptValue"));
}
- @Test
public void testConfigMultipleParametersSomeNotFound() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -857,7 +889,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat((String) config.get("other_file"), equalTo("barScriptValue"));
}
- @Test(expected = ScriptParseException.class)
public void testConfigMultipleParametersInlineWrongType() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", 1l);
@@ -875,10 +906,14 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.getScriptParameterValue("bar_file"), nullValue());
assertThat(paramParser.getScriptParameterValue("baz_id"), nullValue());
assertThat(paramParser.lang(), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Value must be of type String: [foo]"));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigMultipleParametersFileWrongType() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -896,10 +931,15 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.getScriptParameterValue("bar_file"), nullValue());
assertThat(paramParser.getScriptParameterValue("baz_id"), nullValue());
assertThat(paramParser.lang(), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Value must be of type String: [bar_file]"));
+ }
+
}
- @Test(expected = ScriptParseException.class)
public void testConfigMultipleParametersIndexedWrongType() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -917,10 +957,14 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.getScriptParameterValue("bar_file"), nullValue());
assertThat(paramParser.getScriptParameterValue("baz_id"), nullValue());
assertThat(paramParser.lang(), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Value must be of type String: [baz_id]"));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testConfigMultipleParametersLangWrongType() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -938,10 +982,14 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.getScriptParameterValue("bar_file"), nullValue());
assertThat(paramParser.getScriptParameterValue("baz_id"), nullValue());
assertThat(paramParser.lang(), nullValue());
- paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ try {
+ paramParser.parseConfig(config, true, ParseFieldMatcher.STRICT);
+ fail("Expected ScriptParseException");
+ } catch (ScriptParseException e) {
+ assertThat(e.getMessage(), is("Value must be of type String: [lang]"));
+ }
}
- @Test
public void testParamsDefaultInline() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("script", "scriptValue");
@@ -950,7 +998,7 @@ public class ScriptParameterParserTests extends ESTestCase {
paramParser.parseParams(params);
assertDefaultParameterValue(paramParser, "scriptValue", ScriptType.INLINE);
assertThat(paramParser.lang(), nullValue());
-
+
paramParser = new ScriptParameterParser(null);
paramParser.parseParams(params);
assertDefaultParameterValue(paramParser, "scriptValue", ScriptType.INLINE);
@@ -962,7 +1010,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsDefaultFile() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("script_file", "scriptValue");
@@ -973,7 +1020,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsDefaultIndexed() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("script_id", "scriptValue");
@@ -984,7 +1030,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsDefaultNotFound() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "bar");
@@ -996,7 +1041,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsSingleParameter() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "scriptValue");
@@ -1009,7 +1053,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsSingleParameterFile() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo_file", "scriptValue");
@@ -1022,7 +1065,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsSingleParameterIndexed() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo_id", "scriptValue");
@@ -1035,7 +1077,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceInlineFile() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo", "scriptValue");
@@ -1044,10 +1085,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceInlineIndexed() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo", "scriptValue");
@@ -1056,10 +1101,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceFileInline() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo_file", "scriptValue");
@@ -1068,10 +1117,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceFileIndexed() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo_file", "scriptValue");
@@ -1080,10 +1133,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceIndexedInline() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo_id", "scriptValue");
@@ -1092,10 +1149,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test(expected = ScriptParseException.class)
public void testParamsSingleParameterDelcaredTwiceIndexedFile() throws IOException {
Map<String, String> config = new LinkedHashMap<>();
config.put("foo_id", "scriptValue");
@@ -1104,10 +1165,14 @@ public class ScriptParameterParserTests extends ESTestCase {
ScriptParameterParser paramParser = new ScriptParameterParser(parameters);
assertThat(paramParser.getScriptParameterValue("foo"), nullValue());
MapParams params = new MapParams(config);
- paramParser.parseParams(params);
+ try {
+ paramParser.parseParams(params);
+ fail("Expected ScriptParseException");
+ } catch(ScriptParseException e) {
+ assertThat(e.getMessage(), is("Only one of [foo, foo_file, foo_id] is allowed."));
+ }
}
- @Test
public void testParamsMultipleParameters() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -1134,7 +1199,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsMultipleParametersWithLang() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -1162,7 +1226,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), equalTo("myLang"));
}
- @Test
public void testParamsMultipleParametersWithLangNoRemove() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "fooScriptValue");
@@ -1190,7 +1253,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), equalTo("myLang"));
}
- @Test
public void testParamsMultipleParametersNotFound() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("other", "scriptValue");
@@ -1216,7 +1278,6 @@ public class ScriptParameterParserTests extends ESTestCase {
assertThat(paramParser.lang(), nullValue());
}
- @Test
public void testParamsMultipleParametersSomeNotFound() throws IOException {
Map<String, String> config = new HashMap<>();
config.put("foo", "fooScriptValue");
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
index 26ba5807b2..aa7df3f3eb 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -74,7 +73,7 @@ public class ScriptServiceTests extends ESTestCase {
.put("path.conf", genericConfigFolder)
.build();
resourceWatcherService = new ResourceWatcherService(baseSettings, null);
- scriptEngineServices = newHashSet(new TestEngineService(),
+ scriptEngineServices = newHashSet(new TestEngineService(),
new MustacheScriptEngineService(baseSettings));
scriptEnginesByLangMap = ScriptModesTests.buildScriptEnginesByLangMap(scriptEngineServices);
//randomly register custom script contexts
@@ -112,7 +111,6 @@ public class ScriptServiceTests extends ESTestCase {
};
}
- @Test
public void testNotSupportedDisableDynamicSetting() throws IOException {
try {
buildScriptService(Settings.builder().put(ScriptService.DISABLE_DYNAMIC_SCRIPTING_SETTING, randomUnicodeOfLength(randomIntBetween(1, 10))).build());
@@ -122,7 +120,6 @@ public class ScriptServiceTests extends ESTestCase {
}
}
- @Test
public void testScriptsWithoutExtensions() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
@@ -154,7 +151,6 @@ public class ScriptServiceTests extends ESTestCase {
}
}
- @Test
public void testInlineScriptCompiledOnceCache() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -165,7 +161,6 @@ public class ScriptServiceTests extends ESTestCase {
assertThat(compiledScript1.compiled(), sameInstance(compiledScript2.compiled()));
}
- @Test
public void testInlineScriptCompiledOnceMultipleLangAcronyms() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -176,7 +171,6 @@ public class ScriptServiceTests extends ESTestCase {
assertThat(compiledScript1.compiled(), sameInstance(compiledScript2.compiled()));
}
- @Test
public void testFileScriptCompiledOnceMultipleLangAcronyms() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -188,7 +182,6 @@ public class ScriptServiceTests extends ESTestCase {
assertThat(compiledScript1.compiled(), sameInstance(compiledScript2.compiled()));
}
- @Test
public void testDefaultBehaviourFineGrainedSettings() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
Settings.Builder builder = Settings.builder();
@@ -217,7 +210,6 @@ public class ScriptServiceTests extends ESTestCase {
}
}
- @Test
public void testFineGrainedSettings() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
//collect the fine-grained settings to set for this run
@@ -342,7 +334,6 @@ public class ScriptServiceTests extends ESTestCase {
}
}
- @Test
public void testCompileNonRegisteredContext() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -366,7 +357,6 @@ public class ScriptServiceTests extends ESTestCase {
}
}
- @Test
public void testCompileCountedInCompilationStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -374,7 +364,6 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testExecutableCountedInCompilationStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -382,14 +371,12 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testSearchCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
scriptService.search(null, new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts));
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testMultipleCompilationsCountedInCompilationStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -401,7 +388,6 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(numberOfCompilations, scriptService.stats().getCompilations());
}
- @Test
public void testCompilationStatsOnCacheHit() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
Settings.Builder builder = Settings.builder();
@@ -412,7 +398,6 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testFileScriptCountedInCompilationStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -421,7 +406,6 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testIndexedScriptCountedInCompilationStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
buildScriptService(Settings.EMPTY);
@@ -429,7 +413,6 @@ public class ScriptServiceTests extends ESTestCase {
assertEquals(1L, scriptService.stats().getCompilations());
}
- @Test
public void testCacheEvictionCountedInCacheEvictionsStats() throws IOException {
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
Settings.Builder builder = Settings.builder();
diff --git a/core/src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTests.java b/core/src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTests.java
index 28ae80809a..ce29bf246b 100644
--- a/core/src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.script.CompiledScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringWriter;
@@ -47,7 +46,6 @@ public class MustacheScriptEngineTests extends ESTestCase {
escaper = new JsonEscapingMustacheFactory();
}
- @Test
public void testSimpleParameterReplace() {
{
String template = "GET _search {\"query\": " + "{\"boosting\": {" + "\"positive\": {\"match\": {\"body\": \"gift\"}},"
@@ -72,7 +70,6 @@ public class MustacheScriptEngineTests extends ESTestCase {
}
}
- @Test
public void testEscapeJson() throws IOException {
{
StringWriter writer = new StringWriter();
@@ -86,9 +83,9 @@ public class MustacheScriptEngineTests extends ESTestCase {
}
Character[] specialChars = new Character[]{
- '\"',
- '\\',
- '\u0000',
+ '\"',
+ '\\',
+ '\u0000',
'\u0001',
'\u0002',
'\u0003',
@@ -104,9 +101,9 @@ public class MustacheScriptEngineTests extends ESTestCase {
'\u000F',
'\u001F'};
String[] escapedChars = new String[]{
- "\\\"",
- "\\\\",
- "\\u0000",
+ "\\\"",
+ "\\\\",
+ "\\u0000",
"\\u0001",
"\\u0002",
"\\u0003",
@@ -150,14 +147,14 @@ public class MustacheScriptEngineTests extends ESTestCase {
}
return string;
}
-
+
/**
* From https://www.ietf.org/rfc/rfc4627.txt:
- *
+ *
* All Unicode characters may be placed within the
* quotation marks except for the characters that must be escaped:
* quotation mark, reverse solidus, and the control characters (U+0000
- * through U+001F).
+ * through U+001F).
* */
private static boolean isEscapeChar(char c) {
switch (c) {
@@ -165,7 +162,7 @@ public class MustacheScriptEngineTests extends ESTestCase {
case '\\':
return true;
}
-
+
if (c < '\u002F')
return true;
return false;
diff --git a/core/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java b/core/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java
index 9bda581b6d..76c867802a 100644
--- a/core/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java
+++ b/core/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java
@@ -21,8 +21,8 @@ package org.elasticsearch.script.mustache;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheFactory;
+
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.StringReader;
import java.io.StringWriter;
@@ -32,8 +32,6 @@ import java.util.HashMap;
* Figure out how Mustache works for the simplest use case. Leaving in here for now for reference.
* */
public class MustacheTests extends ESTestCase {
-
- @Test
public void test() {
HashMap<String, Object> scopes = new HashMap<>();
scopes.put("boost_val", "0.2");
diff --git a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
index b12843b1ea..a8c6a194c5 100644
--- a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -44,7 +43,6 @@ public class SearchWithRejectionsIT extends ESIntegTestCase {
.build();
}
- @Test
public void testOpenContextsAfterRejections() throws InterruptedException {
createIndex("test");
ensureGreen("test");
diff --git a/core/src/test/java/org/elasticsearch/search/StressSearchServiceReaperIT.java b/core/src/test/java/org/elasticsearch/search/StressSearchServiceReaperIT.java
index c97e29a0f9..addfe14c48 100644
--- a/core/src/test/java/org/elasticsearch/search/StressSearchServiceReaperIT.java
+++ b/core/src/test/java/org/elasticsearch/search/StressSearchServiceReaperIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.concurrent.ExecutionException;
@@ -44,7 +43,7 @@ public class StressSearchServiceReaperIT extends ESIntegTestCase {
.put(SearchService.KEEPALIVE_INTERVAL_KEY, TimeValue.timeValueMillis(1)).build();
}
- @Test // see issue #5165 - this test fails each time without the fix in pull #5170
+ // see issue #5165 - this test fails each time without the fix in pull #5170
public void testStressReaper() throws ExecutionException, InterruptedException {
int num = randomIntBetween(100, 150);
IndexRequestBuilder[] builders = new IndexRequestBuilder[num];
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsBinaryIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsBinaryIT.java
index e5634fed47..80227ff7f6 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsBinaryIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsBinaryIT.java
@@ -31,7 +31,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -61,7 +60,6 @@ public class AggregationsBinaryIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
public void testAggregationsBinary() throws Exception {
TermsBuilder termsBuilder = AggregationBuilders.terms("terms").field(STRING_FIELD_NAME);
TermsBuilder subTerm = AggregationBuilders.terms("subterms").field(INT_FIELD_NAME);
@@ -101,7 +99,6 @@ public class AggregationsBinaryIT extends ESIntegTestCase {
}
}
- @Test
public void testAggregationsBinarySameContentType() throws Exception {
TermsBuilder termsBuilder = AggregationBuilders.terms("terms").field(STRING_FIELD_NAME);
TermsBuilder subTerm = AggregationBuilders.terms("subterms").field(INT_FIELD_NAME);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java
index 8282a538be..5154dcc39e 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java
@@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations;
-import com.carrotsearch.hppc.IntIntMap;
import com.carrotsearch.hppc.IntIntHashMap;
+import com.carrotsearch.hppc.IntIntMap;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.missing.Missing;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Collection;
@@ -55,8 +54,7 @@ public class CombiIT extends ESIntegTestCase {
* it as "numeric", it didn't work. Now we cache the Value Sources by a custom key (field name + ValueSource type)
* so there's no conflict there.
*/
- @Test
- public void multipleAggs_OnSameField_WithDifferentRequiredValueSourceType() throws Exception {
+ public void testMultipleAggsOnSameField_WithDifferentRequiredValueSourceType() throws Exception {
createIndex("idx");
IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)];
@@ -115,8 +113,7 @@ public class CombiIT extends ESIntegTestCase {
* when the sub aggregator is then created, it will take this estimation into account. This used to cause
* and an ArrayIndexOutOfBoundsException...
*/
- @Test
- public void subAggregationForTopAggregationOnUnmappedField() throws Exception {
+ public void testSubAggregationForTopAggregationOnUnmappedField() throws Exception {
prepareCreate("idx").addMapping("type", jsonBuilder()
.startObject()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java
index c83ad5777b..9d83428038 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java
@@ -19,13 +19,13 @@
package org.elasticsearch.search.aggregations;
-import com.carrotsearch.hppc.IntIntMap;
import com.carrotsearch.hppc.IntIntHashMap;
+import com.carrotsearch.hppc.IntIntMap;
+
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -47,8 +47,7 @@ public class MetaDataIT extends ESIntegTestCase {
* it as "numeric", it didn't work. Now we cache the Value Sources by a custom key (field name + ValueSource type)
* so there's no conflict there.
*/
- @Test
- public void meta_data_set_on_aggregation_result() throws Exception {
+ public void testMetaDataSetOnAggregationResult() throws Exception {
createIndex("idx");
IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)];
@@ -112,6 +111,4 @@ public class MetaDataIT extends ESIntegTestCase {
Map<String, Object> nestedMap = (Map<String, Object>)nestedObject;
assertEquals("value", nestedMap.get("nested"));
}
-
-
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/ParsingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/ParsingIT.java
index 87307c0dca..1ac06e61c7 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/ParsingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/ParsingIT.java
@@ -19,19 +19,7 @@
package org.elasticsearch.search.aggregations;
-import com.carrotsearch.randomizedtesting.generators.RandomStrings;
-import org.elasticsearch.action.search.SearchPhaseExecutionException;
-import org.elasticsearch.common.xcontent.json.JsonXContent;
-import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-
-import java.security.SecureRandom;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ParsingIT extends ESIntegTestCase {
-
- // NORELEASE move these tests to unit tests when aggs refactoring is done
+// NORELEASE move these tests to unit tests when aggs refactoring is done
// @Test(expected=SearchPhaseExecutionException.class)
// public void testTwoTypes() throws Exception {
// createIndex("idx");
@@ -178,4 +166,3 @@ public class ParsingIT extends ESIntegTestCase {
// .endObject()).execute().actionGet();
// }
-}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/BooleanTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/BooleanTermsIT.java
index b4c28ac352..0a660b8537 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/BooleanTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/BooleanTermsIT.java
@@ -23,7 +23,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
@@ -85,8 +84,7 @@ public class BooleanTermsIT extends ESIntegTestCase {
indexRandom(true, builders);
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -118,8 +116,7 @@ public class BooleanTermsIT extends ESIntegTestCase {
}
}
- @Test
- public void multiValueField() throws Exception {
+ public void testMultiValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -151,8 +148,7 @@ public class BooleanTermsIT extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java
index c729c2f2d0..b6611a956a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.metrics.tophits.TopHits;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,9 +41,18 @@ import java.util.Set;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.children;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.topHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.sameInstance;
/**
*/
@@ -120,7 +128,6 @@ public class ChildrenIT extends ESIntegTestCase {
ensureSearchable("test");
}
- @Test
public void testChildrenAggs() throws Exception {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(matchQuery("randomized", true))
@@ -162,7 +169,6 @@ public class ChildrenIT extends ESIntegTestCase {
}
}
- @Test
public void testParentWithMultipleBuckets() throws Exception {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(matchQuery("randomized", false))
@@ -225,7 +231,6 @@ public class ChildrenIT extends ESIntegTestCase {
assertThat(topHits.getHits().getAt(0).getType(), equalTo("comment"));
}
- @Test
public void testWithDeletes() throws Exception {
String indexName = "xyz";
assertAcked(
@@ -270,7 +275,6 @@ public class ChildrenIT extends ESIntegTestCase {
}
}
- @Test
public void testNonExistingChildType() throws Exception {
SearchResponse searchResponse = client().prepareSearch("test")
.addAggregation(
@@ -283,7 +287,6 @@ public class ChildrenIT extends ESIntegTestCase {
assertThat(children.getDocCount(), equalTo(0l));
}
- @Test
public void testPostCollection() throws Exception {
String indexName = "prodcatalog";
String masterType = "masterprod";
@@ -343,7 +346,6 @@ public class ChildrenIT extends ESIntegTestCase {
assertThat(termsAgg.getBucketByKey("44").getDocCount(), equalTo(1l));
}
- @Test
public void testHierarchicalChildrenAggs() {
String indexName = "geo";
String grandParentType = "continent";
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java
index 08e07677fa..bb22361ebd 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java
@@ -31,7 +31,6 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.List;
@@ -84,8 +83,7 @@ public class DateHistogramOffsetIT extends ESIntegTestCase {
indexRandom(true, reqs);
}
- @Test
- public void singleValue_WithPositiveOffset() throws Exception {
+ public void testSingleValueWithPositiveOffset() throws Exception {
prepareIndex(date("2014-03-11T00:00:00+00:00"), 5, 1, 0);
SearchResponse response = client().prepareSearch("idx2")
@@ -107,8 +105,7 @@ public class DateHistogramOffsetIT extends ESIntegTestCase {
checkBucketFor(buckets.get(1), new DateTime(2014, 3, 11, 2, 0, DateTimeZone.UTC), 3l);
}
- @Test
- public void singleValue_WithNegativeOffset() throws Exception {
+ public void testSingleValueWithNegativeOffset() throws Exception {
prepareIndex(date("2014-03-11T00:00:00+00:00"), 5, -1, 0);
SearchResponse response = client().prepareSearch("idx2")
@@ -133,8 +130,7 @@ public class DateHistogramOffsetIT extends ESIntegTestCase {
/**
* Set offset so day buckets start at 6am. Index first 12 hours for two days, with one day gap.
*/
- @Test
- public void singleValue_WithOffset_MinDocCount() throws Exception {
+ public void testSingleValueWithOffsetMinDocCount() throws Exception {
prepareIndex(date("2014-03-11T00:00:00+00:00"), 12, 1, 0);
prepareIndex(date("2014-03-14T00:00:00+00:00"), 12, 1, 13);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
index 47de43df20..b447580c7e 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -91,8 +90,7 @@ public class FilterIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(filter("tag1").filter(termQuery("tag", "tag1")))
.execute().actionGet();
@@ -108,8 +106,7 @@ public class FilterIT extends ESIntegTestCase {
// See NullPointer issue when filters are empty:
// https://github.com/elasticsearch/elasticsearch/issues/8438
- @Test
- public void emptyFilterDeclarations() throws Exception {
+ public void testEmptyFilterDeclarations() throws Exception {
QueryBuilder emptyFilter = new BoolQueryBuilder();
SearchResponse response = client().prepareSearch("idx").addAggregation(filter("tag1").filter(emptyFilter)).execute().actionGet();
@@ -120,8 +117,7 @@ public class FilterIT extends ESIntegTestCase {
assertThat(filter.getDocCount(), equalTo((long) numDocs));
}
- @Test
- public void withSubAggregation() throws Exception {
+ public void testWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(filter("tag1")
.filter(termQuery("tag", "tag1"))
@@ -149,9 +145,7 @@ public class FilterIT extends ESIntegTestCase {
assertThat((double) filter.getProperty("avg_value.value"), equalTo((double) sum / numTag1Docs));
}
- @Test
- public void withContextBasedSubAggregation() throws Exception {
-
+ public void testWithContextBasedSubAggregation() throws Exception {
try {
client().prepareSearch("idx")
.addAggregation(filter("tag1")
@@ -162,12 +156,12 @@ public class FilterIT extends ESIntegTestCase {
fail("expected execution to fail - an attempt to have a context based numeric sub-aggregation, but there is not value source" +
"context which the sub-aggregation can inherit");
- } catch (ElasticsearchException ese) {
+ } catch (ElasticsearchException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
index e3ff341101..42e1967409 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -108,8 +107,7 @@ public class FiltersIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filters("tags")
@@ -136,8 +134,7 @@ public class FiltersIT extends ESIntegTestCase {
// See NullPointer issue when filters are empty:
// https://github.com/elasticsearch/elasticsearch/issues/8438
- @Test
- public void emptyFilterDeclarations() throws Exception {
+ public void testEmptyFilterDeclarations() throws Exception {
QueryBuilder emptyFilter = new BoolQueryBuilder();
SearchResponse response = client().prepareSearch("idx")
.addAggregation(filters("tags").filter("all", emptyFilter).filter("tag1", termQuery("tag", "tag1"))).execute()
@@ -155,8 +152,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo((long) numTag1Docs));
}
- @Test
- public void withSubAggregation() throws Exception {
+ public void testWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filters("tags")
@@ -209,8 +205,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat((double) propertiesCounts[1], equalTo((double) sum / numTag2Docs));
}
- @Test
- public void withContextBasedSubAggregation() throws Exception {
+ public void testWithContextBasedSubAggregation() throws Exception {
try {
client().prepareSearch("idx")
@@ -225,12 +220,12 @@ public class FiltersIT extends ESIntegTestCase {
fail("expected execution to fail - an attempt to have a context based numeric sub-aggregation, but there is not value source" +
"context which the sub-aggregation can inherit");
- } catch (ElasticsearchException ese) {
+ } catch (ElasticsearchException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -251,8 +246,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(all.getDocCount(), is(0l));
}
- @Test
- public void simple_nonKeyed() throws Exception {
+ public void testSimpleNonKeyed() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filters("tags")
@@ -280,8 +274,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo((long) numTag2Docs));
}
- @Test
- public void otherBucket() throws Exception {
+ public void testOtherBucket() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -311,8 +304,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo((long) numOtherDocs));
}
- @Test
- public void otherNamedBucket() throws Exception {
+ public void testOtherNamedBucket() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -342,8 +334,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo((long) numOtherDocs));
}
- @Test
- public void other_nonKeyed() throws Exception {
+ public void testOtherNonKeyed() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filters("tags").otherBucket(true)
@@ -375,8 +366,7 @@ public class FiltersIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo((long) numOtherDocs));
}
- @Test
- public void otherWithSubAggregation() throws Exception {
+ public void testOtherWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filters("tags").otherBucket(true)
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
index 6bbbdb501c..e0a3e644c6 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -123,8 +122,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(geoDistance("amsterdam_rings")
.field("location")
@@ -146,7 +144,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
Range.Bucket bucket = buckets.get(0);
assertThat(bucket, notNullValue());
- assertThat((String) (String) bucket.getKey(), equalTo("*-500.0"));
+ assertThat((String) bucket.getKey(), equalTo("*-500.0"));
assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo(0.0));
assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0));
assertThat(bucket.getFromAsString(), equalTo("0.0"));
@@ -155,7 +153,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
bucket = buckets.get(1);
assertThat(bucket, notNullValue());
- assertThat((String) (String) bucket.getKey(), equalTo("500.0-1000.0"));
+ assertThat((String) bucket.getKey(), equalTo("500.0-1000.0"));
assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo(500.0));
assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0));
assertThat(bucket.getFromAsString(), equalTo("500.0"));
@@ -172,8 +170,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
- @Test
- public void simple_WithCustomKeys() throws Exception {
+ public void testSimpleWithCustomKeys() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(geoDistance("amsterdam_rings")
.field("location")
@@ -221,8 +218,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet();
SearchResponse response = client().prepareSearch("idx_unmapped")
@@ -272,8 +268,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(geoDistance("amsterdam_rings")
.field("location")
@@ -321,9 +316,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
-
- @Test
- public void withSubAggregation() throws Exception {
+ public void testWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(geoDistance("amsterdam_rings")
.field("location")
@@ -409,8 +402,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat((Terms) propertiesCities[2], sameInstance(cities));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -437,8 +429,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
assertThat(buckets.get(0).getDocCount(), equalTo(0l));
}
- @Test
- public void multiValues() throws Exception {
+ public void testMultiValues() throws Exception {
SearchResponse response = client().prepareSearch("idx-multi")
.addAggregation(geoDistance("amsterdam_rings")
.field("location")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java
index 82196cc508..534e781b1c 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java
@@ -24,7 +24,6 @@ import com.carrotsearch.hppc.ObjectObjectHashMap;
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.cursors.ObjectIntCursor;
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.XGeoHashUtils;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
@@ -36,7 +35,6 @@ import org.elasticsearch.search.aggregations.bucket.filter.Filter;
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid;
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid.Bucket;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -132,9 +130,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
ensureSearchable();
}
-
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(geohashGrid("geohashgrid")
@@ -165,8 +161,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
}
- @Test
- public void multivalued() throws Exception {
+ public void testMultivalued() throws Exception {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
SearchResponse response = client().prepareSearch("multi_valued_idx")
.addAggregation(geohashGrid("geohashgrid")
@@ -190,8 +185,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
}
- @Test
- public void filtered() throws Exception {
+ public void testFiltered() throws Exception {
GeoBoundingBoxQueryBuilder bbox = new GeoBoundingBoxQueryBuilder("location");
bbox.setCorners(smallestGeoHash, smallestGeoHash).queryName("bbox");
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
@@ -224,8 +218,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(geohashGrid("geohashgrid")
@@ -242,8 +235,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(geohashGrid("geohashgrid")
@@ -267,7 +259,6 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
}
- @Test
public void testTopMatch() throws Exception {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
SearchResponse response = client().prepareSearch("idx")
@@ -300,9 +291,8 @@ public class GeoHashGridIT extends ESIntegTestCase {
}
}
- @Test
// making sure this doesn't runs into an OOME
- public void sizeIsZero() {
+ public void testSizeIsZero() {
for (int precision = 1; precision <= XGeoHashUtils.PRECISION; precision++) {
final int size = randomBoolean() ? 0 : randomIntBetween(1, Integer.MAX_VALUE);
final int shardSize = randomBoolean() ? -1 : 0;
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalIT.java
index a313d15721..9cebfeb982 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalIT.java
@@ -18,9 +18,6 @@
*/
package org.elasticsearch.search.aggregations.bucket;
-import java.util.ArrayList;
-import java.util.List;
-
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
@@ -28,7 +25,9 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.metrics.stats.Stats;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
@@ -72,8 +71,7 @@ public class GlobalIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void withStatsSubAggregator() throws Exception {
+ public void testWithStatsSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.termQuery("tag", "tag1"))
.addAggregation(global("global")
@@ -105,11 +103,8 @@ public class GlobalIT extends ESIntegTestCase {
assertThat(stats.getSum(), equalTo((double) sum));
}
- @Test
- public void nonTopLevel() throws Exception {
-
+ public void testNonTopLevel() throws Exception {
try {
-
client().prepareSearch("idx")
.setQuery(QueryBuilders.termQuery("tag", "tag1"))
.addAggregation(global("global")
@@ -119,7 +114,8 @@ public class GlobalIT extends ESIntegTestCase {
fail("expected to fail executing non-top-level global aggregator. global aggregations are only allowed as top level" +
"aggregations");
- } catch (ElasticsearchException ese) {
+ } catch (ElasticsearchException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java
index 9b5df37cd8..924ba7283f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.search.aggregations.bucket.missing.Missing;
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -88,8 +87,7 @@ public class MissingIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("unmapped_idx")
.addAggregation(missing("missing_tag").field("tag"))
.execute().actionGet();
@@ -103,8 +101,7 @@ public class MissingIT extends ESIntegTestCase {
assertThat(missing.getDocCount(), equalTo((long) numDocsUnmapped));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "unmapped_idx")
.addAggregation(missing("missing_tag").field("tag"))
.execute().actionGet();
@@ -118,8 +115,7 @@ public class MissingIT extends ESIntegTestCase {
assertThat(missing.getDocCount(), equalTo((long) numDocsMissing + numDocsUnmapped));
}
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(missing("missing_tag").field("tag"))
.execute().actionGet();
@@ -133,8 +129,7 @@ public class MissingIT extends ESIntegTestCase {
assertThat(missing.getDocCount(), equalTo((long) numDocsMissing));
}
- @Test
- public void withSubAggregation() throws Exception {
+ public void testWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx", "unmapped_idx")
.addAggregation(missing("missing_tag").field("tag")
.subAggregation(avg("avg_value").field("value")))
@@ -165,9 +160,7 @@ public class MissingIT extends ESIntegTestCase {
assertThat((double) missing.getProperty("avg_value.value"), equalTo((double) sum / (numDocsMissing + numDocsUnmapped)));
}
- @Test
- public void withInheritedSubMissing() throws Exception {
-
+ public void testWithInheritedSubMissing() throws Exception {
SearchResponse response = client().prepareSearch("idx", "unmapped_idx")
.addAggregation(missing("top_missing").field("tag")
.subAggregation(missing("sub_missing")))
@@ -188,8 +181,7 @@ public class MissingIT extends ESIntegTestCase {
assertThat(subMissing.getDocCount(), equalTo((long) numDocsMissing + numDocsUnmapped));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java
index 3825901d54..bfd6837254 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.metrics.MetricsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.avg;
@@ -148,23 +147,19 @@ public class NaNSortingIT extends ESIntegTestCase {
assertCorrectlySorted(terms, asc, agg);
}
- @Test
- public void stringTerms() {
+ public void testStringTerms() {
testTerms("string_value");
}
- @Test
- public void longTerms() {
+ public void testLongTerms() {
testTerms("long_value");
}
- @Test
- public void doubleTerms() {
+ public void testDoubleTerms() {
testTerms("double_value");
}
- @Test
- public void longHistogram() {
+ public void testLongHistogram() {
final boolean asc = randomBoolean();
SubAggregation agg = randomFrom(SubAggregation.values());
SearchResponse response = client().prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java
index 7842fd847a..a1f4b20dc1 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java
@@ -36,7 +36,6 @@ import org.elasticsearch.search.aggregations.metrics.stats.Stats;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -166,8 +165,7 @@ public class NestedIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void simple() throws Exception {
+ public void testSimple() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(nested("nested").path("nested")
.subAggregation(stats("nested_value_stats").field("nested.value")))
@@ -205,8 +203,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat(stats.getAvg(), equalTo((double) sum / count));
}
- @Test
- public void nonExistingNestedField() throws Exception {
+ public void testNonExistingNestedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.addAggregation(nested("nested").path("value")
.subAggregation(stats("nested_value_stats").field("nested.value")))
@@ -218,8 +215,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat(nested.getDocCount(), is(0l));
}
- @Test
- public void nestedWithSubTermsAgg() throws Exception {
+ public void testNestedWithSubTermsAgg() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(nested("nested").path("nested")
.subAggregation(terms("values").field("nested.value").size(100)
@@ -270,8 +266,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat((LongTerms) nested.getProperty("values"), sameInstance(values));
}
- @Test
- public void nestedAsSubAggregation() throws Exception {
+ public void testNestedAsSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("top_values").field("value").size(100)
.collectMode(aggCollectionMode)
@@ -299,8 +294,7 @@ public class NestedIT extends ESIntegTestCase {
}
}
- @Test
- public void nestNestedAggs() throws Exception {
+ public void testNestNestedAggs() throws Exception {
SearchResponse response = client().prepareSearch("idx_nested_nested_aggs")
.addAggregation(nested("level1").path("nested1")
.subAggregation(terms("a").field("nested1.a")
@@ -335,9 +329,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat(sum.getValue(), equalTo(2d));
}
-
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -356,8 +348,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat(nested.getDocCount(), is(0l));
}
- @Test
- public void nestedOnObjectField() throws Exception {
+ public void testNestedOnObjectField() throws Exception {
try {
client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -369,7 +360,6 @@ public class NestedIT extends ESIntegTestCase {
}
}
- @Test
// Test based on: https://github.com/elasticsearch/elasticsearch/issues/9280
public void testParentFilterResolvedCorrectly() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("provider").startObject("properties")
@@ -468,8 +458,7 @@ public class NestedIT extends ESIntegTestCase {
assertThat(tags.getBuckets().size(), equalTo(0)); // and this must be empty
}
- @Test
- public void nestedSameDocIdProcessedMultipleTime() throws Exception {
+ public void testNestedSameDocIdProcessedMultipleTime() throws Exception {
assertAcked(
prepareCreate("idx4")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java
index 75751c1fa4..44bd22af1c 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java
@@ -23,7 +23,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -35,8 +34,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
public class ParentIdAggIT extends ESIntegTestCase {
-
- @Test
public void testParentIdAggregation() throws IOException {
XContentBuilder mapping = jsonBuilder().startObject()
.startObject("childtype")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java
index 2a7be3b8b0..8800063043 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -137,8 +136,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
indexRandom(false, client().prepareIndex("idx", "type2").setRouting("1").setSource(source));
}
- @Test
- public void simple_reverseNestedToRoot() throws Exception {
+ public void testSimpleReverseNestedToRoot() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type1")
.addAggregation(nested("nested1").path("nested1")
.subAggregation(
@@ -326,8 +324,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l));
}
- @Test
- public void simple_nested1ToRootToNested2() throws Exception {
+ public void testSimpleNested1ToRootToNested2() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type2")
.addAggregation(nested("nested1").path("nested1")
.subAggregation(
@@ -349,8 +346,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
assertThat(nested.getDocCount(), equalTo(27l));
}
- @Test
- public void simple_reverseNestedToNested1() throws Exception {
+ public void testSimpleReverseNestedToNested1() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type2")
.addAggregation(nested("nested1").path("nested1.nested2")
.subAggregation(
@@ -452,23 +448,26 @@ public class ReverseNestedIT extends ESIntegTestCase {
assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("f"));
}
- @Test(expected = SearchPhaseExecutionException.class)
- public void testReverseNestedAggWithoutNestedAgg() throws Exception {
- client().prepareSearch("idx")
- .addAggregation(terms("field2").field("nested1.nested2.field2")
- .collectMode(randomFrom(SubAggCollectionMode.values()))
- .subAggregation(
- reverseNested("nested1_to_field1")
- .subAggregation(
- terms("field1").field("nested1.field1")
- .collectMode(randomFrom(SubAggCollectionMode.values()))
- )
- )
- ).get();
+ public void testReverseNestedAggWithoutNestedAgg() {
+ try {
+ client().prepareSearch("idx")
+ .addAggregation(terms("field2").field("nested1.nested2.field2")
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
+ .subAggregation(
+ reverseNested("nested1_to_field1")
+ .subAggregation(
+ terms("field1").field("nested1.field1")
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
+ )
+ )
+ ).get();
+ fail("Expected SearchPhaseExecutionException");
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
+ }
}
- @Test
- public void nonExistingNestedField() throws Exception {
+ public void testNonExistingNestedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(nested("nested2").path("nested1.nested2").subAggregation(reverseNested("incorrect").path("nested3")))
@@ -482,7 +481,6 @@ public class ReverseNestedIT extends ESIntegTestCase {
assertThat(reverseNested.getDocCount(), is(0l));
}
- @Test
public void testSameParentDocHavingMultipleBuckets() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("product").field("dynamic", "strict").startObject("properties")
.startObject("id").field("type", "long").endObject()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java
index 5898722090..2535ca33b7 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.search.aggregations.metrics.max.Max;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
@@ -58,7 +57,7 @@ public class SamplerIT extends ESIntegTestCase {
return randomBoolean() ? null : randomFrom(SamplerAggregator.ExecutionMode.values()).toString();
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(
@@ -70,7 +69,7 @@ public class SamplerIT extends ESIntegTestCase {
.addMapping("book", "name", "type=string,index=analyzed", "genre", "type=string,index=not_analyzed", "price", "type=float"));
ensureGreen();
- String data[] = {
+ String data[] = {
// "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s",
"0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,A Song of Ice and Fire,1,fantasy",
"0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,A Song of Ice and Fire,2,fantasy",
@@ -84,7 +83,7 @@ public class SamplerIT extends ESIntegTestCase {
"080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy"
};
-
+
for (int i = 0; i < data.length; i++) {
String[] parts = data[i].split(",");
client().prepareIndex("test", "book", "" + i).setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price",Float.parseFloat(parts[3])).get();
@@ -92,12 +91,11 @@ public class SamplerIT extends ESIntegTestCase {
}
client().admin().indices().refresh(new RefreshRequest("test")).get();
}
-
- @Test
- public void issue10719() throws Exception {
+
+ public void testIssue10719() throws Exception {
// Tests that we can refer to nested elements under a sample in a path
// statement
- boolean asc = randomBoolean();
+ boolean asc = randomBoolean();
SearchResponse response = client().prepareSearch("test").setTypes("book").setSearchType(SearchType.QUERY_AND_FETCH)
.addAggregation(terms("genres")
.field("genre")
@@ -125,8 +123,7 @@ public class SamplerIT extends ESIntegTestCase {
}
- @Test
- public void noDiversity() throws Exception {
+ public void testNoDiversity() throws Exception {
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100);
sampleAgg.subAggregation(new TermsBuilder("authors").field("author"));
SearchResponse response = client().prepareSearch("test").setSearchType(SearchType.QUERY_AND_FETCH)
@@ -143,8 +140,7 @@ public class SamplerIT extends ESIntegTestCase {
assertThat(maxBooksPerAuthor, equalTo(3l));
}
- @Test
- public void simpleDiversity() throws Exception {
+ public void testSimpleDiversity() throws Exception {
int MAX_DOCS_PER_AUTHOR = 1;
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100);
sampleAgg.field("author").maxDocsPerValue(MAX_DOCS_PER_AUTHOR).executionHint(randomExecutionHint());
@@ -160,14 +156,13 @@ public class SamplerIT extends ESIntegTestCase {
Sampler sample = response.getAggregations().get("sample");
Terms authors = sample.getAggregations().get("authors");
Collection<Bucket> testBuckets = authors.getBuckets();
-
+
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket.getDocCount(), lessThanOrEqualTo((long) NUM_SHARDS * MAX_DOCS_PER_AUTHOR));
- }
+ }
}
- @Test
- public void nestedDiversity() throws Exception {
+ public void testNestedDiversity() throws Exception {
// Test multiple samples gathered under buckets made by a parent agg
int MAX_DOCS_PER_AUTHOR = 1;
TermsBuilder rootTerms = new TermsBuilder("genres").field("genre");
@@ -193,8 +188,7 @@ public class SamplerIT extends ESIntegTestCase {
}
}
- @Test
- public void nestedSamples() throws Exception {
+ public void testNestedSamples() throws Exception {
// Test samples nested under samples
int MAX_DOCS_PER_AUTHOR = 1;
int MAX_DOCS_PER_GENRE = 2;
@@ -226,8 +220,7 @@ public class SamplerIT extends ESIntegTestCase {
}
}
- @Test
- public void unmappedChildAggNoDiversity() throws Exception {
+ public void testUnmappedChildAggNoDiversity() throws Exception {
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100);
sampleAgg.subAggregation(new TermsBuilder("authors").field("author"));
SearchResponse response = client().prepareSearch("idx_unmapped")
@@ -244,10 +237,7 @@ public class SamplerIT extends ESIntegTestCase {
assertThat(authors.getBuckets().size(), equalTo(0));
}
-
-
- @Test
- public void partiallyUnmappedChildAggNoDiversity() throws Exception {
+ public void testPartiallyUnmappedChildAggNoDiversity() throws Exception {
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100);
sampleAgg.subAggregation(new TermsBuilder("authors").field("author"));
SearchResponse response = client().prepareSearch("idx_unmapped", "test")
@@ -264,8 +254,7 @@ public class SamplerIT extends ESIntegTestCase {
assertThat(authors.getBuckets().size(), greaterThan(0));
}
- @Test
- public void partiallyUnmappedDiversifyField() throws Exception {
+ public void testPartiallyUnmappedDiversifyField() throws Exception {
// One of the indexes is missing the "author" field used for
// diversifying results
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100).field("author").maxDocsPerValue(1);
@@ -280,9 +269,8 @@ public class SamplerIT extends ESIntegTestCase {
assertThat(authors.getBuckets().size(), greaterThan(0));
}
- @Test
- public void whollyUnmappedDiversifyField() throws Exception {
- //All of the indices are missing the "author" field used for diversifying results
+ public void testWhollyUnmappedDiversifyField() throws Exception {
+ //All of the indices are missing the "author" field used for diversifying results
int MAX_DOCS_PER_AUTHOR = 1;
SamplerAggregationBuilder sampleAgg = new SamplerAggregationBuilder("sample").shardSize(100);
sampleAgg.field("author").maxDocsPerValue(MAX_DOCS_PER_AUTHOR).executionHint(randomExecutionHint());
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java
index b71ee5b74e..7e3b959598 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.search.aggregations.bucket.nested.Nested;
import org.elasticsearch.search.aggregations.bucket.range.Range;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram;
@@ -88,9 +87,7 @@ public class ShardReduceIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
public void testGlobal() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(global("global")
@@ -104,9 +101,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testFilter() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(filter("filter").filter(QueryBuilders.matchAllQuery())
@@ -120,9 +115,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testMissing() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(missing("missing").field("foobar")
@@ -136,9 +129,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testGlobalWithFilterWithMissing() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(global("global")
@@ -156,9 +147,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testNested() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(nested("nested").path("nested")
@@ -172,9 +161,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testStringTerms() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(terms("terms").field("term-s")
@@ -189,9 +176,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testLongTerms() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(terms("terms").field("term-l")
@@ -206,9 +191,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testDoubleTerms() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(terms("terms").field("term-d")
@@ -223,9 +206,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testRange() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(range("range").field("value").addRange("r1", 0, 10)
@@ -239,9 +220,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testDateRange() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(dateRange("range").field("date").addRange("r1", "2014-01-01", "2014-01-10")
@@ -255,9 +234,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testIpRange() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(ipRange("range").field("ip").addRange("r1", "10.0.0.1", "10.0.0.10")
@@ -271,9 +248,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testHistogram() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(histogram("topHisto").field("value").interval(5)
@@ -287,9 +262,7 @@ public class ShardReduceIT extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(4));
}
- @Test
public void testDateHistogram() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(dateHistogram("topHisto").field("date").interval(DateHistogramInterval.MONTH)
@@ -304,9 +277,7 @@ public class ShardReduceIT extends ESIntegTestCase {
}
- @Test
public void testGeoHashGrid() throws Exception {
-
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(geohashGrid("grid").field("location")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java
index e76f48ae76..78e4f7a099 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java
@@ -21,7 +21,6 @@ package org.elasticsearch.search.aggregations.bucket;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
-import org.junit.Test;
import java.util.Collection;
import java.util.HashMap;
@@ -32,9 +31,7 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
import static org.hamcrest.Matchers.equalTo;
public class ShardSizeTermsIT extends ShardSizeTestCase {
-
- @Test
- public void noShardSize_string() throws Exception {
+ public void testNoShardSizeString() throws Exception {
createIdx("type=string,index=not_analyzed");
indexData();
@@ -57,8 +54,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void shardSizeEqualsSize_string() throws Exception {
+ public void testShardSizeEqualsSizeString() throws Exception {
createIdx("type=string,index=not_analyzed");
indexData();
@@ -81,8 +77,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_string() throws Exception {
+ public void testWithShardSizeString() throws Exception {
createIdx("type=string,index=not_analyzed");
@@ -106,8 +101,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_string_singleShard() throws Exception {
+ public void testWithShardSizeStringSingleShard() throws Exception {
createIdx("type=string,index=not_analyzed");
@@ -131,8 +125,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void noShardSizeTermOrder_string() throws Exception {
+ public void testNoShardSizeTermOrderString() throws Exception {
createIdx("type=string,index=not_analyzed");
indexData();
@@ -155,9 +148,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void noShardSize_long() throws Exception {
-
+ public void testNoShardSizeLong() throws Exception {
createIdx("type=long");
indexData();
@@ -180,9 +171,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void shardSizeEqualsSize_long() throws Exception {
-
+ public void testShardSizeEqualsSizeLong() throws Exception {
createIdx("type=long");
indexData();
@@ -205,9 +194,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_long() throws Exception {
-
+ public void testWithShardSizeLong() throws Exception {
createIdx("type=long");
indexData();
@@ -230,8 +217,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_long_singleShard() throws Exception {
+ public void testWithShardSizeLongSingleShard() throws Exception {
createIdx("type=long");
@@ -255,9 +241,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void noShardSizeTermOrder_long() throws Exception {
-
+ public void testNoShardSizeTermOrderLong() throws Exception {
createIdx("type=long");
indexData();
@@ -280,9 +264,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void noShardSize_double() throws Exception {
-
+ public void testNoShardSizeDouble() throws Exception {
createIdx("type=double");
indexData();
@@ -305,9 +287,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void shardSizeEqualsSize_double() throws Exception {
-
+ public void testShardSizeEqualsSizeDouble() throws Exception {
createIdx("type=double");
indexData();
@@ -330,9 +310,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_double() throws Exception {
-
+ public void testWithShardSizeDouble() throws Exception {
createIdx("type=double");
indexData();
@@ -355,9 +333,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void withShardSize_double_singleShard() throws Exception {
-
+ public void testWithShardSizeDoubleSingleShard() throws Exception {
createIdx("type=double");
indexData();
@@ -380,9 +356,7 @@ public class ShardSizeTermsIT extends ShardSizeTestCase {
}
}
- @Test
- public void noShardSizeTermOrder_double() throws Exception {
-
+ public void testNoShardSizeTermOrderDouble() throws Exception {
createIdx("type=double");
indexData();
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsBackwardCompatibilityIT.java
index 556c012c98..5b7976043f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsBackwardCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsBackwardCompatibilityIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -51,9 +50,7 @@ public class SignificantTermsBackwardCompatibilityIT extends ESBackcompatTestCas
/**
* Simple upgrade test for streaming significant terms buckets
*/
- @Test
public void testBucketStreaming() throws IOException, ExecutionException, InterruptedException {
-
logger.debug("testBucketStreaming: indexing documents");
String type = randomBoolean() ? "string" : "long";
String settings = "{\"index.number_of_shards\": 5, \"index.number_of_replicas\": 0}";
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java
index 882f2b7318..7582d75ca0 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java
@@ -36,7 +36,6 @@ import org.elasticsearch.search.aggregations.bucket.significant.heuristics.Perce
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -72,7 +71,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
public static final int MUSIC_CATEGORY=1;
public static final int OTHER_CATEGORY=2;
public static final int SNOWBOARDING_CATEGORY=3;
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, 5, SETTING_NUMBER_OF_REPLICAS, 0).addMapping("fact",
@@ -81,7 +80,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
createIndex("idx_unmapped");
ensureGreen();
- String data[] = {
+ String data[] = {
"A\t1\tpaul weller was lead singer of the jam before the style council",
"B\t1\tpaul weller left the jam to form the style council",
"A\t2\tpaul smith is a designer in the fashion industry",
@@ -100,9 +99,9 @@ public class SignificantTermsIT extends ESIntegTestCase {
"B\t3\tterje haakonsen has credited craig kelly as his snowboard mentor",
"A\t3\tterje haakonsen and craig kelly were some of the first snowboarders sponsored by burton snowboards",
"B\t3\tlike craig kelly before him terje won the mt baker banked slalom many times - once riding switch",
- "A\t3\tterje haakonsen has been a team rider for burton snowboards for over 20 years"
+ "A\t3\tterje haakonsen has been a team rider for burton snowboards for over 20 years"
};
-
+
for (int i = 0; i < data.length; i++) {
String[] parts = data[i].split("\t");
client().prepareIndex("test", "fact", "" + i)
@@ -112,8 +111,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
client().admin().indices().refresh(new RefreshRequest("test")).get();
}
- @Test
- public void structuredAnalysis() throws Exception {
+ public void testStructuredAnalysis() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -127,9 +125,8 @@ public class SignificantTermsIT extends ESIntegTestCase {
Number topCategory = (Number) topTerms.getBuckets().iterator().next().getKey();
assertTrue(topCategory.equals(new Long(SNOWBOARDING_CATEGORY)));
}
-
- @Test
- public void structuredAnalysisWithIncludeExclude() throws Exception {
+
+ public void testStructuredAnalysisWithIncludeExclude() throws Exception {
long[] excludeTerms = { MUSIC_CATEGORY };
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
@@ -145,8 +142,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
assertTrue(topCategory.equals(new Long(OTHER_CATEGORY)));
}
- @Test
- public void includeExclude() throws Exception {
+ public void testIncludeExclude() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setQuery(new TermQueryBuilder("_all", "weller"))
.addAggregation(new SignificantTermsBuilder("mySignificantTerms").field("description").executionHint(randomExecutionHint())
@@ -180,9 +176,8 @@ public class SignificantTermsIT extends ESIntegTestCase {
assertThat(terms, hasSize(1));
assertThat(terms.contains("weller"), is(true));
}
-
- @Test
- public void includeExcludeExactValues() throws Exception {
+
+ public void testIncludeExcludeExactValues() throws Exception {
String []incExcTerms={"weller","nosuchterm"};
SearchResponse response = client().prepareSearch("test")
.setQuery(new TermQueryBuilder("_all", "weller"))
@@ -210,10 +205,9 @@ public class SignificantTermsIT extends ESIntegTestCase {
}
assertThat(terms, hasSize(1));
assertThat(terms.contains("weller"), is(true));
- }
-
- @Test
- public void unmapped() throws Exception {
+ }
+
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -223,12 +217,11 @@ public class SignificantTermsIT extends ESIntegTestCase {
.execute()
.actionGet();
assertSearchResponse(response);
- SignificantTerms topTerms = response.getAggregations().get("mySignificantTerms");
+ SignificantTerms topTerms = response.getAggregations().get("mySignificantTerms");
assertThat(topTerms.getBuckets().size(), equalTo(0));
}
- @Test
- public void textAnalysis() throws Exception {
+ public void testTextAnalysis() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -242,8 +235,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
checkExpectedStringTermsFound(topTerms);
}
- @Test
- public void textAnalysisGND() throws Exception {
+ public void testTextAnalysisGND() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -257,8 +249,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
checkExpectedStringTermsFound(topTerms);
}
- @Test
- public void textAnalysisChiSquare() throws Exception {
+ public void testTextAnalysisChiSquare() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -272,8 +263,7 @@ public class SignificantTermsIT extends ESIntegTestCase {
checkExpectedStringTermsFound(topTerms);
}
- @Test
- public void textAnalysisPercentageScore() throws Exception {
+ public void testTextAnalysisPercentageScore() throws Exception {
SearchResponse response = client()
.prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
@@ -289,16 +279,15 @@ public class SignificantTermsIT extends ESIntegTestCase {
checkExpectedStringTermsFound(topTerms);
}
- @Test
- public void badFilteredAnalysis() throws Exception {
+ public void testBadFilteredAnalysis() throws Exception {
// Deliberately using a bad choice of filter here for the background context in order
- // to test robustness.
+ // to test robustness.
// We search for the name of a snowboarder but use music-related content (fact_category:1)
// as the background source of term statistics.
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
- .setFrom(0).setSize(60).setExplain(true)
+ .setFrom(0).setSize(60).setExplain(true)
.addAggregation(new SignificantTermsBuilder("mySignificantTerms").field("description")
.minDocCount(2).backgroundFilter(QueryBuilders.termQuery("fact_category", 1)))
.execute()
@@ -316,15 +305,13 @@ public class SignificantTermsIT extends ESIntegTestCase {
}
}
assertTrue(hasMissingBackgroundTerms);
- }
-
-
- @Test
- public void filteredAnalysis() throws Exception {
+ }
+
+ public void testFilteredAnalysis() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "weller"))
- .setFrom(0).setSize(60).setExplain(true)
+ .setFrom(0).setSize(60).setExplain(true)
.addAggregation(new SignificantTermsBuilder("mySignificantTerms").field("description")
.minDocCount(1).backgroundFilter(QueryBuilders.termsQuery("description", "paul")))
.execute()
@@ -335,16 +322,15 @@ public class SignificantTermsIT extends ESIntegTestCase {
for (Bucket topTerm : topTerms) {
topWords.add(topTerm.getKeyAsString());
}
- //The word "paul" should be a constant of all docs in the background set and therefore not seen as significant
+ //The word "paul" should be a constant of all docs in the background set and therefore not seen as significant
assertFalse(topWords.contains("paul"));
- //"Weller" is the only Paul who was in The Jam and therefore this should be identified as a differentiator from the background of all other Pauls.
+ //"Weller" is the only Paul who was in The Jam and therefore this should be identified as a differentiator from the background of all other Pauls.
assertTrue(topWords.contains("jam"));
- }
+ }
- @Test
- public void nestedAggs() throws Exception {
+ public void testNestedAggs() throws Exception {
String[][] expectedKeywordsByCategory={
- { "paul", "weller", "jam", "style", "council" },
+ { "paul", "weller", "jam", "style", "council" },
{ "paul", "smith" },
{ "craig", "kelly", "terje", "haakonsen", "burton" }};
SearchResponse response = client().prepareSearch("test")
@@ -369,11 +355,9 @@ public class SignificantTermsIT extends ESIntegTestCase {
assertTrue(expectedKeyword + " missing from category keywords", foundTopWords.contains(expectedKeyword));
}
}
- }
-
+ }
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped", "test")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(new TermQueryBuilder("_all", "terje"))
@@ -421,7 +405,6 @@ public class SignificantTermsIT extends ESIntegTestCase {
checkExpectedStringTermsFound(topTerms);
}
- @Test
public void testMutualInformation() throws Exception {
SearchResponse response = client().prepareSearch("test")
.setSearchType(SearchType.QUERY_AND_FETCH)
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java
index db6f5be902..79aa6b2d5c 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -103,7 +102,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0l));
-
+
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
@@ -111,7 +110,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
Collection<Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
-
+
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
@@ -121,14 +120,14 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertThat(testBucket.getDocCount() + testBucket.getDocCountError(), greaterThanOrEqualTo(accurateBucket.getDocCount()));
assertThat(testBucket.getDocCount() - testBucket.getDocCountError(), lessThanOrEqualTo(accurateBucket.getDocCount()));
}
-
+
for (Terms.Bucket accurateBucket: accurateTerms.getBuckets()) {
assertThat(accurateBucket, notNullValue());
Terms.Bucket testBucket = accurateTerms.getBucketByKey(accurateBucket.getKeyAsString());
if (testBucket == null) {
assertThat(accurateBucket.getDocCount(), lessThanOrEqualTo(testTerms.getDocCountError()));
}
-
+
}
}
@@ -137,7 +136,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0l));
-
+
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
@@ -145,7 +144,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
Collection<Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
-
+
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
@@ -162,7 +161,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertThat(testTerms.getDocCountError(), equalTo(0l));
Collection<Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
-
+
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
assertThat(testBucket.getDocCountError(), equalTo(0l));
@@ -174,7 +173,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0l));
-
+
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
@@ -182,7 +181,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
Collection<Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
-
+
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
@@ -192,8 +191,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
}
}
- @Test
- public void stringValueField() throws Exception {
+ public void testStringValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx").setTypes("type")
@@ -207,7 +205,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -223,8 +221,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_singleShard() throws Exception {
+ public void testStringValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -238,7 +235,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -254,11 +251,10 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_withRouting() throws Exception {
+ public void testStringValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
-
+
SearchResponse testResponse = client().prepareSearch("idx_with_routing").setTypes("type").setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -274,8 +270,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountErrorSingleResponse(size, testResponse);
}
- @Test
- public void stringValueField_docCountAsc() throws Exception {
+ public void testStringValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -290,7 +285,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -307,8 +302,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_termSortAsc() throws Exception {
+ public void testStringValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -323,7 +317,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -340,8 +334,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_termSortDesc() throws Exception {
+ public void testStringValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -356,7 +349,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -373,8 +366,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_subAggAsc() throws Exception {
+ public void testStringValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -390,7 +382,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -408,8 +400,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void stringValueField_subAggDesc() throws Exception {
+ public void testStringValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -425,7 +416,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -443,8 +434,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField() throws Exception {
+ public void testLongValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx").setTypes("type")
@@ -458,7 +448,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -474,8 +464,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_singleShard() throws Exception {
+ public void testLongValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -489,7 +478,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -505,11 +494,10 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_withRouting() throws Exception {
+ public void testLongValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
-
+
SearchResponse testResponse = client().prepareSearch("idx_with_routing").setTypes("type").setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -525,8 +513,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountErrorSingleResponse(size, testResponse);
}
- @Test
- public void longValueField_docCountAsc() throws Exception {
+ public void testLongValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -541,7 +528,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -558,8 +545,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_termSortAsc() throws Exception {
+ public void testLongValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -574,7 +560,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -591,8 +577,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_termSortDesc() throws Exception {
+ public void testLongValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -607,7 +592,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -624,8 +609,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_subAggAsc() throws Exception {
+ public void testLongValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -641,7 +625,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -659,8 +643,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void longValueField_subAggDesc() throws Exception {
+ public void testLongValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -676,7 +659,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -694,8 +677,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField() throws Exception {
+ public void testDoubleValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx").setTypes("type")
@@ -709,7 +691,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -725,8 +707,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_singleShard() throws Exception {
+ public void testDoubleValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -740,7 +721,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -756,11 +737,10 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_withRouting() throws Exception {
+ public void testDoubleValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
-
+
SearchResponse testResponse = client().prepareSearch("idx_with_routing").setTypes("type").setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -776,8 +756,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountErrorSingleResponse(size, testResponse);
}
- @Test
- public void doubleValueField_docCountAsc() throws Exception {
+ public void testDoubleValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -792,7 +771,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -809,8 +788,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_termSortAsc() throws Exception {
+ public void testDoubleValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -825,7 +803,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -842,8 +820,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_termSortDesc() throws Exception {
+ public void testDoubleValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -858,7 +835,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -875,8 +852,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertNoDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_subAggAsc() throws Exception {
+ public void testDoubleValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -892,7 +868,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
@@ -910,8 +886,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
- @Test
- public void doubleValueField_subAggDesc() throws Exception {
+ public void testDoubleValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard").setTypes("type")
@@ -927,7 +902,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
.execute().actionGet();
assertSearchResponse(accurateResponse);
-
+
SearchResponse testResponse = client().prepareSearch("idx_single_shard").setTypes("type")
.addAggregation(terms("terms")
.executionHint(randomExecutionHint())
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java
index 03aebd6058..9a7b337dc9 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.significant.SignificantTerms
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -51,9 +50,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
}
// see https://github.com/elasticsearch/elasticsearch/issues/5998
- @Test
- public void shardMinDocCountSignificantTermsTest() throws Exception {
-
+ public void testShardMinDocCountSignificantTermsTest() throws Exception {
String termtype = "string";
if (randomBoolean()) {
termtype = "long";
@@ -111,8 +108,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
}
// see https://github.com/elasticsearch/elasticsearch/issues/5998
- @Test
- public void shardMinDocCountTermsTest() throws Exception {
+ public void testShardMinDocCountTermsTest() throws Exception {
final String [] termTypes = {"string", "long", "integer", "float", "double"};
String termtype = termTypes[randomInt(termTypes.length - 1)];
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java
index 56eb619cc8..b5ef5d9eb4 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
-import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.BucketCollector;
@@ -46,7 +45,6 @@ import org.elasticsearch.search.aggregations.SearchContextAggregations;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -57,8 +55,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class NestedAggregatorTests extends ESSingleNodeTestCase {
-
- @Test
public void testResetRootDocId() throws Exception {
Directory directory = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(null);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java
index aea11bab4f..c911da06ae 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java
@@ -34,17 +34,13 @@ import org.elasticsearch.search.aggregations.bucket.significant.heuristics.GND;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.JLHScore;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.MutualInformation;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.PercentageScore;
-import org.elasticsearch.search.aggregations.bucket.significant.heuristics.ScriptHeuristic;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicBuilder;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParser;
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParserMapper;
-import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicStreams;
-import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestSearchContext;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -79,8 +75,7 @@ public class SignificanceHeuristicTests extends ESTestCase {
}
// test that stream output can actually be read - does not replace bwc test
- @Test
- public void streamResponse() throws Exception {
+ public void testStreamResponse() throws Exception {
Version version = randomVersion(random());
InternalSignificantTerms[] sigTerms = getRandomSignificantTerms(getRandomSignificanceheuristic());
@@ -108,13 +103,13 @@ public class SignificanceHeuristicTests extends ESTestCase {
BytesRef term = new BytesRef("123.0");
buckets.add(new SignificantLongTerms.Bucket(1, 2, 3, 4, 123, InternalAggregations.EMPTY, null));
sTerms[0] = new SignificantLongTerms(10, 20, "some_name", null, 1, 1, heuristic, buckets,
- (List<PipelineAggregator>) Collections.EMPTY_LIST, null);
+ Collections.EMPTY_LIST, null);
sTerms[1] = new SignificantLongTerms();
} else {
BytesRef term = new BytesRef("someterm");
buckets.add(new SignificantStringTerms.Bucket(term, 1, 2, 3, 4, InternalAggregations.EMPTY));
- sTerms[0] = new SignificantStringTerms(10, 20, "some_name", 1, 1, heuristic, buckets, (List<PipelineAggregator>) Collections.EMPTY_LIST,
+ sTerms[0] = new SignificantStringTerms(10, 20, "some_name", 1, 1, heuristic, buckets, Collections.EMPTY_LIST,
null);
sTerms[1] = new SignificantStringTerms();
}
@@ -133,7 +128,6 @@ public class SignificanceHeuristicTests extends ESTestCase {
// test that
// 1. The output of the builders can actually be parsed
// 2. The parser does not swallow parameters after a significance heuristic was defined
- @Test
public void testBuilderAndParser() throws Exception {
Set<SignificanceHeuristicParser> parsers = new HashSet<>();
@@ -308,7 +302,6 @@ public class SignificanceHeuristicTests extends ESTestCase {
}
}
- @Test
public void testAssertions() throws Exception {
testBackgroundAssertions(new MutualInformation(true, true), new MutualInformation(true, false));
testBackgroundAssertions(new ChiSquare(true, true), new ChiSquare(true, false));
@@ -317,8 +310,7 @@ public class SignificanceHeuristicTests extends ESTestCase {
testAssertions(JLHScore.INSTANCE);
}
- @Test
- public void basicScoreProperties() {
+ public void testBasicScoreProperties() {
basicScoreProperties(JLHScore.INSTANCE, true);
basicScoreProperties(new GND(true), true);
basicScoreProperties(PercentageScore.INSTANCE, true);
@@ -327,7 +319,6 @@ public class SignificanceHeuristicTests extends ESTestCase {
}
public void basicScoreProperties(SignificanceHeuristic heuristic, boolean test0) {
-
assertThat(heuristic.getScore(1, 1, 1, 3), greaterThan(0.0));
assertThat(heuristic.getScore(1, 1, 2, 3), lessThan(heuristic.getScore(1, 1, 1, 3)));
assertThat(heuristic.getScore(1, 1, 3, 4), lessThan(heuristic.getScore(1, 1, 2, 4)));
@@ -347,8 +338,7 @@ public class SignificanceHeuristicTests extends ESTestCase {
assertThat(score, greaterThanOrEqualTo(0.0));
}
- @Test
- public void scoreMutual() throws Exception {
+ public void testScoreMutual() throws Exception {
SignificanceHeuristic heuristic = new MutualInformation(true, true);
assertThat(heuristic.getScore(1, 1, 1, 3), greaterThan(0.0));
assertThat(heuristic.getScore(1, 1, 2, 3), lessThan(heuristic.getScore(1, 1, 1, 3)));
@@ -384,7 +374,6 @@ public class SignificanceHeuristicTests extends ESTestCase {
assertThat(score, lessThanOrEqualTo(1.0));
}
- @Test
public void testGNDCornerCases() throws Exception {
GND gnd = new GND(true);
//term is only in the subset, not at all in the other set but that is because the other set is empty.
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java
index d60a870610..a2aa5867c3 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java
@@ -31,7 +31,6 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
*/
@ESIntegTestCase.SuiteScopeTestCase
public abstract class AbstractNumericTestCase extends ESIntegTestCase {
-
protected static long minValue, maxValue, minValues, maxValues;
@Override
@@ -77,30 +76,29 @@ public abstract class AbstractNumericTestCase extends ESIntegTestCase {
public abstract void testSingleValuedField() throws Exception;
- public abstract void testSingleValuedField_getProperty() throws Exception;
+ public abstract void testSingleValuedFieldGetProperty() throws Exception;
- public abstract void testSingleValuedField_PartiallyUnmapped() throws Exception;
+ public abstract void testSingleValuedFieldPartiallyUnmapped() throws Exception;
- public abstract void testSingleValuedField_WithValueScript() throws Exception;
+ public abstract void testSingleValuedFieldWithValueScript() throws Exception;
- public abstract void testSingleValuedField_WithValueScript_WithParams() throws Exception;
+ public abstract void testSingleValuedFieldWithValueScriptWithParams() throws Exception;
public abstract void testMultiValuedField() throws Exception;
- public abstract void testMultiValuedField_WithValueScript() throws Exception;
-
- public abstract void testMultiValuedField_WithValueScript_WithParams() throws Exception;
+ public abstract void testMultiValuedFieldWithValueScript() throws Exception;
- public abstract void testScript_SingleValued() throws Exception;
+ public abstract void testMultiValuedFieldWithValueScriptWithParams() throws Exception;
- public abstract void testScript_SingleValued_WithParams() throws Exception;
+ public abstract void testScriptSingleValued() throws Exception;
- public abstract void testScript_ExplicitSingleValued_WithParams() throws Exception;
+ public abstract void testScriptSingleValuedWithParams() throws Exception;
- public abstract void testScript_MultiValued() throws Exception;
+ public abstract void testScriptExplicitSingleValuedWithParams() throws Exception;
- public abstract void testScript_ExplicitMultiValued() throws Exception;
+ public abstract void testScriptMultiValued() throws Exception;
- public abstract void testScript_MultiValued_WithParams() throws Exception;
+ public abstract void testScriptExplicitMultiValued() throws Exception;
+ public abstract void testScriptMultiValuedWithParams() throws Exception;
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java
index 056fc59219..0504cb6ff5 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsAggregator;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.List;
@@ -49,11 +48,9 @@ import static org.hamcrest.Matchers.sameInstance;
*/
@ESIntegTestCase.SuiteScopeTestCase
public class GeoBoundsIT extends AbstractGeoTestCase {
-
private static final String aggName = "geoBounds";
- @Test
- public void singleValuedField() throws Exception {
+ public void testSingleValuedField() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
.wrapLongitude(false))
@@ -72,7 +69,6 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight.lon(), equalTo(singleBottomRight.lon()));
}
- @Test
public void testSingleValuedField_getProperty() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch(IDX_NAME)
@@ -106,10 +102,9 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat((double) global.getProperty(aggName + ".right"), equalTo(singleBottomRight.lon()));
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME)
- .addAggregation(geoBounds(aggName).field(MULTI_VALUED_FIELD_NAME)
+ .addAggregation(geoBounds(aggName).field(MULTI_VALUED_FIELD_NAME)
.wrapLongitude(false))
.execute().actionGet();
@@ -127,8 +122,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight.lon(), equalTo(multiBottomRight.lon()));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch(UNMAPPED_IDX_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
.wrapLongitude(false))
@@ -145,8 +139,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight, equalTo(null));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
.wrapLongitude(false))
@@ -165,8 +158,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight.lon(), equalTo(singleBottomRight.lon()));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch(EMPTY_IDX_NAME)
.setQuery(matchAllQuery())
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
@@ -183,8 +175,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight, equalTo(null));
}
- @Test
- public void singleValuedFieldNearDateLine() throws Exception {
+ public void testSingleValuedFieldNearDateLine() throws Exception {
SearchResponse response = client().prepareSearch(DATELINE_IDX_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
.wrapLongitude(false))
@@ -206,18 +197,16 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
assertThat(bottomRight.lon(), equalTo(geoValuesBottomRight.lon()));
}
- @Test
- public void singleValuedFieldNearDateLineWrapLongitude() throws Exception {
+ public void testSingleValuedFieldNearDateLineWrapLongitude() throws Exception {
GeoPoint geoValuesTopLeft = new GeoPoint(38, 170);
GeoPoint geoValuesBottomRight = new GeoPoint(-24, -175);
-
SearchResponse response = client().prepareSearch(DATELINE_IDX_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(true))
.execute().actionGet();
assertSearchResponse(response);
-
+
GeoBounds geoBounds = response.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
@@ -232,8 +221,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
/**
* This test forces the {@link GeoBoundsAggregator} to resize the {@link BigArray}s it uses to ensure they are resized correctly
*/
- @Test
- public void singleValuedFieldAsSubAggToHighCardTermsAgg() {
+ public void testSingleValuedFieldAsSubAggToHighCardTermsAgg() {
SearchResponse response = client().prepareSearch(HIGH_CARD_IDX_NAME)
.addAggregation(terms("terms").field(NUMBER_FIELD_NAME).subAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME)
.wrapLongitude(false)))
@@ -260,8 +248,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase {
}
}
- @Test
- public void singleValuedFieldWithZeroLon() throws Exception {
+ public void testSingleValuedFieldWithZeroLon() throws Exception {
SearchResponse response = client().prepareSearch(IDX_ZERO_NAME)
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false)).execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java
index 9d2670ca7b..e0d260f543 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid;
import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.metrics.geocentroid.GeoCentroid;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.List;
@@ -34,7 +33,10 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.geoCentr
import static org.elasticsearch.search.aggregations.AggregationBuilders.geohashGrid;
import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
* Integration Test for GeoCentroid metric aggregator
@@ -43,8 +45,7 @@ import static org.hamcrest.Matchers.*;
public class GeoCentroidIT extends AbstractGeoTestCase {
private static final String aggName = "geoCentroid";
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse response = client().prepareSearch(EMPTY_IDX_NAME)
.setQuery(matchAllQuery())
.addAggregation(geoCentroid(aggName).field(SINGLE_VALUED_FIELD_NAME))
@@ -59,8 +60,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat(centroid, equalTo(null));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch(UNMAPPED_IDX_NAME)
.addAggregation(geoCentroid(aggName).field(SINGLE_VALUED_FIELD_NAME))
.execute().actionGet();
@@ -73,8 +73,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat(centroid, equalTo(null));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME)
.addAggregation(geoCentroid(aggName).field(SINGLE_VALUED_FIELD_NAME))
.execute().actionGet();
@@ -88,8 +87,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat(centroid.lon(), closeTo(singleCentroid.lon(), GEOHASH_TOLERANCE));
}
- @Test
- public void singleValuedField() throws Exception {
+ public void testSingleValuedField() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME)
.setQuery(matchAllQuery())
.addAggregation(geoCentroid(aggName).field(SINGLE_VALUED_FIELD_NAME))
@@ -104,8 +102,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat(centroid.lon(), closeTo(singleCentroid.lon(), GEOHASH_TOLERANCE));
}
- @Test
- public void singleValueField_getProperty() throws Exception {
+ public void testSingleValueFieldGetProperty() throws Exception {
SearchResponse response = client().prepareSearch(IDX_NAME)
.setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(geoCentroid(aggName).field(SINGLE_VALUED_FIELD_NAME)))
@@ -132,8 +129,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat((double) global.getProperty(aggName + ".lon"), closeTo(singleCentroid.lon(), GEOHASH_TOLERANCE));
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch(IDX_NAME)
.setQuery(matchAllQuery())
.addAggregation(geoCentroid(aggName).field(MULTI_VALUED_FIELD_NAME))
@@ -148,8 +144,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase {
assertThat(centroid.lon(), closeTo(multiCentroid.lon(), GEOHASH_TOLERANCE));
}
- @Test
- public void singleValueFieldAsSubAggToGeohashGrid() throws Exception {
+ public void testSingleValueFieldAsSubAggToGeohashGrid() throws Exception {
SearchResponse response = client().prepareSearch(HIGH_CARD_IDX_NAME)
.addAggregation(geohashGrid("geoGrid").field(SINGLE_VALUED_FIELD_NAME)
.subAggregation(geoCentroid(aggName)))
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
index 71c7ccd7b3..985e040a8a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
@@ -46,7 +46,6 @@ import org.elasticsearch.search.highlight.HighlightField;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -88,7 +87,7 @@ public class TopHitsIT extends ESIntegTestCase {
private static final String TERMS_AGGS_FIELD = "terms";
private static final String SORT_FIELD = "sort";
-
+
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(MockScriptEngine.TestPlugin.class);
@@ -249,7 +248,6 @@ public class TopHitsIT extends ESIntegTestCase {
return bucket.getKeyAsString();
}
- @Test
public void testBasics() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
@@ -289,7 +287,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testIssue11119() throws Exception {
// Test that top_hits aggregation is fed scores if query results size=0
SearchResponse response = client()
@@ -348,7 +345,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
- @Test
public void testBreadthFirst() throws Exception {
// breadth_first will be ignored since we need scores
SearchResponse response = client().prepareSearch("idx").setTypes("type")
@@ -380,8 +376,7 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
- public void testBasics_getProperty() throws Exception {
+ public void testBasicsGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(topHits("hits"))).execute().actionGet();
@@ -400,7 +395,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
- @Test
public void testPagination() throws Exception {
int size = randomIntBetween(1, 10);
int from = randomIntBetween(0, 10);
@@ -446,7 +440,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testSortByBucket() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -486,7 +479,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testFieldCollapsing() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
@@ -530,7 +522,6 @@ public class TopHitsIT extends ESIntegTestCase {
assertThat(hits.getAt(0).id(), equalTo("2"));
}
- @Test
public void testFetchFeatures() {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.setQuery(matchQuery("text", "text").queryName("test"))
@@ -585,7 +576,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testInvalidSortField() throws Exception {
try {
client().prepareSearch("idx").setTypes("type")
@@ -602,7 +592,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- // @Test
// public void testFailWithSubAgg() throws Exception {
// String source = "{\n" +
// " \"aggs\": {\n" +
@@ -636,7 +625,6 @@ public class TopHitsIT extends ESIntegTestCase {
// }
// } NORELEASE this needs to be tested in a top_hits aggregations unit test
- @Test
public void testEmptyIndex() throws Exception {
SearchResponse response = client().prepareSearch("empty").setTypes("type")
.addAggregation(topHits("hits"))
@@ -649,7 +637,6 @@ public class TopHitsIT extends ESIntegTestCase {
assertThat(hits.getHits().totalHits(), equalTo(0l));
}
- @Test
public void testTrackScores() throws Exception {
boolean[] trackScores = new boolean[]{true, false};
for (boolean trackScore : trackScores) {
@@ -696,7 +683,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testTopHitsInNestedSimple() throws Exception {
SearchResponse searchResponse = client().prepareSearch("articles")
.setQuery(matchQuery("title", "title"))
@@ -748,7 +734,6 @@ public class TopHitsIT extends ESIntegTestCase {
assertThat((Integer) searchHits.getAt(0).getSource().get("date"), equalTo(4));
}
- @Test
public void testTopHitsInSecondLayerNested() throws Exception {
SearchResponse searchResponse = client().prepareSearch("articles")
.setQuery(matchQuery("title", "title"))
@@ -849,7 +834,6 @@ public class TopHitsIT extends ESIntegTestCase {
assertThat(topReviewers.getHits().getAt(0).getNestedIdentity().getChild().getOffset(), equalTo(0));
}
- @Test
public void testNestedFetchFeatures() {
String hlType = randomFrom("plain", "fvh", "postings");
HighlightBuilder.Field hlField = new HighlightBuilder.Field("comments.message")
@@ -902,7 +886,6 @@ public class TopHitsIT extends ESIntegTestCase {
assertThat(searchHit.sourceAsMap().get("message").toString(), equalTo("some comment"));
}
- @Test
public void testTopHitsInNested() throws Exception {
SearchResponse searchResponse = client().prepareSearch("articles")
.addAggregation(
@@ -944,7 +927,6 @@ public class TopHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testDontExplode() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java
index 684a433660..9a00297c57 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java
@@ -21,18 +21,16 @@ package org.elasticsearch.search.aggregations.metrics.cardinality;
import com.carrotsearch.hppc.BitMixer;
import com.carrotsearch.hppc.IntHashSet;
+
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.search.aggregations.metrics.cardinality.HyperLogLogPlusPlus.MAX_PRECISION;
import static org.elasticsearch.search.aggregations.metrics.cardinality.HyperLogLogPlusPlus.MIN_PRECISION;
import static org.hamcrest.Matchers.closeTo;
public class HyperLogLogPlusPlusTests extends ESTestCase {
-
- @Test
- public void encodeDecode() {
+ public void testEncodeDecode() {
final int iters = scaledRandomIntBetween(100000, 500000);
// random hashes
for (int i = 0; i < iters; ++i) {
@@ -56,8 +54,7 @@ public class HyperLogLogPlusPlusTests extends ESTestCase {
assertEquals(runLen, HyperLogLogPlusPlus.decodeRunLen(encoded, p1));
}
- @Test
- public void accuracy() {
+ public void testAccuracy() {
final long bucket = randomInt(20);
final int numValues = randomIntBetween(1, 100000);
final int maxValue = randomIntBetween(1, randomBoolean() ? 1000: 100000);
@@ -77,8 +74,7 @@ public class HyperLogLogPlusPlusTests extends ESTestCase {
assertThat((double) e.cardinality(bucket), closeTo(set.size(), 0.1 * set.size()));
}
- @Test
- public void merge() {
+ public void testMerge() {
final int p = randomIntBetween(MIN_PRECISION, MAX_PRECISION);
final HyperLogLogPlusPlus single = new HyperLogLogPlusPlus(p, BigArrays.NON_RECYCLING_INSTANCE, 0);
final HyperLogLogPlusPlus[] multi = new HyperLogLogPlusPlus[randomIntBetween(2, 100)];
@@ -106,8 +102,7 @@ public class HyperLogLogPlusPlusTests extends ESTestCase {
}
}
- @Test
- public void fakeHashes() {
+ public void testFakeHashes() {
// hashes with lots of leading zeros trigger different paths in the code that we try to go through here
final int p = randomIntBetween(MIN_PRECISION, MAX_PRECISION);
final HyperLogLogPlusPlus counts = new HyperLogLogPlusPlus(p, BigArrays.NON_RECYCLING_INSTANCE, 0);
@@ -123,8 +118,7 @@ public class HyperLogLogPlusPlusTests extends ESTestCase {
assertEquals(1, counts.cardinality(0));
}
- @Test
- public void precisionFromThreshold() {
+ public void testPrecisionFromThreshold() {
assertEquals(4, HyperLogLogPlusPlus.precisionFromThreshold(0));
assertEquals(6, HyperLogLogPlusPlus.precisionFromThreshold(10));
assertEquals(10, HyperLogLogPlusPlus.precisionFromThreshold(100));
@@ -133,5 +127,4 @@ public class HyperLogLogPlusPlusTests extends ESTestCase {
assertEquals(18, HyperLogLogPlusPlus.precisionFromThreshold(100000));
assertEquals(18, HyperLogLogPlusPlus.precisionFromThreshold(1000000));
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java
index a18f1296dd..ea0eb7fd93 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java
@@ -28,17 +28,15 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.avgBucket;
-
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.avgBucket;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
@@ -91,8 +89,7 @@ public class AvgBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -124,8 +121,7 @@ public class AvgBucketIT extends ESIntegTestCase {
assertThat(avgBucketValue.value(), equalTo(avgValue));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -173,8 +169,7 @@ public class AvgBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -208,8 +203,7 @@ public class AvgBucketIT extends ESIntegTestCase {
assertThat(avgBucketValue.value(), equalTo(avgValue));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -262,8 +256,7 @@ public class AvgBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -316,7 +309,6 @@ public class AvgBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -336,7 +328,6 @@ public class AvgBucketIT extends ESIntegTestCase {
assertThat(avgBucketValue.value(), equalTo(Double.NaN));
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumIT.java
index 1d844e17af..6f10e5d91f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -86,7 +85,6 @@ public class CumulativeSumIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
public void testDocCount() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
@@ -116,7 +114,6 @@ public class CumulativeSumIT extends ESIntegTestCase {
}
- @Test
public void testMetric() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
@@ -149,7 +146,6 @@ public class CumulativeSumIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java
index 569830b0a9..3058d1f10d 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java
@@ -34,17 +34,16 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.junit.After;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.derivative;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.derivative;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
@@ -105,8 +104,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
internalCluster().wipeIndices("idx2");
}
- @Test
- public void singleValuedField() throws Exception {
+ public void testSingleValuedField() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -148,8 +146,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
assertThat(docCountDeriv.value(), equalTo(1d));
}
- @Test
- public void singleValuedField_normalised() throws Exception {
+ public void testSingleValuedFieldNormalised() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -194,8 +191,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
assertThat(docCountDeriv.normalizedValue(), closeTo(1d / 29d, 0.00001));
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -264,8 +260,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
assertThat((double) propertiesCounts[2], equalTo(15.0));
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -320,8 +315,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
assertThat(docCountDeriv.value(), equalTo(-2.0));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx_unmapped")
.addAggregation(
@@ -336,8 +330,7 @@ public class DateDerivativeIT extends ESIntegTestCase {
assertThat(deriv.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "idx_unmapped")
.addAggregation(
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java
index fbbb173ee7..b65a86ac57 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java
@@ -36,7 +36,6 @@ import org.elasticsearch.search.aggregations.pipeline.derivative.Derivative;
import org.elasticsearch.search.aggregations.support.AggregationPath;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -167,8 +166,7 @@ public class DerivativeIT extends ESIntegTestCase {
/**
* test first and second derivative on the sing
*/
- @Test
- public void docCountDerivative() {
+ public void testDocCountDerivative() {
SearchResponse response = client()
.prepareSearch("idx")
@@ -208,9 +206,7 @@ public class DerivativeIT extends ESIntegTestCase {
/**
* test first and second derivative on the sing
*/
- @Test
- public void singleValuedField_normalised() {
-
+ public void testSingleValuedField_normalised() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -248,8 +244,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void singleValueAggDerivative() throws Exception {
+ public void testSingleValueAggDerivative() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -294,8 +289,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void multiValueAggDerivative() throws Exception {
+ public void testMultiValueAggDerivative() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -340,8 +334,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx_unmapped")
.addAggregation(
@@ -356,8 +349,7 @@ public class DerivativeIT extends ESIntegTestCase {
assertThat(deriv.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "idx_unmapped")
.addAggregation(
@@ -385,8 +377,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void docCountDerivativeWithGaps() throws Exception {
+ public void testDocCountDerivativeWithGaps() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -414,8 +405,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void docCountDerivativeWithGaps_random() throws Exception {
+ public void testDocCountDerivativeWithGaps_random() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx_rnd")
.setQuery(matchAllQuery())
@@ -445,8 +435,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void docCountDerivativeWithGaps_insertZeros() throws Exception {
+ public void testDocCountDerivativeWithGaps_insertZeros() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -475,8 +464,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void singleValueAggDerivativeWithGaps() throws Exception {
+ public void testSingleValueAggDerivativeWithGaps() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -517,8 +505,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void singleValueAggDerivativeWithGaps_insertZeros() throws Exception {
+ public void testSingleValueAggDerivativeWithGaps_insertZeros() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -556,8 +543,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void singleValueAggDerivativeWithGaps_random() throws Exception {
+ public void testSingleValueAggDerivativeWithGaps_random() throws Exception {
GapPolicy gapPolicy = randomFrom(GapPolicy.values());
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx_rnd")
@@ -600,8 +586,7 @@ public class DerivativeIT extends ESIntegTestCase {
}
}
- @Test
- public void singleValueAggDerivative_invalidPath() throws Exception {
+ public void testSingleValueAggDerivative_invalidPath() throws Exception {
try {
client().prepareSearch("idx")
.addAggregation(
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java
index 3c3d705ecc..6c7ae2383f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java
@@ -30,17 +30,15 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucket;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.extendedStatsBucket;
-
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.extendedStatsBucket;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
@@ -93,8 +91,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -135,8 +132,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
assertThat(extendedStatsBucketValue.getSumOfSquares(), equalTo(sumOfSquares));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -193,8 +189,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -237,8 +232,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
assertThat(extendedStatsBucketValue.getSumOfSquares(), equalTo(sumOfSquares));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -300,8 +294,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -363,7 +356,6 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -383,8 +375,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
assertThat(extendedStatsBucketValue.getAvg(), equalTo(Double.NaN));
}
- @Test
- public void testBadSigma_asSubAgg() throws Exception {
+ public void testBadSigmaAsSubAgg() throws Exception {
try {
SearchResponse response = client()
.prepareSearch("idx")
@@ -404,7 +395,6 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java
index bacb6bda9b..81b5735012 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -94,8 +93,7 @@ public class MaxBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -132,8 +130,7 @@ public class MaxBucketIT extends ESIntegTestCase {
assertThat(maxBucketValue.keys(), equalTo(maxKeys.toArray(new String[maxKeys.size()])));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -186,8 +183,7 @@ public class MaxBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -226,8 +222,7 @@ public class MaxBucketIT extends ESIntegTestCase {
assertThat(maxBucketValue.keys(), equalTo(maxKeys.toArray(new String[maxKeys.size()])));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -285,8 +280,7 @@ public class MaxBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggOfSingleBucketAgg() throws Exception {
+ public void testMetricAsSubAggOfSingleBucketAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -334,8 +328,7 @@ public class MaxBucketIT extends ESIntegTestCase {
assertThat(maxBucketValue.keys(), equalTo(maxKeys.toArray(new String[maxKeys.size()])));
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -392,7 +385,6 @@ public class MaxBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -413,7 +405,6 @@ public class MaxBucketIT extends ESIntegTestCase {
assertThat(maxBucketValue.keys(), equalTo(new String[0]));
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java
index cb83f60f23..f02a85f130 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java
@@ -29,16 +29,15 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.minBucket;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.minBucket;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
@@ -91,8 +90,7 @@ public class MinBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -129,8 +127,7 @@ public class MinBucketIT extends ESIntegTestCase {
assertThat(minBucketValue.keys(), equalTo(minKeys.toArray(new String[minKeys.size()])));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -183,8 +180,7 @@ public class MinBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -223,8 +219,7 @@ public class MinBucketIT extends ESIntegTestCase {
assertThat(minBucketValue.keys(), equalTo(minKeys.toArray(new String[minKeys.size()])));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -282,8 +277,7 @@ public class MinBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -340,7 +334,6 @@ public class MinBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -361,7 +354,6 @@ public class MinBucketIT extends ESIntegTestCase {
assertThat(minBucketValue.keys(), equalTo(new String[0]));
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java
index f7c1d060bd..c4dc267ec5 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucket;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -94,8 +93,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -132,8 +130,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -185,8 +182,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -224,8 +220,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevelDefaultPercents() throws Exception {
+ public void testMetricTopLevelDefaultPercents() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -263,8 +258,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -321,8 +315,7 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -380,7 +373,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -404,7 +396,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testWrongPercents() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -432,7 +423,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testBadPercents() throws Exception {
Double[] badPercents = {-1.0, 110.0};
@@ -453,7 +443,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
- @Test
public void testBadPercents_asSubAgg() throws Exception {
Double[] badPercents = {-1.0, 110.0};
@@ -481,7 +470,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
@@ -547,7 +535,6 @@ public class PercentilesBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNestedWithDecimal() throws Exception {
Double[] percent = {99.9};
SearchResponse response = client()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java
index 866fdc0773..92325ccd81 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java
@@ -29,17 +29,15 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucket;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.statsBucket;
-
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.statsBucket;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
@@ -92,8 +90,7 @@ public class StatsBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -131,8 +128,7 @@ public class StatsBucketIT extends ESIntegTestCase {
assertThat(statsBucketValue.getMax(), equalTo(max));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -186,8 +182,7 @@ public class StatsBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -227,8 +222,7 @@ public class StatsBucketIT extends ESIntegTestCase {
assertThat(statsBucketValue.getMax(), equalTo(max));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -287,8 +281,7 @@ public class StatsBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -347,7 +340,6 @@ public class StatsBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -367,7 +359,6 @@ public class StatsBucketIT extends ESIntegTestCase {
assertThat(statsBucketValue.getAvg(), equalTo(Double.NaN));
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java
index be11f90fa6..ba13b553d8 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java
@@ -28,17 +28,15 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.sumBucket;
-
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
+import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.sumBucket;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
@@ -91,8 +89,7 @@ public class SumBucketIT extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void testDocCount_topLevel() throws Exception {
+ public void testDocCountTopLevel() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.extendedBounds((long) minRandomValue, (long) maxRandomValue))
@@ -121,8 +118,7 @@ public class SumBucketIT extends ESIntegTestCase {
assertThat(sumBucketValue.value(), equalTo(sum));
}
- @Test
- public void testDocCount_asSubAgg() throws Exception {
+ public void testDocCountAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -167,8 +163,7 @@ public class SumBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_topLevel() throws Exception {
+ public void testMetricTopLevel() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -199,8 +194,7 @@ public class SumBucketIT extends ESIntegTestCase {
assertThat(sumBucketValue.value(), equalTo(bucketSum));
}
- @Test
- public void testMetric_asSubAgg() throws Exception {
+ public void testMetricAsSubAgg() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -250,8 +244,7 @@ public class SumBucketIT extends ESIntegTestCase {
}
}
- @Test
- public void testMetric_asSubAggWithInsertZeros() throws Exception {
+ public void testMetricAsSubAggWithInsertZeros() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -301,7 +294,6 @@ public class SumBucketIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBuckets() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field("tag").exclude("tag.*").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -321,7 +313,6 @@ public class SumBucketIT extends ESIntegTestCase {
assertThat(sumBucketValue.value(), equalTo(0.0));
}
- @Test
public void testNested() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java
index ac4fcf89ae..e5c1e8d27d 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java
@@ -32,28 +32,41 @@ import org.elasticsearch.search.aggregations.pipeline.BucketHelpers;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregationHelperTests;
import org.elasticsearch.search.aggregations.pipeline.SimpleValue;
import org.elasticsearch.search.aggregations.pipeline.derivative.Derivative;
-import org.elasticsearch.search.aggregations.pipeline.movavg.models.*;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.EwmaModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltLinearModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.LinearModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelBuilder;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.avg;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.max;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.min;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.range;
import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.derivative;
import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.movingAvg;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
@ESIntegTestCase.SuiteScopeTestCase
public class MovAvgIT extends ESIntegTestCase {
-
private static final String INTERVAL_FIELD = "l_value";
private static final String VALUE_FIELD = "v_value";
- private static final String GAP_FIELD = "g_value";
static int interval;
static int numBuckets;
@@ -79,6 +92,7 @@ public class MovAvgIT extends ESIntegTestCase {
name = s;
}
+ @Override
public String toString(){
return name;
}
@@ -93,6 +107,7 @@ public class MovAvgIT extends ESIntegTestCase {
name = s;
}
+ @Override
public String toString(){
return name;
}
@@ -342,8 +357,8 @@ public class MovAvgIT extends ESIntegTestCase {
s += vs[i];
b += (vs[i + period] - vs[i]) / period;
}
- s /= (double) period;
- b /= (double) period;
+ s /= period;
+ b /= period;
last_s = s;
// Calculate first seasonal
@@ -388,9 +403,7 @@ public class MovAvgIT extends ESIntegTestCase {
/**
* test simple moving average on single value field
*/
- @Test
- public void simpleSingleValuedField() {
-
+ public void testSimpleSingleValuedField() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -440,9 +453,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
- public void linearSingleValuedField() {
-
+ public void testLinearSingleValuedField() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -492,9 +503,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
- public void ewmaSingleValuedField() {
-
+ public void testEwmaSingleValuedField() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -544,9 +553,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
- public void holtSingleValuedField() {
-
+ public void testHoltSingleValuedField() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -596,9 +603,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
- public void HoltWintersValuedField() {
-
+ public void testHoltWintersValuedField() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -652,7 +657,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testPredictNegativeKeysAtStart() {
SearchResponse response = client()
@@ -704,8 +708,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
-
- @Test
public void testSizeZeroWindow() {
try {
client()
@@ -721,13 +723,11 @@ public class MovAvgIT extends ESIntegTestCase {
.setBucketsPaths("the_metric"))
).execute().actionGet();
fail("MovingAvg should not accept a window that is zero");
-
- } catch (SearchPhaseExecutionException exception) {
- // All good
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
}
}
- @Test
public void testBadParent() {
try {
client()
@@ -748,7 +748,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testNegativeWindow() {
try {
client()
@@ -772,7 +771,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testNoBucketsInHistogram() {
SearchResponse response = client()
@@ -797,7 +795,6 @@ public class MovAvgIT extends ESIntegTestCase {
assertThat(buckets.size(), equalTo(0));
}
- @Test
public void testNoBucketsInHistogramWithPredict() {
int numPredictions = randomIntBetween(1,10);
SearchResponse response = client()
@@ -823,7 +820,6 @@ public class MovAvgIT extends ESIntegTestCase {
assertThat(buckets.size(), equalTo(0));
}
- @Test
public void testZeroPrediction() {
try {
client()
@@ -846,7 +842,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testNegativePrediction() {
try {
client()
@@ -869,7 +864,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testHoltWintersNotEnoughData() {
try {
SearchResponse response = client()
@@ -897,9 +891,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
- @Test
public void testTwoMovAvgsWithPredictions() {
-
SearchResponse response = client()
.prepareSearch("double_predict")
.setTypes("type")
@@ -1011,7 +1003,6 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testBadModelParams() {
try {
SearchResponse response = client()
@@ -1032,9 +1023,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
- @Test
- public void HoltWintersMinimization() {
-
+ public void testHoltWintersMinimization() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -1122,9 +1111,7 @@ public class MovAvgIT extends ESIntegTestCase {
*
* We can simulate this by setting the window size == size of histo
*/
- @Test
- public void minimizeNotEnoughData() {
-
+ public void testMinimizeNotEnoughData() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -1179,9 +1166,7 @@ public class MovAvgIT extends ESIntegTestCase {
/**
* Only some models can be minimized, should throw exception for: simple, linear
*/
- @Test
- public void checkIfNonTunableCanBeMinimized() {
-
+ public void testCheckIfNonTunableCanBeMinimized() {
try {
client()
.prepareSearch("idx").setTypes("type")
@@ -1224,9 +1209,7 @@ public class MovAvgIT extends ESIntegTestCase {
/**
* These models are all minimizable, so they should not throw exceptions
*/
- @Test
- public void checkIfTunableCanBeMinimized() {
-
+ public void testCheckIfTunableCanBeMinimized() {
MovAvgModelBuilder[] builders = new MovAvgModelBuilder[]{
new EwmaModel.EWMAModelBuilder(),
new HoltLinearModel.HoltLinearModelBuilder(),
@@ -1254,9 +1237,7 @@ public class MovAvgIT extends ESIntegTestCase {
}
}
- @Test
public void testUnrecognizedParams() {
-
MovAvgModelBuilder[] builders = new MovAvgModelBuilder[]{
new SimpleModel.SimpleModelBuilder(),
new LinearModel.LinearModelBuilder(),
@@ -1375,7 +1356,7 @@ public class MovAvgIT extends ESIntegTestCase {
return new SimpleModel.SimpleModelBuilder();
}
}
-
+
private ValuesSourceMetricsAggregationBuilder randomMetric(String name, String field) {
int rand = randomIntBetween(0,3);
@@ -1388,7 +1369,7 @@ public class MovAvgIT extends ESIntegTestCase {
return avg(name).field(field);
default:
return avg(name).field(field);
- }
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java
index 11c5e4035d..da9c8236f9 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java
@@ -21,18 +21,24 @@ package org.elasticsearch.search.aggregations.pipeline.moving.avg;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.collect.EvictingQueue;
-import org.elasticsearch.search.aggregations.pipeline.movavg.models.*;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.EwmaModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltLinearModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.LinearModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
+import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
public class MovAvgUnitTests extends ESTestCase {
-
- @Test
public void testSimpleMovAvgModel() {
MovAvgModel model = new SimpleModel();
@@ -61,7 +67,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testSimplePredictionModel() {
MovAvgModel model = new SimpleModel();
@@ -87,7 +92,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testLinearMovAvgModel() {
MovAvgModel model = new LinearModel();
@@ -119,7 +123,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testLinearPredictionModel() {
MovAvgModel model = new LinearModel();
@@ -150,7 +153,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testEWMAMovAvgModel() {
double alpha = randomDouble();
MovAvgModel model = new EwmaModel(alpha);
@@ -185,7 +187,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testEWMAPredictionModel() {
double alpha = randomDouble();
MovAvgModel model = new EwmaModel(alpha);
@@ -218,7 +219,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testHoltLinearMovAvgModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -267,7 +267,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testHoltLinearPredictionModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -313,7 +312,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
}
- @Test
public void testHoltWintersMultiplicativePadModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -353,8 +351,8 @@ public class MovAvgUnitTests extends ESTestCase {
s += vs[i];
b += (vs[i + period] - vs[i]) / period;
}
- s /= (double) period;
- b /= (double) period;
+ s /= period;
+ b /= period;
last_s = s;
// Calculate first seasonal
@@ -381,7 +379,6 @@ public class MovAvgUnitTests extends ESTestCase {
assertThat(Double.compare(expected, actual), equalTo(0));
}
- @Test
public void testHoltWintersMultiplicativePadPredictionModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -424,8 +421,8 @@ public class MovAvgUnitTests extends ESTestCase {
s += vs[i];
b += (vs[i + period] - vs[i]) / period;
}
- s /= (double) period;
- b /= (double) period;
+ s /= period;
+ b /= period;
last_s = s;
// Calculate first seasonal
@@ -455,7 +452,6 @@ public class MovAvgUnitTests extends ESTestCase {
}
- @Test
public void testHoltWintersAdditiveModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -494,8 +490,8 @@ public class MovAvgUnitTests extends ESTestCase {
s += vs[i];
b += (vs[i + period] - vs[i]) / period;
}
- s /= (double) period;
- b /= (double) period;
+ s /= period;
+ b /= period;
last_s = s;
// Calculate first seasonal
@@ -522,7 +518,6 @@ public class MovAvgUnitTests extends ESTestCase {
assertThat(Double.compare(expected, actual), equalTo(0));
}
- @Test
public void testHoltWintersAdditivePredictionModel() {
double alpha = randomDouble();
double beta = randomDouble();
@@ -564,8 +559,8 @@ public class MovAvgUnitTests extends ESTestCase {
s += vs[i];
b += (vs[i + period] - vs[i]) / period;
}
- s /= (double) period;
- b /= (double) period;
+ s /= period;
+ b /= period;
last_s = s;
// Calculate first seasonal
@@ -594,9 +589,7 @@ public class MovAvgUnitTests extends ESTestCase {
}
- @Test
public void testNumericValidation() {
-
List<MovAvgModel.AbstractModelParser> parsers = new ArrayList<>(5);
// Simple and Linear don't have any settings to test
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffIT.java
index ccd4dcbc13..aebd6a7e78 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffIT.java
@@ -31,16 +31,23 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregationHelperT
import org.elasticsearch.search.aggregations.pipeline.SimpleValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.avg;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.max;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.min;
import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.diff;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
@@ -67,6 +74,7 @@ public class SerialDiffIT extends ESIntegTestCase {
name = s;
}
+ @Override
public String toString(){
return name;
}
@@ -218,9 +226,7 @@ public class SerialDiffIT extends ESIntegTestCase {
testValues.put(target.toString(), values);
}
- @Test
- public void basicDiff() {
-
+ public void testBasicDiff() {
SearchResponse response = client()
.prepareSearch("idx").setTypes("type")
.addAggregation(
@@ -268,8 +274,7 @@ public class SerialDiffIT extends ESIntegTestCase {
}
}
- @Test
- public void invalidLagSize() {
+ public void testInvalidLagSize() {
try {
client()
.prepareSearch("idx").setTypes("type")
@@ -283,9 +288,7 @@ public class SerialDiffIT extends ESIntegTestCase {
.setBucketsPaths("_count"))
).execute().actionGet();
} catch (SearchPhaseExecutionException e) {
- // All good
+ assertThat(e.getMessage(), is("all shards failed"));
}
}
-
-
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/support/PathTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/support/PathTests.java
index 77a3e12362..4602035a40 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/support/PathTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/support/PathTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.search.aggregations.support;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -32,8 +31,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class PathTests extends ESTestCase {
-
- @Test
public void testInvalidPaths() throws Exception {
assertInvalidPath("[foo]", "brackets at the beginning of the token expression");
assertInvalidPath("foo[bar", "open brackets without closing at the token expression");
@@ -44,7 +41,6 @@ public class PathTests extends ESTestCase {
assertInvalidPath("foo.", "dot separator at the end of the token expression");
}
- @Test
public void testValidPaths() throws Exception {
assertValidPath("foo>bar", tokens().add("foo").add("bar"));
assertValidPath("foo.bar", tokens().add("foo", "bar"));
@@ -81,7 +77,6 @@ public class PathTests extends ESTestCase {
}
private static class Tokens {
-
private List<AggregationPath.PathElement> tokens = new ArrayList<>();
Tokens add(String name) {
@@ -101,8 +96,5 @@ public class PathTests extends ESTestCase {
AggregationPath.PathElement[] toArray() {
return tokens.toArray(new AggregationPath.PathElement[tokens.size()]);
}
-
-
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java
index d1a97c7616..18e9365656 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.search.aggregations.support.values.ScriptBytesValues;
import org.elasticsearch.search.aggregations.support.values.ScriptDoubleValues;
import org.elasticsearch.search.aggregations.support.values.ScriptLongValues;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Map;
@@ -36,10 +35,10 @@ import java.util.Map;
public class ScriptValuesTests extends ESTestCase {
private static class FakeSearchScript implements LeafSearchScript {
-
+
private final Object[][] values;
int index;
-
+
FakeSearchScript(Object[][] values) {
this.values = values;
index = -1;
@@ -94,8 +93,7 @@ public class ScriptValuesTests extends ESTestCase {
}
- @Test
- public void longs() {
+ public void testLongs() {
final Object[][] values = new Long[randomInt(10)][];
for (int i = 0; i < values.length; ++i) {
Long[] longs = new Long[randomInt(8)];
@@ -116,8 +114,7 @@ public class ScriptValuesTests extends ESTestCase {
}
}
- @Test
- public void doubles() {
+ public void testDoubles() {
final Object[][] values = new Double[randomInt(10)][];
for (int i = 0; i < values.length; ++i) {
Double[] doubles = new Double[randomInt(8)];
@@ -138,8 +135,7 @@ public class ScriptValuesTests extends ESTestCase {
}
}
- @Test
- public void bytes() {
+ public void testBytes() {
final String[][] values = new String[randomInt(10)][];
for (int i = 0; i < values.length; ++i) {
String[] strings = new String[randomInt(8)];
diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
index cea6f92f3a..2821b07a2f 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@@ -36,23 +35,18 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
* shards possibly not active at all (cause they haven't allocated) will still work.
*/
public class SearchWhileCreatingIndexIT extends ESIntegTestCase {
-
- @Test
public void testIndexCausesIndexCreation() throws Exception {
searchWhileCreatingIndex(false, 1); // 1 replica in our default...
}
- @Test
public void testNoReplicas() throws Exception {
searchWhileCreatingIndex(true, 0);
}
- @Test
public void testOneReplica() throws Exception {
searchWhileCreatingIndex(true, 1);
}
- @Test
public void testTwoReplicas() throws Exception {
searchWhileCreatingIndex(true, 2);
}
diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
index 86b27f25e7..69c4bbdbd1 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -44,20 +43,16 @@ import static org.hamcrest.Matchers.is;
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SearchWhileRelocatingIT extends ESIntegTestCase {
-
- @Test
@Nightly
public void testSearchAndRelocateConcurrently0Replicas() throws Exception {
testSearchAndRelocateConcurrently(0);
}
- @Test
@Nightly
public void testSearchAndRelocateConcurrently1Replicas() throws Exception {
testSearchAndRelocateConcurrently(1);
}
- @Test
public void testSearchAndRelocateConcurrentlyRanodmReplicas() throws Exception {
testSearchAndRelocateConcurrently(randomIntBetween(0, 1));
}
@@ -77,7 +72,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
.endObject().endObject()));
}
indexRandom(true, indexBuilders.toArray(new IndexRequestBuilder[indexBuilders.size()]));
- assertHitCount(client().prepareSearch().get(), (long) (numDocs));
+ assertHitCount(client().prepareSearch().get(), (numDocs));
final int numIters = scaledRandomIntBetween(5, 20);
for (int i = 0; i < numIters; i++) {
final AtomicBoolean stop = new AtomicBoolean(false);
@@ -98,7 +93,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
// request comes in. It's a small window but a known limitation.
//
criticalException = sr.getTotalShards() == sr.getSuccessfulShards() || sr.getFailedShards() > 0;
- assertHitCount(sr, (long) (numDocs));
+ assertHitCount(sr, (numDocs));
criticalException = true;
final SearchHits sh = sr.getHits();
assertThat("Expected hits to be the same size the actual hits array", sh.getTotalHits(),
diff --git a/core/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java b/core/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
index eba86f35b0..cf58c520c9 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.GeohashCellQuery;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -48,13 +47,11 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
public class TransportSearchFailuresIT extends ESIntegTestCase {
-
@Override
protected int maximumNumberOfReplicas() {
return 1;
}
- @Test
public void testFailedSearchWithWrongQuery() throws Exception {
logger.info("Start Testing failed search with wrong query");
assertAcked(prepareCreate("test", 1, settingsBuilder().put("routing.hash.type", "simple")));
diff --git a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
index 6781c7c03d..6d239a8cdb 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
@@ -41,7 +41,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashSet;
@@ -121,7 +120,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
.endObject();
}
- @Test
public void testDfsQueryThenFetch() throws Exception {
Settings.Builder settingsBuilder = settingsBuilder()
.put(indexSettings())
@@ -161,7 +159,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertEquals(100, total);
}
- @Test
public void testDfsQueryThenFetchWithSort() throws Exception {
prepareData();
@@ -186,7 +183,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertEquals(100, total);
}
- @Test
public void testQueryThenFetch() throws Exception {
prepareData();
@@ -211,7 +207,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertEquals(100, total);
}
- @Test
public void testQueryThenFetchWithFrom() throws Exception {
Set<String> fullExpectedIds = prepareData();
@@ -240,7 +235,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertThat(collectedIds, equalTo(fullExpectedIds));
}
- @Test
public void testQueryThenFetchWithSort() throws Exception {
prepareData();
@@ -265,7 +259,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertEquals(100, total);
}
- @Test
public void testQueryAndFetch() throws Exception {
prepareData(3);
@@ -305,7 +298,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertThat("make sure we got all [" + expectedIds + "]", expectedIds.size(), equalTo(0));
}
- @Test
public void testDfsQueryAndFetch() throws Exception {
prepareData(3);
@@ -347,7 +339,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertThat("make sure we got all [" + expectedIds + "]", expectedIds.size(), equalTo(0));
}
- @Test
public void testSimpleFacets() throws Exception {
prepareData();
@@ -369,7 +360,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
assertThat(all.getDocCount(), equalTo(100l));
}
- @Test
public void testFailedSearchWithWrongQuery() throws Exception {
prepareData();
@@ -390,7 +380,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
logger.info("Done Testing failed search");
}
- @Test
public void testFailedSearchWithWrongFrom() throws Exception {
prepareData();
@@ -421,7 +410,6 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
logger.info("Done Testing failed search");
}
- @Test
public void testFailedMultiSearchWithWrongQuery() throws Exception {
prepareData();
@@ -445,8 +433,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
logger.info("Done Testing failed search");
}
- @Test
- public void testFailedMultiSearchWithWrongQuery_withFunctionScore() throws Exception {
+ public void testFailedMultiSearchWithWrongQueryWithFunctionScore() throws Exception {
prepareData();
logger.info("Start Testing failed multi search with a wrong query");
diff --git a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
index 50da272ec7..18419731bc 100644
--- a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
@@ -57,7 +57,6 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -67,7 +66,6 @@ import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.equalTo;
public class SearchSourceBuilderTests extends ESTestCase {
-
private static Injector injector;
private static NamedWriteableRegistry namedWriteableRegistry;
@@ -293,7 +291,6 @@ public class SearchSourceBuilderTests extends ESTestCase {
return builder;
}
- @Test
public void testFromXContent() throws IOException {
SearchSourceBuilder testBuilder = createSearchSourceBuilder();
String builderAsString = testBuilder.toString();
@@ -320,7 +317,6 @@ public class SearchSourceBuilderTests extends ESTestCase {
return context;
}
- @Test
public void testSerialization() throws IOException {
SearchSourceBuilder testBuilder = createSearchSourceBuilder();
try (BytesStreamOutput output = new BytesStreamOutput()) {
@@ -334,7 +330,6 @@ public class SearchSourceBuilderTests extends ESTestCase {
}
}
- @Test
public void testEqualsAndHashcode() throws IOException {
SearchSourceBuilder firstBuilder = createSearchSourceBuilder();
assertFalse("source builder is equal to null", firstBuilder.equals(null));
@@ -389,7 +384,6 @@ public class SearchSourceBuilderTests extends ESTestCase {
}
}
- @Test
public void testParseSort() throws IOException {
{
String restContent = " { \"sort\": \"foo\"}";
@@ -420,7 +414,6 @@ public class SearchSourceBuilderTests extends ESTestCase {
}
}
- @Test
public void testEmptyPostFilter() throws IOException {
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.postFilter(EmptyQueryBuilder.PROTOTYPE);
diff --git a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java
index 0cf3b81b10..f856e0d16f 100644
--- a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java
@@ -49,7 +49,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -94,7 +93,6 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ClusterScope(scope = Scope.SUITE)
public class ChildQuerySearchIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder().put(super.nodeSettings(nodeOrdinal))
@@ -104,7 +102,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
.build();
}
- @Test
public void testSelfReferentialIsForbidden() {
try {
prepareCreate("test").addMapping("type", "_parent", "type=type").get();
@@ -116,8 +113,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
- public void multiLevelChild() throws Exception {
+ public void testMultiLevelChild() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child", "_parent", "type=parent")
@@ -170,7 +166,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1"));
}
- @Test
// see #2744
public void test2744() throws IOException {
assertAcked(prepareCreate("test")
@@ -190,8 +185,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
- @Test
- public void simpleChildQuery() throws Exception {
+ public void testSimpleChildQuery() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child", "_parent", "type=parent"));
@@ -263,9 +257,8 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
}
- @Test
- // See: https://github.com/elasticsearch/elasticsearch/issues/3290
- public void testCachingBug_withFqueryFilter() throws Exception {
+ // Issue #3290
+ public void testCachingBugWithFqueryFilter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child", "_parent", "type=parent"));
@@ -304,7 +297,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
public void testHasParentFilter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -354,8 +346,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
- public void simpleChildQueryWithFlush() throws Exception {
+ public void testSimpleChildQueryWithFlush() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child", "_parent", "type=parent"));
@@ -418,7 +409,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1")));
}
- @Test
public void testScopedFacet() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -456,7 +446,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(termsFacet.getBuckets().get(1).getDocCount(), equalTo(1L));
}
- @Test
public void testDeletedParent() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -492,7 +481,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1_updated\""));
}
- @Test
public void testDfsSearchType() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -519,7 +507,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertNoFailures(searchResponse);
}
- @Test
public void testHasChildAndHasParentFailWhenSomeSegmentsDontContainAnyParentOrChildDocs() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -544,7 +531,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testCountApiUsage() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -573,7 +559,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertHitCount(countResponse, 1l);
}
- @Test
public void testExplainUsage() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -662,8 +647,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
return indexBuilders;
}
- @Test
- public void testScoreForParentChildQueries_withFunctionScore() throws Exception {
+ public void testScoreForParentChildQueriesWithFunctionScore() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child", "_parent", "type=parent")
@@ -749,8 +733,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[6].score(), equalTo(5f));
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/2536
+ // Issue #2536
public void testParentChildQueriesCanHandleNoRelevantTypesInIndex() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -784,7 +767,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().totalHits(), equalTo(0l));
}
- @Test
public void testHasChildAndHasParentFilter_withFilter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -811,7 +793,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("2"));
}
- @Test
public void testHasChildAndHasParentWrappedInAQueryFilter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -841,7 +822,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertSearchHit(searchResponse, 1, hasId("2"));
}
- @Test
public void testSimpleQueryRewrite() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent", "p_field", "type=string")
@@ -888,9 +868,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
- // See also issue:
- // https://github.com/elasticsearch/elasticsearch/issues/3144
+ // Issue #3144
public void testReIndexingParentAndChildDocuments() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -951,9 +929,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(1).id(), Matchers.anyOf(equalTo("c3"), equalTo("c4")));
}
- @Test
- // See also issue:
- // https://github.com/elasticsearch/elasticsearch/issues/3203
+ // Issue #3203
public void testHasChildQueryWithMinimumScore() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -978,7 +954,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(3.0f));
}
- @Test
public void testParentFieldFilter() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder().put(indexSettings())
@@ -1045,7 +1020,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertHitCount(response, 2l);
}
- @Test
public void testHasChildNotBeingCached() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -1107,8 +1081,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
- // Relates to bug: https://github.com/elasticsearch/elasticsearch/issues/3818
+ // Issue #3818
public void testHasChildQueryOnlyReturnsSingleChildType() {
assertAcked(prepareCreate("grandissue")
.addMapping("grandparent", "name", "type=string")
@@ -1161,8 +1134,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
- public void indexChildDocWithNoParentMapping() throws IOException {
+ public void testIndexChildDocWithNoParentMapping() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("parent")
.addMapping("child1"));
@@ -1185,7 +1157,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
refresh();
}
- @Test
public void testAddingParentToExistingMapping() throws IOException {
createIndex("test");
ensureGreen();
@@ -1210,7 +1181,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
public void testHasChildQueryWithNestedInnerObjects() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent", "objects", "type=nested")
@@ -1252,7 +1222,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
}
- @Test
public void testNamedFilters() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -1289,7 +1258,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("test"));
}
- @Test
public void testParentChildQueriesNoParentType() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
@@ -1347,8 +1315,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
- public void testAdd_ParentFieldAfterIndexingParentDocButBeforeIndexingChildDoc() throws Exception {
+ public void testAddParentFieldAfterIndexingParentDocButBeforeIndexingChildDoc() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
.put(indexSettings())
@@ -1371,7 +1338,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
public void testParentChildCaching() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(
@@ -1420,7 +1386,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testParentChildQueriesViaScrollApi() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -1464,8 +1429,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- // https://github.com/elasticsearch/elasticsearch/issues/5783
- @Test
+ // Issue #5783
public void testQueryBeforeChildType() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("features")
@@ -1484,8 +1448,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertHitCount(resp, 1L);
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/6256
+ // Issue #6256
public void testParentFieldInMultiMatchField() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1")
@@ -1504,7 +1467,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
}
- @Test
public void testTypeIsAppliedInHasParentInnerQuery() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent")
@@ -1595,7 +1557,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
.addSort("_score", SortOrder.DESC).addSort("id", SortOrder.ASC).get();
}
- @Test
public void testMinMaxChildren() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent", "id", "type=long")
@@ -1926,7 +1887,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
}
- @Test
public void testParentFieldToNonExistingType() {
assertAcked(prepareCreate("test").addMapping("parent").addMapping("child", "_parent", "type=parent2"));
client().prepareIndex("test", "parent", "1").setSource("{}").get();
diff --git a/core/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java b/core/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java
index d3b5160db4..d98574bc37 100644
--- a/core/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java
+++ b/core/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java
@@ -32,15 +32,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
-public class SearchSourceCompressTests extends ESSingleNodeTestCase {
-
- @Test
+public class SearchSourceCompressTests extends ESSingleNodeTestCase {
public void testSourceCompressionLZF() throws IOException {
final Compressor defaultCompressor = CompressorFactory.defaultCompressor();
try {
diff --git a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java
index 26fd0cb6f7..1eff57a056 100644
--- a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java
+++ b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java
@@ -40,7 +40,6 @@ import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -59,13 +58,11 @@ import static org.hamcrest.CoreMatchers.equalTo;
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class FetchSubPhasePluginIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(FetchTermVectorsPlugin.class);
}
- @Test
public void testPlugin() throws Exception {
client().admin()
.indices()
diff --git a/core/src/test/java/org/elasticsearch/search/fetch/FieldDataFieldsTests.java b/core/src/test/java/org/elasticsearch/search/fetch/FieldDataFieldsTests.java
index 7fce514567..7405ceef5a 100644
--- a/core/src/test/java/org/elasticsearch/search/fetch/FieldDataFieldsTests.java
+++ b/core/src/test/java/org/elasticsearch/search/fetch/FieldDataFieldsTests.java
@@ -27,7 +27,8 @@ import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsParseElement;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestSearchContext;
-import org.junit.Test;
+
+import static org.hamcrest.Matchers.containsString;
public class FieldDataFieldsTests extends ESTestCase {
@@ -55,7 +56,6 @@ public class FieldDataFieldsTests extends ESTestCase {
parseElement.parse(parser, context);
}
- @Test(expected = IllegalStateException.class)
public void testInvalidFieldDataField() throws Exception {
FieldDataFieldsParseElement parseElement = new FieldDataFieldsParseElement();
@@ -70,6 +70,11 @@ public class FieldDataFieldsTests extends ESTestCase {
parser.nextToken();
parser.nextToken();
SearchContext context = new TestSearchContext();
- parseElement.parse(parser, context);
+ try {
+ parseElement.parse(parser, context);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("Expected either a VALUE_STRING or an START_ARRAY but got "));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/fetch/innerhits/NestedChildrenFilterTests.java b/core/src/test/java/org/elasticsearch/search/fetch/innerhits/NestedChildrenFilterTests.java
index 870a672b26..f00b72bfa8 100644
--- a/core/src/test/java/org/elasticsearch/search/fetch/innerhits/NestedChildrenFilterTests.java
+++ b/core/src/test/java/org/elasticsearch/search/fetch/innerhits/NestedChildrenFilterTests.java
@@ -40,7 +40,6 @@ import org.apache.lucene.store.Directory;
import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.search.fetch.innerhits.InnerHitsContext.NestedInnerHits.NestedChildrenQuery;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -50,8 +49,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class NestedChildrenFilterTests extends ESTestCase {
-
- @Test
public void testNestedChildrenFilter() throws Exception {
int numParentDocs = scaledRandomIntBetween(0, 32);
int maxChildDocsPerParent = scaledRandomIntBetween(8, 16);
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java
index d362b36dd8..f78ef2ef0f 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java
@@ -34,13 +34,10 @@ import org.elasticsearch.search.SearchHits;
import org.elasticsearch.test.ESIntegTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
-import java.util.concurrent.ExecutionException;
import static org.elasticsearch.client.Requests.indexRequest;
import static org.elasticsearch.client.Requests.searchRequest;
@@ -58,15 +55,12 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrde
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.closeTo;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isOneOf;
import static org.hamcrest.Matchers.lessThan;
-
public class DecayFunctionScoreIT extends ESIntegTestCase {
-
- @Test
public void testDistanceScoreGeoLinGaussExp() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
@@ -165,7 +159,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
assertThat(sh.getAt(1).getId(), equalTo("2"));
}
- @Test
public void testDistanceScoreGeoLinGaussExpWithOffset() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
@@ -240,7 +233,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
assertThat(sh.getAt(1).score(), equalTo(sh.getAt(0).score()));
}
- @Test
public void testBoostModeSettingWorks() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
@@ -295,7 +287,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
- @Test
public void testParseGeoPoint() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
@@ -336,9 +327,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
assertThat((double) sh.getAt(0).score(), closeTo(0.30685282, 1.e-5));
}
- @Test
public void testCombineModes() throws Exception {
-
assertAcked(prepareCreate("test").addMapping(
"type1",
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string")
@@ -419,7 +408,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
- @Test(expected = SearchPhaseExecutionException.class)
public void testExceptionThrownIfScaleLE0() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
@@ -438,14 +426,15 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
searchSource().query(
functionScoreQuery(termQuery("test", "value"), gaussDecayFunction("num1", "2013-05-28", "-1d")))));
-
- SearchResponse sr = response.actionGet();
- assertOrderedSearchHits(sr, "2", "1");
+ try {
+ response.actionGet();
+ fail("Expected SearchPhaseExecutionException");
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
+ }
}
- @Test
public void testParseDateMath() throws Exception {
-
assertAcked(prepareCreate("test").addMapping(
"type1",
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string")
@@ -477,9 +466,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
- @Test
public void testValueMissingLin() throws Exception {
-
assertAcked(prepareCreate("test").addMapping(
"type1",
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string")
@@ -528,7 +515,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
- @Test
public void testDateWithoutOrigin() throws Exception {
DateTime dt = new DateTime(DateTimeZone.UTC);
@@ -578,7 +564,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
- @Test
public void testManyDocsLin() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type",
@@ -631,7 +616,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
}
- @Test(expected = SearchPhaseExecutionException.class)
public void testParsingExceptionIfFieldDoesNotExist() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type",
@@ -653,10 +637,14 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
.size(numDocs)
.query(functionScoreQuery(termQuery("test", "value"), linearDecayFunction("type1.geo", lonlat, "1000km"))
.scoreMode(FiltersFunctionScoreQuery.ScoreMode.MULTIPLY))));
- SearchResponse sr = response.actionGet();
+ try {
+ response.actionGet();
+ fail("Expected SearchPhaseExecutionException");
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
+ }
}
- @Test(expected = SearchPhaseExecutionException.class)
public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type",
@@ -672,10 +660,14 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
searchSource().query(
functionScoreQuery(termQuery("test", "value"), linearDecayFunction("num", 1.0, 0.5)).scoreMode(FiltersFunctionScoreQuery.ScoreMode.MULTIPLY))));
- response.actionGet();
+ try {
+ response.actionGet();
+ fail("Expected SearchPhaseExecutionException");
+ } catch (SearchPhaseExecutionException e) {
+ assertThat(e.getMessage(), is("all shards failed"));
+ }
}
- @Test
public void testNoQueryGiven() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type",
@@ -695,7 +687,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
response.actionGet();
}
- @Test
public void testMultiFieldOptions() throws Exception {
assertAcked(prepareCreate("test").addMapping(
"type1",
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
index eb7903f665..39ce61f6c7 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
@@ -27,7 +27,11 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.lucene.search.function.CombineFunction;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.script.*;
+import org.elasticsearch.script.AbstractDoubleSearchScript;
+import org.elasticsearch.script.ExecutableScript;
+import org.elasticsearch.script.ExplainableSearchScript;
+import org.elasticsearch.script.NativeScriptFactory;
+import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
@@ -35,7 +39,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -55,15 +58,12 @@ import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class ExplainableScriptIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(ExplainableScriptPlugin.class);
}
- @Test
public void testNativeExplainScript() throws InterruptedException, IOException, ExecutionException {
-
List<IndexRequestBuilder> indexRequests = new ArrayList<>();
for (int i = 0; i < 20; i++) {
indexRequests.add(client().prepareIndex("test", "type").setId(Integer.toString(i)).setSource(
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java
index 8bf957d283..db5f1ed70e 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.script.Script;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,22 +33,23 @@ import java.util.concurrent.ExecutionException;
import static org.elasticsearch.client.Requests.searchRequest;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
-import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.gaussDecayFunction;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.weightFactorFunction;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
/**
*/
public class FunctionScoreBackwardCompatibilityIT extends ESBackcompatTestCase {
-
/**
- * Simple upgrade test for function score
+ * Simple upgrade test for function score.
*/
- @Test
public void testSimpleFunctionScoreParsingWorks() throws IOException, ExecutionException, InterruptedException {
-
assertAcked(prepareCreate("test").addMapping(
"type1",
jsonBuilder().startObject()
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java
index 419861d2c7..5331dfe6ff 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java
@@ -23,21 +23,22 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.simpleQueryStringQuery;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.fieldValueFactorFunction;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
/**
* Tests for the {@code field_value_factor} function in a function_score query.
*/
public class FunctionScoreFieldValueIT extends ESIntegTestCase {
-
- @Test
public void testFieldValueFactor() throws IOException {
assertAcked(prepareCreate("test").addMapping(
"type1",
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
index 4dab3c3f6c..b428d911dd 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
@@ -35,7 +35,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.junit.Test;
import java.util.Collection;
@@ -52,13 +51,11 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
public class FunctionScorePluginIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(CustomDistanceScorePlugin.class);
}
- @Test
public void testPlugin() throws Exception {
client().admin()
.indices()
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java
index dce6ef3c74..861701a9f6 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java
@@ -40,7 +40,6 @@ import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.rescore.RescoreBuilder;
import org.elasticsearch.search.rescore.RescoreBuilder.QueryRescorer;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Comparator;
@@ -66,8 +65,6 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class QueryRescorerIT extends ESIntegTestCase {
-
- @Test
public void testEnforceWindowSize() {
createIndex("test");
// this
@@ -101,7 +98,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
}
- @Test
public void testRescorePhrase() throws Exception {
assertAcked(prepareCreate("test")
.addMapping(
@@ -148,7 +144,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
assertThirdHit(searchResponse, hasId("3"));
}
- @Test
public void testMoreDocs() throws Exception {
Builder builder = Settings.builder();
builder.put("index.analysis.analyzer.synonym.tokenizer", "whitespace");
@@ -227,7 +222,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
// Tests a rescore window smaller than number of hits:
- @Test
public void testSmallRescoreWindow() throws Exception {
Builder builder = Settings.builder();
builder.put("index.analysis.analyzer.synonym.tokenizer", "whitespace");
@@ -298,7 +292,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
// Tests a rescorer that penalizes the scores:
- @Test
public void testRescorerMadeScoresWorse() throws Exception {
Builder builder = Settings.builder();
builder.put("index.analysis.analyzer.synonym.tokenizer", "whitespace");
@@ -411,7 +404,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
}
- @Test
// forces QUERY_THEN_FETCH because of https://github.com/elasticsearch/elasticsearch/issues/4829
public void testEquivalence() throws Exception {
// no dummy docs since merges can change scores while we run queries.
@@ -496,7 +488,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
}
- @Test
public void testExplain() throws Exception {
assertAcked(prepareCreate("test")
.addMapping(
@@ -596,7 +587,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
}
- @Test
public void testScoring() throws Exception {
int numDocs = indexRandomNumbers("keyword");
@@ -689,7 +679,6 @@ public class QueryRescorerIT extends ESIntegTestCase {
}
}
- @Test
public void testMultipleRescores() throws Exception {
int numDocs = indexRandomNumbers("keyword", 1, true);
QueryRescorer eightIsGreat = RescoreBuilder.queryRescorer(
diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java
index b61b38993e..518e4fc837 100644
--- a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java
+++ b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java
@@ -25,11 +25,11 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.GeoValidationMethod;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
@@ -38,9 +38,7 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class GeoBoundingBoxIT extends ESIntegTestCase {
-
- @Test
- public void simpleBoundingBoxTest() throws Exception {
+ public void testSimpleBoundingBoxTest() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
.endObject().endObject();
@@ -109,8 +107,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
}
}
- @Test
- public void limitsBoundingBoxTest() throws Exception {
+ public void testLimitsBoundingBox() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
.endObject().endObject();
@@ -212,8 +209,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("9"));
}
- @Test
- public void limit2BoundingBoxTest() throws Exception {
+ public void testLimit2BoundingBox() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
.endObject().endObject();
@@ -263,8 +259,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
- public void completeLonRangeTest() throws Exception {
+ public void testCompleteLonRange() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
.endObject().endObject();
diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java
index 152c3c95ec..5bbc1815a8 100644
--- a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java
+++ b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java
@@ -49,7 +49,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
@@ -111,9 +110,7 @@ public class GeoFilterIT extends ESIntegTestCase {
return out.toByteArray();
}
- @Test
public void testShapeBuilders() {
-
try {
// self intersection polygon
ShapeBuilder.newPolygon()
@@ -223,14 +220,11 @@ public class GeoFilterIT extends ESIntegTestCase {
}
- @Test
public void testShapeRelations() throws Exception {
-
assertTrue( "Intersect relation is not supported", intersectSupport);
assertTrue("Disjoint relation is not supported", disjointSupport);
assertTrue("within relation is not supported", withinSupport);
-
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("polygon")
@@ -402,8 +396,7 @@ public class GeoFilterIT extends ESIntegTestCase {
assertHitCount(result, 1);
}
- @Test
- public void bulktest() throws Exception {
+ public void testBulk() throws Exception {
byte[] bulkAction = unZipData("/org/elasticsearch/search/geo/gzippedmap.gz");
String mapping = XContentFactory.jsonBuilder()
@@ -468,7 +461,6 @@ public class GeoFilterIT extends ESIntegTestCase {
}
}
- @Test
public void testGeohashCellFilter() throws IOException {
String geohash = randomhash(10);
logger.info("Testing geohash_cell filter for [{}]", geohash);
@@ -542,7 +534,6 @@ public class GeoFilterIT extends ESIntegTestCase {
}
}
- @Test
public void testNeighbors() {
// Simple root case
assertThat(XGeoHashUtils.addNeighbors("7", new ArrayList<String>()), containsInAnyOrder("4", "5", "6", "d", "e", "h", "k", "s"));
diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoPolygonIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoPolygonIT.java
index 248c62bf16..b364826f71 100644
--- a/core/src/test/java/org/elasticsearch/search/geo/GeoPolygonIT.java
+++ b/core/src/test/java/org/elasticsearch/search/geo/GeoPolygonIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -87,8 +86,7 @@ public class GeoPolygonIT extends ESIntegTestCase {
ensureSearchable("test");
}
- @Test
- public void simplePolygonTest() throws Exception {
+ public void testSimplePolygon() throws Exception {
List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(40.7, -74.0));
points.add(new GeoPoint(40.7, -74.1));
@@ -105,8 +103,7 @@ public class GeoPolygonIT extends ESIntegTestCase {
}
}
- @Test
- public void simpleUnclosedPolygon() throws Exception {
+ public void testSimpleUnclosedPolygon() throws Exception {
List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(40.7, -74.0));
points.add(new GeoPoint(40.7, -74.1));
diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java
index 1f057afc9f..e1f45d746e 100644
--- a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java
@@ -38,7 +38,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.geo.RandomShapeGenerator;
-import org.junit.Test;
import java.io.IOException;
import java.util.Locale;
@@ -55,8 +54,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.nullValue;
public class GeoShapeIntegrationIT extends ESIntegTestCase {
-
- @Test
public void testNullShape() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -71,7 +68,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(result.getField("location"), nullValue());
}
- @Test
public void testIndexPointsFilterRectangle() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -121,9 +117,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
}
- @Test
public void testEdgeCases() throws Exception {
-
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
.field("type", "geo_shape")
@@ -161,7 +155,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("blakely"));
}
- @Test
public void testIndexedShapeReference() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
@@ -205,7 +198,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
}
- @Test
public void testReusableBuilder() throws IOException {
ShapeBuilder polygon = ShapeBuilder.newPolygon()
.point(170, -10).point(190, -10).point(190, 10).point(170, 10)
@@ -225,7 +217,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(before, equalTo(after));
}
- @Test
public void testShapeFetchingPath() throws Exception {
createIndex("shapes");
assertAcked(prepareCreate("test").addMapping("type", "location", "type=geo_shape"));
@@ -308,7 +299,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
}
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elasticsearch/elasticsearch/issues/9904")
- @Test
public void testShapeFilterWithRandomGeoCollection() throws Exception {
// Create a random geometry collection.
GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(getRandom());
@@ -333,7 +323,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertHitCount(result, 1);
}
- @Test
public void testShapeFilterWithDefinedGeoCollection() throws Exception {
createIndex("shapes");
assertAcked(prepareCreate("test").addMapping("type", "location", "type=geo_shape"));
@@ -448,7 +437,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
assertThat(orientation, equalTo(ShapeBuilder.Orientation.CCW));
}
- @Test
public void testPointsOnly() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location")
diff --git a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchIT.java
index 5f5ecfc980..07045cc917 100644
--- a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -56,7 +55,6 @@ public class CustomHighlighterSearchIT extends ESIntegTestCase {
ensureYellow();
}
- @Test
public void testThatCustomHighlightersAreSupported() throws IOException {
SearchResponse searchResponse = client().prepareSearch("test").setTypes("test")
.setQuery(QueryBuilders.matchAllQuery())
@@ -65,7 +63,6 @@ public class CustomHighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "name", 0, equalTo("standard response for name at position 1"));
}
- @Test
public void testThatCustomHighlighterCanBeConfiguredPerField() throws Exception {
HighlightBuilder.Field highlightConfig = new HighlightBuilder.Field("name");
highlightConfig.highlighterType("test-custom");
@@ -82,7 +79,6 @@ public class CustomHighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "name", 1, equalTo("field:myFieldOption:someValue"));
}
- @Test
public void testThatCustomHighlighterCanBeConfiguredGlobally() throws Exception {
Map<String, Object> options = new HashMap<>();
options.put("myGlobalOption", "someValue");
@@ -95,7 +91,6 @@ public class CustomHighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "name", 1, equalTo("field:myGlobalOption:someValue"));
}
- @Test
public void testThatCustomHighlighterReceivesFieldsInOrder() throws Exception {
SearchResponse searchResponse = client().prepareSearch("test").setTypes("test")
.setQuery(QueryBuilders.boolQuery().must(QueryBuilders.matchAllQuery()).should(QueryBuilders
diff --git a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java
index 93fd7eb49a..865c5bf24f 100644
--- a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java
@@ -42,7 +42,6 @@ import org.elasticsearch.search.highlight.HighlightBuilder.Field;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
@@ -81,12 +80,11 @@ import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
public class HighlighterSearchIT extends ESIntegTestCase {
-
- @Test
public void testHighlightingWithWildcardName() throws IOException {
// test the kibana case with * as fieldname that will try highlight all fields including meta fields
XContentBuilder mappings = jsonBuilder();
@@ -115,7 +113,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
}
- @Test
public void testPlainHighlighterWithLongUnanalyzedStringTerm() throws IOException {
XContentBuilder mappings = jsonBuilder();
mappings.startObject();
@@ -165,7 +162,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertThat(search.getHits().getAt(0).getHighlightFields().size(), equalTo(0));
}
- @Test
public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOException {
XContentBuilder mappings = jsonBuilder();
mappings.startObject();
@@ -206,8 +202,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertThat(search.getHits().getAt(0).getHighlightFields().size(), equalTo(0));
}
-
- @Test
// see #3486
public void testHighTermFrequencyDoc() throws IOException {
assertAcked(prepareCreate("test")
@@ -226,7 +220,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "name", 0, startsWith("<em>abc</em> <em>abc</em> <em>abc</em> <em>abc</em>"));
}
- @Test
public void testNgramHighlightingWithBrokenPositions() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("test", jsonBuilder()
@@ -284,7 +277,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "name.autocomplete", 0, equalTo("ARCO<em>TEL</em> Ho<em>tel</em>s <em>Deut</em>schland"));
}
- @Test
public void testMultiPhraseCutoff() throws IOException {
/*
* MultiPhraseQuery can literally kill an entire node if there are too many terms in the
@@ -328,9 +320,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
equalTo("<em>Test</em>: <em>http://www.facebook.com</em> <em>http://elasticsearch.org</em> <em>http://xing.com</em> <em>http://cnn.com</em> http://quora.com"));
}
- @Test
public void testNgramHighlightingPreLucene42() throws IOException {
-
assertAcked(prepareCreate("test")
.addMapping("test",
"name", "type=string,analyzer=name_index_analyzer,search_analyzer=name_search_analyzer," + randomStoreField() + "term_vector=with_positions_offsets",
@@ -402,7 +392,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
equalTo("avinci, unilog avinci, <em>logica</em>cmg, <em>logica</em>")));
}
- @Test
public void testNgramHighlighting() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("test",
@@ -448,7 +437,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "name2", 0, equalTo("<em>logicacmg</em> ehemals avinci - the know how company"));
}
- @Test
public void testEnsureNoNegativeOffsets() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1",
@@ -482,7 +470,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "no_long_term", 0, 1, equalTo("a <b>test</b> where <b>foo</b> is <b>highlighed</b> and"));
}
- @Test
public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -522,7 +509,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -562,7 +548,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -614,7 +599,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testHighlightIssue1994() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=no", "titleTV", "type=string,store=no,term_vector=with_positions_offsets"));
@@ -646,7 +630,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "titleTV", 1, 2, equalTo("<em>highlight</em> other text"));
}
- @Test
public void testGlobalHighlightingSettingsOverriddenAtFieldLevel() {
createIndex("test");
ensureGreen();
@@ -670,7 +653,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("this is another <field2>test</field2>"));
}
- @Test //https://github.com/elasticsearch/elasticsearch/issues/5175
+ // Issue #5175
public void testHighlightingOnWildcardFields() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1",
@@ -698,9 +681,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field-plain", 0, 1, equalTo("This is the <xxx>test</xxx> for the plain highlighter"));
}
- @Test
public void testForceSourceWithSourceDisabled() throws Exception {
-
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1")
.startObject("_source").field("enabled", false).endObject()
@@ -759,7 +740,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
matches("source is forced for fields \\[field\\d, field\\d\\] but type \\[type1\\] has disabled _source"));
}
- @Test
public void testPlainHighlighter() throws Exception {
createIndex("test");
ensureGreen();
@@ -822,7 +802,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <xxx>quick</xxx> brown fox jumps over the lazy dog"));
}
- @Test
public void testFastVectorHighlighter() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
ensureGreen();
@@ -872,9 +851,9 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
/**
- * The FHV can spend a long time highlighting degenerate documents if phraseLimit is not set.
+ * The FHV can spend a long time highlighting degenerate documents if
+ * phraseLimit is not set. Its default is now reasonably low.
*/
- @Test(timeout=120000)
public void testFVHManyMatches() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
ensureGreen();
@@ -886,22 +865,33 @@ public class HighlighterSearchIT extends ESIntegTestCase {
.setSource("field1", value).get();
refresh();
- logger.info("--> highlighting and searching on field1");
+ logger.info("--> highlighting and searching on field1 with default phrase limit");
SearchSourceBuilder source = searchSource()
.query(termQuery("field1", "t"))
.highlighter(highlight().highlighterType("fvh").field("field1", 20, 1).order("score").preTags("<xxx>").postTags("</xxx>"));
- SearchResponse searchResponse = client().search(searchRequest("test").source(source)).actionGet();
- assertHighlight(searchResponse, 0, "field1", 0, 1, containsString("<xxx>t</xxx>"));
- logger.info("--> done");
+ SearchResponse defaultPhraseLimit = client().search(searchRequest("test").source(source)).actionGet();
+ assertHighlight(defaultPhraseLimit, 0, "field1", 0, 1, containsString("<xxx>t</xxx>"));
+
+ logger.info("--> highlighting and searching on field1 with large phrase limit");
+ source = searchSource()
+ .query(termQuery("field1", "t"))
+ .highlighter(highlight().highlighterType("fvh").field("field1", 20, 1).order("score").preTags("<xxx>").postTags("</xxx>").phraseLimit(30000));
+ SearchResponse largePhraseLimit = client().search(searchRequest("test").source(source)).actionGet();
+ assertHighlight(largePhraseLimit, 0, "field1", 0, 1, containsString("<xxx>t</xxx>"));
+
+ /*
+ * I hate comparing times because it can be inconsistent but default is
+ * in the neighborhood of 300ms and the large phrase limit is in the
+ * neighborhood of 8 seconds.
+ */
+ assertThat(defaultPhraseLimit.getTookInMillis(), lessThan(largePhraseLimit.getTookInMillis()));
}
- @Test
public void testMatchedFieldsFvhRequireFieldMatch() throws Exception {
checkMatchedFieldsCase(true);
}
- @Test
public void testMatchedFieldsFvhNoRequireFieldMatch() throws Exception {
checkMatchedFieldsCase(false);
}
@@ -1067,7 +1057,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
RestStatus.INTERNAL_SERVER_ERROR, containsString("IndexOutOfBoundsException"));
}
- @Test
public void testFastVectorHighlighterManyDocs() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
ensureGreen();
@@ -1114,7 +1103,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
.endObject().endObject();
}
- @Test
public void testSameContent() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes,term_vector=with_positions_offsets"));
@@ -1137,7 +1125,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testFastVectorHighlighterOffsetParameter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes,term_vector=with_positions_offsets").get());
@@ -1161,7 +1148,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testEscapeHtml() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes"));
@@ -1184,8 +1170,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
- public void testEscapeHtml_vector() throws Exception {
+ public void testEscapeHtmlVector() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes,term_vector=with_positions_offsets"));
ensureYellow();
@@ -1207,7 +1192,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testMultiMapperVectorWithStore() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1236,7 +1220,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
}
- @Test
public void testMultiMapperVectorFromSource() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1267,7 +1250,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
}
- @Test
public void testMultiMapperNoVectorWithStore() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1298,7 +1280,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
}
- @Test
public void testMultiMapperNoVectorFromSource() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1328,7 +1309,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(search, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
}
- @Test
public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes,term_vector=no"));
@@ -1359,7 +1339,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
.highlighter(new HighlightBuilder().field("tit*", 50, 1, 10).highlighterType("fast-vector-highlighter")).get());
}
- @Test
public void testDisableFastVectorHighlighter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string,store=yes,term_vector=with_positions_offsets,analyzer=classic"));
@@ -1405,7 +1384,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testFSHHighlightAllMvFragments() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "tags", "type=string,term_vector=with_positions_offsets"));
@@ -1424,7 +1402,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(response, 0, "tags", 1, 2, equalTo("here is another one that is very long and has the <em>tag</em> token near the end"));
}
- @Test
public void testBoostingQuery() {
createIndex("test");
ensureGreen();
@@ -1442,7 +1419,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The quick <x>brown</x> fox jumps over the lazy dog"));
}
- @Test
@AwaitsFix(bugUrl="Broken now that BoostingQuery does not extend BooleanQuery anymore")
public void testBoostingQueryTermVector() throws IOException {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
@@ -1461,7 +1437,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The quick <x>brown</x> fox jumps over the lazy dog"));
}
- @Test
public void testCommonTermsQuery() {
createIndex("test");
ensureGreen();
@@ -1480,7 +1455,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <x>quick</x> <x>brown</x> fox jumps over the lazy dog"));
}
- @Test
public void testCommonTermsTermVector() throws IOException {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
ensureGreen();
@@ -1496,7 +1470,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <x>quick</x> <x>brown</x> fox jumps over the lazy dog"));
}
- @Test
public void testPhrasePrefix() throws IOException {
Builder builder = settingsBuilder()
.put(indexSettings())
@@ -1567,7 +1540,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field4", 0, 1, equalTo("<x>a quick fast blue car</x>"));
}
- @Test
public void testPlainHighlightDifferentFragmenter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "tags", "type=string"));
@@ -1605,7 +1577,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
containsString("unknown fragmenter option [invalid] for the field [tags]"));
}
- @Test
public void testPlainHighlighterMultipleFields() {
createIndex("test");
ensureGreen();
@@ -1624,7 +1595,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(response, 0, "field2", 0, 1, equalTo("The <b>slow<b> brown <2>fox</2>"));
}
- @Test
public void testFastVectorHighlighterMultipleFields() {
assertAcked(prepareCreate("test")
.addMapping("type1", "field1", "type=string,term_vector=with_positions_offsets", "field2", "type=string,term_vector=with_positions_offsets"));
@@ -1644,7 +1614,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(response, 0, "field2", 0, 1, equalTo("The <b>slow<b> brown <2>fox</2>"));
}
- @Test
public void testMissingStoredField() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "highlight_field", "type=string,store=yes"));
@@ -1664,8 +1633,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[0].highlightFields().isEmpty(), equalTo(true));
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/3211
+ // Issue #3211
public void testNumericHighlighting() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("test", "text", "type=string,index=analyzed",
@@ -1688,8 +1656,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHitCount(response, 1l);
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/3200
+ // Issue #3200
public void testResetTwice() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
@@ -1710,7 +1677,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHitCount(response, 1l);
}
- @Test
public void testHighlightUsesHighlightQuery() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets"));
@@ -1777,7 +1743,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
return "";
}
- @Test
public void testHighlightNoMatchSize() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets"));
@@ -1886,7 +1851,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertNotHighlighted(response, 0, "text");
}
- @Test
public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets"));
@@ -1999,7 +1963,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertNotHighlighted(response, 0, "text");
}
- @Test
public void testHighlightNoMatchSizeNumberOfFragments() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets"));
@@ -2047,7 +2010,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(response, 0, "text", 1, 2, equalTo("This is the <em>fifth</em> sentence"));
}
- @Test
public void testPostingsHighlighter() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2103,7 +2065,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <xxx>quick</xxx> <xxx>brown</xxx> fox jumps over the lazy <xxx>quick</xxx> dog"));
}
- @Test
public void testPostingsHighlighterMultipleFields() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()).get());
ensureGreen();
@@ -2120,7 +2081,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(response, 0, "field1", 0, 1, equalTo("The <b>quick<b> brown <1>fox</1>."));
}
- @Test
public void testPostingsHighlighterNumberOfFragments() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2167,7 +2127,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testMultiMatchQueryHighlight() throws IOException {
String[] highlighterTypes = new String[] {"fvh", "plain", "postings"};
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
@@ -2208,7 +2167,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testPostingsHighlighterOrderByScore() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2237,7 +2195,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertThat(field1.fragments()[4].string(), equalTo("One <em>sentence</em> match here and scored lower since the text is quite long, not that appealing."));
}
- @Test
public void testPostingsHighlighterEscapeHtml() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "title", "type=string," + randomStoreField() + "index_options=offsets"));
@@ -2259,7 +2216,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testPostingsHighlighterMultiMapperWithStore() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1")
@@ -2293,7 +2249,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em> ."));
}
- @Test
public void testPostingsHighlighterMultiMapperFromSource() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -2323,7 +2278,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "title.key", 0, 1, equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
}
- @Test
public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -2363,7 +2317,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
.highlighter(new HighlightBuilder().field("tit*").highlighterType("postings")).get());
}
- @Test
public void testPostingsHighlighterBoostingQuery() throws IOException {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2380,7 +2333,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The quick <x>brown</x> fox jumps over the lazy dog!"));
}
- @Test
public void testPostingsHighlighterCommonTermsQuery() throws IOException {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2405,7 +2357,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
.endObject().endObject();
}
- @Test
public void testPostingsHighlighterPrefixQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2421,7 +2372,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
- @Test
public void testPostingsHighlighterFuzzyQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2436,7 +2386,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <em>quick</em> brown fox jumps over the lazy dog!"));
}
- @Test
public void testPostingsHighlighterRegexpQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2451,7 +2400,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <em>quick</em> brown fox jumps over the lazy dog!"));
}
- @Test
public void testPostingsHighlighterWildcardQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2473,7 +2421,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <em>quick</em> brown fox jumps over the lazy dog!"));
}
- @Test
public void testPostingsHighlighterTermRangeQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2488,7 +2435,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("<em>aaab</em>"));
}
- @Test
public void testPostingsHighlighterQueryString() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2502,9 +2448,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The <em>quick</em> brown fox jumps over the lazy dog!"));
}
- @Test
public void testPostingsHighlighterRegexpQueryWithinConstantScoreQuery() throws Exception {
-
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2518,9 +2462,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
}
- @Test
public void testPostingsHighlighterMultiTermQueryMultipleLevels() throws Exception {
-
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2537,9 +2479,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
}
- @Test
public void testPostingsHighlighterPrefixQueryWithinBooleanQuery() throws Exception {
-
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2553,9 +2493,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
}
- @Test
public void testPostingsHighlighterQueryStringWithinFilteredQuery() throws Exception {
-
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2569,7 +2507,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
}
- @Test
public void testPostingsHighlighterManyDocs() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
ensureGreen();
@@ -2604,14 +2541,12 @@ public class HighlighterSearchIT extends ESIntegTestCase {
}
}
- @Test
@AwaitsFix(bugUrl="Broken now that BoostingQuery does not extend BooleanQuery anymore")
public void testFastVectorHighlighterPhraseBoost() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
phraseBoostTestCase("fvh");
}
- @Test
public void testPostingsHighlighterPhraseBoost() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
phraseBoostTestCase("postings");
diff --git a/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java b/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java
index 589f79a876..f9245a3d98 100644
--- a/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java
@@ -22,7 +22,6 @@ package org.elasticsearch.search.indicesboost;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.client.Requests.indexRequest;
import static org.elasticsearch.client.Requests.searchRequest;
@@ -36,8 +35,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class SimpleIndicesBoostSearchIT extends ESIntegTestCase {
-
- @Test
public void testIndicesBoost() throws Exception {
assertHitCount(client().prepareSearch().setQuery(termQuery("test", "value")).get(), 0);
diff --git a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java
index e87b1eb9c8..ece9cc0d82 100644
--- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java
@@ -40,7 +40,6 @@ import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -71,13 +70,11 @@ import static org.hamcrest.Matchers.nullValue;
/**
*/
public class InnerHitsIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(MockScriptEngine.TestPlugin.class);
}
- @Test
public void testSimpleNested() throws Exception {
assertAcked(prepareCreate("articles").addMapping("article", jsonBuilder().startObject().startObject("article").startObject("properties")
.startObject("comments")
@@ -207,7 +204,6 @@ public class InnerHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testRandomNested() throws Exception {
assertAcked(prepareCreate("idx").addMapping("type", "field1", "type=nested", "field2", "type=nested"));
int numDocs = scaledRandomIntBetween(25, 100);
@@ -284,7 +280,6 @@ public class InnerHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testSimpleParentChild() throws Exception {
assertAcked(prepareCreate("articles")
.addMapping("article", "title", "type=string")
@@ -395,7 +390,6 @@ public class InnerHitsIT extends ESIntegTestCase {
}
}
- @Test
public void testRandomParentChild() throws Exception {
assertAcked(prepareCreate("idx")
.addMapping("parent")
@@ -491,7 +485,6 @@ public class InnerHitsIT extends ESIntegTestCase {
}
}
- @Test
@AwaitsFix(bugUrl = "need validation of type or path defined in InnerHitsBuilder")
public void testPathOrTypeMustBeDefined() {
createIndex("articles");
@@ -508,7 +501,6 @@ public class InnerHitsIT extends ESIntegTestCase {
}
- @Test
public void testInnerHitsOnHasParent() throws Exception {
assertAcked(prepareCreate("stack")
.addMapping("question", "body", "type=string")
@@ -547,7 +539,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(searchHit.getInnerHits().get("question").getAt(0).id(), equalTo("2"));
}
- @Test
public void testParentChildMultipleLayers() throws Exception {
assertAcked(prepareCreate("articles")
.addMapping("article", "title", "type=string")
@@ -617,7 +608,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(innerHits.getAt(0).type(), equalTo("remark"));
}
- @Test
public void testNestedMultipleLayers() throws Exception {
assertAcked(prepareCreate("articles").addMapping("article", jsonBuilder().startObject().startObject("article").startObject("properties")
.startObject("comments")
@@ -736,8 +726,7 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(innerHits.getAt(0).getNestedIdentity().getChild().getOffset(), equalTo(0));
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/9723
+ // Issue #9723
public void testNestedDefinedAsObject() throws Exception {
assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=string"));
@@ -761,7 +750,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getChild(), nullValue());
}
- @Test
public void testNestedInnerHitsWithStoredFieldsAndNoSourceBackcompat() throws Exception {
assertAcked(prepareCreate("articles")
.setSettings(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
@@ -800,7 +788,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue(), equalTo("fox eat quick"));
}
- @Test
public void testNestedInnerHitsWithHighlightOnStoredFieldBackcompat() throws Exception {
assertAcked(prepareCreate("articles")
.setSettings(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
@@ -840,7 +827,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(String.valueOf(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).highlightFields().get("comments.message").getFragments()[0]), equalTo("<em>fox</em> eat quick"));
}
- @Test
public void testNestedInnerHitsWithExcludeSourceBackcompat() throws Exception {
assertAcked(prepareCreate("articles").setSettings(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
.addMapping("article", jsonBuilder().startObject()
@@ -880,7 +866,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).fields().get("comments.message").getValue(), equalTo("fox eat quick"));
}
- @Test
public void testNestedInnerHitsHiglightWithExcludeSourceBackcompat() throws Exception {
assertAcked(prepareCreate("articles").setSettings(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
.addMapping("article", jsonBuilder().startObject()
@@ -919,7 +904,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(String.valueOf(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).highlightFields().get("comments.message").getFragments()[0]), equalTo("<em>fox</em> eat quick"));
}
- @Test
public void testInnerHitsWithObjectFieldThatHasANestedField() throws Exception {
assertAcked(prepareCreate("articles")
.addMapping("article", jsonBuilder().startObject()
@@ -991,7 +975,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getChild(), nullValue());
}
- @Test
public void testRoyals() throws Exception {
assertAcked(
prepareCreate("royals")
@@ -1069,8 +1052,7 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(innerInnerHits.getAt(0).getId(), equalTo("king"));
}
- @Test
- public void matchesQueries_nestedInnerHits() throws Exception {
+ public void testMatchesQueriesNestedInnerHits() throws Exception {
XContentBuilder builder = jsonBuilder().startObject()
.startObject("type1")
.startObject("properties")
@@ -1167,8 +1149,7 @@ public class InnerHitsIT extends ESIntegTestCase {
}
}
- @Test
- public void matchesQueries_parentChildInnerHits() throws Exception {
+ public void testMatchesQueriesParentChildInnerHits() throws Exception {
assertAcked(prepareCreate("index").addMapping("child", "_parent", "type=parent"));
List<IndexRequestBuilder> requests = new ArrayList<>();
requests.add(client().prepareIndex("index", "parent", "1").setSource("{}"));
@@ -1204,7 +1185,6 @@ public class InnerHitsIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).getInnerHits().get("child").getAt(0).getMatchedQueries()[0], equalTo("_name2"));
}
- @Test
public void testDontExplode() throws Exception {
assertAcked(prepareCreate("index1").addMapping("child", "_parent", "type=parent"));
List<IndexRequestBuilder> requests = new ArrayList<>();
diff --git a/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java b/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java
index acd36e124e..d8c16282e1 100644
--- a/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java
@@ -24,9 +24,17 @@ import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.indicesQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
+import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
+import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
+import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItemInArray;
@@ -35,9 +43,7 @@ import static org.hamcrest.Matchers.hasItemInArray;
*
*/
public class MatchedQueriesIT extends ESIntegTestCase {
-
- @Test
- public void simpleMatchedQueryFromFilteredQuery() throws Exception {
+ public void testSimpleMatchedQueryFromFilteredQuery() throws Exception {
createIndex("test");
ensureGreen();
@@ -77,8 +83,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
- public void simpleMatchedQueryFromTopLevelFilter() throws Exception {
+ public void testSimpleMatchedQueryFromTopLevelFilter() throws Exception {
createIndex("test");
ensureGreen();
@@ -127,8 +132,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
- public void simpleMatchedQueryFromTopLevelFilterAndFilteredQuery() throws Exception {
+ public void testSimpleMatchedQueryFromTopLevelFilterAndFilteredQuery() throws Exception {
createIndex("test");
ensureGreen();
@@ -166,7 +170,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testIndicesFilterSupportsName() {
createIndex("test1", "test2");
ensureGreen();
@@ -205,7 +208,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testRegExpQuerySupportsName() {
createIndex("test1");
ensureGreen();
@@ -227,7 +229,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testPrefixQuerySupportsName() {
createIndex("test1");
ensureGreen();
@@ -249,7 +250,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testFuzzyQuerySupportsName() {
createIndex("test1");
ensureGreen();
@@ -271,7 +271,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testWildcardQuerySupportsName() {
createIndex("test1");
ensureGreen();
@@ -293,7 +292,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testSpanFirstQuerySupportsName() {
createIndex("test1");
ensureGreen();
@@ -318,7 +316,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
/**
* Test case for issue #4361: https://github.com/elasticsearch/elasticsearch/issues/4361
*/
- @Test
public void testMatchedWithShould() throws Exception {
createIndex("test");
ensureGreen();
@@ -355,7 +352,6 @@ public class MatchedQueriesIT extends ESIntegTestCase {
}
}
- @Test
public void testMatchedWithWrapperQuery() throws Exception {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java
index 0e7001555f..9c93f1a266 100644
--- a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java
+++ b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java
@@ -32,21 +32,28 @@ import org.elasticsearch.index.query.MoreLikeThisQueryBuilder;
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
-import static org.elasticsearch.index.query.MoreLikeThisQueryBuilder.ids;
-import static org.elasticsearch.client.Requests.*;
+import static org.elasticsearch.client.Requests.indexAliasesRequest;
+import static org.elasticsearch.client.Requests.indexRequest;
+import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.index.query.MoreLikeThisQueryBuilder.ids;
import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -54,8 +61,6 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class MoreLikeThisIT extends ESIntegTestCase {
-
- @Test
public void testSimpleMoreLikeThis() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test").addMapping("type1",
@@ -77,7 +82,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(response, 1l);
}
- @Test
public void testSimpleMoreLikeOnLongField() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test").addMapping("type1", "some_long", "type=long"));
@@ -97,7 +101,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(response, 0l);
}
- @Test
public void testMoreLikeThisWithAliases() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test").addMapping("type1",
@@ -142,7 +145,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).id(), equalTo("3"));
}
- @Test
public void testMoreLikeThisIssue2197() throws Exception {
Client client = client();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("bar")
@@ -166,8 +168,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertThat(response, notNullValue());
}
- @Test
- // See: https://github.com/elasticsearch/elasticsearch/issues/2489
+ // Issue #2489
public void testMoreLikeWithCustomRouting() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("bar")
.startObject("properties")
@@ -188,8 +189,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertThat(response, notNullValue());
}
- @Test
- // See issue: https://github.com/elasticsearch/elasticsearch/issues/3039
+ // Issue #3039
public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("bar")
.startObject("properties")
@@ -211,8 +211,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertThat(response, notNullValue());
}
- @Test
- // See issue https://github.com/elasticsearch/elasticsearch/issues/3252
+ // Issue #3252
public void testNumericField() throws Exception {
final String[] numericTypes = new String[]{"byte", "short", "integer", "long"};
prepareCreate("test").addMapping("type", jsonBuilder()
@@ -272,7 +271,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
public void testSimpleMoreLikeInclude() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test").addMapping("type1",
@@ -332,7 +330,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(mltResponse, 3l);
}
- @Test
public void testSimpleMoreLikeThisIdsMultipleTypes() throws Exception {
logger.info("Creating index test");
int numOfTypes = randomIntBetween(2, 10);
@@ -365,7 +362,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(mltResponse, numOfTypes);
}
- @Test
public void testMoreLikeThisMultiValueFields() throws Exception {
logger.info("Creating the index ...");
assertAcked(prepareCreate("test")
@@ -398,7 +394,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
}
}
- @Test
public void testMinimumShouldMatch() throws ExecutionException, InterruptedException {
logger.info("Creating the index ...");
assertAcked(prepareCreate("test")
@@ -436,7 +431,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
}
}
- @Test
public void testMoreLikeThisArtificialDocs() throws Exception {
int numFields = randomIntBetween(5, 10);
@@ -463,7 +457,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(response, 1);
}
- @Test
public void testMoreLikeThisMalformedArtificialDocs() throws Exception {
logger.info("Creating the index ...");
assertAcked(prepareCreate("test")
@@ -530,7 +523,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
assertHitCount(response, 1);
}
- @Test
public void testMoreLikeThisUnlike() throws ExecutionException, InterruptedException, IOException {
createIndex("test");
ensureGreen();
@@ -578,7 +570,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
}
}
- @Test
public void testSelectFields() throws IOException, ExecutionException, InterruptedException {
assertAcked(prepareCreate("test")
.addMapping("type1", "text", "type=string,analyzer=whitespace", "text1", "type=string,analyzer=whitespace"));
diff --git a/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java b/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java
index 53f7e615ad..c7454a5c8b 100644
--- a/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java
@@ -22,17 +22,17 @@ package org.elasticsearch.search.msearch;
import org.elasticsearch.action.search.MultiSearchResponse;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId;
import static org.hamcrest.Matchers.equalTo;
/**
*/
public class SimpleMultiSearchIT extends ESIntegTestCase {
-
- @Test
- public void simpleMultiSearch() {
+ public void testSimpleMultiSearch() {
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type", "1").setSource("field", "xxx").execute().actionGet();
@@ -43,7 +43,7 @@ public class SimpleMultiSearchIT extends ESIntegTestCase {
.add(client().prepareSearch("test").setQuery(QueryBuilders.termQuery("field", "yyy")))
.add(client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()))
.execute().actionGet();
-
+
for (MultiSearchResponse.Item item : response) {
assertNoFailures(item.getResponse());
}
diff --git a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java
index 23f6e6f6c6..88f0fbc880 100644
--- a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java
+++ b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java
@@ -36,18 +36,24 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.startsWith;
public class SimpleNestedIT extends ESIntegTestCase {
-
- @Test
- public void simpleNested() throws Exception {
+ public void testSimpleNested() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", "nested1", "type=nested").addMapping("type2", "nested1", "type=nested"));
ensureGreen();
@@ -156,8 +162,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
- public void multiNested() throws Exception {
+ public void testMultiNested() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("nested1")
@@ -226,11 +231,9 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(0l));
}
- @Test
// When IncludeNestedDocsQuery is wrapped in a FilteredQuery then a in-finite loop occurs b/c of a bug in IncludeNestedDocsQuery#advance()
// This IncludeNestedDocsQuery also needs to be aware of the filter from alias
public void testDeleteNestedDocsWithAlias() throws Exception {
-
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder().put(indexSettings()).put("index.referesh_interval", -1).build())
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -282,9 +285,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertDocumentCount("test", 6);
}
- @Test
public void testExplain() throws Exception {
-
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("nested1")
@@ -325,7 +326,6 @@ public class SimpleNestedIT extends ESIntegTestCase {
// assertThat(explanation.getDetails()[1].getDescription(), equalTo("Child[1]"));
}
- @Test
public void testSimpleNestedSorting() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
@@ -408,9 +408,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().hits()[2].sortValues()[0].toString(), equalTo("2"));
}
-
- @Test
- public void testSimpleNestedSorting_withNestedFilterMissing() throws Exception {
+ public void testSimpleNestedSortingWithNestedFilterMissing() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
.put(indexSettings())
@@ -510,7 +508,6 @@ public class SimpleNestedIT extends ESIntegTestCase {
client().prepareClearScroll().addScrollId("_all").get();
}
- @Test
public void testSortNestedWithNestedFilter() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", XContentFactory.jsonBuilder().startObject()
@@ -867,8 +864,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getHits()[2].sortValues()[0].toString(), equalTo("3"));
}
- @Test
- // https://github.com/elasticsearch/elasticsearch/issues/9305
+ // Issue #9305
public void testNestedSortingWithNestedFilterAsFilter() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", jsonBuilder().startObject().startObject("properties")
.startObject("officelocation").field("type", "string").endObject()
@@ -1004,7 +1000,6 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(1).sortValues()[1].toString(), equalTo("fname3"));
}
- @Test
public void testCheckFixedBitSetCache() throws Exception {
boolean loadFixedBitSeLazily = randomBoolean();
Settings.Builder settingsBuilder = Settings.builder().put(indexSettings())
diff --git a/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java b/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java
index a9cd6de06a..fa46ea4878 100644
--- a/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java
@@ -24,7 +24,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
@@ -32,12 +31,14 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SearchPreferenceIT extends ESIntegTestCase {
-
- @Test // see #2896
+ // see #2896
public void testStopOneNodePreferenceWithRedState() throws InterruptedException, IOException {
assertAcked(prepareCreate("test").setSettings(settingsBuilder().put("index.number_of_shards", cluster().numDataNodes()+2).put("index.number_of_replicas", 0)));
ensureGreen();
@@ -67,14 +68,13 @@ public class SearchPreferenceIT extends ESIntegTestCase {
assertThat("_only_local", searchResponse.getFailedShards(), greaterThanOrEqualTo(0));
}
- @Test
- public void noPreferenceRandom() throws Exception {
+ public void testNoPreferenceRandom() throws Exception {
assertAcked(prepareCreate("test").setSettings(
//this test needs at least a replica to make sure two consecutive searches go to two different copies of the same data
settingsBuilder().put(indexSettings()).put(SETTING_NUMBER_OF_REPLICAS, between(1, maximumNumberOfReplicas()))
));
ensureGreen();
-
+
client().prepareIndex("test", "type1").setSource("field1", "value1").execute().actionGet();
refresh();
@@ -87,8 +87,7 @@ public class SearchPreferenceIT extends ESIntegTestCase {
assertThat(firstNodeId, not(equalTo(secondNodeId)));
}
- @Test
- public void simplePreferenceTests() throws Exception {
+ public void testSimplePreference() throws Exception {
client().admin().indices().prepareCreate("test").setSettings("number_of_replicas=1").get();
ensureGreen();
@@ -121,7 +120,6 @@ public class SearchPreferenceIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
- @Test
public void testReplicaPreference() throws Exception {
client().admin().indices().prepareCreate("test").setSettings("number_of_replicas=0").get();
ensureGreen();
@@ -146,11 +144,15 @@ public class SearchPreferenceIT extends ESIntegTestCase {
assertThat(resp.getHits().totalHits(), equalTo(1l));
}
- @Test (expected = IllegalArgumentException.class)
public void testThatSpecifyingNonExistingNodesReturnsUsefulError() throws Exception {
createIndex("test");
ensureGreen();
- client().prepareSearch().setQuery(matchAllQuery()).setPreference("_only_node:DOES-NOT-EXIST").execute().actionGet();
+ try {
+ client().prepareSearch().setQuery(matchAllQuery()).setPreference("_only_node:DOES-NOT-EXIST").execute().actionGet();
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("No data node with id[DOES-NOT-EXIST] found"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java
index d931147f83..235438cc44 100644
--- a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java
+++ b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java
@@ -19,13 +19,17 @@
package org.elasticsearch.search.query;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.query.*;
+import org.elasticsearch.index.query.MatchQueryBuilder;
+import org.elasticsearch.index.query.MultiMatchQueryBuilder;
+import org.elasticsearch.index.query.Operator;
+import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.search.MatchQuery;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
@@ -33,7 +37,6 @@ import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -165,7 +168,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
.endObject().endObject();
}
- @Test
public void testDefaults() throws ExecutionException, InterruptedException {
MatchQuery.Type type = randomBoolean() ? MatchQueryBuilder.DEFAULT_TYPE : MatchQuery.Type.BOOLEAN;
SearchResponse searchResponse = client().prepareSearch("test")
@@ -205,7 +207,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("theone"));
}
- @Test
public void testPhraseType() {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("Man the Ultimate", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase")
@@ -225,7 +226,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2l);
}
- @Test
public void testSingleField() throws NoSuchFieldException, IllegalAccessException {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill"))).get();
@@ -271,7 +271,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
}
- @Test
public void testCutoffFreq() throws ExecutionException, InterruptedException {
final long numDocs = client().prepareSearch("test").setSize(0)
.setQuery(matchAllQuery()).get().getHits().totalHits();
@@ -331,8 +330,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("theother"));
}
-
- @Test
public void testEquivalence() {
final int numDocs = (int) client().prepareSearch("test").setSize(0)
@@ -427,7 +424,6 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testCrossFieldMode() throws ExecutionException, InterruptedException {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name")
diff --git a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java
index b394d10669..358122f54e 100644
--- a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java
+++ b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java
@@ -28,7 +28,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.SimpleQueryStringFlag;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Locale;
@@ -52,8 +51,6 @@ import static org.hamcrest.Matchers.equalTo;
* Tests for the {@code simple_query_string} query
*/
public class SimpleQueryStringIT extends ESIntegTestCase {
-
- @Test
public void testSimpleQueryString() throws ExecutionException, InterruptedException {
createIndex("test");
indexRandom(true, false,
@@ -103,7 +100,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "5", "6");
}
- @Test
public void testSimpleQueryStringMinimumShouldMatch() throws Exception {
createIndex("test");
ensureGreen("test");
@@ -151,7 +147,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "6", "7", "8");
}
- @Test
public void testSimpleQueryStringLowercasing() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("body", "Professional").get();
@@ -175,7 +170,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
public void testQueryStringLocale() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("body", "bılly").get();
@@ -196,7 +190,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "1");
}
- @Test
public void testNestedFieldSimpleQueryString() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder()
@@ -236,7 +229,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "1");
}
- @Test
public void testSimpleQueryStringFlags() throws ExecutionException, InterruptedException {
createIndex("test");
indexRandom(true,
@@ -288,7 +280,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("4"));
}
- @Test
public void testSimpleQueryStringLenient() throws ExecutionException, InterruptedException {
createIndex("test1", "test2");
indexRandom(true, client().prepareIndex("test1", "type1", "1").setSource("field", "foo"),
@@ -306,7 +297,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "1");
}
- @Test // see: https://github.com/elasticsearch/elasticsearch/issues/7967
+ // Issue #7967
public void testLenientFlagBeingTooLenient() throws Exception {
indexRandom(true,
client().prepareIndex("test", "doc", "1").setSource("num", 1, "body", "foo bar baz"),
@@ -321,7 +312,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertSearchHits(resp, "1");
}
- @Test
public void testSimpleQueryStringAnalyzeWildcard() throws ExecutionException, InterruptedException, IOException {
String mapping = XContentFactory.jsonBuilder()
.startObject()
@@ -345,5 +335,4 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
assertSearchHits(searchResponse, "1");
}
-
}
diff --git a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java
index efa26f25f7..720d51508f 100644
--- a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java
+++ b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java
@@ -34,7 +34,6 @@ import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Arrays;
@@ -46,9 +45,7 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class DuelScrollIT extends ESIntegTestCase {
-
- @Test
- public void testDuel_queryThenFetch() throws Exception {
+ public void testDuelQueryThenFetch() throws Exception {
TestContext context = create(SearchType.DFS_QUERY_THEN_FETCH, SearchType.QUERY_THEN_FETCH);
SearchResponse control = client().prepareSearch("index")
@@ -103,8 +100,7 @@ public class DuelScrollIT extends ESIntegTestCase {
clearScroll(scrollId);
}
- @Test
- public void testDuel_queryAndFetch() throws Exception {
+ public void testDuelQueryAndFetch() throws Exception {
// *_QUERY_AND_FETCH search types are tricky: the ordering can be incorrect, since it returns num_shards * (from + size)
// a subsequent scroll call can return hits that should have been in the hits of the first scroll call.
diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java
index 363721a7fc..bb81f28d15 100644
--- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java
+++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java
@@ -19,7 +19,12 @@
package org.elasticsearch.search.scroll;
-import org.elasticsearch.action.search.*;
+import org.elasticsearch.action.search.ClearScrollRequest;
+import org.elasticsearch.action.search.ClearScrollResponse;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.search.SearchScrollRequest;
+import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.bytes.BytesArray;
@@ -40,22 +45,32 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.junit.Test;
import java.io.IOException;
import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.startsWith;
/**
*
*/
public class SearchScrollIT extends ESIntegTestCase {
-
- @Test
public void testSimpleScrollQueryThenFetch() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 3)).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
@@ -107,7 +122,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testSimpleScrollQueryThenFetchSmallSizeUnevenDistribution() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 3)).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
@@ -181,7 +195,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testScrollAndUpdateIndex() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 5)).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
@@ -226,7 +239,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testSimpleScrollQueryThenFetch_clearScrollIds() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 3)).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
@@ -303,7 +315,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertThrows(client().prepareSearchScroll(searchResponse2.getScrollId()).setScroll(TimeValue.timeValueMinutes(2)), RestStatus.NOT_FOUND);
}
- @Test
public void testClearNonExistentScrollId() throws Exception {
createIndex("idx");
ClearScrollResponse response = client().prepareClearScroll()
@@ -317,7 +328,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertToXContentResponse(response, true, response.getNumFreed());
}
- @Test
public void testClearIllegalScrollId() throws Exception {
createIndex("idx");
try {
@@ -340,8 +350,7 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
- public void testSimpleScrollQueryThenFetch_clearAllScrollIds() throws Exception {
+ public void testSimpleScrollQueryThenFetchClearAllScrollIds() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.number_of_shards", 3)).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
@@ -440,7 +449,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testThatNonExistingScrollIdReturnsCorrectException() throws Exception {
client().prepareIndex("index", "type", "1").setSource("field", "value").execute().get();
refresh();
@@ -454,7 +462,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertThrows(internalCluster().transportClient().prepareSearchScroll(searchResponse.getScrollId()), RestStatus.NOT_FOUND);
}
- @Test
public void testStringSortMissingAscTerminates() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(Settings.settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0))
@@ -488,7 +495,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertThat(response.getHits().getHits().length, equalTo(0));
}
- @Test
public void testParseSearchScrollRequest() throws Exception {
BytesReference content = XContentFactory.jsonBuilder()
.startObject()
@@ -503,7 +509,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertThat(searchScrollRequest.scroll().keepAlive(), equalTo(TimeValue.parseTimeValue("1m", null, "scroll")));
}
- @Test
public void testParseSearchScrollRequestWithInvalidJsonThrowsException() throws Exception {
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
try {
@@ -515,7 +520,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testParseSearchScrollRequestWithUnknownParamThrowsException() throws Exception {
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
BytesReference invalidContent = XContentFactory.jsonBuilder().startObject()
@@ -532,7 +536,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testParseClearScrollRequest() throws Exception {
BytesReference content = XContentFactory.jsonBuilder().startObject()
.array("scroll_id", "value_1", "value_2")
@@ -542,7 +545,6 @@ public class SearchScrollIT extends ESIntegTestCase {
assertThat(clearScrollRequest.scrollIds(), contains("value_1", "value_2"));
}
- @Test
public void testParseClearScrollRequestWithInvalidJsonThrowsException() throws Exception {
ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
@@ -555,7 +557,6 @@ public class SearchScrollIT extends ESIntegTestCase {
}
}
- @Test
public void testParseClearScrollRequestWithUnknownParamThrowsException() throws Exception {
BytesReference invalidContent = XContentFactory.jsonBuilder().startObject()
.array("scroll_id", "value_1", "value_2")
diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java
index a037a6d9ae..96f2e23bba 100644
--- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocatio
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -34,13 +33,14 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.lessThan;
/**
*/
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0)
public class SearchScrollWithFailingNodesIT extends ESIntegTestCase {
-
@Override
protected int numberOfShards() {
return 2;
@@ -51,7 +51,6 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase {
return 0;
}
- @Test
public void testScanScrollWithShardExceptions() throws Exception {
internalCluster().startNode();
internalCluster().startNode();
diff --git a/core/src/test/java/org/elasticsearch/search/sort/SortParserTests.java b/core/src/test/java/org/elasticsearch/search/sort/SortParserTests.java
index 84295b7b19..e39fd81b28 100644
--- a/core/src/test/java/org/elasticsearch/search/sort/SortParserTests.java
+++ b/core/src/test/java/org/elasticsearch/search/sort/SortParserTests.java
@@ -17,10 +17,8 @@
* under the License.
*/
-
package org.elasticsearch.search.sort;
-
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -29,13 +27,10 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.TestSearchContext;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
public class SortParserTests extends ESSingleNodeTestCase {
-
- @Test
public void testGeoDistanceSortParserManyPointsNoException() throws Exception {
XContentBuilder mapping = jsonBuilder();
mapping.startObject().startObject("type").startObject("properties").startObject("location").field("type", "geo_point").endObject().endObject().endObject().endObject();
diff --git a/core/src/test/java/org/elasticsearch/search/source/SourceFetchingIT.java b/core/src/test/java/org/elasticsearch/search/source/SourceFetchingIT.java
index d6a8e86032..76086da4de 100644
--- a/core/src/test/java/org/elasticsearch/search/source/SourceFetchingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/source/SourceFetchingIT.java
@@ -21,15 +21,12 @@ package org.elasticsearch.search.source;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsEqual.equalTo;
public class SourceFetchingIT extends ESIntegTestCase {
-
- @Test
public void testSourceDefaultBehavior() {
createIndex("test");
ensureGreen();
@@ -48,7 +45,6 @@ public class SourceFetchingIT extends ESIntegTestCase {
}
- @Test
public void testSourceFiltering() {
createIndex("test");
ensureGreen();
@@ -82,7 +78,6 @@ public class SourceFetchingIT extends ESIntegTestCase {
* Test Case for #5132: Source filtering with wildcards broken when given multiple patterns
* https://github.com/elasticsearch/elasticsearch/issues/5132
*/
- @Test
public void testSourceWithWildcardFiltering() {
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsUnitTests.java b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsUnitTests.java
index 7c1b443a0d..76f20c8551 100644
--- a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsUnitTests.java
@@ -22,14 +22,11 @@ package org.elasticsearch.search.stats;
import org.elasticsearch.index.search.stats.SearchStats;
import org.elasticsearch.index.search.stats.SearchStats.Stats;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class SearchStatsUnitTests extends ESTestCase {
-
- @Test
// https://github.com/elasticsearch/elasticsearch/issues/7644
public void testShardLevelSearchGroupStats() throws Exception {
// let's create two dummy search stats with groups
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
index 4552099464..96eba93439 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
@@ -20,6 +20,7 @@ package org.elasticsearch.search.suggest;
import com.carrotsearch.hppc.ObjectLongHashMap;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
+
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
@@ -46,7 +47,6 @@ import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
import org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -65,17 +65,22 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
@SuppressCodecs("*") // requires custom completion format
public class CompletionSuggestSearchIT extends ESIntegTestCase {
-
private final String INDEX = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT);
private final String TYPE = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT);
private final String FIELD = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT);
private final CompletionMappingBuilder completionMappingBuilder = new CompletionMappingBuilder();
- @Test
public void testSimple() throws Exception {
createIndexAndMapping(completionMappingBuilder);
String[][] input = {{"Foo Fighters"}, {"Foo Fighters"}, {"Foo Fighters"}, {"Foo Fighters"},
@@ -99,7 +104,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestionsNotInOrder("t", "The Prodigy", "Turbonegro", "Turbonegro Get it on", "The Prodigy Firestarter");
}
- @Test
public void testSuggestFieldWithPercolateApi() throws Exception {
createIndexAndMapping(completionMappingBuilder);
String[][] input = {{"Foo Fighters"}, {"Foo Fighters"}, {"Foo Fighters"}, {"Foo Fighters"},
@@ -129,7 +133,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertThat(response.getCount(), equalTo(1l));
}
- @Test
public void testBasicPrefixSuggestion() throws Exception {
completionMappingBuilder.payloads(true);
createIndexAndMapping(completionMappingBuilder);
@@ -142,7 +145,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testThatWeightsAreWorking() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -162,7 +164,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("the", "the", "The the", "The Verve", "The Prodigy");
}
- @Test
public void testThatWeightMustBeAnInteger() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -179,7 +180,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testThatWeightCanBeAString() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -206,7 +206,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
- @Test
public void testThatWeightMustNotBeANonNumberString() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -223,7 +222,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testThatWeightAsStringMustBeInt() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -241,7 +239,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testThatInputCanBeAStringInsteadOfAnArray() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -257,7 +254,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("f", "Boo Fighters");
}
- @Test
public void testThatPayloadsAreArbitraryJsonObjects() throws Exception {
completionMappingBuilder.payloads(true);
createIndexAndMapping(completionMappingBuilder);
@@ -291,7 +287,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertThat(listValues, hasItems("spam", "eggs"));
}
- @Test
public void testPayloadAsNumeric() throws Exception {
completionMappingBuilder.payloads(true);
createIndexAndMapping(completionMappingBuilder);
@@ -319,7 +314,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertThat(prefixOption.getPayloadAsLong(), equalTo(1l));
}
- @Test
public void testPayloadAsString() throws Exception {
completionMappingBuilder.payloads(true);
createIndexAndMapping(completionMappingBuilder);
@@ -347,21 +341,24 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertThat(prefixOption.getPayloadAsString(), equalTo("test"));
}
- @Test(expected = MapperException.class)
public void testThatExceptionIsThrownWhenPayloadsAreDisabledButInIndexRequest() throws Exception {
completionMappingBuilder.payloads(false);
createIndexAndMapping(completionMappingBuilder);
- client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
- .startObject().startObject(FIELD)
- .startArray("input").value("Foo Fighters").endArray()
- .field("output", "Boo Fighters")
- .startArray("payload").value("spam").value("eggs").endArray()
- .endObject().endObject()
- ).get();
+ try {
+ client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
+ .startObject().startObject(FIELD)
+ .startArray("input").value("Foo Fighters").endArray()
+ .field("output", "Boo Fighters")
+ .startArray("payload").value("spam").value("eggs").endArray()
+ .endObject().endObject()
+ ).get();
+ fail("Expected MapperException");
+ } catch (MapperException e) {
+ assertThat(e.getMessage(), is("failed to parse"));
+ }
}
- @Test
public void testDisabledPreserveSeparators() throws Exception {
completionMappingBuilder.preserveSeparators(false);
createIndexAndMapping(completionMappingBuilder);
@@ -385,7 +382,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("foof", "Foof", "Foo Fighters");
}
- @Test
public void testEnabledPreserveSeparators() throws Exception {
completionMappingBuilder.preserveSeparators(true);
createIndexAndMapping(completionMappingBuilder);
@@ -407,7 +403,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("foof", "Foof");
}
- @Test
public void testThatMultipleInputsAreSupported() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -424,7 +419,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("fu", "The incredible Foo Fighters");
}
- @Test
public void testThatShortSyntaxIsWorking() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -440,7 +434,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("f", "Firestarter");
}
- @Test
public void testThatDisablingPositionIncrementsWorkForStopwords() throws Exception {
// analyzer which removes stopwords... so may not be the simple one
completionMappingBuilder.searchAnalyzer("classic").indexAnalyzer("classic").preservePositionIncrements(false);
@@ -457,7 +450,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("b", "The Beatles");
}
- @Test
public void testThatSynonymsWork() throws Exception {
Settings.Builder settingsBuilder = settingsBuilder()
.put("analysis.analyzer.suggest_analyzer_synonyms.type", "custom")
@@ -480,7 +472,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("r", "Foo Fighters");
}
- @Test
public void testThatUpgradeToMultiFieldTypeWorks() throws Exception {
final XContentBuilder mapping = jsonBuilder()
.startObject()
@@ -524,7 +515,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(afterReindexingResponse, "suggs", "Foo Fighters");
}
- @Test
public void testThatUpgradeToMultiFieldsWorks() throws Exception {
final XContentBuilder mapping = jsonBuilder()
.startObject()
@@ -567,7 +557,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(afterReindexingResponse, "suggs", "Foo Fighters");
}
- @Test
public void testThatFuzzySuggesterWorks() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -590,7 +579,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "Nirvana");
}
- @Test
public void testThatFuzzySuggesterSupportsEditDistances() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -615,7 +603,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "Nirvana");
}
- @Test
public void testThatFuzzySuggesterSupportsTranspositions() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -638,7 +625,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "Nirvana");
}
- @Test
public void testThatFuzzySuggesterSupportsMinPrefixLength() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -661,7 +647,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "Nirvana");
}
- @Test
public void testThatFuzzySuggesterSupportsNonPrefixLength() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -684,7 +669,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "Nirvana");
}
- @Test
public void testThatFuzzySuggesterIsUnicodeAware() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -714,7 +698,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions(suggestResponse, false, "foo", "ööööö");
}
- @Test
public void testThatStatsAreWorking() throws Exception {
String otherField = "testOtherField";
@@ -756,7 +739,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertThat(regexSizeInBytes, is(totalSizeInBytes));
}
- @Test
public void testThatSortingOnCompletionFieldReturnsUsefulException() throws Exception {
createIndexAndMapping(completionMappingBuilder);
@@ -776,7 +758,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testThatSuggestStopFilterWorks() throws Exception {
Settings.Builder settingsBuilder = settingsBuilder()
.put("index.analysis.analyzer.stoptest.tokenizer", "standard")
@@ -817,15 +798,19 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
assertSuggestions("feed the t");
}
- @Test(expected = MapperParsingException.class)
public void testThatIndexingInvalidFieldsInCompletionFieldResultsInException() throws Exception {
CompletionMappingBuilder completionMappingBuilder = new CompletionMappingBuilder();
createIndexAndMapping(completionMappingBuilder);
- client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
- .startObject().startObject(FIELD)
- .startArray("FRIGGININVALID").value("Nirvana").endArray()
- .endObject().endObject()).get();
+ try {
+ client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
+ .startObject().startObject(FIELD)
+ .startArray("FRIGGININVALID").value("Nirvana").endArray()
+ .endObject().endObject()).get();
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("failed to parse"));
+ }
}
@@ -953,7 +938,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test // see #3555
+ // see #3555
public void testPrunedSegments() throws IOException {
createIndexAndMappingAndSettings(settingsBuilder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).build(), completionMappingBuilder);
@@ -990,7 +975,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testMaxFieldLength() throws IOException {
client().admin().indices().prepareCreate(INDEX).get();
ensureGreen();
@@ -1028,7 +1012,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
// see #3596
public void testVeryLongInput() throws IOException {
assertAcked(client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, jsonBuilder().startObject()
@@ -1051,7 +1034,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
// see #3648
- @Test(expected = MapperParsingException.class)
public void testReservedChars() throws IOException {
assertAcked(client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, jsonBuilder().startObject()
.startObject(TYPE).startObject("properties")
@@ -1063,15 +1045,20 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
ensureYellow();
// can cause stack overflow without the default max_input_length
String string = "foo" + (char) 0x00 + "bar";
- client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
- .startObject().startObject(FIELD)
- .startArray("input").value(string).endArray()
- .field("output", "foobar")
- .endObject().endObject()
- ).setRefresh(true).get();
+ try {
+ client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
+ .startObject().startObject(FIELD)
+ .startArray("input").value(string).endArray()
+ .field("output", "foobar")
+ .endObject().endObject()
+ ).setRefresh(true).get();
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), containsString("failed to parse"));
+ }
}
- @Test // see #5930
+ // see #5930
public void testIssue5930() throws IOException {
assertAcked(client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, jsonBuilder().startObject()
.startObject(TYPE).startObject("properties")
@@ -1099,7 +1086,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
}
// see issue #6399
- @Test
public void testIndexingUnrelatedNullValue() throws Exception {
String mapping = jsonBuilder()
.startObject()
@@ -1127,7 +1113,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
// make sure that the exception has the name of the field causing the error
assertTrue(e.getDetailedMessage().contains(FIELD));
}
-
}
private static String replaceReservedChars(String input, char replacement) {
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTests.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTests.java
index d7280c89ef..f2e83642f1 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTests.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTests.java
@@ -19,14 +19,18 @@
package org.elasticsearch.search.suggest;
import org.apache.lucene.analysis.MockTokenizer;
-import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.analysis.synonym.SynonymFilter;
import org.apache.lucene.analysis.synonym.SynonymMap;
import org.apache.lucene.analysis.synonym.SynonymMap.Builder;
-import org.apache.lucene.analysis.tokenattributes.*;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
+import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
import org.apache.lucene.search.suggest.analyzing.XAnalyzingSuggester;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
@@ -34,19 +38,17 @@ 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.ESTokenStreamTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
import java.util.Set;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
-
final XAnalyzingSuggester suggester = new XAnalyzingSuggester(new SimpleAnalyzer());
- @Test
public void testSuggestTokenFilter() throws Exception {
Tokenizer tokenStream = new MockTokenizer(MockTokenizer.WHITESPACE, true);
tokenStream.setReader(new StringReader("mykeyword"));
@@ -60,7 +62,6 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
assertTokenStreamContents(suggestTokenStream, new String[] {"mykeyword"}, null, null, new String[] {"Surface keyword|friggin payload|10"}, new int[] { 1 }, null, null);
}
- @Test
public void testSuggestTokenFilterWithSynonym() throws Exception {
Builder builder = new SynonymMap.Builder(true);
builder.add(new CharsRef("mykeyword"), new CharsRef("mysynonym"), true);
@@ -79,7 +80,6 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
assertTokenStreamContents(suggestTokenStream, new String[] {"mysynonym", "mykeyword"}, null, null, new String[] {"Surface keyword|friggin payload|10", "Surface keyword|friggin payload|10"}, new int[] { 2, 0 }, null, null);
}
- @Test
public void testValidNumberOfExpansions() throws IOException {
Builder builder = new SynonymMap.Builder(true);
for (int i = 0; i < 256; i++) {
@@ -93,7 +93,7 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
MockTokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, true);
tokenizer.setReader(new StringReader(valueBuilder.toString()));
SynonymFilter filter = new SynonymFilter(tokenizer, builder.build(), true);
-
+
TokenStream suggestTokenStream = new CompletionTokenStream(filter, new BytesRef("Surface keyword|friggin payload|10"), new CompletionTokenStream.ToFiniteStrings() {
@Override
public Set<IntsRef> toFiniteStrings(TokenStream stream) throws IOException {
@@ -101,7 +101,7 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
return finiteStrings;
}
});
-
+
suggestTokenStream.reset();
ByteTermAttribute attr = suggestTokenStream.addAttribute(ByteTermAttribute.class);
PositionIncrementAttribute posAttr = suggestTokenStream.addAttribute(PositionIncrementAttribute.class);
@@ -118,8 +118,7 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
assertEquals(count, maxPos);
}
-
- @Test(expected = IllegalArgumentException.class)
+
public void testInValidNumberOfExpansions() throws IOException {
Builder builder = new SynonymMap.Builder(true);
for (int i = 0; i < 256; i++) {
@@ -133,7 +132,7 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
MockTokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, true);
tokenizer.setReader(new StringReader(valueBuilder.toString()));
SynonymFilter filter = new SynonymFilter(tokenizer, builder.build(), true);
-
+
TokenStream suggestTokenStream = new CompletionTokenStream(filter, new BytesRef("Surface keyword|friggin payload|10"), new CompletionTokenStream.ToFiniteStrings() {
@Override
public Set<IntsRef> toFiniteStrings(TokenStream stream) throws IOException {
@@ -141,14 +140,18 @@ public class CompletionTokenStreamTests extends ESTokenStreamTestCase {
return finiteStrings;
}
});
-
- suggestTokenStream.reset();
- suggestTokenStream.incrementToken();
- suggestTokenStream.close();
+ suggestTokenStream.reset();
+ try {
+ suggestTokenStream.incrementToken();
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("Only <= 256 finite strings are supported"));
+ } finally {
+ suggestTokenStream.close();
+ }
}
- @Test
public void testSuggestTokenFilterProperlyDelegateInputStream() throws Exception {
Tokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, true);
tokenizer.setReader(new StringReader("mykeyword"));
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearchIT.java
index 48048b7d8b..8deeb0dee1 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearchIT.java
@@ -19,7 +19,6 @@
package org.elasticsearch.search.suggest;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
-
import org.apache.lucene.util.XGeoHashUtils;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.suggest.SuggestRequest;
@@ -40,7 +39,6 @@ import org.elasticsearch.search.suggest.context.ContextBuilder;
import org.elasticsearch.search.suggest.context.ContextMapping;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -56,6 +54,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFa
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestion;
import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertDistance;
import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
@SuppressCodecs("*") // requires custom completion format
public class ContextSuggestSearchIT extends ESIntegTestCase {
@@ -83,7 +82,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
{ "Smythe, Alistair", "Alistair Smythe", "Alistair" }, { "Smythe, Spencer", "Spencer Smythe", "Spencer" },
{ "Whitemane, Aelfyre", "Aelfyre Whitemane", "Aelfyre" }, { "Whitemane, Kofi", "Kofi Whitemane", "Kofi" } };
- @Test
public void testBasicGeo() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.location("st").precision("5km").neighbors(true))));
ensureYellow();
@@ -109,19 +107,18 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
client().prepareIndex(INDEX, TYPE, "2").setSource(source2).execute().actionGet();
client().admin().indices().prepareRefresh(INDEX).get();
-
+
String suggestionName = randomAsciiOfLength(10);
CompletionSuggestionBuilder context = SuggestBuilders.completionSuggestion(suggestionName).field(FIELD).text("h").size(10)
.addGeoLocation("st", 52.52, 13.4);
-
+
SuggestRequestBuilder suggestionRequest = client().prepareSuggest(INDEX).addSuggestion(context);
SuggestResponse suggestResponse = suggestionRequest.execute().actionGet();
-
+
assertEquals(suggestResponse.getSuggest().size(), 1);
assertEquals("Hotel Amsterdam in Berlin", suggestResponse.getSuggest().getSuggestion(suggestionName).iterator().next().getOptions().iterator().next().getText().string());
}
-
- @Test
+
public void testMultiLevelGeo() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.location("st")
.precision(1)
@@ -150,7 +147,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
client().prepareIndex(INDEX, TYPE, "1").setSource(source1).execute().actionGet();
client().admin().indices().prepareRefresh(INDEX).get();
-
+
for (int precision = 1; precision <= 12; precision++) {
String suggestionName = randomAsciiOfLength(10);
CompletionSuggestionBuilder context = new CompletionSuggestionBuilder(suggestionName).field(FIELD).text("h").size(10)
@@ -160,11 +157,10 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
SuggestResponse suggestResponse = suggestionRequest.execute().actionGet();
assertEquals(suggestResponse.getSuggest().size(), 1);
assertEquals("Hotel Amsterdam in Berlin", suggestResponse.getSuggest().getSuggestion(suggestionName).iterator().next()
- .getOptions().iterator().next().getText().string());
+ .getOptions().iterator().next().getText().string());
}
}
- @Test
public void testMappingIdempotency() throws Exception {
List<Integer> precisions = new ArrayList<>();
for (int i = 0; i < randomIntBetween(4, 12); i++) {
@@ -199,10 +195,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(mapping.string()).get());
}
-
- @Test
public void testGeoField() throws Exception {
-
XContentBuilder mapping = jsonBuilder();
mapping.startObject();
mapping.startObject(TYPE);
@@ -249,18 +242,17 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
client().prepareIndex(INDEX, TYPE, "2").setSource(source2).execute().actionGet();
refresh();
-
+
String suggestionName = randomAsciiOfLength(10);
CompletionSuggestionBuilder context = SuggestBuilders.completionSuggestion(suggestionName).field(FIELD).text("h").size(10)
.addGeoLocation("st", 52.52, 13.4);
SuggestRequestBuilder suggestionRequest = client().prepareSuggest(INDEX).addSuggestion(context);
SuggestResponse suggestResponse = suggestionRequest.execute().actionGet();
-
+
assertEquals(suggestResponse.getSuggest().size(), 1);
assertEquals("Hotel Amsterdam in Berlin", suggestResponse.getSuggest().getSuggestion(suggestionName).iterator().next().getOptions().iterator().next().getText().string());
}
-
- @Test
+
public void testSimpleGeo() throws Exception {
String reinickendorf = "u337p3mp11e2";
String pankow = "u33e0cyyjur4";
@@ -315,7 +307,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertGeoSuggestionsInRange(treptow, "pizza", precision);
}
- @Test
public void testSimplePrefix() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.category("st"))));
ensureYellow();
@@ -341,7 +332,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertPrefixSuggestions(2, "w", "Whitemane, Kofi");
}
- @Test
public void testTypeCategoryIsActuallyCalledCategory() throws Exception {
XContentBuilder mapping = jsonBuilder();
mapping.startObject().startObject(TYPE).startObject("properties")
@@ -397,8 +387,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
}
}
-
- @Test
public void testBasic() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, false, ContextBuilder.reference("st", "_type"), ContextBuilder.reference("nd", "_type"))));
ensureYellow();
@@ -415,7 +403,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertDoubleFieldSuggestions(TYPE, TYPE, "m", "my hotel");
}
- @Test
public void testSimpleField() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.reference("st", "category"))));
ensureYellow();
@@ -442,7 +429,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
}
- @Test // see issue #10987
+ // see issue #10987
public void testEmptySuggestion() throws Exception {
String mapping = jsonBuilder()
.startObject()
@@ -470,7 +457,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
}
- @Test
public void testMultiValueField() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.reference("st", "category"))));
ensureYellow();
@@ -496,7 +482,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertFieldSuggestions("2", "w", "Whitemane, Kofi");
}
- @Test
public void testMultiContext() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.reference("st", "categoryA"), ContextBuilder.reference("nd", "categoryB"))));
ensureYellow();
@@ -523,7 +508,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertMultiContextSuggestions("2", "C", "w", "Whitemane, Kofi");
}
- @Test
public void testMultiContextWithFuzzyLogic() throws Exception {
assertAcked(prepareCreate(INDEX).addMapping(TYPE, createMapping(TYPE, ContextBuilder.reference("st", "categoryA"), ContextBuilder.reference("nd", "categoryB"))));
ensureYellow();
@@ -554,7 +538,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
"Mary MacPherran", "Mary MacPherran \"Skeeter\"", "Mikhail", "Mikhail Rasputin", "Moira", "Moira MacTaggert");
}
- @Test
public void testSimpleType() throws Exception {
String[] types = { TYPE + "A", TYPE + "B", TYPE + "C" };
@@ -586,7 +569,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertFieldSuggestions(types[2], "w", "Whitemane, Kofi");
}
- @Test // issue 5525, default location didnt work with lat/lon map, and did not set default location appropriately
+ // issue 5525, default location didnt work with lat/lon map, and did not set default location appropriately
public void testGeoContextDefaultMapping() throws Exception {
GeoPoint berlinAlexanderplatz = GeoPoint.fromGeohash("u33dc1");
@@ -612,7 +595,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Berlin Alexanderplatz");
}
- @Test // issue 5525, setting the path of a category context and then indexing a document without that field returned an error
+ // issue 5525, setting the path of a category context and then indexing a document without that field returned an error
public void testThatMissingPrefixesForContextReturnException() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("service").startObject("properties").startObject("suggest")
@@ -639,7 +622,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
}
}
- @Test // issue 5525, the geo point parser did not work when the lat/lon values were inside of a value object
+ // issue 5525, the geo point parser did not work when the lat/lon values were inside of a value object
public void testThatLocationVenueCanBeParsedAsDocumented() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("poi").startObject("properties").startObject("suggest")
@@ -670,7 +653,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertNoFailures(suggestResponse);
}
- @Test
public void testThatCategoryDefaultWorks() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -693,7 +675,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Hoodie red");
}
- @Test
public void testThatDefaultCategoryAndPathWorks() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -718,7 +699,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Hoodie red");
}
- @Test
public void testThatGeoPrecisionIsWorking() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -751,7 +731,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Berlin Alexanderplatz", "Berlin Poelchaustr.", "Berlin Dahlem");
}
- @Test
public void testThatNeighborsCanBeExcluded() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -781,7 +760,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Berlin Alexanderplatz");
}
- @Test
public void testThatGeoPathCanBeSelected() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -806,7 +784,6 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggestResponse.getSuggest(), 0, "suggestion", "Berlin Alexanderplatz");
}
- @Test(expected = MapperParsingException.class)
public void testThatPrecisionIsRequired() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("item").startObject("properties").startObject("suggest")
@@ -818,10 +795,14 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
.endObject().endObject().endObject()
.endObject();
- assertAcked(prepareCreate(INDEX).addMapping("item", xContentBuilder));
+ try {
+ prepareCreate(INDEX).addMapping("item", xContentBuilder).get();
+ fail("Expected MapperParsingException");
+ } catch (MapperParsingException e) {
+ assertThat(e.getMessage(), is("Failed to parse mapping [item]: field [precision] is missing"));
+ }
}
- @Test
public void testThatLatLonParsingFromSourceWorks() throws Exception {
XContentBuilder xContentBuilder = jsonBuilder().startObject()
.startObject("mappings").startObject("test").startObject("properties").startObject("suggest_geo")
@@ -874,7 +855,7 @@ public class ContextSuggestSearchIT extends ESIntegTestCase {
assertTrue(options.iterator().hasNext());
for (CompletionSuggestion.Entry.Option option : options) {
String target = option.getPayloadAsString();
- assertDistance(location, target, Matchers.lessThanOrEqualTo(precision));
+ assertDistance(location, target, Matchers.lessThanOrEqualTo(precision));
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
index df04d438a9..18b4fa50e7 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
@@ -26,7 +26,6 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -42,13 +41,11 @@ import static org.hamcrest.Matchers.is;
*/
@ClusterScope(scope= Scope.SUITE, numDataNodes =1)
public class CustomSuggesterSearchIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(CustomSuggesterPlugin.class);
}
- @Test
public void testThatCustomSuggestersCanBeRegisteredAndWork() throws Exception {
createIndex("test");
client().prepareIndex("test", "test", "1").setSource(jsonBuilder()
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java
index c5e0912d61..1850abc859 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java
@@ -39,13 +39,17 @@ import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.DirectCan
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
@@ -73,8 +77,7 @@ import static org.hamcrest.Matchers.nullValue;
* request, modify again, request again, etc. This makes it very obvious what changes between requests.
*/
public class SuggestSearchIT extends ESIntegTestCase {
-
- @Test // see #3196
+ // see #3196
public void testSuggestAcrossMultipleIndices() throws IOException {
createIndex("test");
ensureGreen();
@@ -165,7 +168,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
}
}
- @Test // see #3037
+ // see #3037
public void testSuggestModes() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(SETTING_NUMBER_OF_SHARDS, 1)
@@ -175,7 +178,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
.put("index.analysis.filter.shingler.type", "shingle")
.put("index.analysis.filter.shingler.min_shingle_size", 2)
.put("index.analysis.filter.shingler.max_shingle_size", 3));
-
+
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties")
.startObject("name")
@@ -195,7 +198,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
.endObject().endObject();
assertAcked(builder.addMapping("type1", mapping));
ensureGreen();
-
+
index("test", "type1", "1", "name", "I like iced tea");
index("test", "type1", "2", "name", "I like tea.");
@@ -213,8 +216,8 @@ public class SuggestSearchIT extends ESIntegTestCase {
searchSuggest = searchSuggest( "ice tea", phraseSuggestion);
assertSuggestionSize(searchSuggest, 0, 0, "did_you_mean");
}
-
- @Test // see #2729
+
+ // see #2729
public void testSizeOneShard() throws Exception {
prepareCreate("test").setSettings(
SETTING_NUMBER_OF_SHARDS, 1,
@@ -228,7 +231,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
SearchResponse search = client().prepareSearch().setQuery(matchQuery("text", "spellchecker")).get();
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
-
+
TermSuggestionBuilder termSuggestion = termSuggestion("test")
.suggestMode("always") // Always, otherwise the results can vary between requests.
.text("abcd")
@@ -241,8 +244,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
suggest = searchSuggest( termSuggestion);
assertSuggestion(suggest, 0, "test", 5, "abc0");
}
-
- @Test
+
public void testUnmappedField() throws IOException, InterruptedException, ExecutionException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -295,7 +297,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
}
}
- @Test
public void testSimple() throws Exception {
createIndex("test");
ensureGreen();
@@ -305,10 +306,10 @@ public class SuggestSearchIT extends ESIntegTestCase {
index("test", "type1", "3", "text", "abbd");
index("test", "type1", "4", "text", "abcc");
refresh();
-
+
SearchResponse search = client().prepareSearch().setQuery(matchQuery("text", "spellcecker")).get();
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
-
+
TermSuggestionBuilder termSuggest = termSuggestion("test")
.suggestMode("always") // Always, otherwise the results can vary between requests.
.text("abcd")
@@ -322,7 +323,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertThat(suggest.getSuggestion("test").getEntries().get(0).getText().string(), equalTo("abcd"));
}
- @Test
public void testEmpty() throws Exception {
createIndex("test");
ensureGreen();
@@ -343,7 +343,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertThat(suggest.getSuggestion("test").getEntries().get(0).getText().string(), equalTo("abcd"));
}
- @Test
public void testWithMultipleCommands() throws Exception {
createIndex("test");
ensureGreen();
@@ -372,7 +371,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertSuggestionSize(suggest, 0, 0, "accuracy");
}
- @Test
public void testSizeAndSort() throws Exception {
createIndex("test");
ensureGreen();
@@ -420,8 +418,8 @@ public class SuggestSearchIT extends ESIntegTestCase {
// assertThat(suggest.get(3).getSuggestedWords().get("prefix_abcd").get(4).getTerm(), equalTo("prefix_abcc"));
// assertThat(suggest.get(3).getSuggestedWords().get("prefix_abcd").get(4).getTerm(), equalTo("prefix_accd"));
}
-
- @Test // see #2817
+
+ // see #2817
public void testStopwordsOnlyPhraseSuggest() throws IOException {
assertAcked(prepareCreate("test").addMapping("typ1", "body", "type=string,analyzer=stopwd").setSettings(
settingsBuilder()
@@ -438,9 +436,8 @@ public class SuggestSearchIT extends ESIntegTestCase {
.size(1));
assertSuggestionSize(searchSuggest, 0, 0, "simple_phrase");
}
-
- @Test
- public void testPrefixLength() throws IOException { // Stopped here
+
+ public void testPrefixLength() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put("index.analysis.analyzer.reverse.tokenizer", "standard")
@@ -474,15 +471,14 @@ public class SuggestSearchIT extends ESIntegTestCase {
.addCandidateGenerator(PhraseSuggestionBuilder.candidateGenerator("body").prefixLength(4).minWordLength(1).suggestMode("always"))
.size(1).confidence(1.0f));
assertSuggestion(searchSuggest, 0, "simple_phrase", "hello words");
-
+
searchSuggest = searchSuggest( "hello word",
phraseSuggestion("simple_phrase").field("body")
.addCandidateGenerator(PhraseSuggestionBuilder.candidateGenerator("body").prefixLength(2).minWordLength(1).suggestMode("always"))
.size(1).confidence(1.0f));
assertSuggestion(searchSuggest, 0, "simple_phrase", "hello world");
}
-
- @Test
+
@Nightly
public void testMarvelHerosPhraseSuggest() throws IOException, URISyntaxException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
@@ -586,7 +582,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
searchSuggest = searchSuggest( "american ame", phraseSuggest);
assertSuggestion(searchSuggest, 0, "simple_phrase", "american ace");
-
+
// try all smoothing methods
phraseSuggest.smoothingModel(new PhraseSuggestionBuilder.LinearInterpolation(0.4,0.4,0.2));
searchSuggest = searchSuggest( "Xor the Got-Jewel", phraseSuggest);
@@ -616,7 +612,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
return Files.readAllLines(PathUtils.get(SuggestSearchIT.class.getResource("/config/names.txt").toURI()), StandardCharsets.UTF_8);
}
- @Test
public void testSizePararm() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(SETTING_NUMBER_OF_SHARDS, 1)
@@ -630,7 +625,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
.put("index.analysis.filter.my_shingle.output_unigrams", false)
.put("index.analysis.filter.my_shingle.min_shingle_size", 2)
.put("index.analysis.filter.my_shingle.max_shingle_size", 2));
-
+
XContentBuilder mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
@@ -682,7 +677,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertSuggestion(searchSuggest, 0, "simple_phrase", "xorr the god jewel");
}
- @Test
@Nightly
public void testPhraseBoundaryCases() throws IOException, URISyntaxException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
@@ -703,7 +697,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
.put("index.analysis.filter.my_shingle2.output_unigrams", true)
.put("index.analysis.filter.my_shingle2.min_shingle_size", 2)
.put("index.analysis.filter.my_shingle2.max_shingle_size", 2));
-
+
XContentBuilder mapping = XContentFactory.jsonBuilder()
.startObject().startObject("type1")
.startObject("_all").field("store", "yes").field("termVector", "with_positions_offsets").endObject()
@@ -776,7 +770,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertSuggestion(suggest, 0, "simple_phrase", "xorr the god jewel");
}
- @Test
public void testDifferentShardSize() throws Exception {
createIndex("test");
ensureGreen();
@@ -790,7 +783,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
ElasticsearchAssertions.assertSuggestionSize(suggest, 0, 3, "simple");
}
- @Test // see #3469
+ // see #3469
public void testShardFailures() throws IOException, InterruptedException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -844,7 +837,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
ElasticsearchAssertions.assertSuggestion(searchResponse.getSuggest(), 0, 0, "did_you_mean", "testing suggestions");
}
- @Test // see #3469
+ // see #3469
public void testEmptyShards() throws IOException, InterruptedException {
XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().
startObject().
@@ -893,7 +886,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
* Searching for a rare phrase shouldn't provide any suggestions if confidence &gt; 1. This was possible before we rechecked the cutoff
* score during the reduce phase. Failures don't occur every time - maybe two out of five tries but we don't repeat it to save time.
*/
- @Test
public void testSearchForRarePhrase() throws IOException {
// If there isn't enough chaf per shard then shards can become unbalanced, making the cutoff recheck this is testing do more harm then good.
int chafPerShard = 100;
@@ -957,12 +949,8 @@ public class SuggestSearchIT extends ESIntegTestCase {
assertSuggestion(searchSuggest, 0, 0, "simple_phrase", "nobel prize");
}
- /**
- * If the suggester finds tons of options then picking the right one is slow without &lt;&lt;&lt;INSERT SOLUTION HERE&gt;&gt;&gt;.
- */
- @Test
@Nightly
- public void suggestWithManyCandidates() throws InterruptedException, ExecutionException, IOException {
+ public void testSuggestWithManyCandidates() throws InterruptedException, ExecutionException, IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
.put(SETTING_NUMBER_OF_SHARDS, 1) // A single shard will help to keep the tests repeatable.
@@ -1107,7 +1095,6 @@ public class SuggestSearchIT extends ESIntegTestCase {
// assertThat(total, lessThan(1000L)); // Takes many seconds without fix - just for debugging
}
- @Test
public void testPhraseSuggesterCollate() throws InterruptedException, ExecutionException, IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTests.java
index ff672fbab5..9e3043dc62 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTests.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTests.java
@@ -57,10 +57,8 @@ import org.elasticsearch.search.suggest.SuggestUtils;
import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat.LookupFactory;
import org.elasticsearch.search.suggest.context.ContextMapping;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -71,7 +69,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
public class CompletionPostingsFormatTests extends ESTestCase {
-
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
static final CompletionFieldMapper.CompletionFieldType FIELD_TYPE = CompletionFieldMapper.Defaults.FIELD_TYPE.clone();
static final NamedAnalyzer analyzer = new NamedAnalyzer("foo", new StandardAnalyzer());
@@ -82,7 +79,6 @@ public class CompletionPostingsFormatTests extends ESTestCase {
FIELD_TYPE.freeze();
}
- @Test
public void testCompletionPostingsFormat() throws IOException {
AnalyzingCompletionLookupProviderV1 providerV1 = new AnalyzingCompletionLookupProviderV1(true, false, true, true);
AnalyzingCompletionLookupProvider currentProvider = new AnalyzingCompletionLookupProvider(true, false, true, true);
@@ -103,7 +99,6 @@ public class CompletionPostingsFormatTests extends ESTestCase {
dir.close();
}
- @Test
public void testProviderBackwardCompatibilityForVersion1() throws IOException {
AnalyzingCompletionLookupProviderV1 providerV1 = new AnalyzingCompletionLookupProviderV1(true, false, true, true);
AnalyzingCompletionLookupProvider currentProvider = new AnalyzingCompletionLookupProvider(true, false, true, true);
@@ -122,7 +117,6 @@ public class CompletionPostingsFormatTests extends ESTestCase {
dir.close();
}
- @Test
public void testProviderVersion2() throws IOException {
AnalyzingCompletionLookupProvider currentProvider = new AnalyzingCompletionLookupProvider(true, false, true, true);
@@ -140,7 +134,6 @@ public class CompletionPostingsFormatTests extends ESTestCase {
dir.close();
}
- @Test
public void testDuellCompletions() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException,
IllegalAccessException {
final boolean preserveSeparators = getRandom().nextBoolean();
@@ -148,7 +141,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
final boolean usePayloads = getRandom().nextBoolean();
final int options = preserveSeparators ? AnalyzingSuggester.PRESERVE_SEP : 0;
- XAnalyzingSuggester reference = new XAnalyzingSuggester(new StandardAnalyzer(), null, new StandardAnalyzer(),
+ XAnalyzingSuggester reference = new XAnalyzingSuggester(new StandardAnalyzer(), null, new StandardAnalyzer(),
options, 256, -1, preservePositionIncrements, null, false, 1, XAnalyzingSuggester.SEP_LABEL, XAnalyzingSuggester.PAYLOAD_SEP, XAnalyzingSuggester.END_BYTE, XAnalyzingSuggester.HOLE_CHARACTER);
LineFileDocs docs = new LineFileDocs(getRandom());
int num = scaledRandomIntBetween(150, 300);
@@ -159,7 +152,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
IndexableField field = nextDoc.getField("title");
titles[i] = field.stringValue();
weights[i] = between(0, 100);
-
+
}
docs.close();
final InputIterator primaryIter = new InputIterator() {
@@ -223,7 +216,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
public boolean hasPayloads() {
return true;
}
-
+
@Override
public Set<BytesRef> contexts() {
return null;
@@ -270,7 +263,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
lookup.get(j).value, equalTo(refLookup.get(j).value));
assertThat(lookup.get(j).payload, equalTo(refLookup.get(j).payload));
if (usePayloads) {
- assertThat(lookup.get(j).payload.utf8ToString(), equalTo(Long.toString(lookup.get(j).value)));
+ assertThat(lookup.get(j).payload.utf8ToString(), equalTo(Long.toString(lookup.get(j).value)));
}
}
}
@@ -280,6 +273,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
throws IOException {
RAMDirectory dir = new RAMDirectory();
Codec codec = new Lucene53Codec() {
+ @Override
public PostingsFormat getPostingsFormatForField(String field) {
final PostingsFormat in = super.getPostingsFormatForField(field);
return mapper.fieldType().postingsFormat(in);
@@ -312,7 +306,7 @@ public class CompletionPostingsFormatTests extends ESTestCase {
dir.close();
return lookup;
}
- @Test
+
public void testNoDocs() throws IOException {
AnalyzingCompletionLookupProvider provider = new AnalyzingCompletionLookupProvider(true, false, true, true);
RAMDirectory dir = new RAMDirectory();
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/context/GeoLocationContextMappingTests.java b/core/src/test/java/org/elasticsearch/search/suggest/context/GeoLocationContextMappingTests.java
index b525c4aa4b..4d66c7f82f 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/context/GeoLocationContextMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/context/GeoLocationContextMappingTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.search.suggest.context.ContextMapping.ContextConfig;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -37,8 +36,6 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
*
*/
public class GeoLocationContextMappingTests extends ESTestCase {
-
- @Test
public void testThatParsingGeoPointsWorksWithCoercion() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("lat", "52").field("lon", "4").endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
@@ -49,9 +46,7 @@ public class GeoLocationContextMappingTests extends ESTestCase {
GeolocationContextMapping mapping = GeolocationContextMapping.load("foo", config);
mapping.parseQuery("foo", parser);
}
-
- @Test
public void testUseWithDefaultGeoHash() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("lat", 52d).field("lon", 4d).endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
@@ -63,9 +58,8 @@ public class GeoLocationContextMappingTests extends ESTestCase {
config.put("default", geohash);
GeolocationContextMapping mapping = GeolocationContextMapping.load("foo", config);
mapping.parseQuery("foo", parser);
- }
-
- @Test
+ }
+
public void testUseWithDefaultLatLon() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("lat", 52d).field("lon", 4d).endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
@@ -79,9 +73,8 @@ public class GeoLocationContextMappingTests extends ESTestCase {
config.put("default", pointAsMap);
GeolocationContextMapping mapping = GeolocationContextMapping.load("foo", config);
mapping.parseQuery("foo", parser);
- }
-
- @Test
+ }
+
public void testUseWithDefaultBadLatLon() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("lat", 52d).field("lon", 4d).endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
@@ -102,9 +95,8 @@ public class GeoLocationContextMappingTests extends ESTestCase {
expected = e;
}
assertNotNull(expected);
- }
-
- @Test
+ }
+
public void testUseWithMultiplePrecisions() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("lat", 52d).field("lon", 4d).endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
@@ -120,8 +112,7 @@ public class GeoLocationContextMappingTests extends ESTestCase {
GeolocationContextMapping mapping = GeolocationContextMapping.load("foo", config);
mapping.parseQuery("foo", parser);
}
-
- @Test
+
public void testHashcode() throws Exception {
HashMap<String, Object> config = new HashMap<>();
if (randomBoolean()) {
@@ -143,7 +134,6 @@ public class GeoLocationContextMappingTests extends ESTestCase {
assertEquals(mapping.hashCode(), mapping2.hashCode());
}
- @Test
public void testUseWithBadGeoContext() throws Exception {
double lon = 4d;
String badLat = "W";
@@ -165,7 +155,6 @@ public class GeoLocationContextMappingTests extends ESTestCase {
assertNotNull(expected);
}
- @Test
public void testUseWithLonLatGeoContext() throws Exception {
double lon = 4d;
double lat = 52d;
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java b/core/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java
index b02c42107b..812928dee2 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java
@@ -18,7 +18,6 @@
*/
package org.elasticsearch.search.suggest.phrase;
-import java.nio.charset.StandardCharsets;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.Tokenizer;
@@ -43,9 +42,12 @@ import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.search.suggest.phrase.NoisyChannelSpellChecker.Result;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -57,7 +59,6 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
private final BytesRef preTag = new BytesRef("<em>");
private final BytesRef postTag = new BytesRef("</em>");
- @Test
public void testMarvelHeros() throws IOException {
RAMDirectory dir = new RAMDirectory();
Map<String, Analyzer> mapping = new HashMap<>();
@@ -97,7 +98,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
DirectoryReader ir = DirectoryReader.open(writer, false);
WordScorer wordScorer = new LaplaceScorer(ir, MultiFields.getTerms(ir, "body_ngram"), "body_ngram", 0.95d, new BytesRef(" "), 0.5f);
-
+
NoisyChannelSpellChecker suggester = new NoisyChannelSpellChecker();
DirectSpellChecker spellchecker = new DirectSpellChecker();
spellchecker.setMinQueryLength(1);
@@ -108,7 +109,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
assertThat(corrections[0].join(space).utf8ToString(), equalTo("american ace"));
assertThat(corrections[0].join(space, preTag, postTag).utf8ToString(), equalTo("american <em>ace</em>"));
assertThat(result.cutoffScore, greaterThan(0d));
-
+
result = suggester.getCorrections(wrapper, new BytesRef("american ame"), generator, 1, 1, ir, "body", wordScorer, 0, 1);
corrections = result.corrections;
assertThat(corrections.length, equalTo(1));
@@ -128,14 +129,14 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
assertThat(corrections[1].join(space, preTag, postTag).utf8ToString(), equalTo("xor the <em>god</em> jewel"));
assertThat(corrections[2].join(space, preTag, postTag).utf8ToString(), equalTo("<em>xorn</em> the <em>god</em> jewel"));
assertThat(corrections[3].join(space, preTag, postTag).utf8ToString(), equalTo("<em>xorr</em> the got jewel"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 4, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(4));
assertThat(corrections[0].join(space).utf8ToString(), equalTo("xorr the god jewel"));
assertThat(corrections[1].join(space).utf8ToString(), equalTo("xor the god jewel"));
assertThat(corrections[2].join(space).utf8ToString(), equalTo("xorn the god jewel"));
assertThat(corrections[3].join(space).utf8ToString(), equalTo("xorr the got jewel"));
-
+
// Test some of the highlighting corner cases
suggester = new NoisyChannelSpellChecker(0.85);
wordScorer = new LaplaceScorer(ir, MultiFields.getTerms(ir, "body_ngram"), "body_ngram", 0.85d, new BytesRef(" "), 0.5f);
@@ -151,7 +152,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
assertThat(corrections[3].join(space, preTag, postTag).utf8ToString(), equalTo("xor teh <em>god</em> jewel"));
// test synonyms
-
+
Analyzer analyzer = new Analyzer() {
@Override
@@ -160,7 +161,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
TokenFilter filter = new LowerCaseFilter(t);
try {
SolrSynonymParser parser = new SolrSynonymParser(true, false, new WhitespaceAnalyzer());
- ((SolrSynonymParser) parser).parse(new StringReader("usa => usa, america, american\nursa => usa, america, american"));
+ parser.parse(new StringReader("usa => usa, america, american\nursa => usa, america, american"));
filter = new SynonymFilter(filter, parser.build(), true);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -168,7 +169,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
return new TokenStreamComponents(t, filter);
}
};
-
+
spellchecker.setAccuracy(0.0f);
spellchecker.setMinPrefix(1);
spellchecker.setMinQueryLength(1);
@@ -177,7 +178,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
corrections = suggester.getCorrections(analyzer, new BytesRef("captian usa"), generator, 2, 4, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections[0].join(space).utf8ToString(), equalTo("captain america"));
assertThat(corrections[0].join(space, preTag, postTag).utf8ToString(), equalTo("<em>captain america</em>"));
-
+
generator = new DirectCandidateGenerator(spellchecker, "body", SuggestMode.SUGGEST_MORE_POPULAR, ir, 0.85, 10, null, analyzer, MultiFields.getTerms(ir, "body"));
corrections = suggester.getCorrections(analyzer, new BytesRef("captian usw"), generator, 2, 4, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("captain america"));
@@ -189,8 +190,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("captain america"));
assertThat(corrections[0].join(space, preTag, postTag).utf8ToString(), equalTo("captain <em>america</em>"));
}
-
- @Test
+
public void testMarvelHerosMultiGenerator() throws IOException {
RAMDirectory dir = new RAMDirectory();
Map<String, Analyzer> mapping = new HashMap<>();
@@ -246,23 +246,23 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
DirectCandidateGenerator forward = new DirectCandidateGenerator(spellchecker, "body", SuggestMode.SUGGEST_ALWAYS, ir, 0.95, 10);
DirectCandidateGenerator reverse = new DirectCandidateGenerator(spellchecker, "body_reverse", SuggestMode.SUGGEST_ALWAYS, ir, 0.95, 10, wrapper, wrapper, MultiFields.getTerms(ir, "body_reverse"));
CandidateGenerator generator = new MultiCandidateGeneratorWrapper(10, forward, reverse);
-
+
Correction[] corrections = suggester.getCorrections(wrapper, new BytesRef("american cae"), generator, 1, 1, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("american ace"));
-
+
generator = new MultiCandidateGeneratorWrapper(5, forward, reverse);
corrections = suggester.getCorrections(wrapper, new BytesRef("american ame"), generator, 1, 1, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("american ace"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("american cae"), forward, 1, 1, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(0)); // only use forward with constant prefix
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("america cae"), generator, 2, 1, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("american ace"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("Zorr the Got-Jewel"), generator, 0.5f, 4, ir, "body", wordScorer, 0, 2).corrections;
assertThat(corrections.length, equalTo(4));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the god jewel"));
@@ -273,21 +273,18 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
corrections = suggester.getCorrections(wrapper, new BytesRef("Zorr the Got-Jewel"), generator, 0.5f, 1, ir, "body", wordScorer, 1.5f, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the god jewel"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 1, ir, "body", wordScorer, 1.5f, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the god jewel"));
- // Test a special case where one of the suggest term is unchanged by the postFilter, 'II' here is unchanged by the reverse analyzer.
+ // Test a special case where one of the suggest term is unchanged by the postFilter, 'II' here is unchanged by the reverse analyzer.
corrections = suggester.getCorrections(wrapper, new BytesRef("Quazar II"), generator, 1, 1, ir, "body", wordScorer, 1, 2).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("quasar ii"));
}
- @Test
public void testMarvelHerosTrigram() throws IOException {
-
-
RAMDirectory dir = new RAMDirectory();
Map<String, Analyzer> mapping = new HashMap<>();
mapping.put("body_ngram", new Analyzer() {
@@ -334,11 +331,11 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
Correction[] corrections = suggester.getCorrections(wrapper, new BytesRef("american ame"), generator, 1, 1, ir, "body", wordScorer, 1, 3).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("american ace"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("american ame"), generator, 1, 1, ir, "body", wordScorer, 1, 1).corrections;
assertThat(corrections.length, equalTo(0));
// assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("american ape"));
-
+
wordScorer = new LinearInterpoatingScorer(ir, MultiFields.getTerms(ir, "body_ngram"), "body_ngram", 0.85d, new BytesRef(" "), 0.5, 0.4, 0.1);
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 4, ir, "body", wordScorer, 0, 3).corrections;
assertThat(corrections.length, equalTo(4));
@@ -346,25 +343,25 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
assertThat(corrections[1].join(new BytesRef(" ")).utf8ToString(), equalTo("xor the god jewel"));
assertThat(corrections[2].join(new BytesRef(" ")).utf8ToString(), equalTo("xorn the god jewel"));
assertThat(corrections[3].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the got jewel"));
-
-
-
+
+
+
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 4, ir, "body", wordScorer, 1, 3).corrections;
assertThat(corrections.length, equalTo(4));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the god jewel"));
assertThat(corrections[1].join(new BytesRef(" ")).utf8ToString(), equalTo("xor the god jewel"));
assertThat(corrections[2].join(new BytesRef(" ")).utf8ToString(), equalTo("xorn the god jewel"));
assertThat(corrections[3].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the got jewel"));
-
+
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 1, ir, "body", wordScorer, 100, 3).corrections;
assertThat(corrections.length, equalTo(1));
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("xorr the god jewel"));
-
+
// test synonyms
-
+
Analyzer analyzer = new Analyzer() {
@Override
@@ -373,7 +370,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
TokenFilter filter = new LowerCaseFilter(t);
try {
SolrSynonymParser parser = new SolrSynonymParser(true, false, new WhitespaceAnalyzer());
- ((SolrSynonymParser) parser).parse(new StringReader("usa => usa, america, american\nursa => usa, america, american"));
+ parser.parse(new StringReader("usa => usa, america, american\nursa => usa, america, american"));
filter = new SynonymFilter(filter, parser.build(), true);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -381,7 +378,7 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
return new TokenStreamComponents(t, filter);
}
};
-
+
spellchecker.setAccuracy(0.0f);
spellchecker.setMinPrefix(1);
spellchecker.setMinQueryLength(1);
@@ -389,12 +386,12 @@ public class NoisyChannelSpellCheckerTests extends ESTestCase {
wordScorer = new LinearInterpoatingScorer(ir, MultiFields.getTerms(ir, "body_ngram"), "body_ngram", 0.95d, new BytesRef(" "), 0.5, 0.4, 0.1);
corrections = suggester.getCorrections(analyzer, new BytesRef("captian usa"), generator, 2, 4, ir, "body", wordScorer, 1, 3).corrections;
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("captain america"));
-
+
generator = new DirectCandidateGenerator(spellchecker, "body", SuggestMode.SUGGEST_MORE_POPULAR, ir, 0.95, 10, null, analyzer, MultiFields.getTerms(ir, "body"));
corrections = suggester.getCorrections(analyzer, new BytesRef("captian usw"), generator, 2, 4, ir, "body", wordScorer, 1, 3).corrections;
assertThat(corrections[0].join(new BytesRef(" ")).utf8ToString(), equalTo("captain america"));
-
-
+
+
wordScorer = new StupidBackoffScorer(ir, MultiFields.getTerms(ir, "body_ngram"), "body_ngram", 0.85d, new BytesRef(" "), 0.4);
corrections = suggester.getCorrections(wrapper, new BytesRef("Xor the Got-Jewel"), generator, 0.5f, 2, ir, "body", wordScorer, 0, 3).corrections;
assertThat(corrections.length, equalTo(2));
diff --git a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java
index d486cdba22..ab6a10f3cd 100644
--- a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java
+++ b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java
@@ -22,7 +22,6 @@ package org.elasticsearch.similarity;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
@@ -30,8 +29,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
public class SimilarityIT extends ESIntegTestCase {
-
- @Test
public void testCustomBM25Similarity() throws Exception {
try {
client().admin().indices().prepareDelete("test").execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java
index 9047c710c4..666ef9dfe3 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java
@@ -34,17 +34,26 @@ import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.FromXContentBuilder;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.translog.BufferedChecksumStreamOutput;
import org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat;
import org.elasticsearch.repositories.blobstore.LegacyBlobStoreFormat;
-import org.junit.Test;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
-import java.util.concurrent.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
@@ -99,6 +108,7 @@ public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
return new BlobObj(text);
}
+ @Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.field("text", getText());
return builder;
@@ -147,7 +157,6 @@ public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
}
}
- @Test
public void testBlobStoreOperations() throws IOException {
BlobStore blobStore = createTestBlobStore();
BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
@@ -183,8 +192,6 @@ public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
assertEquals(legacySMILE.read(blobContainer, "legacy-smile-comp").getText(), "legacy smile compressed");
}
-
- @Test
public void testCompressionIsApplied() throws IOException {
BlobStore blobStore = createTestBlobStore();
BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
@@ -202,7 +209,6 @@ public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
assertThat(blobs.get("blob-not-comp").length(), greaterThan(blobs.get("blob-comp").length()));
}
- @Test
public void testBlobCorruption() throws IOException {
BlobStore blobStore = createTestBlobStore();
BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
diff --git a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
index 8b69ae38d7..f9392836d8 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
@@ -21,6 +21,7 @@ package org.elasticsearch.snapshots;
import com.carrotsearch.hppc.IntHashSet;
import com.carrotsearch.hppc.IntSet;
+
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
@@ -64,9 +65,10 @@ import org.elasticsearch.rest.action.admin.cluster.repositories.get.RestGetRepos
import org.elasticsearch.rest.action.admin.cluster.state.RestClusterStateAction;
import org.elasticsearch.snapshots.mockstore.MockRepository;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.rest.FakeRestRequest;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
@@ -80,24 +82,30 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
@ESIntegTestCase.SuppressLocalMode // TODO only restorePersistentSettingsTest needs this maybe factor out?
public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(MockRepository.Plugin.class);
}
- @Test
- public void restorePersistentSettingsTest() throws Exception {
+ public void testRestorePersistentSettings() throws Exception {
logger.info("--> start 2 nodes");
Settings nodeSettings = settingsBuilder()
.put("discovery.type", "zen")
@@ -157,8 +165,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
.getMetaData().persistentSettings().getAsInt(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES, -1), not(equalTo(2)));
}
- @Test
- public void restoreCustomMetadata() throws Exception {
+ public void testRestoreCustomMetadata() throws Exception {
Path tempDir = randomRepoPath();
logger.info("--> start node");
@@ -286,8 +293,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
public ClusterState execute(ClusterState currentState) throws Exception;
}
- @Test
- public void snapshotDuringNodeShutdownTest() throws Exception {
+ public void testSnapshotDuringNodeShutdown() throws Exception {
logger.info("--> start 2 nodes");
Client client = client();
@@ -332,8 +338,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
logger.info("--> done");
}
- @Test
- public void snapshotWithStuckNodeTest() throws Exception {
+ public void testSnapshotWithStuckNode() throws Exception {
logger.info("--> start 2 nodes");
ArrayList<String> nodes = new ArrayList<>();
nodes.add(internalCluster().startNode());
@@ -397,8 +402,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
logger.info("--> done");
}
- @Test
- public void restoreIndexWithMissingShards() throws Exception {
+ public void testRestoreIndexWithMissingShards() throws Exception {
logger.info("--> start 2 nodes");
internalCluster().startNode();
internalCluster().startNode();
@@ -547,8 +551,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
assertThat(client().prepareSearch("test-idx-some").setSize(0).get().getHits().totalHits(), allOf(greaterThan(0L), lessThan(100L)));
}
- @Test
- public void restoreIndexWithShardsMissingInLocalGateway() throws Exception {
+ public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
logger.info("--> start 2 nodes");
Settings nodeSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, EnableAllocationDecider.Rebalance.NONE)
@@ -607,9 +610,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
assertThat(reusedShards.size(), greaterThanOrEqualTo(numberOfShards / 2));
}
-
- @Test
- public void registrationFailureTest() {
+ public void testRegistrationFailure() {
logger.info("--> start first node");
internalCluster().startNode();
logger.info("--> start second node");
@@ -628,7 +629,6 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
}
- @Test
public void testThatSensitiveRepositorySettingsAreNotExposed() throws Exception {
Settings nodeSettings = settingsBuilder().put().build();
logger.info("--> start two nodes");
@@ -683,12 +683,11 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
if (clusterStateError.get() != null) {
throw clusterStateError.get();
}
-
+
}
- @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/12621")
- public void chaosSnapshotTest() throws Exception {
+ public void testChaosSnapshot() throws Exception {
final List<String> indices = new CopyOnWriteArrayList<>();
Settings settings = settingsBuilder().put("action.write_consistency", "one").build();
int initialNodes = between(1, 3);
@@ -790,9 +789,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
logger.info("--> done");
}
- @Test
- public void masterShutdownDuringSnapshotTest() throws Exception {
-
+ public void testMasterShutdownDuringSnapshot() throws Exception {
Settings masterSettings = settingsBuilder().put("node.data", false).build();
Settings dataSettings = settingsBuilder().put("node.master", false).build();
diff --git a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java
index c5221d12f3..0bfc76f4d9 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.repositories.RepositoryException;
import org.elasticsearch.repositories.RepositoryVerificationException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.nio.file.Path;
import java.util.List;
@@ -48,8 +47,6 @@ import static org.hamcrest.Matchers.notNullValue;
*/
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
-
- @Test
public void testRepositoryCreation() throws Exception {
Client client = client();
@@ -123,7 +120,6 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
return null;
}
- @Test
public void testMisconfiguredRepository() throws Exception {
Client client = client();
@@ -170,8 +166,7 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
}
}
- @Test
- public void repositoryAckTimeoutTest() throws Exception {
+ public void testRepositoryAckTimeout() throws Exception {
logger.info("--> creating repository test-repo-1 with 0s timeout - shouldn't ack");
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo-1")
.setType("fs").setSettings(Settings.settingsBuilder()
@@ -201,8 +196,7 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
assertThat(deleteRepositoryResponse.isAcknowledged(), equalTo(true));
}
- @Test
- public void repositoryVerificationTest() throws Exception {
+ public void testRepositoryVerification() throws Exception {
Client client = client();
Settings settings = Settings.settingsBuilder()
@@ -236,8 +230,7 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
}
}
- @Test
- public void repositoryVerificationTimeoutTest() throws Exception {
+ public void testRepositoryVerificationTimeout() throws Exception {
Client client = client();
Settings settings = Settings.settingsBuilder()
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
index 1c5fc2331e..8043137103 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
@@ -64,7 +64,6 @@ import org.elasticsearch.indices.InvalidIndexNameException;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.RepositoryException;
import org.elasticsearch.test.junit.annotations.TestLogging;
-import org.junit.Test;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
@@ -104,9 +103,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCase {
-
- @Test
- public void basicWorkFlowTest() throws Exception {
+ public void testBasicWorkFlow() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -203,9 +200,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
-
- @Test
- public void singleGetAfterRestoreTest() throws Exception {
+ public void testSingleGetAfterRestore() throws Exception {
String indexName = "testindex";
String repoName = "test-restore-snapshot-repo";
String snapshotName = "test-restore-snapshot";
@@ -245,7 +240,6 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(client.prepareGet(restoredIndexName, typeName, docId).get().isExists(), equalTo(true));
}
- @Test
public void testFreshIndexUUID() {
Client client = client();
@@ -294,8 +288,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertFalse("UUID has been reused on restore: " + copyRestoreUUID + " vs. " + originalIndexUUID, copyRestoreUUID.equals(originalIndexUUID));
}
- @Test
- public void restoreWithDifferentMappingsAndSettingsTest() throws Exception {
+ public void testRestoreWithDifferentMappingsAndSettings() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -343,8 +336,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(getSettingsResponse.getSetting("test-idx", "index.refresh_interval"), equalTo("10000ms"));
}
- @Test
- public void emptySnapshotTest() throws Exception {
+ public void testEmptySnapshot() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -360,8 +352,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
}
- @Test
- public void restoreAliasesTest() throws Exception {
+ public void testRestoreAliases() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -416,8 +407,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void restoreTemplatesTest() throws Exception {
+ public void testRestoreTemplates() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -449,8 +439,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void includeGlobalStateTest() throws Exception {
+ public void testIncludeGlobalState() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -528,8 +517,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void snapshotFileFailureDuringSnapshotTest() throws Exception {
+ public void testSnapshotFileFailureDuringSnapshot() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -579,8 +567,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
- @Test
- public void dataFileFailureDuringSnapshotTest() throws Exception {
+ public void testDataFileFailureDuringSnapshot() throws Exception {
Client client = client();
logger.info("--> creating repository");
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
@@ -643,11 +630,9 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
assertThat(indexStatus.getShardsStats().getFailedShards(), equalTo(numberOfFailures));
}
-
}
- @Test
- public void dataFileFailureDuringRestoreTest() throws Exception {
+ public void testDataFileFailureDuringRestore() throws Exception {
Path repositoryLocation = randomRepoPath();
Client client = client();
logger.info("--> creating repository");
@@ -688,9 +673,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
logger.info("--> total number of simulated failures during restore: [{}]", getFailureCount("test-repo"));
}
-
- @Test
- public void deletionOfFailingToRecoverIndexShouldStopRestore() throws Exception {
+ public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Exception {
Path repositoryLocation = randomRepoPath();
Client client = client();
logger.info("--> creating repository");
@@ -753,8 +736,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void unallocatedShardsTest() throws Exception {
+ public void testUnallocatedShards() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -773,8 +755,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(createSnapshotResponse.getSnapshotInfo().reason(), startsWith("Indices don't have primary shards"));
}
- @Test
- public void deleteSnapshotTest() throws Exception {
+ public void testDeleteSnapshot() throws Exception {
final int numberOfSnapshots = between(5, 15);
Client client = client();
@@ -831,8 +812,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(numberOfFiles(repo), equalTo(numberOfFiles[0]));
}
- @Test
- public void deleteSnapshotWithMissingIndexAndShardMetadataTest() throws Exception {
+ public void testDeleteSnapshotWithMissingIndexAndShardMetadata() throws Exception {
Client client = client();
Path repo = randomRepoPath();
@@ -870,8 +850,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);
}
- @Test
- public void deleteSnapshotWithMissingMetadataTest() throws Exception {
+ public void testDeleteSnapshotWithMissingMetadata() throws Exception {
Client client = client();
Path repo = randomRepoPath();
@@ -905,8 +884,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);
}
- @Test
- public void deleteSnapshotWithCorruptedSnapshotFileTest() throws Exception {
+ public void testDeleteSnapshotWithCorruptedSnapshotFile() throws Exception {
Client client = client();
Path repo = randomRepoPath();
@@ -946,9 +924,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
}
-
- @Test
- public void snapshotClosedIndexTest() throws Exception {
+ public void testSnapshotClosedIndex() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -976,8 +952,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertBlocked(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx", "test-idx-closed"), MetaDataIndexStateService.INDEX_CLOSED_BLOCK);
}
- @Test
- public void snapshotSingleClosedIndexTest() throws Exception {
+ public void testSnapshotSingleClosedIndex() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -995,8 +970,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
.setWaitForCompletion(true).setIndices("test-idx"), MetaDataIndexStateService.INDEX_CLOSED_BLOCK);
}
- @Test
- public void renameOnRestoreTest() throws Exception {
+ public void testRenameOnRestore() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1115,8 +1089,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void moveShardWhileSnapshottingTest() throws Exception {
+ public void testMoveShardWhileSnapshotting() throws Exception {
Client client = client();
Path repositoryLocation = randomRepoPath();
logger.info("--> creating repository");
@@ -1177,8 +1150,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().totalHits(), equalTo(100L));
}
- @Test
- public void deleteRepositoryWhileSnapshottingTest() throws Exception {
+ public void testDeleteRepositoryWhileSnapshotting() throws Exception {
Client client = client();
Path repositoryLocation = randomRepoPath();
logger.info("--> creating repository");
@@ -1260,8 +1232,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().totalHits(), equalTo(100L));
}
- @Test
- public void urlRepositoryTest() throws Exception {
+ public void testUrlRepository() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1318,9 +1289,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThat(getSnapshotsResponse.getSnapshots().size(), equalTo(0));
}
-
- @Test
- public void readonlyRepositoryTest() throws Exception {
+ public void testReadonlyRepository() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1375,8 +1344,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertThrows(client.admin().cluster().prepareCreateSnapshot("readonly-repo", "test-snap-2").setWaitForCompletion(true).setIndices("test-idx"), RepositoryException.class, "cannot create snapshot in a readonly repository");
}
- @Test
- public void throttlingTest() throws Exception {
+ public void testThrottling() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1434,9 +1402,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
-
- @Test
- public void snapshotStatusTest() throws Exception {
+ public void testSnapshotStatus() throws Exception {
Client client = client();
Path repositoryLocation = randomRepoPath();
logger.info("--> creating repository");
@@ -1534,9 +1500,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
-
- @Test
- public void snapshotRelocatingPrimary() throws Exception {
+ public void testSnapshotRelocatingPrimary() throws Exception {
Client client = client();
logger.info("--> creating repository");
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
@@ -1645,8 +1609,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
- @Test
- public void changeSettingsOnRestoreTest() throws Exception {
+ public void testChangeSettingsOnRestore() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1760,8 +1723,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
- @Test
- public void recreateBlocksOnRestoreTest() throws Exception {
+ public void testRecreateBlocksOnRestore() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1850,8 +1812,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
- @Test
- public void deleteIndexDuringSnapshotTest() throws Exception {
+ public void testDeleteIndexDuringSnapshot() throws Exception {
Client client = client();
boolean allowPartial = randomBoolean();
@@ -1903,9 +1864,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
}
-
- @Test
- public void deleteOrphanSnapshotTest() throws Exception {
+ public void testDeleteOrphanSnapshot() throws Exception {
Client client = client();
logger.info("--> creating repository");
@@ -1970,10 +1929,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
return awaitBusy(() -> client().admin().cluster().prepareHealth(index).execute().actionGet().getRelocatingShards() > 0, timeout.millis(), TimeUnit.MILLISECONDS);
}
- @Test
@TestLogging("cluster:DEBUG")
- public void batchingShardUpdateTaskTest() throws Exception {
-
+ public void testBatchingShardUpdateTask() throws Exception {
final Client client = client();
logger.info("--> creating repository");
@@ -2052,9 +2009,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
assertEquals(1, restoreListener.count());
}
- @Test
- public void snapshotNameTest() throws Exception {
-
+ public void testSnapshotName() throws Exception {
final Client client = client();
logger.info("--> creating repository");
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java
index 32aaa16fe9..b66d4572d6 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java
@@ -33,7 +33,6 @@ import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.test.ESBackcompatTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -50,8 +49,6 @@ import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
public class SnapshotBackwardsCompatibilityIT extends ESBackcompatTestCase {
-
- @Test
public void testSnapshotAndRestore() throws ExecutionException, InterruptedException, IOException {
logger.info("--> creating repository");
assertAcked(client().admin().cluster().preparePutRepository("test-repo")
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotRequestsTests.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotRequestsTests.java
index 7cf56bfc7d..38d858c49a 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotRequestsTests.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotRequestsTests.java
@@ -24,16 +24,13 @@ import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotR
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
public class SnapshotRequestsTests extends ESTestCase {
- @Test
public void testRestoreSnapshotRequestParsing() throws IOException {
-
RestoreSnapshotRequest request = new RestoreSnapshotRequest("test-repo", "test-snap");
XContentBuilder builder = jsonBuilder().startObject();
@@ -94,9 +91,7 @@ public class SnapshotRequestsTests extends ESTestCase {
}
- @Test
public void testCreateSnapshotRequestParsing() throws IOException {
-
CreateSnapshotRequest request = new CreateSnapshotRequest("test-repo", "test-snap");
XContentBuilder builder = jsonBuilder().startObject();
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java
index 8e9d7cb842..a121427b44 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java
@@ -20,7 +20,6 @@ package org.elasticsearch.snapshots;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Arrays;
import java.util.List;
@@ -30,7 +29,6 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
/**
*/
public class SnapshotUtilsTests extends ESTestCase {
- @Test
public void testIndexNameFiltering() {
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{}, new String[]{"foo", "bar", "baz"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"*"}, new String[]{"foo", "bar", "baz"});
diff --git a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
index 3a4d03a49f..1c9c82cf69 100644
--- a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
@@ -24,6 +24,7 @@ import com.carrotsearch.randomizedtesting.Randomness;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
import org.apache.http.impl.client.HttpClients;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
@@ -128,15 +129,33 @@ import org.junit.BeforeClass;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.annotation.*;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BooleanSupplier;
@@ -148,8 +167,15 @@ import static org.elasticsearch.common.util.CollectionUtils.eagerPartition;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.XContentTestUtils.convertToMap;
import static org.elasticsearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
+import static org.hamcrest.Matchers.emptyArray;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.startsWith;
/**
* {@link ESIntegTestCase} is an abstract base class to run integration
@@ -168,7 +194,7 @@ import static org.hamcrest.Matchers.*;
* <pre>
*
* @ClusterScope(scope=Scope.TEST) public class SomeIT extends ESIntegTestCase {
- * @Test public void testMethod() {}
+ * public void testMethod() {}
* }
* </pre>
* <p>
@@ -180,7 +206,7 @@ import static org.hamcrest.Matchers.*;
* <pre>
* @ClusterScope(scope=Scope.SUITE, numDataNodes=3)
* public class SomeIT extends ESIntegTestCase {
- * @Test public void testMethod() {}
+ * public void testMethod() {}
* }
* </pre>
* <p>
diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java b/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java
index fc2b9469a7..b1ce97374a 100644
--- a/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java
+++ b/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java
@@ -17,27 +17,22 @@
* under the License.
*/
-
package org.elasticsearch.test.disruption;
-
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.transport.MockTransportService;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
public class NetworkPartitionIT extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(MockTransportService.TestPlugin.class);
}
- @Test
public void testNetworkPartitionWithNodeShutdown() throws IOException {
internalCluster().ensureAtLeastNumDataNodes(2);
String[] nodeNames = internalCluster().getNodeNames();
diff --git a/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java b/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
index 33ddea019a..805808968c 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
@@ -22,6 +22,7 @@ package org.elasticsearch.test.rest;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
+
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.LuceneTestCase.SuppressFsync;
@@ -49,7 +50,6 @@ import org.elasticsearch.test.rest.support.FileUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -158,7 +158,7 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
.put("node.testattr", "test")
.put(super.nodeSettings(nodeOrdinal)).build();
}
-
+
public static Iterable<Object[]> createParameters(int id, int count) throws IOException, RestTestParseException {
TestGroup testGroup = Rest.class.getAnnotation(TestGroup.class);
String sysProperty = TestGroup.Utilities.getSysProperty(Rest.class);
@@ -217,7 +217,7 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
return testCandidates;
}
-
+
private static boolean mustExecute(String test, int id, int count) {
int hash = (int) (Math.abs((long)test.hashCode()) % count);
return hash == id;
@@ -239,13 +239,13 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
@SuppressForbidden(reason = "proper use of URL, hack around a JDK bug")
static FileSystem getFileSystem() throws IOException {
// REST suite handling is currently complicated, with lots of filtering and so on
- // For now, to work embedded in a jar, return a ZipFileSystem over the jar contents.
+ // For now, to work embedded in a jar, return a ZipFileSystem over the jar contents.
URL codeLocation = FileUtils.class.getProtectionDomain().getCodeSource().getLocation();
boolean loadPackaged = RandomizedTest.systemPropertyAsBoolean(REST_LOAD_PACKAGED_TESTS, true);
if (codeLocation.getFile().endsWith(".jar") && loadPackaged) {
try {
// hack around a bug in the zipfilesystem implementation before java 9,
- // its checkWritable was incorrect and it won't work without write permissions.
+ // its checkWritable was incorrect and it won't work without write permissions.
// if we add the permission, it will open jars r/w, which is too scary! so copy to a safe r-w location.
Path tmp = Files.createTempFile(null, ".jar");
try (InputStream in = codeLocation.openStream()) {
@@ -352,7 +352,6 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
return messageBuilder.toString();
}
- @Test
public void test() throws IOException {
//let's check that there is something to run, otherwise there might be a problem with the test section
if (testCandidate.getTestSection().getExecutableSections().size() == 0) {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java
index b316ae0fac..68b84b9963 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java
@@ -19,18 +19,28 @@
package org.elasticsearch.test.rest.test;
import org.elasticsearch.common.xcontent.yaml.YamlXContent;
-import org.elasticsearch.test.rest.parser.*;
-import org.elasticsearch.test.rest.section.*;
-import org.junit.Test;
+import org.elasticsearch.test.rest.parser.GreaterThanParser;
+import org.elasticsearch.test.rest.parser.IsFalseParser;
+import org.elasticsearch.test.rest.parser.IsTrueParser;
+import org.elasticsearch.test.rest.parser.LengthParser;
+import org.elasticsearch.test.rest.parser.LessThanParser;
+import org.elasticsearch.test.rest.parser.MatchParser;
+import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
+import org.elasticsearch.test.rest.section.GreaterThanAssertion;
+import org.elasticsearch.test.rest.section.IsFalseAssertion;
+import org.elasticsearch.test.rest.section.IsTrueAssertion;
+import org.elasticsearch.test.rest.section.LengthAssertion;
+import org.elasticsearch.test.rest.section.LessThanAssertion;
+import org.elasticsearch.test.rest.section.MatchAssertion;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
public class AssertionParsersTests extends AbstractParserTestCase {
-
- @Test
public void testParseIsTrue() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"get.fields._timestamp"
@@ -43,7 +53,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat(trueAssertion.getField(), equalTo("get.fields._timestamp"));
}
- @Test
public void testParseIsFalse() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"docs.1._source"
@@ -56,7 +65,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat(falseAssertion.getField(), equalTo("docs.1._source"));
}
- @Test
public void testParseGreaterThan() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ field: 3}"
@@ -70,7 +78,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat((Integer) greaterThanAssertion.getExpectedValue(), equalTo(3));
}
- @Test
public void testParseLessThan() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ field: 3}"
@@ -84,7 +91,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat((Integer) lessThanAssertion.getExpectedValue(), equalTo(3));
}
- @Test
public void testParseLength() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ _id: 22}"
@@ -98,8 +104,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat((Integer) lengthAssertion.getExpectedValue(), equalTo(22));
}
- @Test
- @SuppressWarnings("unchecked")
public void testParseMatchSimpleIntegerValue() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ field: 10 }"
@@ -114,8 +118,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat((Integer) matchAssertion.getExpectedValue(), equalTo(10));
}
- @Test
- @SuppressWarnings("unchecked")
public void testParseMatchSimpleStringValue() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ foo: bar }"
@@ -130,8 +132,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("bar"));
}
- @Test
- @SuppressWarnings("unchecked")
public void testParseMatchArray() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{'matches': ['test_percolator_1', 'test_percolator_2']}"
@@ -149,7 +149,6 @@ public class AssertionParsersTests extends AbstractParserTestCase {
assertThat(strings.get(1).toString(), equalTo("test_percolator_2"));
}
- @Test
@SuppressWarnings("unchecked")
public void testParseMatchSourceValues() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java
index c3aba8114a..5f0f2bd8b3 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java
@@ -27,18 +27,16 @@ import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
import org.elasticsearch.test.rest.section.ApiCallSection;
import org.elasticsearch.test.rest.section.DoSection;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
import java.io.IOException;
import java.util.Map;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class DoSectionParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseDoSectionNoBody() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"get:\n" +
@@ -60,7 +58,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertThat(apiCallSection.hasBody(), equalTo(false));
}
- @Test
public void testParseDoSectionNoParamsNoBody() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"cluster.node_info: {}"
@@ -76,7 +73,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertThat(apiCallSection.hasBody(), equalTo(false));
}
- @Test
public void testParseDoSectionWithJsonBody() throws Exception {
String body = "{ \"include\": { \"field1\": \"v1\", \"field2\": \"v2\" }, \"count\": 1 }";
parser = YamlXContent.yamlXContent.createParser(
@@ -102,7 +98,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertJsonEquals(apiCallSection.getBodies().get(0), body);
}
- @Test
public void testParseDoSectionWithJsonMultipleBodiesAsLongString() throws Exception {
String bodies[] = new String[]{
"{ \"index\": { \"_index\":\"test_index\", \"_type\":\"test_type\", \"_id\":\"test_id\" } }\n",
@@ -132,7 +127,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertThat(apiCallSection.getBodies().size(), equalTo(4));
}
- @Test
public void testParseDoSectionWithJsonMultipleBodiesRepeatedProperty() throws Exception {
String[] bodies = new String[] {
"{ \"index\": { \"_index\":\"test_index\", \"_type\":\"test_type\", \"_id\":\"test_id\" } }",
@@ -162,7 +156,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
}
}
- @Test
public void testParseDoSectionWithYamlBody() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"search:\n" +
@@ -184,7 +177,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertJsonEquals(apiCallSection.getBodies().get(0), body);
}
- @Test
public void testParseDoSectionWithYamlMultipleBodies() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"bulk:\n" +
@@ -225,7 +217,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
}
}
- @Test
public void testParseDoSectionWithYamlMultipleBodiesRepeatedProperty() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"bulk:\n" +
@@ -259,7 +250,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
}
}
- @Test
public void testParseDoSectionWithYamlBodyMultiGet() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"mget:\n" +
@@ -285,7 +275,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertJsonEquals(apiCallSection.getBodies().get(0), body);
}
- @Test
public void testParseDoSectionWithBodyStringified() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"index:\n" +
@@ -311,7 +300,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertJsonEquals(apiCallSection.getBodies().get(0), "{ _source: true, query: { match_all: {} } }");
}
- @Test
public void testParseDoSectionWithBodiesStringifiedAndNot() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"index:\n" +
@@ -335,7 +323,6 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertJsonEquals(apiCallSection.getBodies().get(1), body);
}
- @Test
public void testParseDoSectionWithCatch() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"catch: missing\n" +
@@ -354,17 +341,20 @@ public class DoSectionParserTests extends AbstractParserTestCase {
assertThat(doSection.getApiCallSection().hasBody(), equalTo(false));
}
- @Test (expected = RestTestParseException.class)
public void testParseDoSectionWithoutClientCallSection() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"catch: missing\n"
);
DoSectionParser doSectionParser = new DoSectionParser();
- doSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ doSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), is("client call section is mandatory within a do section"));
+ }
}
- @Test
public void testParseDoSectionMultivaluedField() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"indices.get_field_mapping:\n" +
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java
index 2aad874774..20bd7a2124 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java
@@ -20,7 +20,6 @@ package org.elasticsearch.test.rest.test;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.support.FileUtils;
-import org.junit.Test;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -32,8 +31,6 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.Matchers.greaterThan;
public class FileUtilsTests extends ESTestCase {
-
- @Test
public void testLoadSingleYamlSuite() throws Exception {
Map<String,Set<Path>> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "/rest-api-spec/test/get/10_basic");
assertSingleFile(yamlSuites, "get", "10_basic.yaml");
@@ -47,7 +44,6 @@ public class FileUtilsTests extends ESTestCase {
assertSingleFile(yamlSuites, "get", "10_basic.yaml");
}
- @Test
public void testLoadMultipleYamlSuites() throws Exception {
//single directory
Map<String,Set<Path>> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "get");
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java
index dfc12253ed..fefcd57af7 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java
@@ -21,17 +21,19 @@ package org.elasticsearch.test.rest.test;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.Stash;
import org.elasticsearch.test.rest.json.JsonPath;
-import org.junit.Test;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class JsonPathTests extends ESTestCase {
-
- @Test
public void testEvaluateObjectPathEscape() throws Exception {
String json = "{ \"field1\": { \"field2.field3\" : \"value2\" } }";
JsonPath jsonPath = new JsonPath(json);
@@ -40,7 +42,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateObjectPathWithDoubleDot() throws Exception {
String json = "{ \"field1\": { \"field2\" : \"value2\" } }";
JsonPath jsonPath = new JsonPath(json);
@@ -49,7 +50,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateObjectPathEndsWithDot() throws Exception {
String json = "{ \"field1\": { \"field2\" : \"value2\" } }";
JsonPath jsonPath = new JsonPath(json);
@@ -58,7 +58,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateString() throws Exception {
String json = "{ \"field1\": { \"field2\" : \"value2\" } }";
JsonPath jsonPath = new JsonPath(json);
@@ -67,7 +66,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateInteger() throws Exception {
String json = "{ \"field1\": { \"field2\" : 333 } }";
JsonPath jsonPath = new JsonPath(json);
@@ -76,7 +74,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((Integer)object, equalTo(333));
}
- @Test
public void testEvaluateDouble() throws Exception {
String json = "{ \"field1\": { \"field2\" : 3.55 } }";
JsonPath jsonPath = new JsonPath(json);
@@ -85,7 +82,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((Double)object, equalTo(3.55));
}
- @Test
public void testEvaluateArray() throws Exception {
String json = "{ \"field1\": { \"array1\" : [ \"value1\", \"value2\" ] } }";
JsonPath jsonPath = new JsonPath(json);
@@ -99,7 +95,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)list.get(1), equalTo("value2"));
}
- @Test
public void testEvaluateArrayElement() throws Exception {
String json = "{ \"field1\": { \"array1\" : [ \"value1\", \"value2\" ] } }";
JsonPath jsonPath = new JsonPath(json);
@@ -108,7 +103,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateArrayElementObject() throws Exception {
String json = "{ \"field1\": { \"array1\" : [ {\"element\": \"value1\"}, {\"element\":\"value2\"} ] } }";
JsonPath jsonPath = new JsonPath(json);
@@ -117,7 +111,6 @@ public class JsonPathTests extends ESTestCase {
assertThat((String)object, equalTo("value2"));
}
- @Test
public void testEvaluateArrayElementObjectWrongPath() throws Exception {
String json = "{ \"field1\": { \"array1\" : [ {\"element\": \"value1\"}, {\"element\":\"value2\"} ] } }";
JsonPath jsonPath = new JsonPath(json);
@@ -125,7 +118,6 @@ public class JsonPathTests extends ESTestCase {
assertThat(object, nullValue());
}
- @Test
@SuppressWarnings("unchecked")
public void testEvaluateObjectKeys() throws Exception {
String json = "{ \"metadata\": { \"templates\" : {\"template_1\": { \"field\" : \"value\"}, \"template_2\": { \"field\" : \"value\"} } } }";
@@ -138,7 +130,6 @@ public class JsonPathTests extends ESTestCase {
assertThat(strings, contains("template_1", "template_2"));
}
- @Test
@SuppressWarnings("unchecked")
public void testEvaluateEmptyPath() throws Exception {
String json = "{ \"field1\": { \"array1\" : [ {\"element\": \"value1\"}, {\"element\":\"value2\"} ] } }";
@@ -149,7 +140,6 @@ public class JsonPathTests extends ESTestCase {
assertThat(((Map<String, Object>)object).containsKey("field1"), equalTo(true));
}
- @Test
public void testEvaluateStashInPropertyName() throws Exception {
String json = "{ \"field1\": { \"elements\" : {\"element1\": \"value1\"}}}";
JsonPath jsonPath = new JsonPath(json);
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java
index c25ebd42ff..e2f321c81c 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java
@@ -22,7 +22,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.spec.RestApiParser;
-import org.junit.Test;
import java.io.IOException;
@@ -32,14 +31,11 @@ import static org.hamcrest.Matchers.containsString;
*
*/
public class RestApiParserFailingTests extends ESTestCase {
-
- @Test
- public void brokenSpecShouldThrowUsefulExceptionWhenParsingFailsOnParams() throws Exception {
+ public void testBrokenSpecShouldThrowUsefulExceptionWhenParsingFailsOnParams() throws Exception {
parseAndExpectFailure(BROKEN_SPEC_PARAMS, "Expected params field in rest api definition to contain an object");
}
- @Test
- public void brokenSpecShouldThrowUsefulExceptionWhenParsingFailsOnParts() throws Exception {
+ public void testBrokenSpecShouldThrowUsefulExceptionWhenParsingFailsOnParts() throws Exception {
parseAndExpectFailure(BROKEN_SPEC_PARTS, "Expected parts field in rest api definition to contain an object");
}
@@ -51,7 +47,6 @@ public class RestApiParserFailingTests extends ESTestCase {
} catch (IOException e) {
assertThat(e.getMessage(), containsString(expectedErrorMessage));
}
-
}
// see params section is broken, an inside param is missing
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java
index 7f4cdf10ab..262b155c66 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java
@@ -21,15 +21,12 @@ package org.elasticsearch.test.rest.test;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.test.rest.spec.RestApi;
import org.elasticsearch.test.rest.spec.RestApiParser;
-import org.junit.Test;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class RestApiParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseRestSpecIndexApi() throws Exception {
parser = JsonXContent.jsonXContent.createParser(REST_SPEC_INDEX_API);
RestApi restApi = new RestApiParser().parse(parser);
@@ -52,7 +49,6 @@ public class RestApiParserTests extends AbstractParserTestCase {
assertThat(restApi.isBodyRequired(), equalTo(true));
}
- @Test
public void testParseRestSpecGetTemplateApi() throws Exception {
parser = JsonXContent.jsonXContent.createParser(REST_SPEC_GET_TEMPLATE_API);
RestApi restApi = new RestApiParser().parse(parser);
@@ -70,7 +66,6 @@ public class RestApiParserTests extends AbstractParserTestCase {
assertThat(restApi.isBodyRequired(), equalTo(false));
}
- @Test
public void testParseRestSpecCountApi() throws Exception {
parser = JsonXContent.jsonXContent.createParser(REST_SPEC_COUNT_API);
RestApi restApi = new RestApiParser().parse(parser);
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java
index 5a31bfb0ba..e15b62147c 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java
@@ -30,14 +30,16 @@ import org.elasticsearch.test.rest.section.IsTrueAssertion;
import org.elasticsearch.test.rest.section.MatchAssertion;
import org.elasticsearch.test.rest.section.RestTestSuite;
import org.junit.After;
-import org.junit.Test;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class RestTestParserTests extends ESTestCase {
-
private XContentParser parser;
@Override
@@ -52,7 +54,6 @@ public class RestTestParserTests extends ESTestCase {
parser.close();
}
- @Test
public void testParseTestSetupAndSections() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"setup:\n" +
@@ -139,7 +140,6 @@ public class RestTestParserTests extends ESTestCase {
assertThat(matchAssertion.getExpectedValue().toString(), equalTo("whitespace"));
}
- @Test
public void testParseTestSingleTestSection() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"---\n" +
@@ -238,7 +238,6 @@ public class RestTestParserTests extends ESTestCase {
assertThat(((Map) matchAssertion.getExpectedValue()).get("foo").toString(), equalTo("bar"));
}
- @Test
public void testParseTestMultipleTestSections() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"---\n" +
@@ -330,7 +329,6 @@ public class RestTestParserTests extends ESTestCase {
assertThat(doSection.getApiCallSection().hasBody(), equalTo(true));
}
- @Test(expected = RestTestParseException.class)
public void testParseTestDuplicateTestSections() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"---\n" +
@@ -361,6 +359,11 @@ public class RestTestParserTests extends ESTestCase {
);
RestTestSuiteParser testParser = new RestTestSuiteParser();
- testParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ testParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), containsString("duplicate test section"));
+ }
}
}
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java
index ba28a48663..c2b6637566 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java
@@ -23,14 +23,12 @@ import org.elasticsearch.test.rest.parser.RestTestParseException;
import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
import org.elasticsearch.test.rest.parser.SetSectionParser;
import org.elasticsearch.test.rest.section.SetSection;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
public class SetSectionParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseSetSectionSingleValue() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ _id: id }"
@@ -46,7 +44,6 @@ public class SetSectionParserTests extends AbstractParserTestCase {
assertThat(setSection.getStash().get("_id"), equalTo("id"));
}
- @Test
public void testParseSetSectionMultipleValues() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ _id: id, _type: type, _index: index }"
@@ -64,14 +61,17 @@ public class SetSectionParserTests extends AbstractParserTestCase {
assertThat(setSection.getStash().get("_index"), equalTo("index"));
}
- @Test(expected = RestTestParseException.class)
public void testParseSetSectionNoValues() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"{ }"
);
SetSectionParser setSectionParser = new SetSectionParser();
-
- setSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ setSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), is("set section must set at least a value"));
+ }
}
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java
index beb7449d83..9dd388056d 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java
@@ -23,16 +23,12 @@ import org.elasticsearch.common.xcontent.yaml.YamlXContent;
import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
import org.elasticsearch.test.rest.parser.SetupSectionParser;
import org.elasticsearch.test.rest.section.SetupSection;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class SetupSectionParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseSetupSection() throws Exception {
-
parser = YamlXContent.yamlXContent.createParser(
" - do:\n" +
" index1:\n" +
@@ -58,9 +54,7 @@ public class SetupSectionParserTests extends AbstractParserTestCase {
assertThat(setupSection.getDoSections().get(1).getApiCallSection().getApi(), equalTo("index2"));
}
- @Test
public void testParseSetupAndSkipSectionNoSkip() throws Exception {
-
parser = YamlXContent.yamlXContent.createParser(
" - skip:\n" +
" version: \"0.90.0 - 0.90.7\"\n" +
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java
index a697427f85..5864e78134 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java
@@ -25,13 +25,13 @@ import org.elasticsearch.test.rest.parser.RestTestParseException;
import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
import org.elasticsearch.test.rest.parser.SkipSectionParser;
import org.elasticsearch.test.rest.section.SkipSection;
-import org.junit.Test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class SkipSectionParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseSkipSectionVersionNoFeature() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"version: \" - 0.90.2\"\n" +
@@ -66,7 +66,6 @@ public class SkipSectionParserTests extends AbstractParserTestCase {
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
}
- @Test
public void testParseSkipSectionFeatureNoVersion() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"features: regex"
@@ -83,7 +82,6 @@ public class SkipSectionParserTests extends AbstractParserTestCase {
assertThat(skipSection.getReason(), nullValue());
}
- @Test
public void testParseSkipSectionFeaturesNoVersion() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"features: [regex1,regex2,regex3]"
@@ -102,7 +100,6 @@ public class SkipSectionParserTests extends AbstractParserTestCase {
assertThat(skipSection.getReason(), nullValue());
}
- @Test(expected = RestTestParseException.class)
public void testParseSkipSectionBothFeatureAndVersion() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"version: \" - 0.90.2\"\n" +
@@ -112,26 +109,39 @@ public class SkipSectionParserTests extends AbstractParserTestCase {
SkipSectionParser skipSectionParser = new SkipSectionParser();
- skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), is("version or features are mutually exclusive"));
+ }
}
- @Test(expected = RestTestParseException.class)
public void testParseSkipSectionNoReason() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"version: \" - 0.90.2\"\n"
);
SkipSectionParser skipSectionParser = new SkipSectionParser();
- skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), is("reason is mandatory within skip version section"));
+ }
}
- @Test(expected = RestTestParseException.class)
public void testParseSkipSectionNoVersionNorFeature() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"reason: Delete ignores the parent param\n"
);
SkipSectionParser skipSectionParser = new SkipSectionParser();
- skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ try {
+ skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
+ fail("Expected RestTestParseException");
+ } catch (RestTestParseException e) {
+ assertThat(e.getMessage(), is("version or features is mandatory within skip section"));
+ }
}
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java b/core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java
index ac6a3c129f..c157610b64 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java
@@ -22,16 +22,25 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.xcontent.yaml.YamlXContent;
import org.elasticsearch.test.rest.parser.RestTestSectionParser;
import org.elasticsearch.test.rest.parser.RestTestSuiteParseContext;
-import org.elasticsearch.test.rest.section.*;
-import org.junit.Test;
+import org.elasticsearch.test.rest.section.DoSection;
+import org.elasticsearch.test.rest.section.GreaterThanAssertion;
+import org.elasticsearch.test.rest.section.IsFalseAssertion;
+import org.elasticsearch.test.rest.section.IsTrueAssertion;
+import org.elasticsearch.test.rest.section.LengthAssertion;
+import org.elasticsearch.test.rest.section.LessThanAssertion;
+import org.elasticsearch.test.rest.section.MatchAssertion;
+import org.elasticsearch.test.rest.section.SetSection;
+import org.elasticsearch.test.rest.section.SkipSection;
+import org.elasticsearch.test.rest.section.TestSection;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class TestSectionParserTests extends AbstractParserTestCase {
-
- @Test
public void testParseTestSectionWithDoSection() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"\"First test section\": \n" +
@@ -57,7 +66,6 @@ public class TestSectionParserTests extends AbstractParserTestCase {
assertThat(doSection.getApiCallSection().hasBody(), equalTo(false));
}
- @Test
public void testParseTestSectionWithDoSetAndSkipSectionsNoSkip() throws Exception {
String yaml =
"\"First test section\": \n" +
@@ -94,7 +102,6 @@ public class TestSectionParserTests extends AbstractParserTestCase {
assertThat(setSection.getStash().get("_scroll_id"), equalTo("scroll_id"));
}
- @Test
public void testParseTestSectionWithMultipleDoSections() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"\"Basic\":\n" +
@@ -133,7 +140,6 @@ public class TestSectionParserTests extends AbstractParserTestCase {
assertThat(doSection.getApiCallSection().hasBody(), equalTo(false));
}
- @Test
public void testParseTestSectionWithDoSectionsAndAssertions() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"\"Basic\":\n" +
@@ -228,9 +234,7 @@ public class TestSectionParserTests extends AbstractParserTestCase {
assertThat((Integer) lessThanAssertion.getExpectedValue(), equalTo(10));
}
- @Test
public void testSmallSection() throws Exception {
-
parser = YamlXContent.yamlXContent.createParser(
"\"node_info test\":\n" +
" - do:\n" +
diff --git a/core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java b/core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java
index e4c5f2edaf..3c8913fded 100644
--- a/core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java
+++ b/core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.junit.listeners.LoggingListener;
-import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.Result;
@@ -34,10 +33,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
public class LoggingListenerTests extends ESTestCase {
-
- @Test
public void testCustomLevelPerMethod() throws Exception {
-
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(TestClass.class);
@@ -67,9 +63,7 @@ public class LoggingListenerTests extends ESTestCase {
assertThat(abcLogger.getLevel(), nullValue());
}
- @Test
public void testCustomLevelPerClass() throws Exception {
-
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class);
@@ -97,9 +91,7 @@ public class LoggingListenerTests extends ESTestCase {
assertThat(xyzLogger.getLevel(), nullValue());
}
- @Test
public void testCustomLevelPerClassAndPerMethod() throws Exception {
-
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class);
diff --git a/core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java b/core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java
index 5233bae7c7..8c3c18454c 100644
--- a/core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java
+++ b/core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java
@@ -20,7 +20,6 @@ package org.elasticsearch.test.test;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.TestCluster;
-import org.junit.Test;
import java.io.IOException;
@@ -36,7 +35,6 @@ public class TestScopeClusterIT extends ESIntegTestCase {
private static long[] SEQUENCE = new long[100];
private static Long CLUSTER_SEED = null;
- @Test
public void testReproducible() throws IOException {
if (ITER++ == 0) {
CLUSTER_SEED = cluster().seed();
diff --git a/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java b/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
index 0bf04918a0..d52f67dc82 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
@@ -32,12 +32,12 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.hamcrest.RegexMatcher;
import org.elasticsearch.threadpool.ThreadPool.Names;
import org.elasticsearch.tribe.TribeIT;
-import org.junit.Test;
import java.io.IOException;
import java.lang.management.ManagementFactory;
@@ -55,7 +55,6 @@ import java.util.regex.Pattern;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -66,15 +65,12 @@ import static org.hamcrest.Matchers.sameInstance;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0)
public class SimpleThreadPoolIT extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put("threadpool.search.type", "cached").build();
}
- @Test
- public void verifyThreadNames() throws Exception {
-
+ public void testThreadNames() throws Exception {
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
Set<String> preNodeStartThreadNames = new HashSet<>();
for (long l : threadBean.getAllThreadIds()) {
@@ -130,7 +126,6 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
}
}
- @Test(timeout = 20000)
public void testUpdatingThreadPoolSettings() throws Exception {
internalCluster().startNodesAsync(2).get();
ThreadPool threadPool = internalCluster().getDataNodeInstance(ThreadPool.class);
@@ -159,7 +154,7 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
assertThat(((ThreadPoolExecutor) oldExecutor).isShutdown(), equalTo(true));
assertThat(((ThreadPoolExecutor) oldExecutor).isTerminating(), equalTo(true));
assertThat(((ThreadPoolExecutor) oldExecutor).isTerminated(), equalTo(false));
- barrier.await();
+ barrier.await(10, TimeUnit.SECONDS);
// Make sure that new thread executor is functional
threadPool.executor(Names.SEARCH).execute(new Runnable() {
@@ -175,8 +170,10 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
}
});
client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.type", "fixed").build()).execute().actionGet();
- barrier.await();
- Thread.sleep(200);
+ barrier.await(10, TimeUnit.SECONDS);
+
+ // This was here: Thread.sleep(200);
+ // Why? What was it for?
// Check that node info is correct
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().all().execute().actionGet();
@@ -191,12 +188,9 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
}
}
assertThat(found, equalTo(true));
-
- Map<String, Object> poolMap = getPoolSettingsThroughJson(nodeInfo.getThreadPool(), Names.SEARCH);
}
}
- @Test
public void testThreadPoolLeakingThreadsWithTribeNode() {
Settings settings = Settings.builder()
.put("node.name", "thread_pool_leaking_threads_tribe_node")
diff --git a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java
index be33df33d3..cb27fd71f9 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.Map;
@@ -44,10 +43,8 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class ThreadPoolSerializationTests extends ESTestCase {
-
BytesStreamOutput output = new BytesStreamOutput();
- @Test
public void testThatQueueSizeSerializationWorks() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), SizeValue.parseSizeValue("10k"));
output.setVersion(Version.CURRENT);
@@ -60,7 +57,6 @@ public class ThreadPoolSerializationTests extends ESTestCase {
assertThat(newInfo.getQueueSize().singles(), is(10000l));
}
- @Test
public void testThatNegativeQueueSizesCanBeSerialized() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), null);
output.setVersion(Version.CURRENT);
@@ -73,7 +69,6 @@ public class ThreadPoolSerializationTests extends ESTestCase {
assertThat(newInfo.getQueueSize(), is(nullValue()));
}
- @Test
public void testThatToXContentWritesOutUnboundedCorrectly() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), null);
XContentBuilder builder = jsonBuilder();
@@ -92,7 +87,6 @@ public class ThreadPoolSerializationTests extends ESTestCase {
assertThat(map.get("queue_size").toString(), is("-1"));
}
- @Test
public void testThatNegativeSettingAllowsToStart() throws InterruptedException {
Settings settings = settingsBuilder().put("name", "index").put("threadpool.index.queue_size", "-1").build();
ThreadPool threadPool = new ThreadPool(settings);
@@ -100,7 +94,6 @@ public class ThreadPoolSerializationTests extends ESTestCase {
terminate(threadPool);
}
- @Test
public void testThatToXContentWritesInteger() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), SizeValue.parseSizeValue("1k"));
XContentBuilder builder = jsonBuilder();
diff --git a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
index 0fc4f4c7a7..69fe3b33a1 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -36,8 +35,6 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
public class ThreadPoolStatsTests extends ESTestCase {
-
- @Test
public void testThreadPoolStatsSort() throws IOException {
List<ThreadPoolStats.Stats> stats = new ArrayList<>();
stats.add(new ThreadPoolStats.Stats("z", -1, 0, 0, 0, 0, 0L));
@@ -64,7 +61,6 @@ public class ThreadPoolStatsTests extends ESTestCase {
assertThat(threads, contains(-1, -1, 1, 2, 3,-1,-1));
}
- @Test
public void testThreadPoolStatsToXContent() throws IOException {
try (BytesStreamOutput os = new BytesStreamOutput()) {
diff --git a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java
index 562adaa8a0..cd252b60d7 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool.Names;
-import org.junit.Test;
import java.lang.reflect.Field;
import java.util.concurrent.CountDownLatch;
@@ -32,12 +31,16 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
*/
public class UpdateThreadPoolSettingsTests extends ESTestCase {
-
private ThreadPool.Info info(ThreadPool threadPool, String name) {
for (ThreadPool.Info info : threadPool.info()) {
if (info.getName().equals(name)) {
@@ -47,7 +50,6 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
return null;
}
- @Test
public void testCachedExecutorType() throws InterruptedException {
ThreadPool threadPool = new ThreadPool(
Settings.settingsBuilder()
@@ -103,7 +105,6 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
terminate(threadPool);
}
- @Test
public void testFixedExecutorType() throws InterruptedException {
ThreadPool threadPool = new ThreadPool(settingsBuilder()
.put("threadpool.search.type", "fixed")
@@ -162,8 +163,6 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
terminate(threadPool);
}
-
- @Test
public void testScalingExecutorType() throws InterruptedException {
ThreadPool threadPool = new ThreadPool(settingsBuilder()
.put("threadpool.search.type", "scaling")
@@ -198,19 +197,18 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
terminate(threadPool);
}
- @Test(timeout = 10000)
- public void testShutdownDownNowDoesntBlock() throws Exception {
+ public void testShutdownNowInterrupts() throws Exception {
ThreadPool threadPool = new ThreadPool(Settings.settingsBuilder()
.put("threadpool.search.type", "cached")
.put("name","testCachedExecutorType").build());
final CountDownLatch latch = new CountDownLatch(1);
- Executor oldExecutor = threadPool.executor(Names.SEARCH);
+ ThreadPoolExecutor oldExecutor = (ThreadPoolExecutor) threadPool.executor(Names.SEARCH);
threadPool.executor(Names.SEARCH).execute(new Runnable() {
@Override
public void run() {
try {
- Thread.sleep(20000);
+ new CountDownLatch(1).await();
} catch (InterruptedException ex) {
latch.countDown();
Thread.currentThread().interrupt();
@@ -219,15 +217,14 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
});
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "fixed").build());
assertThat(threadPool.executor(Names.SEARCH), not(sameInstance(oldExecutor)));
- assertThat(((ThreadPoolExecutor) oldExecutor).isShutdown(), equalTo(true));
- assertThat(((ThreadPoolExecutor) oldExecutor).isTerminating(), equalTo(true));
- assertThat(((ThreadPoolExecutor) oldExecutor).isTerminated(), equalTo(false));
- threadPool.shutdownNow(); // interrupt the thread
- latch.await();
+ assertThat(oldExecutor.isShutdown(), equalTo(true));
+ assertThat(oldExecutor.isTerminating(), equalTo(true));
+ assertThat(oldExecutor.isTerminated(), equalTo(false));
+ threadPool.shutdownNow(); // should interrupt the thread
+ latch.await(3, TimeUnit.SECONDS); // If this throws then shotdownNow didn't interrupt
terminate(threadPool);
}
- @Test
public void testCustomThreadPool() throws Exception {
ThreadPool threadPool = new ThreadPool(Settings.settingsBuilder()
.put("threadpool.my_pool1.type", "cached")
diff --git a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java
index 3cfbd42e2e..30ed8fe25c 100644
--- a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java
+++ b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java
@@ -26,7 +26,6 @@ import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Locale;
@@ -40,11 +39,8 @@ import static org.hamcrest.Matchers.notNullValue;
/**
*/
-public class SimpleTimestampIT extends ESIntegTestCase {
-
- @Test
+public class SimpleTimestampIT extends ESIntegTestCase {
public void testSimpleTimestamp() throws Exception {
-
client().admin().indices().prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("_timestamp").field("enabled", true).endObject().endObject().endObject())
.execute().actionGet();
@@ -94,7 +90,7 @@ public class SimpleTimestampIT extends ESIntegTestCase {
assertThat(((Number) getResponse.getField("_timestamp").getValue()).longValue(), equalTo(timestamp));
}
- @Test // issue 5053
+ // issue #5053
public void testThatUpdatingMappingShouldNotRemoveTimestampConfiguration() throws Exception {
String index = "foo";
String type = "mytype";
@@ -114,7 +110,6 @@ public class SimpleTimestampIT extends ESIntegTestCase {
assertTimestampMappingEnabled(index, type, true);
}
- @Test
public void testThatTimestampCanBeSwitchedOnAndOff() throws Exception {
String index = "foo";
String type = "mytype";
diff --git a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java
index c423fb7dba..643b4fe88a 100644
--- a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java
+++ b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java
@@ -33,7 +33,6 @@ import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
@@ -126,7 +125,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
terminate(threadPool);
}
- @Test
public void testHelloWorld() {
serviceA.registerRequestHandler("sayHello", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -206,7 +204,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHello");
}
- @Test
public void testLocalNodeConnection() throws InterruptedException {
assertTrue("serviceA is not connected to nodeA", serviceA.nodeConnected(nodeA));
if (((TransportService) serviceA).getLocalNode() != null) {
@@ -254,7 +251,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(responseString.get(), equalTo("test"));
}
- @Test
public void testVoidMessageCompressed() {
serviceA.registerRequestHandler("sayHello", TransportRequest.Empty::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<TransportRequest.Empty>() {
@Override
@@ -301,7 +297,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHello");
}
- @Test
public void testHelloWorldCompressed() {
serviceA.registerRequestHandler("sayHello", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -350,7 +345,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHello");
}
- @Test
public void testErrorMessage() {
serviceA.registerRequestHandler("sayHelloException", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -393,7 +387,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHelloException");
}
- @Test
public void testDisconnectListener() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
TransportConnectionListener disconnectListener = new TransportConnectionListener() {
@@ -412,7 +405,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true));
}
- @Test
public void testNotifyOnShutdown() throws Exception {
final CountDownLatch latch2 = new CountDownLatch(1);
@@ -440,7 +432,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHelloTimeoutDelayedResponse");
}
- @Test
public void testTimeoutSendExceptionWithNeverSendingBackResponse() throws Exception {
serviceA.registerRequestHandler("sayHelloTimeoutNoResponse", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -489,7 +480,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHelloTimeoutNoResponse");
}
- @Test
public void testTimeoutSendExceptionWithDelayedResponse() throws Exception {
serviceA.registerRequestHandler("sayHelloTimeoutDelayedResponse", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -576,8 +566,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHelloTimeoutDelayedResponse");
}
-
- @Test
@TestLogging(value = "test. transport.tracer:TRACE")
public void testTracerLog() throws InterruptedException {
TransportRequestHandler handler = new TransportRequestHandler<StringMessageRequest>() {
@@ -883,8 +871,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
}
}
- @Test
- public void testVersion_from0to1() throws Exception {
+ public void testVersionFrom0to1() throws Exception {
serviceB.registerRequestHandler("/version", Version1Request::new, ThreadPool.Names.SAME, new TransportRequestHandler<Version1Request>() {
@Override
public void messageReceived(Version1Request request, TransportChannel channel) throws Exception {
@@ -925,8 +912,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(version0Response.value1, equalTo(1));
}
- @Test
- public void testVersion_from1to0() throws Exception {
+ public void testVersionFrom1to0() throws Exception {
serviceA.registerRequestHandler("/version", Version0Request::new, ThreadPool.Names.SAME, new TransportRequestHandler<Version0Request>() {
@Override
public void messageReceived(Version0Request request, TransportChannel channel) throws Exception {
@@ -968,8 +954,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(version1Response.value2, equalTo(0));
}
- @Test
- public void testVersion_from1to1() throws Exception {
+ public void testVersionFrom1to1() throws Exception {
serviceB.registerRequestHandler("/version", Version1Request::new, ThreadPool.Names.SAME, new TransportRequestHandler<Version1Request>() {
@Override
public void messageReceived(Version1Request request, TransportChannel channel) throws Exception {
@@ -1013,8 +998,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(version1Response.value2, equalTo(2));
}
- @Test
- public void testVersion_from0to0() throws Exception {
+ public void testVersionFrom0to0() throws Exception {
serviceA.registerRequestHandler("/version", Version0Request::new, ThreadPool.Names.SAME, new TransportRequestHandler<Version0Request>() {
@Override
public void messageReceived(Version0Request request, TransportChannel channel) throws Exception {
@@ -1053,7 +1037,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
assertThat(version0Response.value1, equalTo(1));
}
- @Test
public void testMockFailToSendNoConnectRule() {
serviceA.registerRequestHandler("sayHello", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -1112,7 +1095,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceA.removeHandler("sayHello");
}
- @Test
public void testMockUnresponsiveRule() {
serviceA.registerRequestHandler("sayHello", StringMessageRequest::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
@Override
@@ -1172,7 +1154,6 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
}
- @Test
public void testHostOnMessages() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(2);
final AtomicReference<TransportAddress> addressA = new AtomicReference<>();
diff --git a/core/src/test/java/org/elasticsearch/transport/ActionNamesIT.java b/core/src/test/java/org/elasticsearch/transport/ActionNamesIT.java
index d3b8533d55..d790137b38 100644
--- a/core/src/test/java/org/elasticsearch/transport/ActionNamesIT.java
+++ b/core/src/test/java/org/elasticsearch/transport/ActionNamesIT.java
@@ -20,7 +20,6 @@
package org.elasticsearch.transport;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.startsWith;
@@ -42,9 +41,6 @@ import static org.hamcrest.CoreMatchers.startsWith;
* we use the `[n]` suffix to identify node actions and the `[s]` suffix to identify shard actions.
*/
public class ActionNamesIT extends ESIntegTestCase {
-
- @Test
- @SuppressWarnings("unchecked")
public void testActionNamesCategories() throws NoSuchFieldException, IllegalAccessException {
TransportService transportService = internalCluster().getInstance(TransportService.class);
for (String action : transportService.requestHandlers.keySet()) {
diff --git a/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java b/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java
index 44039ce157..c8a566a776 100644
--- a/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java
@@ -19,29 +19,27 @@
package org.elasticsearch.transport;
-import java.nio.charset.StandardCharsets;
-
import org.elasticsearch.Version;
+import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.util.BigArrays;
+import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.node.settings.NodeSettingsService;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.common.util.MockBigArrays;
-import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.netty.NettyTransport;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.is;
@@ -82,7 +80,6 @@ public class NettySizeHeaderFrameDecoderTests extends ESTestCase {
terminate(threadPool);
}
- @Test
public void testThatTextMessageIsReturnedOnHTTPLikeRequest() throws Exception {
String randomMethod = randomFrom("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH");
String data = randomMethod + " / HTTP/1.1";
@@ -97,7 +94,6 @@ public class NettySizeHeaderFrameDecoderTests extends ESTestCase {
}
}
- @Test
public void testThatNothingIsReturnedForOtherInvalidPackets() throws Exception {
try (Socket socket = new Socket(host, port)) {
socket.getOutputStream().write("FOOBAR".getBytes(StandardCharsets.UTF_8));
diff --git a/core/src/test/java/org/elasticsearch/transport/TransportMessageTests.java b/core/src/test/java/org/elasticsearch/transport/TransportMessageTests.java
index bb907e5fb2..a94b06f6f0 100644
--- a/core/src/test/java/org/elasticsearch/transport/TransportMessageTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/TransportMessageTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -32,8 +31,6 @@ import static org.hamcrest.Matchers.is;
*
*/
public class TransportMessageTests extends ESTestCase {
-
- @Test
public void testSerialization() throws Exception {
Message message = new Message();
message.putHeader("key1", "value1");
@@ -57,7 +54,6 @@ public class TransportMessageTests extends ESTestCase {
assertThat(key1, is("value1"));
}
- @Test
public void testCopyHeadersAndContext() throws Exception {
Message m1 = new Message();
m1.putHeader("key1", "value1");
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java b/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java
index 43d03729bf..cbac0aded0 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.transport.netty;
import org.elasticsearch.common.util.concurrent.KeyedLock;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.Map.Entry;
import java.util.Set;
@@ -30,13 +29,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
public class KeyedLockTests extends ESTestCase {
-
- @Test
- public void checkIfMapEmptyAfterLotsOfAcquireAndReleases() throws InterruptedException {
+ public void testIfMapEmptyAfterLotsOfAcquireAndReleases() throws InterruptedException {
ConcurrentHashMap<String, Integer> counter = new ConcurrentHashMap<>();
ConcurrentHashMap<String, AtomicInteger> safeCounter = new ConcurrentHashMap<>();
KeyedLock<String> connectionLock = new KeyedLock<String>(randomBoolean());
@@ -69,19 +68,27 @@ public class KeyedLockTests extends ESTestCase {
}
}
- @Test(expected = IllegalStateException.class)
- public void checkCannotAcquireTwoLocks() throws InterruptedException {
+ public void testCannotAcquireTwoLocks() throws InterruptedException {
KeyedLock<String> connectionLock = new KeyedLock<String>();
String name = randomRealisticUnicodeOfLength(scaledRandomIntBetween(10, 50));
connectionLock.acquire(name);
- connectionLock.acquire(name);
+ try {
+ connectionLock.acquire(name);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("Lock already acquired"));
+ }
}
- @Test(expected = IllegalStateException.class)
- public void checkCannotReleaseUnacquiredLock() throws InterruptedException {
+ public void testCannotReleaseUnacquiredLock() throws InterruptedException {
KeyedLock<String> connectionLock = new KeyedLock<String>();
String name = randomRealisticUnicodeOfLength(scaledRandomIntBetween(10, 50));
- connectionLock.release(name);
+ try {
+ connectionLock.release(name);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), is("Lock not acquired"));
+ }
}
public static class AcquireAndReleaseThread extends Thread {
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java b/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java
index 4e03b8ea1d..9634af7d39 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.transport.TransportRequestHandler;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportResponseOptions;
-import org.junit.Test;
import java.io.IOException;
@@ -47,8 +46,6 @@ import static org.hamcrest.Matchers.greaterThan;
/**
*/
public class NettyScheduledPingTests extends ESTestCase {
-
- @Test
public void testScheduledPing() throws Exception {
ThreadPool threadPool = new ThreadPool(getClass().getName());
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportIT.java b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportIT.java
index 2870124881..688ecd54df 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportIT.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportIT.java
@@ -35,6 +35,8 @@ import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.ActionNotFoundTransportException;
import org.elasticsearch.transport.RequestHandlerRegistry;
@@ -43,15 +45,12 @@ import org.elasticsearch.transport.TransportRequest;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@@ -60,7 +59,6 @@ import static org.hamcrest.Matchers.is;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 1)
public class NettyTransportIT extends ESIntegTestCase {
-
// static so we can use it in anonymous classes
private static String channelProfileName = null;
@@ -76,7 +74,6 @@ public class NettyTransportIT extends ESIntegTestCase {
return pluginList(ExceptionThrowingNettyTransport.TestPlugin.class);
}
- @Test
public void testThatConnectionFailsAsIntended() throws Exception {
Client transportClient = internalCluster().transportClient();
ClusterHealthResponse clusterIndexHealths = transportClient.admin().cluster().prepareHealth().get();
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationIT.java b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationIT.java
index 9a6486134d..369e853de4 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationIT.java
@@ -28,17 +28,22 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.test.ESIntegTestCase;
+import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.Network;
import org.elasticsearch.transport.TransportModule;
-import org.junit.Test;
import java.net.InetAddress;
import java.util.Locale;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, numClientNodes = 0)
public class NettyTransportMultiPortIntegrationIT extends ESIntegTestCase {
@@ -64,7 +69,6 @@ public class NettyTransportMultiPortIntegrationIT extends ESIntegTestCase {
return builder.build();
}
- @Test
public void testThatTransportClientCanConnect() throws Exception {
Settings settings = settingsBuilder()
.put("cluster.name", internalCluster().getClusterName())
@@ -78,7 +82,6 @@ public class NettyTransportMultiPortIntegrationIT extends ESIntegTestCase {
}
}
- @Test
@Network
public void testThatInfosAreExposed() throws Exception {
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setTransport(true).get();
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java
index 9d9c093ecc..02819525fa 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java
@@ -19,7 +19,7 @@
package org.elasticsearch.transport.netty;
import com.carrotsearch.hppc.IntHashSet;
-import java.nio.charset.StandardCharsets;
+
import org.elasticsearch.Version;
import org.elasticsearch.cache.recycler.PageCacheRecycler;
import org.elasticsearch.common.component.Lifecycle;
@@ -29,16 +29,15 @@ import org.elasticsearch.common.network.NetworkUtils;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.util.BigArrays;
+import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.common.util.MockBigArrays;
import org.elasticsearch.test.junit.rule.RepeatOnExceptionRule;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.BindTransportException;
import org.elasticsearch.transport.TransportService;
import org.junit.Before;
import org.junit.Rule;
-import org.junit.Test;
import java.io.IOException;
import java.io.OutputStream;
@@ -46,6 +45,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.is;
@@ -71,7 +71,6 @@ public class NettyTransportMultiPortTests extends ESTestCase {
}
}
- @Test
public void testThatNettyCanBindToMultiplePorts() throws Exception {
int[] ports = getRandomPorts(3);
@@ -92,7 +91,6 @@ public class NettyTransportMultiPortTests extends ESTestCase {
}
}
- @Test
public void testThatDefaultProfileInheritsFromStandardSettings() throws Exception {
int[] ports = getRandomPorts(2);
@@ -111,7 +109,6 @@ public class NettyTransportMultiPortTests extends ESTestCase {
}
}
- @Test
public void testThatProfileWithoutPortSettingsFails() throws Exception {
int[] ports = getRandomPorts(1);
@@ -129,7 +126,6 @@ public class NettyTransportMultiPortTests extends ESTestCase {
}
}
- @Test
public void testThatDefaultProfilePortOverridesGeneralConfiguration() throws Exception {
int[] ports = getRandomPorts(3);
@@ -150,7 +146,6 @@ public class NettyTransportMultiPortTests extends ESTestCase {
}
}
- @Test
public void testThatProfileWithoutValidNameIsIgnored() throws Exception {
int[] ports = getRandomPorts(3);
diff --git a/core/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java b/core/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java
index 923ed63aea..c18597ff8d 100644
--- a/core/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java
@@ -29,13 +29,13 @@ import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.AbstractSimpleTransportTestCase;
import org.elasticsearch.transport.ConnectTransportException;
-import org.junit.Test;
import java.net.InetAddress;
import java.net.UnknownHostException;
-public class SimpleNettyTransportTests extends AbstractSimpleTransportTestCase {
+import static org.hamcrest.Matchers.containsString;
+public class SimpleNettyTransportTests extends AbstractSimpleTransportTestCase {
@Override
protected MockTransportService build(Settings settings, Version version, NamedWriteableRegistry namedWriteableRegistry) {
int startPort = 11000 + randomIntBetween(0, 255);
@@ -46,8 +46,13 @@ public class SimpleNettyTransportTests extends AbstractSimpleTransportTestCase {
return transportService;
}
- @Test(expected = ConnectTransportException.class)
public void testConnectException() throws UnknownHostException {
- serviceA.connectToNode(new DiscoveryNode("C", new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9876), Version.CURRENT));
+ try {
+ serviceA.connectToNode(new DiscoveryNode("C", new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9876), Version.CURRENT));
+ fail("Expected ConnectTransportException");
+ } catch (ConnectTransportException e) {
+ assertThat(e.getMessage(), containsString("connect_timeout"));
+ assertThat(e.getMessage(), containsString("[localhost/127.0.0.1:9876]"));
+ }
}
} \ No newline at end of file
diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java
index cd29d403ab..627d0c1ec0 100644
--- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java
+++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java
@@ -45,14 +45,15 @@ import org.elasticsearch.test.TestCluster;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -136,7 +137,6 @@ public class TribeIT extends ESIntegTestCase {
tribeClient = tribeNode.client();
}
- @Test
public void testGlobalReadWriteBlocks() throws Exception {
logger.info("create 2 indices, test1 on t1, and test2 on t2");
internalCluster().client().admin().indices().prepareCreate("test1").get();
@@ -174,7 +174,6 @@ public class TribeIT extends ESIntegTestCase {
}
}
- @Test
public void testIndexWriteBlocks() throws Exception {
logger.info("create 2 indices, test1 on t1, and test2 on t2");
assertAcked(internalCluster().client().admin().indices().prepareCreate("test1"));
@@ -208,7 +207,6 @@ public class TribeIT extends ESIntegTestCase {
}
}
- @Test
public void testOnConflictDrop() throws Exception {
logger.info("create 2 indices, test1 on t1, and test2 on t2");
assertAcked(cluster().client().admin().indices().prepareCreate("conflict"));
@@ -232,7 +230,6 @@ public class TribeIT extends ESIntegTestCase {
assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().hasIndex("conflict"), equalTo(false));
}
- @Test
public void testOnConflictPrefer() throws Exception {
testOnConflictPrefer(randomBoolean() ? "t1" : "t2");
}
@@ -260,7 +257,6 @@ public class TribeIT extends ESIntegTestCase {
assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("conflict").getSettings().get(TribeService.TRIBE_NAME), equalTo(tribe));
}
- @Test
public void testTribeOnOneCluster() throws Exception {
setupTribeNode(Settings.EMPTY);
logger.info("create 2 indices, test1 on t1, and test2 on t2");
@@ -337,7 +333,6 @@ public class TribeIT extends ESIntegTestCase {
}
}
- @Test
public void testCloseAndOpenIndex() throws Exception {
//create an index and close it even before starting the tribe node
assertAcked(internalCluster().client().admin().indices().prepareCreate("test1"));
diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java b/core/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java
index 10b45017b2..9652537318 100644
--- a/core/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java
+++ b/core/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.nio.file.Path;
@@ -70,7 +69,6 @@ public class TribeUnitTests extends ESTestCase {
tribe2 = null;
}
- @Test
public void testThatTribeClientsIgnoreGlobalSysProps() throws Exception {
System.setProperty("es.cluster.name", "tribe_node_cluster");
System.setProperty("es.tribe.t1.cluster.name", "tribe1");
@@ -85,7 +83,6 @@ public class TribeUnitTests extends ESTestCase {
}
}
- @Test
public void testThatTribeClientsIgnoreGlobalConfig() throws Exception {
Path pathConf = getDataPath("elasticsearch.yml").getParent();
Settings settings = Settings.builder().put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true).put("path.conf", pathConf).build();
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java b/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
index 1faee8811b..dc10c9751c 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
@@ -30,7 +30,6 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.util.Collection;
import java.util.HashMap;
@@ -50,7 +49,6 @@ public class UpdateByNativeScriptIT extends ESIntegTestCase {
return pluginList(CustomNativeScriptFactory.TestPlugin.class);
}
- @Test
public void testThatUpdateUsingNativeScriptWorks() throws Exception {
createIndex("test");
ensureYellow();
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
index 8c62d97349..a197e918c2 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
@@ -47,10 +47,15 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.SearchScript;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
@@ -59,7 +64,14 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
public class UpdateIT extends ESIntegTestCase {
@@ -457,7 +469,6 @@ public class UpdateIT extends ESIntegTestCase {
.endObject()));
}
- @Test
public void testUpsert() throws Exception {
createTestIndex();
ensureGreen();
@@ -487,7 +498,6 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
public void testScriptedUpsert() throws Exception {
createTestIndex();
ensureGreen();
@@ -531,7 +541,6 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
public void testUpsertDoc() throws Exception {
createTestIndex();
ensureGreen();
@@ -547,8 +556,7 @@ public class UpdateIT extends ESIntegTestCase {
assertThat(updateResponse.getGetResult().sourceAsMap().get("bar").toString(), equalTo("baz"));
}
- @Test
- // See: https://github.com/elasticsearch/elasticsearch/issues/3265
+ // Issue #3265
public void testNotUpsertDoc() throws Exception {
createTestIndex();
ensureGreen();
@@ -560,7 +568,6 @@ public class UpdateIT extends ESIntegTestCase {
.execute(), DocumentMissingException.class);
}
- @Test
public void testUpsertFields() throws Exception {
createTestIndex();
ensureGreen();
@@ -590,7 +597,6 @@ public class UpdateIT extends ESIntegTestCase {
assertThat(updateResponse.getGetResult().sourceAsMap().get("extra").toString(), equalTo("foo"));
}
- @Test
public void testVersionedUpdate() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen();
@@ -651,7 +657,6 @@ public class UpdateIT extends ESIntegTestCase {
assertThrows(client().prepareUpdate(indexOrAlias(), "type", "1").setVersion(10).setRetryOnConflict(5), ActionRequestValidationException.class);
}
- @Test
public void testIndexAutoCreation() throws Exception {
UpdateResponse updateResponse = client().prepareUpdate("test", "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("bar", "baz").endObject())
@@ -666,7 +671,6 @@ public class UpdateIT extends ESIntegTestCase {
assertThat(updateResponse.getGetResult().sourceAsMap().get("extra"), nullValue());
}
- @Test
public void testUpdate() throws Exception {
createTestIndex();
ensureGreen();
@@ -813,7 +817,6 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
public void testUpdateRequestWithBothScriptAndDoc() throws Exception {
createTestIndex();
ensureGreen();
@@ -831,7 +834,6 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
public void testUpdateRequestWithScriptAndShouldUpsertDoc() throws Exception {
createTestIndex();
ensureGreen();
@@ -848,7 +850,6 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
public void testContextVariables() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.addMapping("type1", XContentFactory.jsonBuilder()
@@ -927,7 +928,6 @@ public class UpdateIT extends ESIntegTestCase {
assertNull(updateContext.get("_ttl"));
}
- @Test
public void testConcurrentUpdateWithRetryOnConflict() throws Exception {
final boolean useBulkApi = randomBoolean();
createTestIndex();
@@ -985,8 +985,7 @@ public class UpdateIT extends ESIntegTestCase {
}
}
- @Test
- public void stressUpdateDeleteConcurrency() throws Exception {
+ public void testStressUpdateDeleteConcurrency() throws Exception {
//We create an index with merging disabled so that deletes don't get merged away
assertAcked(prepareCreate("test")
.addMapping("type1", XContentFactory.jsonBuilder()
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java b/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java
index 499fb52a98..b4b5eefc83 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
-import org.junit.Test;
import java.io.IOException;
@@ -35,8 +34,7 @@ import static org.hamcrest.Matchers.notNullValue;
* Tests for noop updates.
*/
public class UpdateNoopIT extends ESIntegTestCase {
- @Test
- public void singleField() throws Exception {
+ public void testSingleField() throws Exception {
updateAndCheckSource(1, fields("bar", "baz"));
updateAndCheckSource(1, fields("bar", "baz"));
updateAndCheckSource(2, fields("bar", "bir"));
@@ -51,8 +49,7 @@ public class UpdateNoopIT extends ESIntegTestCase {
assertEquals(4, totalNoopUpdates());
}
- @Test
- public void twoFields() throws Exception {
+ public void testTwoFields() throws Exception {
// Use random keys so we get random iteration order.
String key1 = 1 + randomAsciiOfLength(3);
String key2 = 2 + randomAsciiOfLength(3);
@@ -74,8 +71,7 @@ public class UpdateNoopIT extends ESIntegTestCase {
assertEquals(5, totalNoopUpdates());
}
- @Test
- public void arrayField() throws Exception {
+ public void testArrayField() throws Exception {
updateAndCheckSource(1, fields("bar", "baz"));
updateAndCheckSource(2, fields("bar", new String[] {"baz", "bort"}));
updateAndCheckSource(2, fields("bar", new String[] {"baz", "bort"}));
@@ -92,8 +88,7 @@ public class UpdateNoopIT extends ESIntegTestCase {
assertEquals(5, totalNoopUpdates());
}
- @Test
- public void map() throws Exception {
+ public void testMap() throws Exception {
// Use random keys so we get variable iteration order.
String key1 = 1 + randomAsciiOfLength(3);
String key2 = 2 + randomAsciiOfLength(3);
@@ -143,8 +138,7 @@ public class UpdateNoopIT extends ESIntegTestCase {
assertEquals(3, totalNoopUpdates());
}
- @Test
- public void mapAndField() throws Exception {
+ public void testMapAndField() throws Exception {
updateAndCheckSource(1, XContentFactory.jsonBuilder().startObject()
.field("f", "foo")
.startObject("m")
@@ -216,8 +210,7 @@ public class UpdateNoopIT extends ESIntegTestCase {
* Totally empty requests are noop if and only if detect noops is true and
* its true by default.
*/
- @Test
- public void totallyEmpty() throws Exception {
+ public void testTotallyEmpty() throws Exception {
updateAndCheckSource(1, XContentFactory.jsonBuilder().startObject()
.field("f", "foo")
.startObject("m")
diff --git a/core/src/test/java/org/elasticsearch/validate/RenderSearchTemplateIT.java b/core/src/test/java/org/elasticsearch/validate/RenderSearchTemplateIT.java
index 10812c1555..e819286dca 100644
--- a/core/src/test/java/org/elasticsearch/validate/RenderSearchTemplateIT.java
+++ b/core/src/test/java/org/elasticsearch/validate/RenderSearchTemplateIT.java
@@ -29,7 +29,6 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.script.Template;
import org.elasticsearch.script.mustache.MustacheScriptEngineService;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -40,23 +39,21 @@ import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.SuiteScopeTestCase
public class RenderSearchTemplateIT extends ESIntegTestCase {
-
private static final String TEMPLATE_CONTENTS = "{\"size\":\"{{size}}\",\"query\":{\"match\":{\"foo\":\"{{value}}\"}},\"aggs\":{\"objects\":{\"terms\":{\"field\":\"{{value}}\",\"size\":\"{{size}}\"}}}}";
-
+
@Override
protected void setupSuiteScopeCluster() throws Exception {
client().preparePutIndexedScript(MustacheScriptEngineService.NAME, "index_template_1", "{ \"template\": " + TEMPLATE_CONTENTS + " }").get();
}
-
+
@Override
public Settings nodeSettings(int nodeOrdinal) {
//Set path so ScriptService will pick up the test scripts
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
.put("path.conf", this.getDataPath("config")).build();
}
-
- @Test
- public void inlineTemplate() {
+
+ public void testInlineTemplate() {
Map<String, Object> params = new HashMap<>();
params.put("value", "bar");
params.put("size", 20);
@@ -70,7 +67,7 @@ public class RenderSearchTemplateIT extends ESIntegTestCase {
String expected = TEMPLATE_CONTENTS.replace("{{value}}", "bar").replace("{{size}}", "20");
Map<String, Object> expectedMap = XContentHelper.convertToMap(new BytesArray(expected), false).v2();
assertThat(sourceAsMap, equalTo(expectedMap));
-
+
params = new HashMap<>();
params.put("value", "baz");
params.put("size", 100);
@@ -84,9 +81,8 @@ public class RenderSearchTemplateIT extends ESIntegTestCase {
expectedMap = XContentHelper.convertToMap(new BytesArray(expected), false).v2();
assertThat(sourceAsMap, equalTo(expectedMap));
}
-
- @Test
- public void indexedTemplate() {
+
+ public void testIndexedTemplate() {
Map<String, Object> params = new HashMap<>();
params.put("value", "bar");
params.put("size", 20);
@@ -100,7 +96,7 @@ public class RenderSearchTemplateIT extends ESIntegTestCase {
String expected = TEMPLATE_CONTENTS.replace("{{value}}", "bar").replace("{{size}}", "20");
Map<String, Object> expectedMap = XContentHelper.convertToMap(new BytesArray(expected), false).v2();
assertThat(sourceAsMap, equalTo(expectedMap));
-
+
params = new HashMap<>();
params.put("value", "baz");
params.put("size", 100);
@@ -114,9 +110,8 @@ public class RenderSearchTemplateIT extends ESIntegTestCase {
expectedMap = XContentHelper.convertToMap(new BytesArray(expected), false).v2();
assertThat(sourceAsMap, equalTo(expectedMap));
}
-
- @Test
- public void fileTemplate() {
+
+ public void testFileTemplate() {
Map<String, Object> params = new HashMap<>();
params.put("value", "bar");
params.put("size", 20);
@@ -130,7 +125,7 @@ public class RenderSearchTemplateIT extends ESIntegTestCase {
String expected = TEMPLATE_CONTENTS.replace("{{value}}", "bar").replace("{{size}}", "20");
Map<String, Object> expectedMap = XContentHelper.convertToMap(new BytesArray(expected), false).v2();
assertThat(sourceAsMap, equalTo(expectedMap));
-
+
params = new HashMap<>();
params.put("value", "baz");
params.put("size", 100);
diff --git a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java
index 22c959f5cd..81aaa5d683 100644
--- a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java
+++ b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java
@@ -18,7 +18,6 @@
*/
package org.elasticsearch.validate;
-import java.nio.charset.StandardCharsets;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
import org.elasticsearch.client.Client;
@@ -37,9 +36,9 @@ import org.hamcrest.Matcher;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
-import org.junit.Test;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
@@ -47,6 +46,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
/**
@@ -54,9 +54,7 @@ import static org.hamcrest.Matchers.nullValue;
*/
@ClusterScope(randomDynamicTemplates = false, scope = Scope.SUITE)
public class SimpleValidateQueryIT extends ESIntegTestCase {
-
- @Test
- public void simpleValidateQuery() throws Exception {
+ public void testSimpleValidateQuery() throws Exception {
createIndex("test");
ensureGreen();
client().admin().indices().preparePutMapping("test").setType("type1")
@@ -80,8 +78,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryStringQuery("foo:1 AND")).execute().actionGet().isValid(), equalTo(false));
}
- @Test
- public void explainValidateQueryTwoNodes() throws IOException {
+ public void testExplainValidateQueryTwoNodes() throws IOException {
createIndex("test");
ensureGreen();
client().admin().indices().preparePutMapping("test").setType("type1")
@@ -119,8 +116,8 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
}
}
- @Test //https://github.com/elasticsearch/elasticsearch/issues/3629
- public void explainDateRangeInQueryString() {
+ // Issue #3629
+ public void testExplainDateRangeInQueryString() {
assertAcked(prepareCreate("test").setSettings(Settings.settingsBuilder()
.put(indexSettings())
.put("index.number_of_shards", 1)));
@@ -145,13 +142,16 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(response.isValid(), equalTo(true));
}
- @Test(expected = IndexNotFoundException.class)
- public void validateEmptyCluster() {
- client().admin().indices().prepareValidateQuery().get();
+ public void testValidateEmptyCluster() {
+ try {
+ client().admin().indices().prepareValidateQuery().get();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
+ }
}
- @Test
- public void explainNoQuery() {
+ public void testExplainNoQuery() {
createIndex("test");
ensureGreen();
@@ -162,8 +162,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(validateQueryResponse.getQueryExplanation().get(0).getExplanation(), equalTo("*:*"));
}
- @Test
- public void explainFilteredAlias() {
+ public void testExplainFilteredAlias() {
assertAcked(prepareCreate("test")
.addMapping("test", "field", "type=string")
.addAlias(new Alias("alias").filter(QueryBuilders.termQuery("field", "value1"))));
@@ -177,8 +176,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(validateQueryResponse.getQueryExplanation().get(0).getExplanation(), containsString("field:value1"));
}
- @Test
- public void explainMatchPhrasePrefix() {
+ public void testExplainMatchPhrasePrefix() {
assertAcked(prepareCreate("test").setSettings(
Settings.settingsBuilder().put(indexSettings())
.put("index.analysis.filter.syns.type", "synonym")
@@ -214,8 +212,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(validateQueryResponse.getQueryExplanation().get(0).getExplanation(), containsString("field:\"foo (one* two*)\""));
}
- @Test
- public void explainWithRewriteValidateQuery() throws Exception {
+ public void testExplainWithRewriteValidateQuery() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("type1", "field", "type=string,analyzer=whitespace")
.setSettings(SETTING_NUMBER_OF_SHARDS, 1).get();
@@ -258,8 +255,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
containsString("field:huge field:pidgin"), true);
}
- @Test
- public void irrelevantPropertiesBeforeQuery() throws IOException {
+ public void testIrrelevantPropertiesBeforeQuery() throws IOException {
createIndex("test");
ensureGreen();
refresh();
@@ -267,8 +263,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
assertThat(client().admin().indices().prepareValidateQuery("test").setSource(new BytesArray("{\"foo\": \"bar\", \"query\": {\"term\" : { \"user\" : \"kimchy\" }}}")).get().isValid(), equalTo(false));
}
- @Test
- public void irrelevantPropertiesAfterQuery() throws IOException {
+ public void testIrrelevantPropertiesAfterQuery() throws IOException {
createIndex("test");
ensureGreen();
refresh();
diff --git a/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java b/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
index 402ec0d8dc..bb8636d36e 100644
--- a/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
+++ b/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
@@ -22,7 +22,6 @@ package org.elasticsearch.versioning;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -37,10 +36,7 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class ConcurrentDocumentOperationIT extends ESIntegTestCase {
-
- @Test
- public void concurrentOperationOnSameDocTest() throws Exception {
-
+ public void testConcurrentOperationOnSameDoc() throws Exception {
logger.info("--> create an index with 1 shard and max replicas based on nodes");
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder().put(indexSettings()).put("index.number_of_shards", 1)));
diff --git a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java
index 93c29e0c92..edbbebbbc4 100644
--- a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java
+++ b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java
@@ -31,9 +31,13 @@ import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.engine.FlushNotAllowedEngineException;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
@@ -47,8 +51,6 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
*
*/
public class SimpleVersioningIT extends ESIntegTestCase {
-
- @Test
public void testExternalVersioningInitialDelete() throws Exception {
createIndex("test");
ensureGreen();
@@ -69,7 +71,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(indexResponse.getVersion(), equalTo(18L));
}
- @Test
public void testForce() throws Exception {
createIndex("test");
ensureGreen("test"); // we are testing force here which doesn't work if we are recovering at the same time - zzzzz...
@@ -100,7 +101,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(deleteResponse.getVersion(), equalTo(v));
}
- @Test
public void testExternalGTE() throws Exception {
createIndex("test");
@@ -147,7 +147,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(deleteResponse.getVersion(), equalTo(18l));
}
- @Test
public void testExternalVersioning() throws Exception {
createIndex("test");
ensureGreen();
@@ -211,7 +210,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(indexResponse.getVersion(), equalTo(20l));
}
- @Test
public void testRequireUnitsOnUpdateSettings() throws Exception {
createIndex("test");
ensureGreen();
@@ -226,7 +224,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
}
}
- @Test
public void testInternalVersioningInitialDelete() throws Exception {
createIndex("test");
ensureGreen();
@@ -239,8 +236,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(indexResponse.getVersion(), equalTo(1l));
}
-
- @Test
public void testInternalVersioning() throws Exception {
createIndex("test");
ensureGreen();
@@ -298,7 +293,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
assertThat(deleteResponse.getVersion(), equalTo(4l));
}
- @Test
public void testSimpleVersioningWithFlush() throws Exception {
createIndex("test");
ensureGreen();
@@ -336,7 +330,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
}
}
- @Test
public void testVersioningWithBulk() {
createIndex("test");
ensureGreen();
@@ -521,8 +514,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
}
}
-
- @Test
public void testRandomIDsAndVersions() throws Exception {
createIndex("test");
ensureGreen();
@@ -719,7 +710,6 @@ public class SimpleVersioningIT extends ESIntegTestCase {
}
}
- @Test
public void testDeleteNotLost() throws Exception {
// We require only one shard for this test, so that the 2nd delete provokes pruning the deletes map:
@@ -799,9 +789,7 @@ public class SimpleVersioningIT extends ESIntegTestCase {
equalTo(-1L));
}
- @Test
public void testGCDeletesZero() throws Exception {
-
createIndex("test");
ensureGreen();
diff --git a/core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java b/core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java
index 14f7eca683..5b5a16c604 100644
--- a/core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java
+++ b/core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.watcher;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -32,13 +31,13 @@ import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
@LuceneTestCase.SuppressFileSystems("ExtrasFS")
public class FileWatcherTests extends ESTestCase {
-
private class RecordingChangeListener extends FileChangesListener {
-
private Path rootDir;
private RecordingChangeListener(Path rootDir) {
@@ -91,7 +90,6 @@ public class FileWatcherTests extends ESTestCase {
}
}
- @Test
public void testSimpleFileOperations() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -120,7 +118,6 @@ public class FileWatcherTests extends ESTestCase {
}
- @Test
public void testSimpleDirectoryOperations() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -210,7 +207,6 @@ public class FileWatcherTests extends ESTestCase {
}
- @Test
public void testNestedDirectoryOperations() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -276,7 +272,6 @@ public class FileWatcherTests extends ESTestCase {
));
}
- @Test
public void testFileReplacingDirectory() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -323,7 +318,6 @@ public class FileWatcherTests extends ESTestCase {
));
}
- @Test
public void testEmptyDirectory() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -346,7 +340,6 @@ public class FileWatcherTests extends ESTestCase {
));
}
- @Test
public void testNoDirectoryOnInit() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -370,7 +363,6 @@ public class FileWatcherTests extends ESTestCase {
));
}
- @Test
public void testNoFileOnInit() throws IOException {
Path tempDir = createTempDir();
RecordingChangeListener changes = new RecordingChangeListener(tempDir);
@@ -389,11 +381,11 @@ public class FileWatcherTests extends ESTestCase {
equalTo("onFileCreated: testfile.txt")
));
}
-
+
static void touch(Path path) throws IOException {
Files.newOutputStream(path).close();
}
-
+
static void append(String string, Path path, Charset cs) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(path, cs, StandardOpenOption.APPEND)) {
writer.append(string);
diff --git a/core/src/test/java/org/elasticsearch/watcher/ResourceWatcherServiceTests.java b/core/src/test/java/org/elasticsearch/watcher/ResourceWatcherServiceTests.java
index b503436add..6c6c45e9cf 100644
--- a/core/src/test/java/org/elasticsearch/watcher/ResourceWatcherServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/watcher/ResourceWatcherServiceTests.java
@@ -22,17 +22,16 @@ package org.elasticsearch.watcher;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
-import org.junit.Test;
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
/**
*
*/
public class ResourceWatcherServiceTests extends ESTestCase {
-
- @Test
public void testSettings() throws Exception {
ThreadPool threadPool = new ThreadPool("test");
@@ -65,8 +64,6 @@ public class ResourceWatcherServiceTests extends ESTestCase {
terminate(threadPool);
}
-
- @Test
public void testHandle() throws Exception {
ThreadPool threadPool = new ThreadPool("test");
Settings settings = Settings.builder().build();
diff --git a/dev-tools/src/main/resources/forbidden/test-signatures.txt b/dev-tools/src/main/resources/forbidden/test-signatures.txt
index 3cde735261..bd6744ee05 100644
--- a/dev-tools/src/main/resources/forbidden/test-signatures.txt
+++ b/dev-tools/src/main/resources/forbidden/test-signatures.txt
@@ -21,3 +21,5 @@ com.carrotsearch.randomizedtesting.annotations.Repeat @ Don't commit hardcoded r
org.apache.lucene.codecs.Codec#setDefault(org.apache.lucene.codecs.Codec) @ Use the SuppressCodecs("*") annotation instead
org.apache.lucene.util.LuceneTestCase$Slow @ Don't write slow tests
org.junit.Ignore @ Use AwaitsFix instead
+
+org.junit.Test @defaultMessage Just name your test method testFooBar
diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java
index 8369809aee..5dfff29b2a 100644
--- a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java
+++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java
@@ -21,7 +21,6 @@ package org.elasticsearch.index.analysis;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.analysis.AnalysisTestUtils.createAnalysisService;
@@ -29,8 +28,6 @@ import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class SimpleIcuAnalysisTests extends ESTestCase {
-
- @Test
public void testDefaultsIcuAnalysis() {
Settings settings = settingsBuilder()
.put("path.home", createTempDir()).build();
diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuCollationTokenFilterTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuCollationTokenFilterTests.java
index 6be0b2f23a..9e59b8e42c 100644
--- a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuCollationTokenFilterTests.java
+++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuCollationTokenFilterTests.java
@@ -22,13 +22,13 @@ package org.elasticsearch.index.analysis;
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
import com.ibm.icu.util.ULocale;
+
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -38,14 +38,12 @@ import static org.hamcrest.Matchers.equalTo;
// Tests borrowed from Solr's Icu collation key filter factory test.
public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
-
/*
* Turkish has some funny casing.
* This test shows how you can solve this kind of thing easily with collation.
* Instead of using LowerCaseFilter, use a turkish collator with primary strength.
* Then things will sort and match correctly.
*/
- @Test
public void testBasicUsage() throws Exception {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -62,7 +60,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
/*
* Test usage of the decomposition option for unicode normalization.
*/
- @Test
public void testNormalization() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -80,7 +77,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
/*
* Test secondary strength, for english case is not significant.
*/
- @Test
public void testSecondaryStrength() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -99,7 +95,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* Setting alternate=shifted to shift whitespace, punctuation and symbols
* to quaternary level
*/
- @Test
public void testIgnorePunctuation() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -118,7 +113,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* Setting alternate=shifted and variableTop to shift whitespace, but not
* punctuation or symbols, to quaternary level
*/
- @Test
public void testIgnoreWhitespace() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -140,7 +134,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* Setting numeric to encode digits with numeric value, so that
* foobar-9 sorts before foobar-10
*/
- @Test
public void testNumerics() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -158,7 +151,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* Setting caseLevel=true to create an additional case level between
* secondary and tertiary
*/
- @Test
public void testIgnoreAccentsButNotCase() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -180,7 +172,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* Setting caseFirst=upper to cause uppercase strings to sort
* before lowercase ones.
*/
- @Test
public void testUpperCaseFirst() throws IOException {
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
@@ -202,7 +193,6 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
* The default is DIN 5007-1, this shows how to tailor a collator to get DIN 5007-2 behavior.
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4423383
*/
- @Test
public void testCustomRules() throws Exception {
RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE"));
String DIN5007_2_tailorings =
@@ -224,20 +214,20 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
TokenFilterFactory filterFactory = analysisService.tokenFilter("myCollator");
assertCollatesToSame(filterFactory, "Töne", "Toene");
}
-
+
private void assertCollatesToSame(TokenFilterFactory factory, String string1, String string2) throws IOException {
assertCollation(factory, string1, string2, 0);
}
-
+
private void assertCollation(TokenFilterFactory factory, String string1, String string2, int comparison) throws IOException {
Tokenizer tokenizer = new KeywordTokenizer();
tokenizer.setReader(new StringReader(string1));
TokenStream stream1 = factory.create(tokenizer);
-
+
tokenizer = new KeywordTokenizer();
tokenizer.setReader(new StringReader(string2));
TokenStream stream2 = factory.create(tokenizer);
-
+
assertCollation(stream1, stream2, comparison);
}
@@ -253,10 +243,10 @@ public class SimpleIcuCollationTokenFilterTests extends ESTestCase {
assertThat(Integer.signum(term1.toString().compareTo(term2.toString())), equalTo(Integer.signum(comparison)));
assertThat(stream1.incrementToken(), equalTo(false));
assertThat(stream2.incrementToken(), equalTo(false));
-
+
stream1.end();
stream2.end();
-
+
stream1.close();
stream2.close();
}
diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuNormalizerCharFilterTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuNormalizerCharFilterTests.java
index 748b439a9e..bd2f959bf9 100644
--- a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuNormalizerCharFilterTests.java
+++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuNormalizerCharFilterTests.java
@@ -20,10 +20,10 @@
package org.elasticsearch.index.analysis;
import com.ibm.icu.text.Normalizer2;
+
import org.apache.lucene.analysis.CharFilter;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.StringReader;
@@ -33,10 +33,7 @@ import static org.elasticsearch.index.analysis.AnalysisTestUtils.createAnalysisS
* Test
*/
public class SimpleIcuNormalizerCharFilterTests extends ESTestCase {
-
- @Test
public void testDefaultSetting() throws Exception {
-
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
.put("index.analysis.char_filter.myNormalizerChar.type", "icu_normalizer")
@@ -59,10 +56,7 @@ public class SimpleIcuNormalizerCharFilterTests extends ESTestCase {
assertEquals(expectedOutput, output.toString());
}
-
- @Test
public void testNameAndModeSetting() throws Exception {
-
Settings settings = Settings.settingsBuilder()
.put("path.home", createTempDir())
.put("index.analysis.char_filter.myNormalizerChar.type", "icu_normalizer")
diff --git a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java
index b39103bb23..212ab0d7cb 100644
--- a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java
+++ b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.plugin.analysis.kuromoji.AnalysisKuromojiPlugin;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -55,8 +54,6 @@ import static org.hamcrest.Matchers.notNullValue;
/**
*/
public class KuromojiAnalysisTests extends ESTestCase {
-
- @Test
public void testDefaultsKuromojiAnalysis() throws IOException {
AnalysisService analysisService = createAnalysisService();
@@ -90,7 +87,6 @@ public class KuromojiAnalysisTests extends ESTestCase {
}
- @Test
public void testBaseFormFilterFactory() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenFilterFactory tokenFilter = analysisService.tokenFilter("kuromoji_pos");
@@ -102,7 +98,6 @@ public class KuromojiAnalysisTests extends ESTestCase {
assertSimpleTSOutput(tokenFilter.create(tokenizer), expected);
}
- @Test
public void testReadingFormFilterFactory() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenFilterFactory tokenFilter = analysisService.tokenFilter("kuromoji_rf");
@@ -123,7 +118,6 @@ public class KuromojiAnalysisTests extends ESTestCase {
assertSimpleTSOutput(tokenFilter.create(tokenizer), expected_tokens_katakana);
}
- @Test
public void testKatakanaStemFilter() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenFilterFactory tokenFilter = analysisService.tokenFilter("kuromoji_stemmer");
@@ -148,7 +142,7 @@ public class KuromojiAnalysisTests extends ESTestCase {
expected_tokens_katakana = new String[]{"明後日", "パーティー", "に", "行く", "予定", "が", "ある", "図書館", "で", "資料", "を", "コピー", "し", "まし", "た"};
assertSimpleTSOutput(tokenFilter.create(tokenizer), expected_tokens_katakana);
}
- @Test
+
public void testIterationMarkCharFilter() throws IOException {
AnalysisService analysisService = createAnalysisService();
// test only kanji
@@ -182,7 +176,6 @@ public class KuromojiAnalysisTests extends ESTestCase {
assertCharFilterEquals(charFilterFactory.create(new StringReader(source)), expected);
}
- @Test
public void testJapaneseStopFilterFactory() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenFilterFactory tokenFilter = analysisService.tokenFilter("ja_stop");
@@ -256,7 +249,6 @@ public class KuromojiAnalysisTests extends ESTestCase {
return buffer.toString();
}
- @Test
public void testKuromojiUserDict() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenizerFactory tokenizerFactory = analysisService.tokenizer("kuromoji_user_dict");
@@ -269,11 +261,9 @@ public class KuromojiAnalysisTests extends ESTestCase {
}
// fix #59
- @Test
public void testKuromojiEmptyUserDict() throws IOException {
AnalysisService analysisService = createAnalysisService();
TokenizerFactory tokenizerFactory = analysisService.tokenizer("kuromoji_empty_user_dict");
assertThat(tokenizerFactory, instanceOf(KuromojiTokenizerFactory.class));
}
-
}
diff --git a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java
index 1467626dd7..bf763cf7cc 100644
--- a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java
+++ b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.instanceOf;
@@ -41,8 +40,6 @@ import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class SimplePhoneticAnalysisTests extends ESTestCase {
-
- @Test
public void testPhoneticTokenFilterFactory() {
String yaml = "/org/elasticsearch/index/analysis/phonetic-1.yml";
Settings settings = settingsBuilder().loadFromStream(yaml, getClass().getResourceAsStream(yaml))
diff --git a/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java b/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java
index 0f5d300465..7c6f3584c4 100644
--- a/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java
+++ b/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java
@@ -33,17 +33,14 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class SimpleSmartChineseAnalysisTests extends ESTestCase {
-
- @Test
public void testDefaultsIcuAnalysis() {
Index index = new Index("test");
Settings settings = settingsBuilder()
diff --git a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java
index b17f3a12e3..e48829397f 100644
--- a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java
+++ b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java
@@ -37,17 +37,14 @@ import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.hamcrest.Matchers.instanceOf;
/**
*/
public class PolishAnalysisTests extends ESTestCase {
-
- @Test
public void testDefaultsPolishAnalysis() {
Index index = new Index("test");
Settings settings = settingsBuilder()
diff --git a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java
index 70465417c6..e55ffa8528 100644
--- a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java
+++ b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.index.analysis.pl.PolishAnalysisBinderProcessor;
import org.elasticsearch.index.settings.IndexSettingsModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -46,8 +45,6 @@ import java.io.StringReader;
import static org.hamcrest.Matchers.equalTo;
public class SimplePolishTokenFilterTests extends ESTestCase {
-
- @Test
public void testBasicUsage() throws Exception {
testToken("kwiaty", "kwć");
testToken("canona", "ć");
diff --git a/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java b/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java
index f11a0043c3..ea814b44f5 100644
--- a/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java
+++ b/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java
@@ -24,13 +24,10 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class IndexDeleteByQueryResponseTests extends ESTestCase {
-
- @Test
public void testIncrements() {
String indexName = randomAsciiOfLength(5);
@@ -70,7 +67,6 @@ public class IndexDeleteByQueryResponseTests extends ESTestCase {
assertThat(response.getFailed(), equalTo(failed + 1 + inc));
}
- @Test
public void testNegativeCounters() {
assumeTrue("assertions must be enable for this test to pass", assertionsEnabled());
try {
@@ -106,7 +102,6 @@ public class IndexDeleteByQueryResponseTests extends ESTestCase {
}
}
- @Test
public void testNegativeIncrements() {
assumeTrue("assertions must be enable for this test to pass", assertionsEnabled());
try {
@@ -146,7 +141,6 @@ public class IndexDeleteByQueryResponseTests extends ESTestCase {
}
}
- @Test
public void testSerialization() throws Exception {
IndexDeleteByQueryResponse response = new IndexDeleteByQueryResponse(randomAsciiOfLength(5), Math.abs(randomLong()), Math.abs(randomLong()), Math.abs(randomLong()), Math.abs(randomLong()));
Version testVersion = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
@@ -165,5 +159,4 @@ public class IndexDeleteByQueryResponseTests extends ESTestCase {
assertThat(deserializedResponse.getMissing(), equalTo(response.getMissing()));
assertThat(deserializedResponse.getFailed(), equalTo(response.getFailed()));
}
-
}
diff --git a/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryActionTests.java b/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryActionTests.java
index cc50e6e11f..2b708341c7 100644
--- a/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryActionTests.java
+++ b/plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryActionTests.java
@@ -20,7 +20,6 @@
package org.elasticsearch.action.deletebyquery;
import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.bulk.BulkItemResponse;
@@ -37,7 +36,6 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.junit.Test;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
@@ -46,8 +44,6 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
-
- @Test
public void testExecuteScanFailsOnMissingIndex() {
DeleteByQueryRequest delete = new DeleteByQueryRequest().indices(new String[]{"none"});
TestActionListener listener = new TestActionListener();
@@ -59,7 +55,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScan() {
createIndex("test");
final int numDocs = randomIntBetween(1, 200);
@@ -84,7 +79,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScrollFailsOnMissingScrollId() {
DeleteByQueryRequest delete = new DeleteByQueryRequest();
TestActionListener listener = new TestActionListener();
@@ -96,7 +90,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScrollFailsOnMalformedScrollId() {
DeleteByQueryRequest delete = new DeleteByQueryRequest();
TestActionListener listener = new TestActionListener();
@@ -108,7 +101,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScrollFailsOnExpiredScrollId() {
final long numDocs = randomIntBetween(1, 100);
for (int i = 1; i <= numDocs; i++) {
@@ -137,7 +129,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScrollTimedOut() throws InterruptedException {
client().prepareIndex("test", "type", "1").setSource("num", "1").get();
client().prepareIndex("test", "type", "2").setSource("num", "1").get();
@@ -163,7 +154,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScrollNoDocuments() {
createIndex("test");
SearchResponse searchResponse = client().prepareSearch("test").setScroll(TimeValue.timeValueSeconds(10)).get();
@@ -183,7 +173,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testExecuteScroll() {
final int numDocs = randomIntBetween(1, 100);
for (int i = 1; i <= numDocs; i++) {
@@ -220,7 +209,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertSearchContextsClosed();
}
- @Test
public void testOnBulkResponse() {
final int nbItems = randomIntBetween(0, 20);
long deleted = 0;
@@ -266,7 +254,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testOnBulkResponseMultipleIndices() {
final int nbIndices = randomIntBetween(2, 5);
@@ -337,7 +324,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
}
}
- @Test
public void testOnBulkFailureNoDocuments() {
DeleteByQueryRequest delete = new DeleteByQueryRequest();
TestActionListener listener = new TestActionListener();
@@ -348,7 +334,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertFailure(listener, "This is a bulk failure");
}
- @Test
public void testOnBulkFailure() {
final int nbDocs = randomIntBetween(0, 20);
SearchHit[] docs = new SearchHit[nbDocs];
@@ -371,7 +356,6 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertThat(response.getTotalDeleted(), equalTo(0L));
}
- @Test
public void testFinishHim() {
TestActionListener listener = new TestActionListener();
newAsyncAction(new DeleteByQueryRequest(), listener).finishHim(null, false, null);
@@ -433,19 +417,7 @@ public class TransportDeleteByQueryActionTests extends ESSingleNodeTestCase {
assertThat(t.toString(), containsString(expectedFailure));
}
- private void assertShardFailuresContains(ShardOperationFailedException[] shardFailures, String expectedFailure) {
- assertNotNull(shardFailures);
- for (ShardOperationFailedException failure : shardFailures) {
- Throwable t = failure.getCause();
- if (t.toString().contains(expectedFailure)) {
- return;
- }
- }
- fail("failed to find shard failure [" + expectedFailure + "]");
- }
-
private class TestActionListener implements ActionListener<DeleteByQueryResponse> {
-
private final CountDown count = new CountDown(1);
private DeleteByQueryResponse response;
diff --git a/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java b/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java
index f523f7167c..a4aa334e39 100644
--- a/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java
+++ b/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.junit.Test;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
@@ -47,25 +46,29 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = SUITE, transportClientRatio = 0)
public class DeleteByQueryTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(DeleteByQueryPlugin.class);
}
- @Test(expected = ActionRequestValidationException.class)
public void testDeleteByQueryWithNoSource() {
- newDeleteByQuery().get();
- fail("should have thrown a validation exception because of the missing source");
+ try {
+ newDeleteByQuery().get();
+ fail("should have thrown a validation exception because of the missing source");
+ } catch (ActionRequestValidationException e) {
+ assertThat(e.getMessage(), containsString("source is missing"));
+ }
}
- @Test
public void testDeleteByQueryWithNoIndices() throws Exception {
DeleteByQueryRequestBuilder delete = newDeleteByQuery().setQuery(QueryBuilders.matchAllQuery());
delete.setIndicesOptions(IndicesOptions.fromOptions(false, true, true, false));
@@ -73,7 +76,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithOneIndex() throws Exception {
final long docs = randomIntBetween(1, 50);
for (int i = 0; i < docs; i++) {
@@ -89,7 +91,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithMultipleIndices() throws Exception {
final int indices = randomIntBetween(2, 5);
final int docs = randomIntBetween(2, 10) * 2;
@@ -143,7 +144,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithMissingIndex() throws Exception {
client().prepareIndex("test", "test")
.setSource(jsonBuilder().startObject().field("field1", 1).endObject())
@@ -166,7 +166,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithTypes() throws Exception {
final long docs = randomIntBetween(1, 50);
for (int i = 0; i < docs; i++) {
@@ -188,7 +187,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithRouting() throws Exception {
assertAcked(prepareCreate("test").setSettings("number_of_shards", 2));
ensureGreen("test");
@@ -217,7 +215,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByFieldQuery() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
@@ -240,7 +237,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryWithDateMath() throws Exception {
index("test", "type", "1", "d", "2013-01-01");
ensureGreen();
@@ -254,7 +250,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByTermQuery() throws Exception {
createIndex("test");
ensureGreen();
@@ -281,8 +276,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
-
public void testConcurrentDeleteByQueriesOnDifferentDocs() throws Exception {
createIndex("test");
ensureGreen();
@@ -342,7 +335,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testConcurrentDeleteByQueriesOnSameDocs() throws Exception {
assertAcked(prepareCreate("test").setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
ensureGreen();
@@ -402,7 +394,6 @@ public class DeleteByQueryTests extends ESIntegTestCase {
assertSearchContextsClosed();
}
- @Test
public void testDeleteByQueryOnReadOnlyIndex() throws Exception {
createIndex("test");
ensureGreen();
diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java
index 75ae011e75..19d6d038e8 100644
--- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java
+++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java
@@ -19,14 +19,13 @@
package org.elasticsearch.discovery.azure;
+import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTestCase;
import org.elasticsearch.cloud.azure.AzureComputeServiceTwoNodesMock;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
-import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import java.io.IOException;
@@ -60,8 +59,7 @@ public class AzureMinimumMasterNodesTests extends AbstractAzureComputeServiceTes
return builder.build();
}
- @Test
- public void simpleOnlyMasterNodeElection() throws IOException {
+ public void testSimpleOnlyMasterNodeElection() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode();
try {
diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java
index 74daf1a75e..cc4021fb78 100644
--- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java
+++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java
@@ -20,12 +20,11 @@
package org.elasticsearch.discovery.azure;
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTestCase;
+import org.elasticsearch.cloud.azure.AzureComputeServiceSimpleMock;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
-import org.elasticsearch.cloud.azure.AzureComputeServiceSimpleMock;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
@@ -34,13 +33,11 @@ import static org.hamcrest.Matchers.notNullValue;
transportClientRatio = 0.0,
numClientNodes = 0)
public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase {
-
public AzureSimpleTests() {
super(AzureComputeServiceSimpleMock.TestPlugin.class);
}
- @Test
- public void one_node_should_run_using_private_ip() {
+ public void testOneNodeDhouldRunUsingPrivateIp() {
Settings.Builder settings = Settings.settingsBuilder()
.put(Management.SERVICE_NAME, "dummy")
.put(Discovery.HOST_TYPE, "private_ip");
@@ -53,8 +50,7 @@ public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase {
checkNumberOfNodes(1);
}
- @Test
- public void one_node_should_run_using_public_ip() {
+ public void testOneNodeShouldRunUsingPublicIp() {
Settings.Builder settings = Settings.settingsBuilder()
.put(Management.SERVICE_NAME, "dummy")
.put(Discovery.HOST_TYPE, "public_ip");
@@ -67,8 +63,7 @@ public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase {
checkNumberOfNodes(1);
}
- @Test
- public void one_node_should_run_using_wrong_settings() {
+ public void testOneNodeShouldRunUsingWrongSettings() {
Settings.Builder settings = Settings.settingsBuilder()
.put(Management.SERVICE_NAME, "dummy")
.put(Discovery.HOST_TYPE, "do_not_exist");
diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java
index dbccc4ac45..2d134d0cc8 100644
--- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java
+++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java
@@ -20,12 +20,11 @@
package org.elasticsearch.discovery.azure;
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTestCase;
+import org.elasticsearch.cloud.azure.AzureComputeServiceTwoNodesMock;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
-import org.elasticsearch.cloud.azure.AzureComputeServiceTwoNodesMock;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
@@ -39,9 +38,8 @@ public class AzureTwoStartedNodesTests extends AbstractAzureComputeServiceTestCa
super(AzureComputeServiceTwoNodesMock.TestPlugin.class);
}
- @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/11533")
- public void two_nodes_should_run_using_private_ip() {
+ public void testTwoNodesShouldRunUsingPrivateIp() {
Settings.Builder settings = Settings.settingsBuilder()
.put(Management.SERVICE_NAME, "dummy")
.put(Discovery.HOST_TYPE, "private_ip");
@@ -58,9 +56,8 @@ public class AzureTwoStartedNodesTests extends AbstractAzureComputeServiceTestCa
checkNumberOfNodes(2);
}
- @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/11533")
- public void two_nodes_should_run_using_public_ip() {
+ public void testTwoNodesShouldRunUsingPublicIp() {
Settings.Builder settings = Settings.settingsBuilder()
.put(Management.SERVICE_NAME, "dummy")
.put(Discovery.HOST_TYPE, "public_ip");
diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
index c1d5daf07f..d69d939e5b 100644
--- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
+++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
@@ -20,14 +20,12 @@
package org.elasticsearch.cloud.aws;
import com.amazonaws.ClientConfiguration;
+
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class AWSSignersTests extends ESTestCase {
-
- @Test
public void testSigners() {
assertThat(signerTester(null), is(false));
assertThat(signerTester("QueryStringSignerType"), is(true));
diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java
index 1d7b525ed8..ca9493bc4c 100644
--- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java
+++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java
@@ -20,6 +20,7 @@
package org.elasticsearch.discovery.ec2;
import com.amazonaws.services.ec2.model.Tag;
+
import org.elasticsearch.Version;
import org.elasticsearch.cloud.aws.AwsEc2Service;
import org.elasticsearch.cloud.aws.AwsEc2Service.DISCOVERY_EC2;
@@ -35,11 +36,11 @@ import org.elasticsearch.transport.local.LocalTransport;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
@@ -86,8 +87,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
return discoveryNodes;
}
- @Test
- public void defaultSettings() throws InterruptedException {
+ public void testDefaultSettings() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder()
.build();
@@ -95,8 +95,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(nodes));
}
- @Test
- public void privateIp() throws InterruptedException {
+ public void testPrivateIp() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE, "private_ip")
@@ -112,8 +111,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
}
}
- @Test
- public void publicIp() throws InterruptedException {
+ public void testPublicIp() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE, "public_ip")
@@ -129,8 +127,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
}
}
- @Test
- public void privateDns() throws InterruptedException {
+ public void testPrivateDns() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE, "private_dns")
@@ -148,8 +145,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
}
}
- @Test
- public void publicDns() throws InterruptedException {
+ public void testPublicDns() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE, "public_dns")
@@ -167,16 +163,19 @@ public class Ec2DiscoveryTests extends ESTestCase {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void invalidHostType() throws InterruptedException {
+ public void testInvalidHostType() throws InterruptedException {
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE, "does_not_exist")
.build();
- buildDynamicNodes(nodeSettings, 1);
+ try {
+ buildDynamicNodes(nodeSettings, 1);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("No enum constant"));
+ }
}
- @Test
- public void filterByTags() throws InterruptedException {
+ public void testFilterByTags() throws InterruptedException {
int nodes = randomIntBetween(5, 10);
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.TAG_PREFIX + "stage", "prod")
@@ -201,8 +200,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(prodInstances));
}
- @Test
- public void filterByMultipleTags() throws InterruptedException {
+ public void testFilterByMultipleTags() throws InterruptedException {
int nodes = randomIntBetween(5, 10);
Settings nodeSettings = Settings.builder()
.putArray(DISCOVERY_EC2.TAG_PREFIX + "stage", "prod", "preprod")
diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
index de3efcf134..68596ce2ac 100644
--- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
+++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugin.discovery.ec2.Ec2DiscoveryPlugin;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.CoreMatchers.is;
@@ -38,8 +37,6 @@ import static org.hamcrest.CoreMatchers.is;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0)
public class Ec2DiscoveryUpdateSettingsTests extends AbstractAwsTestCase {
-
- @Test
public void testMinimumMasterNodesStart() {
Settings nodeSettings = settingsBuilder()
.put("plugin.types", Ec2DiscoveryPlugin.class.getName())
@@ -57,5 +54,4 @@ public class Ec2DiscoveryUpdateSettingsTests extends AbstractAwsTestCase {
Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null);
assertThat(min, is(1));
}
-
}
diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java
index 8aa9ca56a3..4c943950af 100644
--- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java
+++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.cloud.aws.network.Ec2NameResolver;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.net.InetAddress;
@@ -35,12 +34,10 @@ import static org.hamcrest.Matchers.containsString;
* Test for EC2 network.host settings.
*/
public class Ec2NetworkTests extends ESTestCase {
-
/**
* Test for network.host: _ec2_
*/
- @Test
- public void networkHostEc2() throws IOException {
+ public void testNetworkHostEc2() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2_")
.build();
@@ -58,8 +55,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:publicIp_
*/
- @Test
- public void networkHostEc2PublicIp() throws IOException {
+ public void testNetworkHostEc2PublicIp() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:publicIp_")
.build();
@@ -77,8 +73,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:privateIp_
*/
- @Test
- public void networkHostEc2PrivateIp() throws IOException {
+ public void testNetworkHostEc2PrivateIp() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:privateIp_")
.build();
@@ -96,8 +91,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:privateIpv4_
*/
- @Test
- public void networkHostEc2PrivateIpv4() throws IOException {
+ public void testNetworkHostEc2PrivateIpv4() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:privateIpv4_")
.build();
@@ -115,8 +109,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:privateDns_
*/
- @Test
- public void networkHostEc2PrivateDns() throws IOException {
+ public void testNetworkHostEc2PrivateDns() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:privateDns_")
.build();
@@ -134,8 +127,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:publicIpv4_
*/
- @Test
- public void networkHostEc2PublicIpv4() throws IOException {
+ public void testNetworkHostEc2PublicIpv4() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:publicIpv4_")
.build();
@@ -153,8 +145,7 @@ public class Ec2NetworkTests extends ESTestCase {
/**
* Test for network.host: _ec2:publicDns_
*/
- @Test
- public void networkHostEc2PublicDns() throws IOException {
+ public void testNetworkHostEc2PublicDns() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_ec2:publicDns_")
.build();
@@ -173,8 +164,7 @@ public class Ec2NetworkTests extends ESTestCase {
* Test that we don't have any regression with network host core settings such as
* network.host: _local_
*/
- @Test
- public void networkHostCoreLocal() throws IOException {
+ public void testNetworkHostCoreLocal() throws IOException {
Settings nodeSettings = Settings.builder()
.put("network.host", "_local_")
.build();
diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java
index 450ff72ca4..eafd3997b5 100644
--- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java
+++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java
@@ -29,7 +29,10 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.local.LocalTransport;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
import java.util.List;
import java.util.Locale;
@@ -45,7 +48,7 @@ import static org.hamcrest.Matchers.is;
*
* compute/v1/projects/[project-id]/zones/[zone]
*
- * By default, project-id is the test method name, lowercase.
+ * By default, project-id is the test method name, lowercase and missing the "test" prefix.
*
* For example, if you create a test `myNewAwesomeTest` with following settings:
*
@@ -83,6 +86,10 @@ public class GceDiscoveryTests extends ESTestCase {
@Before
public void setProjectName() {
projectName = getTestName().toLowerCase(Locale.ROOT);
+ // Slice off the "test" part of the method names so the project names
+ if (projectName.startsWith("test")) {
+ projectName = projectName.substring("test".length());
+ }
}
@Before
@@ -113,8 +120,7 @@ public class GceDiscoveryTests extends ESTestCase {
return discoveryNodes;
}
- @Test
- public void nodesWithDifferentTagsAndNoTagSet() {
+ public void testNodesWithDifferentTagsAndNoTagSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -124,8 +130,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(2));
}
- @Test
- public void nodesWithDifferentTagsAndOneTagSet() {
+ public void testNodesWithDifferentTagsAndOneTagSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -137,8 +142,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes.get(0).getId(), is("#cloud-test2-0"));
}
- @Test
- public void nodesWithDifferentTagsAndTwoTagSet() {
+ public void testNodesWithDifferentTagsAndTwoTagSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -150,8 +154,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes.get(0).getId(), is("#cloud-test2-0"));
}
- @Test
- public void nodesWithSameTagsAndNoTagSet() {
+ public void testNodesWithSameTagsAndNoTagSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -161,8 +164,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(2));
}
- @Test
- public void nodesWithSameTagsAndOneTagSet() {
+ public void testNodesWithSameTagsAndOneTagSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -173,8 +175,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(2));
}
- @Test
- public void nodesWithSameTagsAndTwoTagsSet() {
+ public void testNodesWithSameTagsAndTwoTagsSet() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.put(GceComputeService.Fields.ZONE, "europe-west1-b")
@@ -185,8 +186,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(2));
}
- @Test
- public void multipleZonesAndTwoNodesInSameZone() {
+ public void testMultipleZonesAndTwoNodesInSameZone() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.putArray(GceComputeService.Fields.ZONE, "us-central1-a", "europe-west1-b")
@@ -196,8 +196,7 @@ public class GceDiscoveryTests extends ESTestCase {
assertThat(discoveryNodes, hasSize(2));
}
- @Test
- public void multipleZonesAndTwoNodesInDifferentZones() {
+ public void testMultipleZonesAndTwoNodesInDifferentZones() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.putArray(GceComputeService.Fields.ZONE, "us-central1-a", "europe-west1-b")
@@ -210,8 +209,7 @@ public class GceDiscoveryTests extends ESTestCase {
/**
* For issue https://github.com/elastic/elasticsearch-cloud-gce/issues/43
*/
- @Test
- public void zeroNode43() {
+ public void testZeroNode43() {
Settings nodeSettings = Settings.builder()
.put(GceComputeService.Fields.PROJECT, projectName)
.putArray(GceComputeService.Fields.ZONE, "us-central1-a", "us-central1-b")
diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java
index 7550cdce7e..dfa41f4c85 100644
--- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java
+++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.cloud.gce.network.GceNameResolver;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.net.InetAddress;
@@ -36,28 +35,24 @@ import static org.hamcrest.Matchers.containsString;
* Related to https://github.com/elastic/elasticsearch/issues/13605
*/
public class GceNetworkTests extends ESTestCase {
-
/**
* Test for network.host: _gce_
*/
- @Test
- public void networkHostGceDefault() throws IOException {
+ public void testNetworkHostGceDefault() throws IOException {
resolveGce("_gce_", InetAddress.getByName("10.240.0.2"));
}
/**
* Test for network.host: _gce:privateIp_
*/
- @Test
- public void networkHostPrivateIp() throws IOException {
+ public void testNetworkHostPrivateIp() throws IOException {
resolveGce("_gce:privateIp_", InetAddress.getByName("10.240.0.2"));
}
/**
* Test for network.host: _gce:hostname_
*/
- @Test
- public void networkHostPrivateDns() throws IOException {
+ public void testNetworkHostPrivateDns() throws IOException {
resolveGce("_gce:hostname_", InetAddress.getByName("localhost"));
}
@@ -65,8 +60,7 @@ public class GceNetworkTests extends ESTestCase {
* Test for network.host: _gce:doesnotexist_
* This should raise an IllegalArgumentException as this setting does not exist
*/
- @Test
- public void networkHostWrongSetting() throws IOException {
+ public void testNetworkHostWrongSetting() throws IOException {
resolveGce("_gce:doesnotexist_", (InetAddress) null);
}
@@ -75,8 +69,7 @@ public class GceNetworkTests extends ESTestCase {
* network.host: _gce:privateIp:0_
* network.host: _gce:privateIp:1_
*/
- @Test
- public void networkHostPrivateIpInterface() throws IOException {
+ public void testNetworkHostPrivateIpInterface() throws IOException {
resolveGce("_gce:privateIp:0_", InetAddress.getByName("10.240.0.2"));
resolveGce("_gce:privateIp:1_", InetAddress.getByName("10.150.0.1"));
}
@@ -85,8 +78,7 @@ public class GceNetworkTests extends ESTestCase {
* Test that we don't have any regression with network host core settings such as
* network.host: _local_
*/
- @Test
- public void networkHostCoreLocal() throws IOException {
+ public void testNetworkHostCoreLocal() throws IOException {
resolveGce("_local_", new NetworkService(Settings.EMPTY).resolveBindHostAddress(NetworkService.DEFAULT_NETWORK_HOST));
}
diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/RetryHttpInitializerWrapperTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/RetryHttpInitializerWrapperTests.java
index 9bbc17feaa..dcbd878bea 100644
--- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/RetryHttpInitializerWrapperTests.java
+++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/RetryHttpInitializerWrapperTests.java
@@ -94,7 +94,6 @@ public class RetryHttpInitializerWrapperTests extends ESTestCase {
}
public void testSimpleRetry() throws Exception {
-
FailThenSuccessBackoffTransport fakeTransport =
new FailThenSuccessBackoffTransport(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, 3);
@@ -153,7 +152,6 @@ public class RetryHttpInitializerWrapperTests extends ESTestCase {
}
public void testIOExceptionRetry() throws Exception {
-
FailThenSuccessBackoffTransport fakeTransport =
new FailThenSuccessBackoffTransport(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, 1, true);
@@ -174,4 +172,3 @@ public class RetryHttpInitializerWrapperTests extends ESTestCase {
assertThat(response.getStatusCode(), equalTo(200));
}
}
-
diff --git a/plugins/discovery-multicast/src/test/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPingTests.java b/plugins/discovery-multicast/src/test/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPingTests.java
index 7ab0aa7ee9..b9be113cdc 100644
--- a/plugins/discovery-multicast/src/test/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPingTests.java
+++ b/plugins/discovery-multicast/src/test/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPingTests.java
@@ -39,14 +39,12 @@ import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.local.LocalTransport;
import org.hamcrest.Matchers;
import org.junit.Assert;
-import org.junit.Test;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
public class MulticastZenPingTests extends ESTestCase {
-
private Settings buildRandomMulticast(Settings settings) {
Settings.Builder builder = Settings.builder().put(settings);
builder.put("discovery.zen.ping.multicast.group", "224.2.3." + randomIntBetween(0, 255));
@@ -58,7 +56,6 @@ public class MulticastZenPingTests extends ESTestCase {
return builder.build();
}
- @Test
public void testSimplePings() throws InterruptedException {
Settings settings = Settings.EMPTY;
settings = buildRandomMulticast(settings);
@@ -132,7 +129,7 @@ public class MulticastZenPingTests extends ESTestCase {
}
}
- @Test @SuppressForbidden(reason = "I bind to wildcard addresses. I am a total nightmare")
+ @SuppressForbidden(reason = "I bind to wildcard addresses. I am a total nightmare")
public void testExternalPing() throws Exception {
Settings settings = Settings.EMPTY;
settings = buildRandomMulticast(settings);
diff --git a/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/IndexedExpressionTests.java b/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/IndexedExpressionTests.java
index b8d7044622..65b47b9233 100644
--- a/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/IndexedExpressionTests.java
+++ b/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/IndexedExpressionTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -37,7 +36,6 @@ import static org.hamcrest.Matchers.containsString;
//TODO: please convert to unit tests!
public class IndexedExpressionTests extends ESIntegTestCase {
-
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal));
@@ -53,7 +51,6 @@ public class IndexedExpressionTests extends ESIntegTestCase {
return Collections.singleton(ExpressionPlugin.class);
}
- @Test
public void testAllOpsDisabledIndexedScripts() throws IOException {
if (randomBoolean()) {
client().preparePutIndexedScript(ExpressionScriptEngineService.NAME, "script1", "{\"script\":\"2\"}").get();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java
index 8ee84f1bcf..9317be70bb 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.avg.Avg;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -47,14 +46,12 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class AvgTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
- @Test
public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
@@ -75,7 +72,6 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -91,7 +87,6 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -107,8 +102,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(avg("avg").field("value"))).execute().actionGet();
@@ -133,7 +127,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("value"))
@@ -148,8 +142,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("value").script(new Script("_value + 1")))
@@ -164,8 +157,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -195,7 +187,6 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -211,8 +202,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("values").script(new Script("_value + 1")))
@@ -227,8 +217,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -245,8 +234,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").script(new Script("doc['value'].value")))
@@ -261,8 +249,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -279,8 +266,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -297,8 +283,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").script(new Script("[ doc['value'].value, doc['value'].value + 1 ]")))
@@ -313,8 +298,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").script(new Script("[ doc['value'].value, doc['value'].value + 1 ]")))
@@ -329,8 +313,7 @@ public class AvgTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketScriptTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketScriptTests.java
index af17e469b2..06119fd6a7 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketScriptTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketScriptTests.java
@@ -34,7 +34,6 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.SimpleValue;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -70,7 +69,7 @@ public class BucketScriptTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -103,9 +102,7 @@ public class BucketScriptTests extends ESIntegTestCase {
return jsonBuilder;
}
- @Test
- public void inlineScript() {
-
+ public void testInlineScript() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -149,9 +146,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScript2() {
-
+ public void testInlineScript2() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -195,9 +190,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptSingleVariable() {
-
+ public void testInlineScriptSingleVariable() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -233,9 +226,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptNamedVars() {
-
+ public void testInlineScriptNamedVars() {
Map<String, String> bucketsPathsMap = new HashMap<>();
bucketsPathsMap.put("foo", "field2Sum");
bucketsPathsMap.put("bar", "field3Sum");
@@ -283,9 +274,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptWithParams() {
-
+ public void testInlineScriptWithParams() {
Map<String, Object> params = new HashMap<>();
params.put("factor", 3);
SearchResponse response = client()
@@ -331,9 +320,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptInsertZeros() {
-
+ public void testInlineScriptInsertZeros() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -379,9 +366,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void indexedScript() {
-
+ public void testIndexedScript() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -425,8 +410,7 @@ public class BucketScriptTests extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx_unmapped")
.addAggregation(
@@ -449,8 +433,7 @@ public class BucketScriptTests extends ESIntegTestCase {
assertThat(deriv.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "idx_unmapped")
.addAggregation(
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java
index 7b14bca98b..2883b74cc1 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -70,7 +69,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -104,9 +103,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
return jsonBuilder;
}
- @Test
- public void inlineScript() {
-
+ public void testInlineScript() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -140,9 +137,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptNoBucketsPruned() {
-
+ public void testInlineScriptNoBucketsPruned() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -176,9 +171,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptNoBucketsLeft() {
-
+ public void testInlineScriptNoBucketsLeft() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -201,9 +194,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
assertThat(buckets.size(), equalTo(0));
}
- @Test
- public void inlineScript2() {
-
+ public void testInlineScript2() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -236,9 +227,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptSingleVariable() {
-
+ public void testInlineScriptSingleVariable() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -267,9 +256,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptNamedVars() {
-
+ public void testInlineScriptNamedVars() {
Map<String, String> bucketPathsMap = new HashMap<>();
bucketPathsMap.put("my_value1", "field2Sum");
bucketPathsMap.put("my_value2", "field3Sum");
@@ -307,9 +294,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptWithParams() {
-
+ public void testInlineScriptWithParams() {
Map<String, Object> params = new HashMap<>();
params.put("threshold", 100);
SearchResponse response = client()
@@ -345,9 +330,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void inlineScriptInsertZeros() {
-
+ public void testInlineScriptInsertZeros() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -380,9 +363,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void indexedScript() {
-
+ public void testIndexedScript() {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -414,9 +395,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
-
+ public void testUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx_unmapped")
.addAggregation(
@@ -439,9 +418,7 @@ public class BucketSelectorTests extends ESIntegTestCase {
assertThat(deriv.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
-
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "idx_unmapped")
.addAggregation(
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java
index 4cd8016030..d893b2767c 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java
@@ -45,7 +45,6 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -54,18 +53,23 @@ import java.util.Collections;
import java.util.concurrent.CyclicBarrier;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
public class BulkTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
- @Test
- public void testBulkUpdate_simple() throws Exception {
+
+ public void testBulkUpdateSimple() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen();
@@ -156,7 +160,6 @@ public class BulkTests extends ESIntegTestCase {
assertThat(((Long) getResponse.getField("field").getValue()), equalTo(4l));
}
- @Test
public void testBulkVersioning() throws Exception {
createIndex("test");
ensureGreen();
@@ -203,9 +206,7 @@ public class BulkTests extends ESIntegTestCase {
assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(21l));
}
- @Test
- public void testBulkUpdate_malformedScripts() throws Exception {
-
+ public void testBulkUpdateMalformedScripts() throws Exception {
createIndex("test");
ensureGreen();
@@ -244,8 +245,7 @@ public class BulkTests extends ESIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse(), nullValue());
}
- @Test
- public void testBulkUpdate_largerVolume() throws Exception {
+ public void testBulkUpdateLargerVolume() throws Exception {
createIndex("test");
ensureGreen();
@@ -378,9 +378,7 @@ public class BulkTests extends ESIntegTestCase {
}
}
- @Test
public void testBulkIndexingWhileInitializing() throws Exception {
-
int replica = randomInt(2);
internalCluster().ensureAtLeastNumDataNodes(1 + replica);
@@ -414,7 +412,6 @@ public class BulkTests extends ESIntegTestCase {
/*
Test for https://github.com/elasticsearch/elasticsearch/issues/3444
*/
- @Test
public void testBulkUpdateDocAsUpsertWithParent() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("parent", "{\"parent\":{}}")
@@ -452,7 +449,6 @@ public class BulkTests extends ESIntegTestCase {
/*
Test for https://github.com/elasticsearch/elasticsearch/issues/3444
*/
- @Test
public void testBulkUpdateUpsertWithParent() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("parent", "{\"parent\":{}}")
@@ -487,7 +483,6 @@ public class BulkTests extends ESIntegTestCase {
/*
* Test for https://github.com/elasticsearch/elasticsearch/issues/8365
*/
- @Test
public void testBulkUpdateChildMissingParentRouting() throws Exception {
assertAcked(prepareCreate("test").addMapping("parent", "{\"parent\":{}}").addMapping("child",
"{\"child\": {\"_parent\": {\"type\": \"parent\"}}}"));
@@ -518,7 +513,6 @@ public class BulkTests extends ESIntegTestCase {
assertThat(bulkResponse.getItems()[3].isFailed(), equalTo(false));
}
- @Test
public void testFailingVersionedUpdatedOnBulk() throws Exception {
createIndex("test");
index("test", "type", "1", "field", "1");
@@ -561,8 +555,8 @@ public class BulkTests extends ESIntegTestCase {
assertThat(successes, equalTo(1));
}
- @Test // issue 4745
- public void preParsingSourceDueToMappingShouldNotBreakCompleteBulkRequest() throws Exception {
+ // issue 4745
+ public void testPreParsingSourceDueToMappingShouldNotBreakCompleteBulkRequest() throws Exception {
XContentBuilder builder = jsonBuilder().startObject()
.startObject("type")
.startObject("_timestamp")
@@ -587,8 +581,8 @@ public class BulkTests extends ESIntegTestCase {
assertExists(get("test", "type", "2"));
}
- @Test // issue 4745
- public void preParsingSourceDueToRoutingShouldNotBreakCompleteBulkRequest() throws Exception {
+ // issue 4745
+ public void testPreParsingSourceDueToRoutingShouldNotBreakCompleteBulkRequest() throws Exception {
XContentBuilder builder = jsonBuilder().startObject()
.startObject("type")
.startObject("_routing")
@@ -615,8 +609,8 @@ public class BulkTests extends ESIntegTestCase {
}
- @Test // issue 4745
- public void preParsingSourceDueToIdShouldNotBreakCompleteBulkRequest() throws Exception {
+ // issue 4745
+ public void testPreParsingSourceDueToIdShouldNotBreakCompleteBulkRequest() throws Exception {
XContentBuilder builder = jsonBuilder().startObject()
.startObject("type")
.startObject("_id")
@@ -641,7 +635,7 @@ public class BulkTests extends ESIntegTestCase {
assertExists(get("test", "type", "48"));
}
- @Test // issue 4987
+ // issue 4987
public void testThatInvalidIndexNamesShouldNotBreakCompleteBulkRequest() {
int bulkEntryCount = randomIntBetween(10, 50);
BulkRequestBuilder builder = client().prepareBulk();
@@ -669,7 +663,7 @@ public class BulkTests extends ESIntegTestCase {
}
}
- @Test // issue 6630
+ // issue 6630
public void testThatFailedUpdateRequestReturnsCorrectType() throws Exception {
BulkResponse indexBulkItemResponse = client().prepareBulk()
.add(new IndexRequest("test", "type", "3").source("{ \"title\" : \"Great Title of doc 3\" }"))
@@ -704,7 +698,7 @@ public class BulkTests extends ESIntegTestCase {
return randomBoolean() ? "test" : "alias";
}
- @Test // issue 6410
+ // issue 6410
public void testThatMissingIndexDoesNotAbortFullBulkRequest() throws Exception{
createIndex("bulkindex1", "bulkindex2");
ensureYellow();
@@ -727,7 +721,7 @@ public class BulkTests extends ESIntegTestCase {
assertThat(bulkResponse.getItems().length, is(5));
}
- @Test // issue 9821
+ // issue 9821
public void testFailedRequestsOnClosedIndex() throws Exception {
createIndex("bulkindex1");
ensureYellow();
@@ -749,7 +743,7 @@ public class BulkTests extends ESIntegTestCase {
assertThat(responseItems[2].getOpType(), is("delete"));
}
- @Test // issue 9821
+ // issue 9821
public void testInvalidIndexNamesCorrectOpType() {
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex("INVALID.NAME").setType("type1").setId("1").setSource("field", 1))
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java
index 37ed5a6890..4c034b9dcb 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -52,7 +51,7 @@ public class CardinalityTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public Settings indexSettings() {
return Settings.builder()
@@ -132,8 +131,7 @@ public class CardinalityTests extends ESIntegTestCase {
return randomBoolean() ? "l_values" : "d_values";
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value"))
.execute().actionGet();
@@ -146,8 +144,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, 0);
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value"))
.execute().actionGet();
@@ -160,8 +157,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void singleValuedString() throws Exception {
+ public void testSingleValuedString() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value"))
.execute().actionGet();
@@ -174,8 +170,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void singleValuedNumeric() throws Exception {
+ public void testSingleValuedNumeric() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField()))
.execute().actionGet();
@@ -188,9 +183,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void singleValuedNumeric_getProperty() throws Exception {
-
+ public void testSingleValuedNumericGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(
global("global").subAggregation(
@@ -216,8 +209,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertThat((double) cardinality.getProperty("value"), equalTo((double) cardinality.getValue()));
}
- @Test
- public void singleValuedNumericHashed() throws Exception {
+ public void testSingleValuedNumericHashed() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField()))
.execute().actionGet();
@@ -230,8 +222,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void multiValuedString() throws Exception {
+ public void testMultiValuedString() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_values"))
.execute().actionGet();
@@ -244,8 +235,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void multiValuedNumeric() throws Exception {
+ public void testMultiValuedNumeric() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false)))
.execute().actionGet();
@@ -258,8 +248,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void multiValuedNumericHashed() throws Exception {
+ public void testMultiValuedNumericHashed() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(true)))
.execute().actionGet();
@@ -272,8 +261,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void singleValuedStringScript() throws Exception {
+ public void testSingleValuedStringScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).script(new Script("doc['str_value'].value")))
@@ -287,8 +275,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void multiValuedStringScript() throws Exception {
+ public void testMultiValuedStringScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).script(new Script("doc['str_values'].values")))
@@ -302,8 +289,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void singleValuedNumericScript() throws Exception {
+ public void testSingleValuedNumericScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).script(
@@ -318,8 +304,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void multiValuedNumericScript() throws Exception {
+ public void testMultiValuedNumericScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).script(
@@ -334,8 +319,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void singleValuedStringValueScript() throws Exception {
+ public void testSingleValuedStringValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value").script(new Script("_value")))
@@ -349,8 +333,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void multiValuedStringValueScript() throws Exception {
+ public void testMultiValuedStringValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_values").script(new Script("_value")))
@@ -364,8 +347,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void singleValuedNumericValueScript() throws Exception {
+ public void testSingleValuedNumericValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField())
@@ -380,8 +362,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs);
}
- @Test
- public void multiValuedNumericValueScript() throws Exception {
+ public void testMultiValuedNumericValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(
cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false))
@@ -396,8 +377,7 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, numDocs * 2);
}
- @Test
- public void asSubAgg() throws Exception {
+ public void testAsSubAgg() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms").field("str_value")
.collectMode(randomFrom(SubAggCollectionMode.values()))
@@ -414,5 +394,4 @@ public class CardinalityTests extends ESIntegTestCase {
assertCount(count, 2);
}
}
-
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java
index 81971d60f0..1362975a92 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java
@@ -77,7 +77,6 @@ import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.elasticsearch.test.rest.client.http.HttpResponse;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -108,7 +107,6 @@ import static org.hamcrest.Matchers.is;
@ClusterScope(scope = SUITE)
public class ContextAndHeaderTransportTests extends ESIntegTestCase {
-
private static final List<ActionRequest> requests = new CopyOnWriteArrayList<>();
private String randomHeaderKey = randomAsciiOfLength(10);
private String randomHeaderValue = randomAsciiOfLength(20);
@@ -157,7 +155,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(RefreshRequest.class);
}
- @Test
public void testThatTermsLookupGetRequestContainsContextAndHeaders() throws Exception {
transportClient().prepareIndex(lookupIndex, "type", "1")
.setSource(jsonBuilder().startObject().array("followers", "foo", "bar", "baz").endObject()).get();
@@ -178,7 +175,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertGetRequestsContainHeaders();
}
- @Test
public void testThatGeoShapeQueryGetRequestContainsContextAndHeaders() throws Exception {
transportClient().prepareIndex(lookupIndex, "type", "1").setSource(jsonBuilder().startObject()
.field("name", "Munich Suburban Area")
@@ -220,7 +216,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertGetRequestsContainHeaders();
}
- @Test
public void testThatMoreLikeThisQueryMultiTermVectorRequestContainsContextAndHeaders() throws Exception {
transportClient().prepareIndex(lookupIndex, "type", "1")
.setSource(jsonBuilder().startObject().field("name", "Star Wars - The new republic").endObject())
@@ -248,7 +243,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(MultiTermVectorsRequest.class);
}
- @Test
public void testThatPercolatingExistingDocumentGetRequestContainsContextAndHeaders() throws Exception {
transportClient().prepareIndex(lookupIndex, ".percolator", "1")
.setSource(jsonBuilder().startObject().startObject("query").startObject("match").field("name", "star wars").endObject().endObject().endObject())
@@ -265,7 +259,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertGetRequestsContainHeaders();
}
- @Test
public void testThatIndexedScriptGetRequestContainsContextAndHeaders() throws Exception {
PutIndexedScriptResponse scriptResponse = transportClient().preparePutIndexedScript(GroovyScriptEngineService.NAME, "my_script",
jsonBuilder().startObject().field("script", "_score * 10").endObject().string()
@@ -291,7 +284,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(PutIndexedScriptRequest.class);
}
- @Test
public void testThatIndexedScriptGetRequestInTemplateQueryContainsContextAndHeaders() throws Exception {
PutIndexedScriptResponse scriptResponse = transportClient()
.preparePutIndexedScript(
@@ -317,7 +309,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(PutIndexedScriptRequest.class);
}
- @Test
public void testThatIndexedScriptGetRequestInReducePhaseContainsContextAndHeaders() throws Exception {
PutIndexedScriptResponse scriptResponse = transportClient().preparePutIndexedScript(GroovyScriptEngineService.NAME, "my_script",
jsonBuilder().startObject().field("script", "_value0 * 10").endObject().string()).get();
@@ -344,7 +335,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(PutIndexedScriptRequest.class);
}
- @Test
public void testThatSearchTemplatesWithIndexedTemplatesGetRequestContainsContextAndHeaders() throws Exception {
PutIndexedScriptResponse scriptResponse = transportClient().preparePutIndexedScript(MustacheScriptEngineService.NAME, "the_template",
jsonBuilder().startObject().startObject("template").startObject("query").startObject("match")
@@ -370,7 +360,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(PutIndexedScriptRequest.class);
}
- @Test
public void testThatIndexedScriptGetRequestInPhraseSuggestContainsContextAndHeaders() throws Exception {
CreateIndexRequestBuilder builder = transportClient().admin().indices().prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -461,8 +450,6 @@ public class ContextAndHeaderTransportTests extends ESIntegTestCase {
assertRequestsContainHeader(PutIndexedScriptRequest.class);
}
-
- @Test
public void testThatRelevantHttpHeadersBecomeRequestHeaders() throws Exception {
String releventHeaderName = "relevant_" + randomHeaderKey;
for (RestController restController : internalCluster().getDataNodeInstances(RestController.class)) {
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java
index cea4a32ab9..d65b469e6e 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java
@@ -40,7 +40,6 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.junit.After;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -54,9 +53,18 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.max;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.stats;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
/**
@@ -69,7 +77,7 @@ public class DateHistogramTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private DateTime date(int month, int day) {
return new DateTime(2012, month, day, 0, 0, DateTimeZone.UTC);
}
@@ -137,8 +145,7 @@ public class DateHistogramTests extends ESIntegTestCase {
return Joda.forPattern(DateFieldMapper.Defaults.DATE_TIME_FORMATTER.format()).printer().withZone(tz).print(key);
}
- @Test
- public void singleValuedField() throws Exception {
+ public void testSingleValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -173,8 +180,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(3l));
}
- @Test
- public void singleValuedField_WithTimeZone() throws Exception {
+ public void testSingleValuedFieldWithTimeZone() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.DAY).minDocCount(1).timeZone("+01:00")).execute()
.actionGet();
@@ -230,8 +236,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
- @Test
- public void singleValuedField_OrderedByKeyAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByKeyAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -254,8 +259,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByKeyDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByKeyDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -277,8 +281,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByCountAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -300,8 +303,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByCountDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -323,8 +325,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.MONTH)
.subAggregation(sum("sum").field("value")))
@@ -381,8 +382,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat((double) propertiesCounts[2], equalTo(15.0));
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.MONTH)
.subAggregation(max("max")))
@@ -427,8 +427,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(max.getValue(), equalTo((double) new DateTime(2012, 3, 23, 0, 0, DateTimeZone.UTC).getMillis()));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -451,8 +450,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -475,8 +473,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregationAsc_Inherited() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationAscInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -499,8 +496,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -523,8 +519,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
@@ -573,8 +568,7 @@ public class DateHistogramTests extends ESIntegTestCase {
[ Mar 23, Apr 24]
*/
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").field("dates").interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -616,8 +610,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(3l));
}
- @Test
- public void multiValuedField_OrderedByKeyDesc() throws Exception {
+ public void testMultiValuedFieldOrderedByKeyDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("dates")
@@ -662,8 +655,7 @@ public class DateHistogramTests extends ESIntegTestCase {
* doc 5: [ Apr 15, May 16]
* doc 6: [ Apr 23, May 24]
*/
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("dates")
@@ -717,8 +709,7 @@ public class DateHistogramTests extends ESIntegTestCase {
* doc 5: [ Apr 15, May 16]
* doc 6: [ Apr 23, May 24]
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("dates")
@@ -782,8 +773,7 @@ public class DateHistogramTests extends ESIntegTestCase {
* Mar 15
* Mar 23
*/
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").script(new Script("doc['date'].value")).interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -818,8 +808,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(3l));
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.script(new Script("doc['date'].value")).interval(DateHistogramInterval.MONTH)
@@ -864,8 +853,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(max.getValue(), equalTo((double) new DateTime(2012, 3, 23, 0, 0, DateTimeZone.UTC).getMillis()));
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo").script(new Script("doc['dates'].values")).interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -918,8 +906,7 @@ public class DateHistogramTests extends ESIntegTestCase {
[ Mar 23, Apr 24]
*/
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.script(new Script("doc['dates'].values")).interval(DateHistogramInterval.MONTH)
@@ -974,8 +961,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat((long) max.getValue(), equalTo(new DateTime(2012, 4, 24, 0, 0, DateTimeZone.UTC).getMillis()));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -988,8 +974,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(dateHistogram("histo").field("date").interval(DateHistogramInterval.MONTH))
.execute().actionGet();
@@ -1024,8 +1009,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(3l));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(dateHistogram("date_histo").interval(1)))
@@ -1048,8 +1032,7 @@ public class DateHistogramTests extends ESIntegTestCase {
}
- @Test
- public void singleValue_WithTimeZone() throws Exception {
+ public void testSingleValueWithTimeZone() throws Exception {
prepareCreate("idx2").addMapping("type", "date", "type=date").execute().actionGet();
IndexRequestBuilder[] reqs = new IndexRequestBuilder[5];
DateTime date = date("2014-03-11T00:00:00+00:00");
@@ -1085,9 +1068,7 @@ public class DateHistogramTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(3l));
}
- @Test
- public void singleValueField_WithExtendedBounds() throws Exception {
-
+ public void testSingleValueFieldWithExtendedBounds() throws Exception {
String pattern = "yyyy-MM-dd";
// we're testing on days, so the base must be rounded to a day
int interval = randomIntBetween(1, 2); // in days
@@ -1202,9 +1183,7 @@ public class DateHistogramTests extends ESIntegTestCase {
* Test date histogram aggregation with hour interval, timezone shift and
* extended bounds (see https://github.com/elastic/elasticsearch/issues/12278)
*/
- @Test
- public void singleValueField_WithExtendedBoundsTimezone() throws Exception {
-
+ public void testSingleValueFieldWithExtendedBoundsTimezone() throws Exception {
String index = "test12278";
prepareCreate(index)
.setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 1).put("index.number_of_replicas", 0))
@@ -1263,9 +1242,7 @@ public class DateHistogramTests extends ESIntegTestCase {
internalCluster().wipeIndices("test12278");
}
- @Test
- public void singleValue_WithMultipleDateFormatsFromMapping() throws Exception {
-
+ public void testSingleValueWithMultipleDateFormatsFromMapping() throws Exception {
String mappingJson = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("date").field("type", "date").field("format", "dateOptionalTime||dd-MM-yyyy").endObject().endObject().endObject().endObject().string();
prepareCreate("idx2").addMapping("type", mappingJson).execute().actionGet();
IndexRequestBuilder[] reqs = new IndexRequestBuilder[5];
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java
index f6425fc6b2..ba4ca38d16 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java
@@ -34,7 +34,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -66,7 +65,7 @@ public class DateRangeTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static IndexRequestBuilder indexDoc(int month, int day, int value) throws Exception {
return client().prepareIndex("idx", "type").setSource(jsonBuilder()
.startObject()
@@ -112,8 +111,7 @@ public class DateRangeTests extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void dateMath() throws Exception {
+ public void testDateMath() throws Exception {
DateRangeBuilder rangeBuilder = dateRange("range");
if (randomBoolean()) {
rangeBuilder.field("date");
@@ -152,8 +150,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0L));
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -199,8 +196,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void singleValueField_WithStringDates() throws Exception {
+ public void testSingleValueFieldWithStringDates() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -246,8 +242,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void singleValueField_WithStringDates_WithCustomFormat() throws Exception {
+ public void testSingleValueFieldWithStringDatesWithCustomFormat() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -294,8 +289,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void singleValueField_WithDateMath() throws Exception {
+ public void testSingleValueFieldWithDateMath() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -341,8 +335,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void singleValueField_WithCustomKey() throws Exception {
+ public void testSingleValueFieldWithCustomKey() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -397,8 +390,7 @@ public class DateRangeTests extends ESIntegTestCase {
Mar 23, 6
*/
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -464,8 +456,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat((long) propertiesDocCounts[2], equalTo(numDocs - 4l));
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("date")
@@ -530,8 +521,7 @@ public class DateRangeTests extends ESIntegTestCase {
Mar 23, Apr 24 6
*/
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("dates")
@@ -587,8 +577,7 @@ public class DateRangeTests extends ESIntegTestCase {
*/
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("dates")
@@ -632,7 +621,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 1l));
}
-
+
/*
Feb 2, Mar 3, 1
@@ -643,8 +632,7 @@ public class DateRangeTests extends ESIntegTestCase {
Apr 23, May 24 6
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("dates")
@@ -696,8 +684,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(max, notNullValue());
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.script(new Script("doc['date'].value"))
@@ -743,8 +730,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -796,7 +782,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(max, notNullValue());
}
-
+
/*
Jan 2, Feb 3, 1
@@ -807,8 +793,7 @@ public class DateRangeTests extends ESIntegTestCase {
Mar 23, Apr 24 6
*/
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -851,8 +836,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 2l));
}
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.script(new Script("doc['dates'].values")).addUnboundedTo(date(2, 15))
@@ -904,8 +888,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(min.getValue(), equalTo((double) date(2, 15).getMillis()));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet();
SearchResponse response = client().prepareSearch("idx_unmapped")
@@ -953,8 +936,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void unmapped_WithStringDates() throws Exception {
+ public void testUnmappedWithStringDates() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(dateRange("range")
.field("date")
@@ -1000,8 +982,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(dateRange("range")
.field("date")
@@ -1047,8 +1028,7 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(dateRange("date_range").addRange("0-1", 0, 1)))
@@ -1071,6 +1051,5 @@ public class DateRangeTests extends ESIntegTestCase {
assertThat(((DateTime) buckets.get(0).getTo()).getMillis(), equalTo(1l));
assertThat(buckets.get(0).getDocCount(), equalTo(0l));
assertThat(buckets.get(0).getAggregations().asList().isEmpty(), is(true));
-
}
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java
index 78398a1f6a..d0de4c7fd8 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java
@@ -38,7 +38,6 @@ import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStat
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -77,7 +76,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static final int NUM_DOCS = 5; // TODO: randomize the size?
private static final String SINGLE_VALUED_FIELD_NAME = "d_value";
private static final String MULTI_VALUED_FIELD_NAME = "d_values";
@@ -233,9 +232,8 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
return bucket.getKeyAsString();
}
- @Test
// the main purpose of this test is to make sure we're not allocating 2GB of memory per shard
- public void sizeIsZero() {
+ public void testSizeIsZero() {
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -252,8 +250,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(100));
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -277,8 +274,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_WithMaxSize() throws Exception {
+ public void testSingleValueFieldWithMaxSize() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -303,9 +299,8 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
}
-
- @Test
- public void singleValueFieldWithFiltering() throws Exception {
+
+ public void testSingleValueFieldWithFiltering() throws Exception {
double includes[] = { 1, 2, 3, 98.2 };
double excludes[] = { 2, 4, 99 };
double empty[] = {};
@@ -334,10 +329,8 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(bucket.getDocCount(), equalTo(1l));
}
}
-
- @Test
- public void singleValueField_OrderedByTermAsc() throws Exception {
+ public void testSingleValueFieldOrderedByTermAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -363,8 +356,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_OrderedByTermDesc() throws Exception {
+ public void testSingleValueFieldOrderedByTermDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -390,8 +382,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -425,8 +416,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -454,8 +444,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -480,8 +469,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -509,8 +497,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -539,8 +526,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript_NotUnique() throws Exception {
+ public void testMultiValuedFieldWithValueScriptNotUnique() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -580,8 +566,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -618,8 +603,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -643,8 +627,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -672,8 +655,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -701,9 +683,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued_WithAggregatorInherited_NoExplicitType() throws Exception {
-
+ public void testScriptMultiValuedWithAggregatorInheritedNoExplicitType() throws Exception {
// since no type is explicitly defined, es will assume all values returned by the script to be strings (bytes),
// so the aggregation should fail, since the "sum" aggregation can only operation on numeric values.
@@ -725,8 +705,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void script_MultiValued_WithAggregatorInherited_WithExplicitType() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInheritedWithExplicitType() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
@@ -763,8 +742,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -781,8 +759,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped", "idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -806,8 +783,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0)
@@ -826,8 +802,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().isEmpty(), is(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -856,8 +831,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscWithSubTermsAgg() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscWithSubTermsAgg() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -902,8 +876,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleBucketSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleBucketSubAggregationAsc() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client()
.prepareSearch("idx")
@@ -940,8 +913,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc_MultiHierarchyLevels() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client()
.prepareSearch("idx")
@@ -998,8 +970,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(max.getValue(), equalTo(asc ? 4.0 : 2.0));
}
- @Test
- public void singleValuedField_OrderedByMissingSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByMissingSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1016,8 +987,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1039,8 +1009,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithUknownMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithUknownMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1059,8 +1028,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithoutMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithoutMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1079,8 +1047,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1109,11 +1076,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(avg, notNullValue());
assertThat(avg.getValue(), equalTo((double) i));
}
-
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1140,11 +1105,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(stats, notNullValue());
assertThat(stats.getMax(), equalTo((double) i));
}
-
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1171,11 +1134,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
assertThat(stats, notNullValue());
assertThat(stats.getMax(), equalTo((double) i));
}
-
}
- @Test
- public void singleValuedField_OrderedByMultiValueExtendedStatsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueExtendedStatsAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1205,8 +1166,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void script_Score() {
+ public void testScriptScore() {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -1232,44 +1192,37 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
double[] expectedKeys = new double[] { 1, 2, 4, 3, 7, 6, 5 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
double[] expectedKeys = new double[] { 1, 2, 3, 4, 5, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
double[] expectedKeys = new double[] { 5, 6, 7, 3, 4, 2, 1 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", false), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
double[] expectedKeys = new double[] { 6, 7, 3, 4, 5, 1, 2 };
assertMultiSortResponse(expectedKeys, Terms.Order.count(true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
double[] expectedKeys = new double[] { 6, 7, 3, 5, 4, 1, 2 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("sum_d", true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedByThreeCriteria() throws Exception {
+ public void testSingleValuedFieldOrderedByThreeCriteria() throws Exception {
double[] expectedKeys = new double[] { 2, 1, 4, 5, 3, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.count(false), Terms.Order.aggregation("sum_d", false), Terms.Order.aggregation("avg_l", false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
double[] expectedKeys = new double[] { 1, 2, 3, 4, 5, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true));
}
@@ -1305,8 +1258,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void otherDocCount() {
+ public void testOtherDocCount() {
testOtherDocCount(SINGLE_VALUED_FIELD_NAME, MULTI_VALUED_FIELD_NAME);
}
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java
index 47cdc42987..67ddc231e9 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -49,7 +48,6 @@ import static org.hamcrest.Matchers.sameInstance;
*
*/
public class ExtendedStatsTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
@@ -70,9 +68,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(extendedStats("stats")))
@@ -99,7 +95,6 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -124,7 +119,6 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -148,9 +142,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
checkUpperLowerBounds(stats, sigma);
}
- @Test
public void testSingleValuedFieldDefaultSigma() throws Exception {
-
// Same as previous test, but uses a default value for sigma
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -204,9 +196,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
-
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(extendedStats("stats").field("value"))).execute().actionGet();
@@ -252,8 +242,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
@@ -277,8 +266,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -302,8 +290,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
double sigma = randomDouble() * randomIntBetween(1, 10);
@@ -331,7 +318,6 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -356,8 +342,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -381,8 +366,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
double sigma = randomDouble() * randomIntBetween(1, 10);
@@ -410,8 +394,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -435,8 +418,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
double sigma = randomDouble() * randomIntBetween(1, 10);
@@ -463,8 +445,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
double sigma = randomDouble() * randomIntBetween(1, 10);
@@ -491,8 +472,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -516,8 +496,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -543,8 +522,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
double sigma = randomDouble() * randomIntBetween(1, 10);
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java
index 8b7cdba511..22bb778c7b 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -52,7 +51,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
public class FunctionScoreTests extends ESIntegTestCase {
-
static final String TYPE = "type";
static final String INDEX = "index";
@@ -60,9 +58,7 @@ public class FunctionScoreTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
- @Test
public void testScriptScoresNested() throws IOException {
createIndex(INDEX);
ensureYellow();
@@ -84,7 +80,6 @@ public class FunctionScoreTests extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).score(), equalTo(1.0f));
}
- @Test
public void testScriptScoresWithAgg() throws IOException {
createIndex(INDEX);
ensureYellow();
@@ -132,7 +127,6 @@ public class FunctionScoreTests extends ESIntegTestCase {
}
}
- @Test
public void testMinScoreFunctionScoreManyDocsAndRandomMinScore() throws IOException, ExecutionException, InterruptedException {
List<IndexRequestBuilder> docs = new ArrayList<>();
int numDocs = randomIntBetween(1, 100);
@@ -175,7 +169,6 @@ public class FunctionScoreTests extends ESIntegTestCase {
}
}
- @Test
public void testWithEmptyFunctions() throws IOException, ExecutionException, InterruptedException {
assertAcked(prepareCreate("test"));
ensureYellow();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java
index 4e601c2389..066645e701 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -66,14 +65,12 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class GeoDistanceTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
- @Test
- public void simpleDistanceTests() throws Exception {
+
+ public void testSimpleDistance() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("location").field("type", "geo_point").field("lat_lon", true)
.startObject("fielddata").field("format", randomNumericFieldDataFormat()).endObject().endObject().endObject()
@@ -225,7 +222,6 @@ public class GeoDistanceTests extends ESIntegTestCase {
assertOrderedSearchHits(searchResponse, "7", "2", "6", "5", "4", "3", "1");
}
- @Test
public void testDistanceSortingMVFields() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("locations").field("type", "geo_point").field("lat_lon", true)
@@ -360,7 +356,6 @@ public class GeoDistanceTests extends ESIntegTestCase {
containsString("sort_mode [sum] isn't supported for sorting by geo distance"));
}
- @Test
// Regression bug: https://github.com/elasticsearch/elasticsearch/issues/2851
public void testDistanceSortingWithMissingGeoPoint() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
@@ -408,8 +403,7 @@ public class GeoDistanceTests extends ESIntegTestCase {
assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).doubleValue(), closeTo(5286d, 10d));
}
- @Test
- public void distanceScriptTests() throws Exception {
+ public void testDistanceScript() throws Exception {
double source_lat = 32.798;
double source_long = -117.151;
double target_lat = 32.81;
@@ -489,8 +483,6 @@ public class GeoDistanceTests extends ESIntegTestCase {
closeTo(GeoDistance.PLANE.calculate(source_lat, source_long, target_lat, target_long, DistanceUnit.MILES), 0.0001d));
}
-
- @Test
public void testDistanceSortingNestedFields() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("company")
.startObject("properties")
@@ -654,7 +646,6 @@ public class GeoDistanceTests extends ESIntegTestCase {
/**
* Issue 3073
*/
- @Test
public void testGeoDistanceFilter() throws IOException {
double lat = 40.720611;
double lon = -73.998776;
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java
index b22455ad0b..bb6bebb973 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesMethod;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -42,22 +41,26 @@ import java.util.Map;
import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.percentileRanks;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
*
*/
public class HDRPercentileRanksTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
- private static double[] randomPercents(long minValue, long maxValue) {
+ private static double[] randomPercents(long minValue, long maxValue) {
final int length = randomIntBetween(1, 20);
final double[] percents = new double[length];
for (int i = 0; i < percents.length; ++i) {
@@ -107,9 +110,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
@@ -137,7 +138,6 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -159,7 +159,6 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
@@ -177,8 +176,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client()
@@ -205,7 +203,6 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
- @Test
public void testSingleValuedFieldOutsideRange() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = new double[] { minValue - 1, maxValue + 1 };
@@ -223,8 +220,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client()
@@ -241,8 +237,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client()
@@ -259,8 +254,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
@@ -280,7 +274,6 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues, maxValues);
@@ -298,8 +291,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
SearchResponse searchResponse = client()
@@ -315,8 +307,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1, sigDigits);
}
- @Test
- public void testMultiValuedField_WithValueScript_Reverse() throws Exception {
+ public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(20 - maxValues, 20 - minValues);
SearchResponse searchResponse = client()
@@ -333,8 +324,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
@@ -354,8 +344,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client()
@@ -372,8 +361,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
@@ -393,8 +381,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
@@ -414,8 +401,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client()
@@ -432,8 +418,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client()
@@ -450,8 +435,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
int sigDigits = randomSignificantDigits();
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
@@ -473,7 +457,6 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1, sigDigits);
}
- @Test
public void testOrderBySubAggregation() {
int sigDigits = randomSignificantDigits();
boolean asc = randomBoolean();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java
index 07e9d1097f..c40b0fdd53 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesMethod;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -42,20 +41,26 @@ import java.util.List;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
*
*/
public class HDRPercentilesTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static double[] randomPercentiles() {
final int length = randomIntBetween(1, 20);
final double[] percentiles = new double[length];
@@ -106,7 +111,6 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testEmptyAggregation() throws Exception {
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -136,7 +140,6 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -158,7 +161,6 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomIntBetween(1, 5);
@@ -177,8 +179,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -207,8 +208,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -226,8 +226,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -244,8 +243,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -265,7 +263,6 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
@@ -284,8 +281,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -301,8 +297,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1, sigDigits);
}
- @Test
- public void testMultiValuedField_WithValueScript_Reverse() throws Exception {
+ public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -319,8 +314,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -340,8 +334,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -358,8 +351,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -379,8 +371,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -400,8 +391,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -418,8 +408,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
SearchResponse searchResponse = client()
@@ -436,8 +425,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -459,7 +447,6 @@ public class HDRPercentilesTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1, sigDigits);
}
- @Test
public void testOrderBySubAggregation() {
int sigDigits = randomSignificantDigits();
boolean asc = randomBoolean();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java
index e36e38e956..d6799835a0 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.search.aggregations.metrics.stats.Stats;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -79,7 +78,7 @@ public class HistogramTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -128,8 +127,7 @@ public class HistogramTests extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void singleValuedField() throws Exception {
+ public void testSingleValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval))
.execute().actionGet();
@@ -182,8 +180,7 @@ public class HistogramTests extends ESIntegTestCase {
* Shift buckets by random offset between [2..interval]. From setup we have 1 doc per values from 1..numdocs.
* Special care needs to be taken for expecations on counts in first and last bucket.
*/
- @Test
- public void singleValuedField_withRandomOffset() throws Exception {
+ public void testSingleValuedFieldWithRandomOffset() throws Exception {
int offset = randomIntBetween(2, interval);
SearchResponse response = client()
.prepareSearch("idx")
@@ -218,8 +215,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByKeyAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByKeyAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.KEY_ASC))
.execute().actionGet();
@@ -242,8 +238,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByKeyDesc() throws Exception {
+ public void testsingleValuedFieldOrderedByKeyDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.KEY_DESC))
.execute().actionGet();
@@ -266,8 +261,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByCountAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.COUNT_ASC))
.execute().actionGet();
@@ -296,8 +290,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByCountDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.COUNT_DESC))
.execute().actionGet();
@@ -326,8 +319,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -367,8 +359,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
.subAggregation(sum("sum")))
@@ -402,8 +393,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("sum", true))
.subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -443,8 +433,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("sum", false))
.subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
@@ -484,8 +473,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregationAsc_Inherited() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationAscInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("stats.sum", true))
.subAggregation(stats("stats")))
@@ -525,8 +513,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("stats.sum", false))
.subAggregation(stats("stats").field(SINGLE_VALUED_FIELD_NAME)))
@@ -566,8 +553,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySubAggregationDesc_DeepOrderPath() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationDescDeepOrderPath() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("filter>max", asc))
@@ -605,8 +591,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).script(new Script("_value + 1")).interval(interval))
.execute().actionGet();
@@ -634,8 +619,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(MULTI_VALUED_FIELD_NAME).interval(interval))
.execute().actionGet();
@@ -657,8 +641,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void multiValuedField_OrderedByKeyDesc() throws Exception {
+ public void testMultiValuedFieldOrderedByKeyDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(MULTI_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.KEY_DESC))
.execute().actionGet();
@@ -681,8 +664,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(MULTI_VALUED_FIELD_NAME).script(new Script("_value + 1")).interval(interval))
.execute().actionGet();
@@ -715,8 +697,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
histogram("histo")
@@ -765,8 +746,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").script(new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value")).interval(interval))
.execute().actionGet();
@@ -787,8 +767,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -822,8 +801,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']")).interval(interval))
.execute().actionGet();
@@ -844,8 +822,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -879,8 +856,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval))
.execute().actionGet();
@@ -894,8 +870,7 @@ public class HistogramTests extends ESIntegTestCase {
assertThat(histo.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval))
.execute().actionGet();
@@ -917,8 +892,7 @@ public class HistogramTests extends ESIntegTestCase {
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0)
@@ -938,8 +912,7 @@ public class HistogramTests extends ESIntegTestCase {
assertThat(histo.getBuckets().isEmpty(), is(true));
}
- @Test
- public void singleValuedField_WithExtendedBounds() throws Exception {
+ public void testSingleValuedFieldWithExtendedBounds() throws Exception {
int lastDataBucketKey = (numValueBuckets - 1) * interval;
// randomizing the number of buckets on the min bound
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java
index 7ade58ce6c..b93d090b56 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.search.aggregations.metrics.max.Max;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -61,7 +60,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
{
@@ -122,8 +121,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -143,25 +141,25 @@ public class IPv4RangeTests extends ESIntegTestCase {
Range.Bucket bucket = buckets.get(0);
assertThat(bucket, notNullValue());
- assertThat((String) (String) bucket.getKey(), equalTo("*-10.0.0.100"));
- assertThat(((Number) ((Number) bucket.getFrom())).doubleValue(), equalTo(Double.NEGATIVE_INFINITY));
+ assertThat((String) bucket.getKey(), equalTo("*-10.0.0.100"));
+ assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo(Double.NEGATIVE_INFINITY));
assertThat(bucket.getFromAsString(), nullValue());
assertThat(bucket.getToAsString(), equalTo("10.0.0.100"));
- assertThat(((Number) ((Number) bucket.getTo())).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100")));
+ assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100")));
assertThat(bucket.getDocCount(), equalTo(100l));
bucket = buckets.get(1);
assertThat(bucket, notNullValue());
- assertThat((String) (String) bucket.getKey(), equalTo("10.0.0.100-10.0.0.200"));
+ assertThat((String) bucket.getKey(), equalTo("10.0.0.100-10.0.0.200"));
assertThat(bucket.getFromAsString(), equalTo("10.0.0.100"));
- assertThat(((Number) ((Number) bucket.getFrom())).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100")));
+ assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100")));
assertThat(bucket.getToAsString(), equalTo("10.0.0.200"));
- assertThat(((Number) ((Number) bucket.getTo())).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200")));
+ assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200")));
assertThat(bucket.getDocCount(), equalTo(100l));
bucket = buckets.get(2);
assertThat(bucket, notNullValue());
- assertThat((String) (String) bucket.getKey(), equalTo("10.0.0.200-*"));
+ assertThat((String) bucket.getKey(), equalTo("10.0.0.200-*"));
assertThat(bucket.getFromAsString(), equalTo("10.0.0.200"));
assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200")));
assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY));
@@ -169,8 +167,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(55l));
}
- @Test
- public void singleValueField_WithMaskRange() throws Exception {
+ public void testSingleValueFieldWithMaskRange() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -206,8 +203,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(127l)); // include 10.0.0.128
}
- @Test
- public void singleValueField_WithCustomKey() throws Exception {
+ public void testSingleValueFieldWithCustomKey() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -253,8 +249,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(55l));
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -322,8 +317,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat((double) propertiesCounts[2], equalTo((double) 55 * 3));
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -379,8 +373,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.254")));
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -440,8 +433,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
[255, 256]
*/
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ips")
@@ -487,8 +479,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(56l));
}
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -532,8 +523,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(56l));
}
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -586,8 +576,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.255")));
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -631,8 +620,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(55l));
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -686,8 +674,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.254")));
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -731,8 +718,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(56l));
}
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -786,8 +772,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.255")));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(ipRange("range")
.field("ip")
@@ -833,8 +818,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(ipRange("range")
.field("ip")
@@ -880,8 +864,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(55l));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -906,8 +889,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertThat(buckets.get(0).getDocCount(), equalTo(0l));
}
- @Test
- public void mask0() {
+ public void testMask0() {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(ipRange("range")
.field("ip")
@@ -930,10 +912,7 @@ public class IPv4RangeTests extends ESIntegTestCase {
assertEquals(255l, bucket.getDocCount());
}
-
- @Test
- public void mask0SpecialIps() {
-
+ public void testMask0SpecialIps() {
SearchResponse response = client().prepareSearch("range_idx")
.addAggregation(ipRange("range")
.field("ip")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java
index b1c2a332f1..f972f3b894 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java
@@ -33,7 +33,6 @@ import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -49,7 +48,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitC
import static org.hamcrest.Matchers.equalTo;
public class IndexLookupTests extends ESIntegTestCase {
-
String includeAllFlag = "_FREQUENCIES | _OFFSETS | _PAYLOADS | _POSITIONS | _CACHE";
String includeAllWithoutRecordFlag = "_FREQUENCIES | _OFFSETS | _PAYLOADS | _POSITIONS ";
private HashMap<String, List<Object>> expectedEndOffsetsArray;
@@ -62,7 +60,7 @@ public class IndexLookupTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
void initTestData() throws InterruptedException, ExecutionException, IOException {
emptyArray = new HashMap<>();
List<Object> empty1 = new ArrayList<>();
@@ -154,9 +152,7 @@ public class IndexLookupTests extends ESIntegTestCase {
ensureGreen();
}
- @Test
public void testTwoScripts() throws Exception {
-
initTestData();
// check term frequencies for 'a'
@@ -176,9 +172,7 @@ public class IndexLookupTests extends ESIntegTestCase {
}
- @Test
public void testCallWithDifferentFlagsFails() throws Exception {
-
initTestData();
// should throw an exception, we cannot call with different flags twice
@@ -212,9 +206,7 @@ public class IndexLookupTests extends ESIntegTestCase {
}
}
- @Test
public void testDocumentationExample() throws Exception {
-
initTestData();
Script script = new Script("term = _index['float_payload_field'].get('b'," + includeAllFlag
@@ -237,9 +229,7 @@ public class IndexLookupTests extends ESIntegTestCase {
checkValueInEachDoc(script, zeroArray, 3);
}
- @Test
public void testIteratorAndRecording() throws Exception {
-
initTestData();
// call twice with record: should work as expected
@@ -300,9 +290,7 @@ public class IndexLookupTests extends ESIntegTestCase {
return new Script(script);
}
- @Test
public void testFlags() throws Exception {
-
initTestData();
// check default flag
@@ -409,7 +397,6 @@ public class IndexLookupTests extends ESIntegTestCase {
assertThat(nullCounter, equalTo(expectedArray.size()));
}
- @Test
public void testAllExceptPosAndOffset() throws Exception {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("float_payload_field").field("type", "string").field("index_options", "offsets").field("term_vector", "no")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java
index d5c2f55e15..a3a786a140 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java
@@ -26,18 +26,17 @@ import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.script.groovy.GroovyPlugin;
-import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.script.ScriptService.ScriptType;
+import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.script.groovy.GroovyScriptEngineService;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,7 +52,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class IndexedScriptTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
@@ -73,7 +71,6 @@ public class IndexedScriptTests extends ESIntegTestCase {
return builder.build();
}
- @Test
public void testFieldIndexedScript() throws ExecutionException, InterruptedException {
List<IndexRequestBuilder> builders = new ArrayList<>();
builders.add(client().prepareIndex(ScriptService.SCRIPT_INDEX, "groovy", "script1").setSource("{" +
@@ -112,7 +109,6 @@ public class IndexedScriptTests extends ESIntegTestCase {
}
// Relates to #10397
- @Test
public void testUpdateScripts() {
createIndex("test_index");
ensureGreen("test_index");
@@ -121,7 +117,7 @@ public class IndexedScriptTests extends ESIntegTestCase {
int iterations = randomIntBetween(2, 11);
for (int i = 1; i < iterations; i++) {
- PutIndexedScriptResponse response =
+ PutIndexedScriptResponse response =
client().preparePutIndexedScript(GroovyScriptEngineService.NAME, "script1", "{\"script\":\"" + i + "\"}").get();
assertEquals(i, response.getVersion());
SearchResponse searchResponse = client()
@@ -136,7 +132,6 @@ public class IndexedScriptTests extends ESIntegTestCase {
}
}
- @Test
public void testDisabledUpdateIndexedScriptsOnly() {
if (randomBoolean()) {
client().preparePutIndexedScript(GroovyScriptEngineService.NAME, "script1", "{\"script\":\"2\"}").get();
@@ -155,7 +150,6 @@ public class IndexedScriptTests extends ESIntegTestCase {
}
}
- @Test
public void testDisabledAggsDynamicScripts() {
//dynamic scripts don't need to be enabled for an indexed script to be indexed and later on executed
if (randomBoolean()) {
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java
index 041838552e..86d17556ff 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java
@@ -98,22 +98,36 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.*;
+import org.elasticsearch.transport.Transport;
+import org.elasticsearch.transport.TransportChannel;
+import org.elasticsearch.transport.TransportModule;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestHandler;
+import org.elasticsearch.transport.TransportService;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
-import java.util.*;
-import java.util.concurrent.Callable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Supplier;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.instanceOf;
@ClusterScope(scope = Scope.SUITE, numClientNodes = 1, minNumDataNodes = 2)
public class IndicesRequestTests extends ESIntegTestCase {
-
private final List<String> indices = new ArrayList<>();
@Override
@@ -159,7 +173,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
indices.clear();
}
- @Test
public void testGetFieldMappings() {
String getFieldMappingsShardAction = GetFieldMappingsAction.NAME + "[index][s]";
interceptTransportActions(getFieldMappingsShardAction);
@@ -172,7 +185,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(getFieldMappingsRequest, getFieldMappingsShardAction);
}
- @Test
public void testAnalyze() {
String analyzeShardAction = AnalyzeAction.NAME + "[s]";
interceptTransportActions(analyzeShardAction);
@@ -185,7 +197,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(analyzeRequest, analyzeShardAction);
}
- @Test
public void testIndex() {
String[] indexShardActions = new String[]{IndexAction.NAME, IndexAction.NAME + "[r]"};
interceptTransportActions(indexShardActions);
@@ -197,7 +208,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(indexRequest, indexShardActions);
}
- @Test
public void testDelete() {
String[] deleteShardActions = new String[]{DeleteAction.NAME, DeleteAction.NAME + "[r]"};
interceptTransportActions(deleteShardActions);
@@ -209,7 +219,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(deleteRequest, deleteShardActions);
}
- @Test
public void testUpdate() {
//update action goes to the primary, index op gets executed locally, then replicated
String[] updateShardActions = new String[]{UpdateAction.NAME + "[s]", IndexAction.NAME + "[r]"};
@@ -225,7 +234,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(updateRequest, updateShardActions);
}
- @Test
public void testUpdateUpsert() {
//update action goes to the primary, index op gets executed locally, then replicated
String[] updateShardActions = new String[]{UpdateAction.NAME + "[s]", IndexAction.NAME + "[r]"};
@@ -240,7 +248,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(updateRequest, updateShardActions);
}
- @Test
public void testUpdateDelete() {
//update action goes to the primary, delete op gets executed locally, then replicated
String[] updateShardActions = new String[]{UpdateAction.NAME + "[s]", DeleteAction.NAME + "[r]"};
@@ -256,7 +263,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(updateRequest, updateShardActions);
}
- @Test
public void testBulk() {
String[] bulkShardActions = new String[]{BulkAction.NAME + "[s]", BulkAction.NAME + "[s][r]"};
interceptTransportActions(bulkShardActions);
@@ -288,7 +294,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(indices, bulkShardActions);
}
- @Test
public void testGet() {
String getShardAction = GetAction.NAME + "[s]";
interceptTransportActions(getShardAction);
@@ -300,7 +305,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(getRequest, getShardAction);
}
- @Test
public void testExplain() {
String explainShardAction = ExplainAction.NAME + "[s]";
interceptTransportActions(explainShardAction);
@@ -312,7 +316,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(explainRequest, explainShardAction);
}
- @Test
public void testTermVector() {
String termVectorShardAction = TermVectorsAction.NAME + "[s]";
interceptTransportActions(termVectorShardAction);
@@ -324,7 +327,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(termVectorsRequest, termVectorShardAction);
}
- @Test
public void testMultiTermVector() {
String multiTermVectorsShardAction = MultiTermVectorsAction.NAME + "[shard][s]";
interceptTransportActions(multiTermVectorsShardAction);
@@ -343,7 +345,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(indices, multiTermVectorsShardAction);
}
- @Test
public void testMultiGet() {
String multiGetShardAction = MultiGetAction.NAME + "[shard][s]";
interceptTransportActions(multiGetShardAction);
@@ -362,7 +363,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(indices, multiGetShardAction);
}
- @Test
public void testExists() {
String existsShardAction = ExistsAction.NAME + "[s]";
interceptTransportActions(existsShardAction);
@@ -374,7 +374,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(existsRequest, existsShardAction);
}
- @Test
public void testFlush() {
String[] indexShardActions = new String[]{TransportShardFlushAction.NAME + "[r]", TransportShardFlushAction.NAME};
interceptTransportActions(indexShardActions);
@@ -387,7 +386,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(Arrays.asList(indices), indexShardActions);
}
- @Test
public void testOptimize() {
String optimizeShardAction = OptimizeAction.NAME + "[n]";
interceptTransportActions(optimizeShardAction);
@@ -399,7 +397,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(optimizeRequest, optimizeShardAction);
}
- @Test
public void testRefresh() {
String[] indexShardActions = new String[]{TransportShardRefreshAction.NAME + "[r]", TransportShardRefreshAction.NAME};
interceptTransportActions(indexShardActions);
@@ -412,7 +409,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(Arrays.asList(indices), indexShardActions);
}
- @Test
public void testClearCache() {
String clearCacheAction = ClearIndicesCacheAction.NAME + "[n]";
interceptTransportActions(clearCacheAction);
@@ -424,7 +420,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(clearIndicesCacheRequest, clearCacheAction);
}
- @Test
public void testRecovery() {
String recoveryAction = RecoveryAction.NAME + "[n]";
interceptTransportActions(recoveryAction);
@@ -436,7 +431,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(recoveryRequest, recoveryAction);
}
- @Test
public void testSegments() {
String segmentsAction = IndicesSegmentsAction.NAME + "[n]";
interceptTransportActions(segmentsAction);
@@ -448,7 +442,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(segmentsRequest, segmentsAction);
}
- @Test
public void testIndicesStats() {
String indicesStats = IndicesStatsAction.NAME + "[n]";
interceptTransportActions(indicesStats);
@@ -460,7 +453,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(indicesStatsRequest, indicesStats);
}
- @Test
public void testSuggest() {
String suggestAction = SuggestAction.NAME + "[s]";
interceptTransportActions(suggestAction);
@@ -472,7 +464,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(suggestRequest, suggestAction);
}
- @Test
public void testValidateQuery() {
String validateQueryShardAction = ValidateQueryAction.NAME + "[s]";
interceptTransportActions(validateQueryShardAction);
@@ -484,7 +475,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(validateQueryRequest, validateQueryShardAction);
}
- @Test
public void testPercolate() {
String percolateShardAction = PercolateAction.NAME + "[s]";
interceptTransportActions(percolateShardAction);
@@ -503,7 +493,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(percolateRequest, percolateShardAction);
}
- @Test
public void testMultiPercolate() {
String multiPercolateShardAction = MultiPercolateAction.NAME + "[shard][s]";
interceptTransportActions(multiPercolateShardAction);
@@ -531,7 +520,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertIndicesSubset(indices, multiPercolateShardAction);
}
- @Test
public void testOpenIndex() {
interceptTransportActions(OpenIndexAction.NAME);
@@ -542,7 +530,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(openIndexRequest, OpenIndexAction.NAME);
}
- @Test
public void testCloseIndex() {
interceptTransportActions(CloseIndexAction.NAME);
@@ -553,7 +540,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(closeIndexRequest, CloseIndexAction.NAME);
}
- @Test
public void testDeleteIndex() {
interceptTransportActions(DeleteIndexAction.NAME);
@@ -565,7 +551,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(deleteIndexRequest, DeleteIndexAction.NAME);
}
- @Test
public void testGetMappings() {
interceptTransportActions(GetMappingsAction.NAME);
@@ -576,7 +561,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(getMappingsRequest, GetMappingsAction.NAME);
}
- @Test
public void testPutMapping() {
interceptTransportActions(PutMappingAction.NAME);
@@ -587,7 +571,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(putMappingRequest, PutMappingAction.NAME);
}
- @Test
public void testGetSettings() {
interceptTransportActions(GetSettingsAction.NAME);
@@ -598,7 +581,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(getSettingsRequest, GetSettingsAction.NAME);
}
- @Test
public void testUpdateSettings() {
interceptTransportActions(UpdateSettingsAction.NAME);
@@ -609,7 +591,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndices(updateSettingsRequest, UpdateSettingsAction.NAME);
}
- @Test
public void testSearchQueryThenFetch() throws Exception {
interceptTransportActions(SearchServiceTransportAction.QUERY_ACTION_NAME,
SearchServiceTransportAction.FETCH_ID_ACTION_NAME, SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
@@ -631,7 +612,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndicesOptionalRequests(searchRequest, SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
}
- @Test
public void testSearchDfsQueryThenFetch() throws Exception {
interceptTransportActions(SearchServiceTransportAction.DFS_ACTION_NAME, SearchServiceTransportAction.QUERY_ID_ACTION_NAME,
SearchServiceTransportAction.FETCH_ID_ACTION_NAME, SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
@@ -654,7 +634,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndicesOptionalRequests(searchRequest, SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
}
- @Test
public void testSearchQueryAndFetch() throws Exception {
interceptTransportActions(SearchServiceTransportAction.QUERY_FETCH_ACTION_NAME,
SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
@@ -676,7 +655,6 @@ public class IndicesRequestTests extends ESIntegTestCase {
assertSameIndicesOptionalRequests(searchRequest, SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
}
- @Test
public void testSearchDfsQueryAndFetch() throws Exception {
interceptTransportActions(SearchServiceTransportAction.QUERY_QUERY_FETCH_ACTION_NAME,
SearchServiceTransportAction.FREE_CONTEXT_ACTION_NAME);
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java
index 8657534e3d..638d9238b4 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java
@@ -37,7 +37,6 @@ import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStat
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -75,7 +74,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static final int NUM_DOCS = 5; // TODO randomize the size?
private static final String SINGLE_VALUED_FIELD_NAME = "l_value";
private static final String MULTI_VALUED_FIELD_NAME = "l_values";
@@ -235,9 +234,8 @@ public class LongTermsTests extends AbstractTermsTestCase {
return bucket.getKeyAsString();
}
- @Test
// the main purpose of this test is to make sure we're not allocating 2GB of memory per shard
- public void sizeIsZero() {
+ public void testSizeIsZero() {
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -254,8 +252,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(100));
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -279,8 +276,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueFieldWithFiltering() throws Exception {
+ public void testSingleValueFieldWithFiltering() throws Exception {
long includes[] = { 1, 2, 3, 98 };
long excludes[] = { -1, 2, 4 };
long empty[] = {};
@@ -310,8 +306,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_WithMaxSize() throws Exception {
+ public void testSingleValueFieldWithMaxSize() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -337,8 +332,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_OrderedByTermAsc() throws Exception {
+ public void testSingleValueFieldOrderedByTermAsc() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -362,8 +356,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_OrderedByTermDesc() throws Exception {
+ public void testSingleValueFieldOrderedByTermDesc() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -389,8 +382,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -424,8 +416,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -453,8 +444,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -479,8 +469,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -508,8 +497,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -538,8 +526,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript_NotUnique() throws Exception {
+ public void testMultiValuedFieldWithValueScriptNotUnique() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -579,8 +566,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
@@ -617,12 +603,11 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
-.script(
+ .script(
new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value")))
.execute().actionGet();
@@ -643,8 +628,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -672,12 +656,11 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
-.script(
+ .script(
new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']")))
.execute().actionGet();
@@ -702,30 +685,23 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued_WithAggregatorInherited_NoExplicitType() throws Exception {
-
+ public void testScriptMultiValuedWithAggregatorInheritedNoExplicitType() throws Exception {
// since no type ie explicitly defined, es will assume all values returned by the script to be strings (bytes),
// so the aggregation should fail, since the "sum" aggregation can only operation on numeric values.
-
try {
-
client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
.script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']"))
.subAggregation(sum("sum")))
.execute().actionGet();
-
fail("expected to fail as sub-aggregation sum requires a numeric value source context, but there is none");
-
} catch (Exception e) {
// expected
}
}
- @Test
- public void script_MultiValued_WithAggregatorInherited_WithExplicitType() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInheritedWithExplicitType() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
@@ -762,8 +738,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -780,8 +755,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped", "idx").setTypes("type")
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -805,8 +779,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0)
@@ -825,8 +798,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().isEmpty(), is(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -855,8 +827,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscWithTermsSubAgg() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscWithTermsSubAgg() throws Exception {
boolean asc = true;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -898,8 +869,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleBucketSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleBucketSubAggregationAsc() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("num_tags")
@@ -936,8 +906,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc_MultiHierarchyLevels() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("tags")
@@ -991,8 +960,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
assertThat(max.getValue(), equalTo(asc ? 4.0 : 2.0));
}
- @Test
- public void singleValuedField_OrderedByMissingSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByMissingSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index).setTypes("type")
@@ -1010,8 +978,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index).setTypes("type")
@@ -1031,8 +998,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithUknownMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithUknownMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index).setTypes("type")
@@ -1052,8 +1018,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithoutMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithoutMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index).setTypes("type")
@@ -1073,8 +1038,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -1106,8 +1070,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -1137,8 +1100,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -1168,8 +1130,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByMultiValueExtendedStatsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueExtendedStatsAsc() throws Exception {
boolean asc = true;
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -1199,44 +1160,37 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
long[] expectedKeys = new long[] { 1, 2, 4, 3, 7, 6, 5 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
long[] expectedKeys = new long[] { 1, 2, 3, 4, 5, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
long[] expectedKeys = new long[] { 5, 6, 7, 3, 4, 2, 1 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", false), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
long[] expectedKeys = new long[] { 6, 7, 3, 4, 5, 1, 2 };
assertMultiSortResponse(expectedKeys, Terms.Order.count(true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
long[] expectedKeys = new long[] { 6, 7, 3, 5, 4, 1, 2 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("sum_d", true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedByThreeCriteria() throws Exception {
+ public void testSingleValuedFieldOrderedByThreeCriteria() throws Exception {
long[] expectedKeys = new long[] { 2, 1, 4, 5, 3, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.count(false), Terms.Order.aggregation("sum_d", false), Terms.Order.aggregation("avg_l", false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
long[] expectedKeys = new long[] { 1, 2, 3, 4, 5, 6, 7 };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true));
}
@@ -1273,8 +1227,7 @@ public class LongTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void otherDocCount() {
+ public void testOtherDocCount() {
testOtherDocCount(SINGLE_VALUED_FIELD_NAME, MULTI_VALUED_FIELD_NAME);
}
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java
index ec21ddc05c..ae4fc2b262 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.max.Max;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -46,16 +45,13 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class MaxTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(max("max")))
@@ -72,10 +68,9 @@ public class MaxTests extends AbstractNumericTestCase {
assertThat(max.getName(), equalTo("max"));
assertThat(max.getValue(), equalTo(Double.NEGATIVE_INFINITY));
}
+
@Override
- @Test
public void testUnmapped() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(max("max").field("value"))
@@ -90,7 +85,6 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -105,8 +99,7 @@ public class MaxTests extends AbstractNumericTestCase {
assertThat(max.getValue(), equalTo(10.0));
}
- @Test
- public void testSingleValuedField_WithFormatter() throws Exception {
+ public void testSingleValuedFieldWithFormatter() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(max("max").format("0000.0").field("value")).execute().actionGet();
@@ -120,9 +113,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
-
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(max("max").field("value"))).execute().actionGet();
@@ -146,8 +137,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(max("max").field("value"))
@@ -162,8 +152,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(max("max").field("value").script(new Script("_value + 1")))
@@ -178,8 +167,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -196,7 +184,6 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -212,8 +199,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(max("max").field("values").script(new Script("_value + 1")))
@@ -228,8 +214,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -246,8 +231,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(max("max").script(new Script("doc['value'].value")))
@@ -262,8 +246,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -280,8 +263,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -298,8 +280,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(max("max").script(new Script("doc['values'].values")))
@@ -314,8 +295,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(max("max").script(new Script("doc['values'].values")))
@@ -330,8 +310,7 @@ public class MaxTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java
index 27086bbc8a..a6bf986ab3 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.min.Min;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -46,16 +45,13 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class MinTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(min("min")))
@@ -74,7 +70,6 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -90,7 +85,6 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -105,8 +99,7 @@ public class MinTests extends AbstractNumericTestCase {
assertThat(min.getValue(), equalTo(1.0));
}
- @Test
- public void testSingleValuedField_WithFormatter() throws Exception {
+ public void testSingleValuedFieldWithFormatter() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").format("0000.0").field("value")).execute().actionGet();
@@ -120,8 +113,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(min("min").field("value"))).execute().actionGet();
@@ -146,8 +138,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(min("min").field("value"))
@@ -162,8 +153,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(min("min").field("value").script(new Script("_value - 1")))
@@ -178,8 +168,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -196,7 +185,6 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -212,8 +200,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(min("min").field("values").script(new Script("_value - 1"))).execute().actionGet();
@@ -226,8 +213,7 @@ public class MinTests extends AbstractNumericTestCase {
assertThat(min.getValue(), equalTo(1.0));
}
- @Test
- public void testMultiValuedField_WithValueScript_Reverse() throws Exception {
+ public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
// test what happens when values arrive in reverse order since the min
// aggregator is optimized to work on sorted values
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -242,8 +228,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -259,8 +244,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(new Script("doc['value'].value"))).execute().actionGet();
@@ -273,8 +257,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -290,8 +273,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -307,8 +289,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(new Script("doc['values'].values"))).execute().actionGet();
@@ -321,8 +302,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(new Script("doc['values'].values"))).execute().actionGet();
@@ -335,8 +315,7 @@ public class MinTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client()
@@ -355,5 +334,4 @@ public class MinTests extends AbstractNumericTestCase {
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(1.0));
}
-
} \ No newline at end of file
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java
index 0ab0b1b9ec..5d78b99ded 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.search.aggregations.metrics.avg.Avg;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -67,7 +66,7 @@ public class RangeTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -93,8 +92,7 @@ public class RangeTests extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void rangeAsSubAggregation() throws Exception {
+ public void testRangeAsSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(terms("terms").field(MULTI_VALUED_FIELD_NAME).size(100)
.collectMode(randomFrom(SubAggCollectionMode.values())).subAggregation(
@@ -157,8 +155,7 @@ public class RangeTests extends ESIntegTestCase {
}
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -179,8 +176,8 @@ public class RangeTests extends ESIntegTestCase {
Range.Bucket bucket = buckets.get(0);
assertThat(bucket, notNullValue());
assertThat((String) bucket.getKey(), equalTo("*-3.0"));
- assertThat(((Number) ((Number) bucket.getFrom())).doubleValue(), equalTo(Double.NEGATIVE_INFINITY));
- assertThat(((Number) ((Number) bucket.getTo())).doubleValue(), equalTo(3.0));
+ assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo(Double.NEGATIVE_INFINITY));
+ assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0));
assertThat(bucket.getFromAsString(), nullValue());
assertThat(bucket.getToAsString(), equalTo("3.0"));
assertThat(bucket.getDocCount(), equalTo(2l));
@@ -204,8 +201,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 5L));
}
- @Test
- public void singleValueField_WithFormat() throws Exception {
+ public void testSingleValueFieldWithFormat() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -249,8 +245,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 5L));
}
- @Test
- public void singleValueField_WithCustomKey() throws Exception {
+ public void testSingleValueFieldWithCustomKey() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -296,8 +291,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 5L));
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -369,8 +363,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat((double) propertiesCounts[2], equalTo((double) total));
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregationInherited() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -430,8 +423,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(avg.getValue(), equalTo((double) total / (numDocs - 5))); // (6 + 7 + 8 + 9 + 10) / 5
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -487,8 +479,7 @@ public class RangeTests extends ESIntegTestCase {
[10, 11]
*/
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(MULTI_VALUED_FIELD_NAME)
@@ -547,8 +538,7 @@ public class RangeTests extends ESIntegTestCase {
[11, 12]
*/
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -609,8 +599,7 @@ public class RangeTests extends ESIntegTestCase {
r3: 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -670,8 +659,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(sum.getValue(), equalTo((double) total));
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -715,8 +703,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 5l));
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -773,8 +760,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(avg.getValue(), equalTo((double) total / (numDocs - 5))); // (6 + 7 + 8 + 9 + 10) / 5
}
- @Test
- public void emptyRange() throws Exception {
+ public void testEmptyRange() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(MULTI_VALUED_FIELD_NAME)
@@ -810,8 +796,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -854,7 +839,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getToAsString(), nullValue());
assertThat(bucket.getDocCount(), equalTo(numDocs - 4l));
}
-
+
/*
[1, 2]
[2, 3]
@@ -866,14 +851,13 @@ public class RangeTests extends ESIntegTestCase {
[8, 9]
[9, 10]
[10, 11]
-
+
r1: 1, 2, 2
r2: 3, 3, 4, 4, 5, 5
r3: 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11
*/
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -933,8 +917,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(sum.getValue(), equalTo((double) total));
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(range("range")
.field(SINGLE_VALUED_FIELD_NAME)
@@ -980,8 +963,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(0l));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet();
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
@@ -1029,8 +1011,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 5l));
}
- @Test
- public void overlappingRanges() throws Exception {
+ public void testOverlappingRanges() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(range("range")
.field(MULTI_VALUED_FIELD_NAME)
@@ -1086,8 +1067,7 @@ public class RangeTests extends ESIntegTestCase {
assertThat(bucket.getDocCount(), equalTo(numDocs - 2l));
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0)
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptIndexSettingsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptIndexSettingsTests.java
index 06db7e89ee..34ca4f4966 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptIndexSettingsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptIndexSettingsTests.java
@@ -23,7 +23,6 @@ import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsReques
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
-import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse;
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.index.IndexNotFoundException;
@@ -31,20 +30,19 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
+import static org.hamcrest.Matchers.is;
+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class ScriptIndexSettingsTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
- @Test
public void testScriptIndexSettings() {
PutIndexedScriptResponse putIndexedScriptResponse =
client().preparePutIndexedScript().setId("foobar").setScriptLang("groovy").setSource("{ \"script\": 1 }")
@@ -77,7 +75,6 @@ public class ScriptIndexSettingsTests extends ESIntegTestCase {
assertEquals("Auto expand replicas should be 0-all", "0-all", numberOfReplicas);
}
- @Test
public void testDeleteScriptIndex() {
PutIndexedScriptResponse putIndexedScriptResponse =
client().preparePutIndexedScript().setId("foobar").setScriptLang("groovy").setSource("{ \"script\": 1 }")
@@ -87,13 +84,10 @@ public class ScriptIndexSettingsTests extends ESIntegTestCase {
assertTrue(deleteResponse.isAcknowledged());
ensureGreen();
try {
- GetIndexedScriptResponse response = client().prepareGetIndexedScript("groovy","foobar").get();
- assertTrue(false); //This should not happen
- } catch (IndexNotFoundException ime) {
- assertTrue(true);
+ client().prepareGetIndexedScript("groovy","foobar").get();
+ fail("Expected IndexNotFoundException");
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getMessage(), is("no such index"));
}
}
-
-
-
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java
index 27262177d4..2b419c4075 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java
@@ -22,14 +22,12 @@ package org.elasticsearch.messy.tests;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.cache.IndexCacheModule;
-import org.elasticsearch.index.cache.query.index.IndexQueryCache;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -38,7 +36,6 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.scriptQuery;
import static org.hamcrest.Matchers.equalTo;
@@ -47,12 +44,11 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ESIntegTestCase.ClusterScope(scope= ESIntegTestCase.Scope.SUITE)
public class ScriptQuerySearchTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder().put(super.nodeSettings(nodeOrdinal))
@@ -62,7 +58,6 @@ public class ScriptQuerySearchTests extends ESIntegTestCase {
.build();
}
- @Test
public void testCustomScriptBoost() throws Exception {
createIndex("test");
client().prepareIndex("test", "type1", "1")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java
index e28554a44f..c54510acd4 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java
@@ -37,7 +37,6 @@ import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetric;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -72,7 +71,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -116,7 +115,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
"{\"script\":\"newaggregation = []; sum = 0;for (agg in _aggs) { for (a in agg) { sum += a} }; newaggregation.add(sum); return newaggregation\"}")
.get();
assertThat(indexScriptResponse.isCreated(), equalTo(true));
-
+
indexRandom(true, builders);
ensureSearchable();
}
@@ -130,7 +129,6 @@ public class ScriptedMetricTests extends ESIntegTestCase {
return settings;
}
- @Test
public void testMap() {
SearchResponse response = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(scriptedMetric("scripted").mapScript(new Script("_agg['count'] = 1"))).execute().actionGet();
@@ -164,8 +162,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(numShardsRun, greaterThan(0));
}
- @Test
- public void testMap_withParams() {
+ public void testMapWithParams() {
Map<String, Object> params = new HashMap<>();
params.put("_agg", new ArrayList<>());
@@ -199,8 +196,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(totalCount, equalTo(numDocs));
}
- @Test
- public void testInitMap_withParams() {
+ public void testInitMapWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -241,8 +237,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(totalCount, equalTo(numDocs * 3));
}
- @Test
- public void testMapCombine_withParams() {
+ public void testMapCombineWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -291,8 +286,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(totalCount, equalTo(numDocs));
}
- @Test
- public void testInitMapCombine_withParams() {
+ public void testInitMapCombineWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -342,8 +336,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(totalCount, equalTo(numDocs * 3));
}
- @Test
- public void testInitMapCombineReduce_withParams() {
+ public void testInitMapCombineReduceWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -383,9 +376,8 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs * 3));
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInitMapCombineReduce_getProperty() throws Exception {
+ @SuppressWarnings("rawtypes")
+ public void testInitMapCombineReduceGetProperty() throws Exception {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -436,8 +428,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
}
- @Test
- public void testMapCombineReduce_withParams() {
+ public void testMapCombineReduceWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -476,8 +467,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs));
}
- @Test
- public void testInitMapReduce_withParams() {
+ public void testInitMapReduceWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -514,8 +504,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs * 3));
}
- @Test
- public void testMapReduce_withParams() {
+ public void testMapReduceWithParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -551,8 +540,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs));
}
- @Test
- public void testInitMapCombineReduce_withParamsAndReduceParams() {
+ public void testInitMapCombineReduceWithParamsAndReduceParams() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -595,8 +583,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs * 12));
}
- @Test
- public void testInitMapCombineReduce_withParams_Indexed() {
+ public void testInitMapCombineReduceWithParamsIndexed() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -630,9 +617,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs * 3));
}
- @Test
- public void testInitMapCombineReduce_withParams_File() {
-
+ public void testInitMapCombineReduceWithParamsFile() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -665,8 +650,7 @@ public class ScriptedMetricTests extends ESIntegTestCase {
assertThat(((Number) object).longValue(), equalTo(numDocs * 3));
}
- @Test
- public void testInitMapCombineReduce_withParams_asSubAgg() {
+ public void testInitMapCombineReduceWithParamsAsSubAgg() {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
Map<String, Object> params = new HashMap<>();
@@ -723,7 +707,6 @@ public class ScriptedMetricTests extends ESIntegTestCase {
}
}
- @Test
public void testEmptyAggregation() throws Exception {
Map<String, Object> varsMap = new HashMap<>();
varsMap.put("multiplier", 1);
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java
index a7618f0989..632f93d870 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java
@@ -44,7 +44,6 @@ import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -75,13 +74,11 @@ import static org.hamcrest.Matchers.nullValue;
*
*/
public class SearchFieldsTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
- @Test
public void testStoredFields() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
@@ -141,7 +138,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3"));
}
- @Test
public void testScriptDocAndFields() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
@@ -226,7 +222,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat((Double) response.getHits().getAt(2).fields().get("sNum1").values().get(0), equalTo(6.0));
}
- @Test
public void testUidBasedScriptFields() throws Exception {
prepareCreate("test").addMapping("type1", "num1", "type=long").execute().actionGet();
ensureYellow();
@@ -303,7 +298,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
}
}
- @Test
public void testScriptFieldUsingSource() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
@@ -347,7 +341,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat(((Map) sObj2Arr3.get(0)).get("arr3_field1").toString(), equalTo("arr3_value1"));
}
- @Test
public void testPartialFields() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
@@ -367,7 +360,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
client().admin().indices().prepareRefresh().execute().actionGet();
}
- @Test
public void testStoredFieldsWithoutSource() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
@@ -434,8 +426,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
}
- @Test
- public void testSearchFields_metaData() throws Exception {
+ public void testSearchFieldsMetaData() throws Exception {
client().prepareIndex("my-index", "my-type1", "1")
.setRouting("1")
.setSource(jsonBuilder().startObject().field("field1", "value").endObject())
@@ -454,8 +445,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).field("_routing").getValue().toString(), equalTo("1"));
}
- @Test
- public void testSearchFields_nonLeafField() throws Exception {
+ public void testSearchFieldsNonLeafField() throws Exception {
client().prepareIndex("my-index", "my-type1", "1")
.setSource(jsonBuilder().startObject().startObject("field1").field("field2", "value1").endObject().endObject())
.setRefresh(true)
@@ -466,8 +456,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
containsString("field [field1] isn't a leaf field"));
}
- @Test
- public void testGetFields_complexField() throws Exception {
+ public void testGetFieldsComplexField() throws Exception {
client().admin().indices().prepareCreate("my-index")
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))
.addMapping("my-type2", jsonBuilder().startObject().startObject("my-type2").startObject("properties")
@@ -524,7 +513,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).field(field).getValues().get(1).toString(), equalTo("value2"));
}
- @Test // see #8203
+ // see #8203
public void testSingleValueFieldDatatField() throws ExecutionException, InterruptedException {
createIndex("test");
indexRandom(true, client().prepareIndex("test", "type", "1").setSource("test_field", "foobar"));
@@ -536,7 +525,6 @@ public class SearchFieldsTests extends ESIntegTestCase {
assertThat((String)fields.get("test_field").value(), equalTo("foobar"));
}
- @Test
public void testFieldsPulledFromFieldData() throws Exception {
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java
index 89d1670c47..c301f97ccc 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java
@@ -36,7 +36,6 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -61,7 +60,6 @@ import static org.hamcrest.Matchers.nullValue;
*/
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SearchStatsTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
@@ -72,7 +70,6 @@ public class SearchStatsTests extends ESIntegTestCase {
return 0;
}
- @Test
public void testSimpleStats() throws Exception {
// clear all stats first
client().admin().indices().prepareStats().clear().execute().actionGet();
@@ -147,9 +144,9 @@ public class SearchStatsTests extends ESIntegTestCase {
assertThat(total.getQueryTimeInMillis(), equalTo(0l));
}
}
-
+
assertThat(num, greaterThan(0));
-
+
}
private Set<String> nodeIdsWithIndex(String... indices) {
@@ -167,7 +164,6 @@ public class SearchStatsTests extends ESIntegTestCase {
return nodes;
}
- @Test
public void testOpenContexts() {
String index = "test1";
createIndex(index);
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchTimeoutTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchTimeoutTests.java
index 1b53550932..219773b85c 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchTimeoutTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchTimeoutTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -44,14 +43,13 @@ public class SearchTimeoutTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder().put(super.nodeSettings(nodeOrdinal)).build();
}
- @Test
- public void simpleTimeoutTest() throws Exception {
+ public void testSimpleTimeout() throws Exception {
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet();
SearchResponse searchResponse = client().prepareSearch("test")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SignificantTermsSignificanceScoreTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SignificantTermsSignificanceScoreTests.java
index 5e6625a26b..8828d064b6 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SignificantTermsSignificanceScoreTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SignificantTermsSignificanceScoreTests.java
@@ -59,7 +59,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -85,7 +84,6 @@ import static org.hamcrest.Matchers.is;
*/
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
-
static final String INDEX_NAME = "testidx";
static final String DOC_TYPE = "doc";
static final String TEXT_FIELD = "text";
@@ -108,7 +106,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
return randomBoolean() ? null : randomFrom(SignificantTermsAggregatorFactory.ExecutionMode.values()).toString();
}
- @Test
public void testPlugin() throws Exception {
String type = randomBoolean() ? "string" : "long";
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
@@ -259,10 +256,7 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
}
}
-
- @Test
public void testXContentResponse() throws Exception {
-
String type = randomBoolean() ? "string" : "long";
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
index01Docs(type, settings);
@@ -295,7 +289,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
}
- @Test
public void testDeletesIssue7951() throws Exception {
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
String mappings = "{\"doc\": {\"properties\":{\"text\": {\"type\":\"string\",\"index\":\"not_analyzed\"}}}}";
@@ -338,7 +331,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
.actionGet();
}
- @Test
public void testBackgroundVsSeparateSet() throws Exception {
String type = randomBoolean() ? "string" : "long";
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
@@ -425,7 +417,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
indexRandom(true, false, indexRequestBuilderList);
}
- @Test
public void testScoresEqualForPositiveAndNegative() throws Exception {
indexEqualTestData();
testScoresEqualForPositiveAndNegative(new MutualInformation.MutualInformationBuilder(true, true));
@@ -491,7 +482,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
indexRandom(true, false, indexRequestBuilders);
}
- @Test
public void testScriptScore() throws ExecutionException, InterruptedException, IOException {
indexRandomFrequencies01(randomBoolean() ? "string" : "long");
ScriptHeuristic.ScriptHeuristicBuilder scriptHeuristicBuilder = getScriptSignificanceHeuristicBuilder();
@@ -512,7 +502,6 @@ public class SignificantTermsSignificanceScoreTests extends ESIntegTestCase {
}
}
- @Test
public void testNoNumberFormatExceptionWithDefaultScriptingEngine() throws ExecutionException, InterruptedException, IOException {
assertAcked(client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1)));
index("test", "doc", "1", "{\"field\":\"a\"}");
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java
index 5f51b6505f..8d2c72e902 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java
@@ -45,35 +45,62 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.GeoDistanceSortBuilder;
import org.elasticsearch.search.sort.ScriptSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
-import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.fieldValueFactorFunction;
import static org.elasticsearch.search.sort.SortBuilders.fieldSort;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
-import static org.hamcrest.Matchers.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSecondHit;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSortValues;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId;
+import static org.hamcrest.Matchers.closeTo;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
/**
*
*/
public class SimpleSortTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
@@ -182,7 +209,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertOrderedSearchHits(searchResponse, "data.activity.6", "data.activity.5");
}
- @Test
public void testTrackScores() throws Exception {
createIndex("test");
ensureGreen();
@@ -299,8 +325,6 @@ public class SimpleSortTests extends ESIntegTestCase {
}
}
-
- @Test
public void test3078() {
createIndex("test");
ensureGreen();
@@ -348,7 +372,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(2).sortValues()[0].toString(), equalTo("100"));
}
- @Test
public void testScoreSortDirection() throws Exception {
createIndex("test");
ensureGreen();
@@ -391,9 +414,7 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
}
-
- @Test
- public void testScoreSortDirection_withFunctionScore() throws Exception {
+ public void testScoreSortDirectionWithFunctionScore() throws Exception {
createIndex("test");
ensureGreen();
@@ -428,7 +449,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
}
- @Test
public void testIssue2986() {
createIndex("test");
@@ -443,7 +463,6 @@ public class SimpleSortTests extends ESIntegTestCase {
}
}
- @Test
public void testIssue2991() {
for (int i = 1; i < 4; i++) {
try {
@@ -479,7 +498,6 @@ public class SimpleSortTests extends ESIntegTestCase {
}
}
- @Test
public void testSimpleSorts() throws Exception {
Random random = getRandom();
assertAcked(prepareCreate("test")
@@ -734,7 +752,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertNoFailures(searchResponse);
}
- @Test
public void test2920() throws IOException {
assertAcked(prepareCreate("test").addMapping(
"test",
@@ -751,7 +768,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertNoFailures(searchResponse);
}
- @Test
public void testSortMinValueScript() throws IOException {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("lvalue").field("type", "long").endObject()
@@ -839,7 +855,6 @@ public class SimpleSortTests extends ESIntegTestCase {
}
}
- @Test
public void testDocumentsWithNullValue() throws Exception {
// TODO: sort shouldn't fail when sort field is mapped dynamically
// We have to specify mapping explicitly because by the time search is performed dynamic mapping might not
@@ -933,7 +948,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(0).field("id").value(), equalTo("2"));
}
- @Test
public void testSortMissingNumbers() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1",
XContentFactory.jsonBuilder()
@@ -1008,7 +1022,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(2).id(), equalTo("3"));
}
- @Test
public void testSortMissingStrings() throws IOException {
assertAcked(prepareCreate("test").addMapping("type1",
XContentFactory.jsonBuilder()
@@ -1096,7 +1109,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(searchResponse.getHits().getAt(2).id(), equalTo("3"));
}
- @Test
public void testIgnoreUnmapped() throws Exception {
createIndex("test");
ensureYellow();
@@ -1128,7 +1140,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertNoFailures(searchResponse);
}
- @Test
public void testSortMVField() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1443,7 +1454,6 @@ public class SimpleSortTests extends ESIntegTestCase {
assertThat(((Text) searchResponse.getHits().getAt(2).sortValues()[0]).string(), equalTo("03"));
}
- @Test
public void testSortOnRareField() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
@@ -1609,7 +1619,6 @@ public class SimpleSortTests extends ESIntegTestCase {
/**
* Test case for issue 6150: https://github.com/elasticsearch/elasticsearch/issues/6150
*/
- @Test
public void testNestedSort() throws IOException, InterruptedException, ExecutionException {
assertAcked(prepareCreate("test")
.addMapping("type",
@@ -1677,7 +1686,6 @@ public class SimpleSortTests extends ESIntegTestCase {
}
}
- @Test
public void testSortDuelBetweenSingleShardAndMultiShardIndex() throws Exception {
String sortField = "sortField";
assertAcked(prepareCreate("test1")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java
index dfc37450b9..0b519fa6f7 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java
@@ -28,7 +28,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.stats.Stats;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -49,16 +48,13 @@ import static org.hamcrest.Matchers.sameInstance;
*
*/
public class StatsTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(stats("stats")))
@@ -83,7 +79,6 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -105,7 +100,6 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -149,9 +143,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
-
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(stats("stats").field("value"))).execute().actionGet();
@@ -188,8 +180,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").field("value"))
@@ -210,8 +201,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").field("value").script(new Script("_value + 1")))
@@ -232,8 +222,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -256,7 +245,6 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -278,8 +266,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").field("values").script(new Script("_value - 1")))
@@ -300,8 +287,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -324,8 +310,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").script(new Script("doc['value'].value")))
@@ -346,8 +331,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -370,8 +354,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -394,8 +377,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").script(new Script("doc['values'].values")))
@@ -416,8 +398,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(stats("stats").script(new Script("doc['values'].values")))
@@ -438,8 +419,7 @@ public class StatsTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java
index be9e90f2c7..55672a0ce4 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java
@@ -43,7 +43,6 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
-import org.junit.Test;
import java.io.IOException;
import java.text.NumberFormat;
@@ -79,7 +78,6 @@ import static org.hamcrest.core.IsNull.nullValue;
*/
@ESIntegTestCase.SuiteScopeTestCase
public class StringTermsTests extends AbstractTermsTestCase {
-
private static final String SINGLE_VALUED_FIELD_NAME = "s_value";
private static final String MULTI_VALUED_FIELD_NAME = "s_values";
private static Map<String, Map<String, Object>> expectedMultiSortBuckets;
@@ -88,7 +86,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -193,9 +191,8 @@ public class StringTermsTests extends AbstractTermsTestCase {
return bucket.getKeyAsString();
}
- @Test
// the main purpose of this test is to make sure we're not allocating 2GB of memory per shard
- public void sizeIsZero() {
+ public void testSizeIsZero() {
final int minDocCount = randomInt(1);
SearchResponse response = client()
.prepareSearch("idx")
@@ -213,8 +210,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(minDocCount == 0 ? 105 : 100)); // 105 because of the other type
}
- @Test
- public void singleValueField() throws Exception {
+ public void testSingleValueField() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -241,8 +237,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_withGlobalOrdinals() throws Exception {
+ public void testSingleValueFieldWithGlobalOrdinals() throws Exception {
ExecutionMode[] executionModes = new ExecutionMode[] { null, ExecutionMode.GLOBAL_ORDINALS, ExecutionMode.GLOBAL_ORDINALS_HASH,
ExecutionMode.GLOBAL_ORDINALS_LOW_CARDINALITY };
for (ExecutionMode executionMode : executionModes) {
@@ -269,9 +264,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_WithRegexFiltering() throws Exception {
-
+ public void testSingleValueFieldWithRegexFiltering() throws Exception {
// include without exclude
// we should be left with: val000, val001, val002, val003, val004, val005, val006, val007, val008, val009
@@ -346,8 +339,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_WithExactTermFiltering() throws Exception {
+ public void testSingleValueFieldWithExactTermFiltering() throws Exception {
// include without exclude
String incVals[] = { "val000", "val001", "val002", "val003", "val004", "val005", "val006", "val007", "val008", "val009" };
SearchResponse response = client()
@@ -428,8 +420,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValueField_WithMaxSize() throws Exception {
+ public void testSingleValueFieldWithMaxSize() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("high_card_type")
@@ -453,8 +444,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_OrderedByTermAsc() throws Exception {
+ public void testSingleValueFieldOrderedByTermAsc() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -479,8 +469,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValueField_OrderedByTermDesc() throws Exception {
+ public void testSingleValueFieldOrderedByTermDesc() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -505,8 +494,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -539,8 +527,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
+ public void testSingleValuedFieldWithSubAggregation_Inherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -567,8 +554,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -592,8 +578,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript_NotUnique() throws Exception {
+ public void testMultiValuedFieldWithValueScriptNotUnique() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -615,8 +600,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(bucket.getDocCount(), equalTo(5l));
}
- @Test
- public void multiValuedField() throws Exception {
+ public void testMultiValuedField() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -643,8 +627,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedScript() throws Exception {
+ public void testMultiValuedScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -671,8 +654,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void multiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -712,8 +694,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
* doc_count: 1 - val_count: 2
*/
- @Test
- public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -747,8 +728,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue() throws Exception {
+ public void testScriptSingleValue() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -771,8 +751,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue_ExplicitSingleValue() throws Exception {
+ public void testScriptSingleValueExplicitSingleValue() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -795,8 +774,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
+ public void testScriptSingleValueWithSubAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -823,8 +801,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -851,8 +828,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void script_MultiValued_WithAggregatorInherited() throws Exception {
+ public void testScriptMultiValuedWithAggregatorInherited() throws Exception {
SearchResponse response = client()
.prepareSearch("idx")
.setTypes("type")
@@ -886,8 +862,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx_unmapped")
.setTypes("type")
@@ -903,8 +878,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().size(), equalTo(0));
}
- @Test
- public void partiallyUnmapped() throws Exception {
+ public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "idx_unmapped")
.setTypes("type")
@@ -927,8 +901,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void stringTermsNestedIntoPerBucketAggregator() throws Exception {
+ public void testStringTermsNestedIntoPerBucketAggregator() throws Exception {
// no execution hint so that the logic that decides whether or not to use ordinals is executed
SearchResponse response = client()
.prepareSearch("idx")
@@ -955,8 +928,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void emptyAggregation() throws Exception {
+ public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client()
.prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -976,8 +948,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(terms.getBuckets().isEmpty(), is(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1006,8 +977,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByIllegalAgg() throws Exception {
+ public void testSingleValuedFieldOrderedByIllegalAgg() throws Exception {
boolean asc = true;
try {
client()
@@ -1036,8 +1006,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleBucketSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleBucketSubAggregationAsc() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client()
.prepareSearch("idx")
@@ -1073,8 +1042,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc_MultiHierarchyLevels() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception {
boolean asc = randomBoolean();
SearchResponse response = client()
.prepareSearch("idx")
@@ -1131,8 +1099,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc_MultiHierarchyLevels_specialChars() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevelsSpecialChars() throws Exception {
StringBuilder filter2NameBuilder = new StringBuilder("filt.er2");
filter2NameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", ""));
String filter2Name = filter2NameBuilder.toString();
@@ -1195,8 +1162,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0));
}
- @Test
- public void singleValuedField_OrderedBySubAggregationAsc_MultiHierarchyLevels_specialCharsNoDotNotation() throws Exception {
+ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevelsSpecialCharsNoDotNotation() throws Exception {
StringBuilder filter2NameBuilder = new StringBuilder("filt.er2");
filter2NameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", ""));
String filter2Name = filter2NameBuilder.toString();
@@ -1259,8 +1225,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0));
}
- @Test
- public void singleValuedField_OrderedByMissingSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByMissingSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1278,8 +1243,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
+ public void testSingleValuedFieldOrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1299,8 +1263,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithUknownMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithUknownMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
SearchResponse response = client()
@@ -1320,8 +1283,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedByMultiValuedSubAggregation_WithoutMetric() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValuedSubAggregationWithoutMetric() throws Exception {
for (String index : Arrays.asList("idx", "idx_unmapped")) {
try {
client().prepareSearch(index)
@@ -1341,8 +1303,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1373,8 +1334,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1402,11 +1362,9 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertThat(stats.getMax(), equalTo((double) i));
i++;
}
-
}
- @Test
- public void singleValuedField_OrderedByMultiValueSubAggregationDesc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueSubAggregationDesc() throws Exception {
boolean asc = false;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1437,8 +1395,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByMultiValueExtendedStatsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByMultiValueExtendedStatsAsc() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1470,8 +1427,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedByStatsAggAscWithTermsSubAgg() throws Exception {
+ public void testSingleValuedFieldOrderedByStatsAggAscWithTermsSubAgg() throws Exception {
boolean asc = true;
SearchResponse response = client()
.prepareSearch("idx")
@@ -1516,45 +1472,38 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsDesc() throws Exception {
String[] expectedKeys = new String[] { "val1", "val2", "val4", "val3", "val7", "val6", "val5" };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAndTermsAsc() throws Exception {
String[] expectedKeys = new String[] { "val1", "val2", "val3", "val4", "val5", "val6", "val7" };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationDescAndTermsAsc() throws Exception {
String[] expectedKeys = new String[] { "val5", "val6", "val7", "val3", "val4", "val2", "val1" };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", false), Terms.Order.term(true));
}
- @Test
- public void singleValuedField_OrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedByCountAscAndSingleValueSubAggregationAsc() throws Exception {
String[] expectedKeys = new String[] { "val6", "val7", "val3", "val4", "val5", "val1", "val2" };
assertMultiSortResponse(expectedKeys, Terms.Order.count(true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscSingleValueSubAggregationAsc() throws Exception {
String[] expectedKeys = new String[] { "val6", "val7", "val3", "val5", "val4", "val1", "val2" };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("sum_d", true), Terms.Order.aggregation("avg_l", true));
}
- @Test
- public void singleValuedField_OrderedByThreeCriteria() throws Exception {
+ public void testSingleValuedFieldOrderedByThreeCriteria() throws Exception {
String[] expectedKeys = new String[] { "val2", "val1", "val4", "val5", "val3", "val6", "val7" };
assertMultiSortResponse(expectedKeys, Terms.Order.count(false), Terms.Order.aggregation("sum_d", false),
Terms.Order.aggregation("avg_l", false));
}
- @Test
- public void singleValuedField_OrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
+ public void testSingleValuedFieldOrderedBySingleValueSubAggregationAscAsCompound() throws Exception {
String[] expectedKeys = new String[] { "val1", "val2", "val3", "val4", "val5", "val6", "val7" };
assertMultiSortResponse(expectedKeys, Terms.Order.aggregation("avg_l", true));
}
@@ -1590,8 +1539,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
}
}
- @Test
- public void indexMetaField() throws Exception {
+ public void testIndexMetaField() throws Exception {
SearchResponse response = client()
.prepareSearch("idx", "empty_bucket_idx")
.setTypes("type")
@@ -1621,8 +1569,7 @@ public class StringTermsTests extends AbstractTermsTestCase {
assertEquals(5L, terms.getBucketByKey("i").getDocCount());
}
- @Test
- public void otherDocCount() {
+ public void testOtherDocCount() {
testOtherDocCount(SINGLE_VALUED_FIELD_NAME, MULTI_VALUED_FIELD_NAME);
}
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java
index d36d833e09..4b9ba484da 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -46,14 +45,12 @@ import static org.hamcrest.Matchers.notNullValue;
*
*/
public class SumTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
- @Test
public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
@@ -74,7 +71,6 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -90,7 +86,6 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -105,8 +100,7 @@ public class SumTests extends AbstractNumericTestCase {
assertThat(sum.getValue(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
}
- @Test
- public void testSingleValuedField_WithFormatter() throws Exception {
+ public void testSingleValuedFieldWithFormatter() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(sum("sum").format("0000.0").field("value")).execute().actionGet();
@@ -120,8 +114,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(sum("sum").field("value"))).execute().actionGet();
@@ -146,7 +139,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(sum("sum").field("value"))
@@ -161,8 +154,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(sum("sum").field("value").script(new Script("_value + 1")))
@@ -177,8 +169,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("increment", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -195,8 +186,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(sum("sum").script(new Script("doc['value'].value")))
@@ -211,8 +201,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -229,8 +218,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -248,8 +236,7 @@ public class SumTests extends AbstractNumericTestCase {
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(sum("sum").script(new Script("[ doc['value'].value, doc['value'].value + 1 ]")))
@@ -264,8 +251,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(sum("sum").script(new Script("[ doc['value'].value, doc['value'].value + 1 ]")))
@@ -280,8 +266,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -299,7 +284,6 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -316,8 +300,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -332,8 +315,7 @@ public class SumTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("increment", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java
index 0c5aef40eb..e32a7f0199 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksBuilder;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -42,20 +41,25 @@ import java.util.List;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.percentileRanks;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
*
*/
public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static double[] randomPercents(long minValue, long maxValue) {
final int length = randomIntBetween(1, 20);
@@ -108,9 +112,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -132,7 +134,6 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -153,7 +154,6 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -170,8 +170,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client()
.prepareSearch("idx")
@@ -197,7 +196,6 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
- @Test
public void testSingleValuedFieldOutsideRange() throws Exception {
final double[] pcts = new double[] {minValue - 1, maxValue + 1};
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -214,8 +212,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
@@ -231,8 +228,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -248,8 +244,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
@@ -268,7 +263,6 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -285,8 +279,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -301,8 +294,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
}
- @Test
- public void testMultiValuedField_WithValueScript_Reverse() throws Exception {
+ public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
final double[] pcts = randomPercents(-maxValues, -minValues);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -318,8 +310,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
@@ -338,8 +329,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
final double[] pcts = randomPercents(minValue, maxValue);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -355,8 +345,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
@@ -375,8 +364,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValue -1 , maxValue - 1);
@@ -395,8 +383,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -412,8 +399,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
final double[] pcts = randomPercents(minValues, maxValues);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -429,8 +415,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
@@ -449,7 +434,6 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
}
- @Test
public void testOrderBySubAggregation() {
boolean asc = randomBoolean();
SearchResponse searchResponse = client().prepareSearch("idx")
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java
index afa9f204da..68975ae818 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles;
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesBuilder;
-import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -42,20 +41,25 @@ import java.util.List;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
/**
*
*/
public class TDigestPercentilesTests extends AbstractNumericTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
private static double[] randomPercentiles() {
final int length = randomIntBetween(1, 20);
final double[] percentiles = new double[length];
@@ -108,9 +112,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testEmptyAggregation() throws Exception {
-
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0)
@@ -132,7 +134,6 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
@@ -153,7 +154,6 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testSingleValuedField() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -170,8 +170,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_getProperty() throws Exception {
+ public void testSingleValuedFieldGetProperty() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client()
.prepareSearch("idx")
@@ -197,8 +196,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
@@ -214,8 +212,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript() throws Exception {
+ public void testSingleValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -231,8 +228,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testSingleValuedField_WithValueScript_WithParams() throws Exception {
+ public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -251,7 +247,6 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
public void testMultiValuedField() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -268,8 +263,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript() throws Exception {
+ public void testMultiValuedFieldWithValueScript() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -284,13 +278,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
}
- @Test
- public void testMultiValuedField_WithValueScript_Reverse() throws Exception {
+ public void testMultiValuedFieldWithValueScriptReverse() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(randomCompression(percentiles("percentiles"))
-.field("values").script(new Script("_value * -1"))
+ .field("values").script(new Script("_value * -1"))
.percentiles(pcts))
.execute().actionGet();
@@ -301,8 +294,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testMultiValuedField_WithValueScript_WithParams() throws Exception {
+ public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -321,8 +313,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued() throws Exception {
+ public void testScriptSingleValued() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -338,15 +329,14 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_SingleValued_WithParams() throws Exception {
+ public void testScriptSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(randomCompression(percentiles("percentiles"))
-.script(
+ .script(
new Script("doc['value'].value - dec", ScriptType.INLINE, null, params))
.percentiles(pcts))
.execute().actionGet();
@@ -358,15 +348,14 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitSingleValued_WithParams() throws Exception {
+ public void testScriptExplicitSingleValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(randomCompression(percentiles("percentiles"))
-.script(
+ .script(
new Script("doc['value'].value - dec", ScriptType.INLINE, null, params))
.percentiles(pcts))
.execute().actionGet();
@@ -378,8 +367,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued() throws Exception {
+ public void testScriptMultiValued() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -395,13 +383,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_ExplicitMultiValued() throws Exception {
+ public void testScriptExplicitMultiValued() throws Exception {
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(randomCompression(percentiles("percentiles"))
-.script(new Script("doc['values'].values"))
+ .script(new Script("doc['values'].values"))
.percentiles(pcts))
.execute().actionGet();
@@ -412,8 +399,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
}
@Override
- @Test
- public void testScript_MultiValued_WithParams() throws Exception {
+ public void testScriptMultiValuedWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
final double[] pcts = randomPercentiles();
@@ -432,7 +418,6 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
}
- @Test
public void testOrderBySubAggregation() {
boolean asc = randomBoolean();
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -458,5 +443,4 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
previous = p99;
}
}
-
} \ No newline at end of file
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java
index 69da9c7d65..20411963ab 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java
@@ -32,7 +32,6 @@ import org.elasticsearch.script.groovy.GroovyScriptEngineService;
import org.elasticsearch.search.suggest.SuggestBuilders;
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@@ -57,14 +56,12 @@ import static org.hamcrest.Matchers.not;
*/
@SuppressCodecs("*") // requires custom completion format
public class TransformOnIndexMapperTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
- @Test
- public void searchOnTransformed() throws Exception {
+ public void testSearchOnTransformed() throws Exception {
setup(true);
// Searching by the field created in the transport finds the entry
@@ -79,8 +76,7 @@ public class TransformOnIndexMapperTests extends ESIntegTestCase {
assertHitCount(response, 0);
}
- @Test
- public void getTransformed() throws Exception {
+ public void testGetTransformed() throws Exception {
setup(getRandom().nextBoolean());
GetResponse response = client().prepareGet("test", "test", "righttitle").get();
assertExists(response);
@@ -94,8 +90,7 @@ public class TransformOnIndexMapperTests extends ESIntegTestCase {
// TODO: the completion suggester currently returns payloads with no reencoding so this test
// exists to make sure that _source transformation and completion work well together. If we
// ever fix the completion suggester to reencode the payloads then we can remove this test.
- @Test
- public void contextSuggestPayloadTransformed() throws Exception {
+ public void testContextSuggestPayloadTransformed() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
builder.startObject("properties");
builder.startObject("suggest").field("type", "completion").field("payloads", true).endObject();
@@ -182,5 +177,4 @@ public class TransformOnIndexMapperTests extends ESIntegTestCase {
private void assertRightTitleSourceTransformed(Map<String, Object> source) {
assertThat(source, both(hasEntry("destination", (Object) "findme")).and(not(hasKey("content"))));
}
-
}
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ValueCountTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ValueCountTests.java
index ca2cffce59..8bb6b1adad 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ValueCountTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ValueCountTests.java
@@ -26,7 +26,6 @@ import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
@@ -51,7 +50,7 @@ public class ValueCountTests extends ESIntegTestCase {
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
+
@Override
public void setupSuiteScopeCluster() throws Exception {
createIndex("idx");
@@ -69,8 +68,7 @@ public class ValueCountTests extends ESIntegTestCase {
ensureSearchable();
}
- @Test
- public void unmapped() throws Exception {
+ public void testUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(count("count").field("value"))
@@ -84,9 +82,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(0l));
}
- @Test
- public void singleValuedField() throws Exception {
-
+ public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(count("count").field("value"))
@@ -100,9 +96,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(10l));
}
- @Test
- public void singleValuedField_getProperty() throws Exception {
-
+ public void testSingleValuedFieldGetProperty() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(global("global").subAggregation(count("count").field("value"))).execute().actionGet();
@@ -124,8 +118,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat((double) valueCount.getProperty("value"), equalTo(10d));
}
- @Test
- public void singleValuedField_PartiallyUnmapped() throws Exception {
+ public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
.setQuery(matchAllQuery())
.addAggregation(count("count").field("value"))
@@ -139,9 +132,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(10l));
}
- @Test
- public void multiValuedField() throws Exception {
-
+ public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(count("count").field("values"))
@@ -155,8 +146,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(20l));
}
- @Test
- public void singleValuedScript() throws Exception {
+ public void testSingleValuedScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(count("count").script(new Script("doc['value'].value"))).execute().actionGet();
@@ -168,8 +158,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(10l));
}
- @Test
- public void multiValuedScript() throws Exception {
+ public void testMultiValuedScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(count("count").script(new Script("doc['values'].values"))).execute().actionGet();
@@ -181,8 +170,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(20l));
}
- @Test
- public void singleValuedScriptWithParams() throws Exception {
+ public void testSingleValuedScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("s", "value");
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -196,8 +184,7 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getValue(), equalTo(10l));
}
- @Test
- public void multiValuedScriptWithParams() throws Exception {
+ public void testMultiValuedScriptWithParams() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("s", "values");
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
@@ -210,5 +197,4 @@ public class ValueCountTests extends ESIntegTestCase {
assertThat(valueCount.getName(), equalTo("count"));
assertThat(valueCount.getValue(), equalTo(20l));
}
-
} \ No newline at end of file
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptTests.java
index 337f4eb6dc..dcc3abf2e1 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptTests.java
@@ -23,15 +23,13 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.lucene.search.function.CombineFunction;
+import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.Script;
-import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.script.ScriptService.ScriptType;
-import org.elasticsearch.script.groovy.GroovyScriptEngineService;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,13 +51,11 @@ import static org.hamcrest.Matchers.equalTo;
*/
// TODO: refactor into unit test or proper rest tests
public class GroovyScriptTests extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(GroovyPlugin.class);
}
-
- @Test
+
public void testGroovyBigDecimalTransformation() {
client().prepareIndex("test", "doc", "1").setSource("foo", 5).setRefresh(true).get();
@@ -77,7 +73,6 @@ public class GroovyScriptTests extends ESIntegTestCase {
assertNoFailures(resp);
}
- @Test
public void testGroovyExceptionSerialization() throws Exception {
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (int i = 0; i < randomIntBetween(50, 500); i++) {
@@ -113,7 +108,6 @@ public class GroovyScriptTests extends ESIntegTestCase {
}
}
- @Test
public void testGroovyScriptAccess() {
client().prepareIndex("test", "doc", "1").setSource("foo", "quick brow fox jumped over the lazy dog", "bar", 1).get();
client().prepareIndex("test", "doc", "2").setSource("foo", "fast jumping spiders", "bar", 2).get();
@@ -127,7 +121,7 @@ public class GroovyScriptTests extends ESIntegTestCase {
assertNoFailures(resp);
assertOrderedSearchHits(resp, "3", "2", "1");
}
-
+
public void testScoreAccess() {
client().prepareIndex("test", "doc", "1").setSource("foo", "quick brow fox jumped over the lazy dog", "bar", 1).get();
client().prepareIndex("test", "doc", "2").setSource("foo", "fast jumping spiders", "bar", 2).get();
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovySecurityTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovySecurityTests.java
index f002bd1bef..1e5b4515d7 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovySecurityTests.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovySecurityTests.java
@@ -31,7 +31,6 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.nio.file.Path;
import java.util.Collection;
@@ -48,7 +47,6 @@ import static org.hamcrest.CoreMatchers.instanceOf;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
// TODO: refactor into unit test, or, proper REST test
public class GroovySecurityTests extends ESIntegTestCase {
-
@Override
public void setUp() throws Exception {
super.setUp();
@@ -60,7 +58,6 @@ public class GroovySecurityTests extends ESIntegTestCase {
return Collections.singleton(GroovyPlugin.class);
}
- @Test
public void testEvilGroovyScripts() throws Exception {
int nodes = randomIntBetween(1, 3);
Settings nodeSettings = Settings.builder()
@@ -109,7 +106,7 @@ public class GroovySecurityTests extends ESIntegTestCase {
// AccessControlException[access denied ("java.io.FilePermission" "<<ALL FILES>>" "execute")]
assertFailure("def methodName = 'ex'; Runtime.\"${'get' + 'Runtime'}\"().\"${methodName}ec\"(\"touch /tmp/gotcha2\")");
-
+
// test a directory we normally have access to, but the groovy script does not.
Path dir = createTempDir();
// TODO: figure out the necessary escaping for windows paths here :)
diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java
index bc3537c869..f3b0a576c8 100644
--- a/plugins/lang-groovy/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java
+++ b/plugins/lang-groovy/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java
@@ -51,7 +51,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
-import org.junit.Test;
import java.io.IOException;
import java.util.Random;
@@ -120,7 +119,6 @@ public class SearchQueryIT extends ESIntegTestCase {
return Math.min(2, cluster().numDataNodes() - 1);
}
- @Test
public void testOmitNormsOnAll() throws ExecutionException, InterruptedException, IOException {
assertAcked(prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1")
@@ -152,7 +150,7 @@ public class SearchQueryIT extends ESIntegTestCase {
}
- @Test // see #3952
+ // see #3952
public void testEmptyQueryString() throws ExecutionException, InterruptedException, IOException {
createIndex("test");
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox jumps"),
@@ -163,7 +161,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setQuery(queryStringQuery("")).get(), 0l); // return no docs
}
- @Test // see https://github.com/elasticsearch/elasticsearch/issues/3177
+ // see https://github.com/elasticsearch/elasticsearch/issues/3177
public void testIssue3177() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
@@ -196,7 +194,6 @@ public class SearchQueryIT extends ESIntegTestCase {
2l);
}
- @Test
public void testIndexOptions() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "field1", "type=string,index_options=docs"));
@@ -212,7 +209,7 @@ public class SearchQueryIT extends ESIntegTestCase {
containsString("field \"field1\" was indexed without position data; cannot run PhraseQuery"));
}
- @Test // see #3521
+ // see #3521
public void testConstantScoreQuery() throws Exception {
Random random = getRandom();
createIndex("test");
@@ -274,7 +271,7 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test // see #3521
+ // see #3521
public void testAllDocsQueryString() throws InterruptedException, ExecutionException {
createIndex("test");
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("foo", "bar"),
@@ -294,7 +291,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testCommonTermsQueryOnAllField() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("type1", "message", "type=string", "comment", "type=string,boost=5.0")
@@ -309,7 +305,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().getHits()[0].getScore(), greaterThan(searchResponse.getHits().getHits()[1].getScore()));
}
- @Test
public void testCommonTermsQuery() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("type1", "field1", "type=string,analyzer=whitespace")
@@ -390,7 +385,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertThirdHit(searchResponse, hasId("2"));
}
- @Test
public void testCommonTermsQueryStackedTokens() throws Exception {
assertAcked(prepareCreate("test")
.setSettings(settingsBuilder()
@@ -483,7 +477,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertThirdHit(searchResponse, hasId("2"));
}
- @Test
public void testOmitTermFreqsAndPositions() throws Exception {
cluster().wipeTemplates(); // no randomized template for this test -- we are testing bwc compat and set version explicitly this might cause failures if an unsupported feature
// is added randomly via an index template.
@@ -517,8 +510,7 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
- public void queryStringAnalyzedWildcard() throws Exception {
+ public void testQueryStringAnalyzedWildcard() throws Exception {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("field1", "value_1", "field2", "value_2").get();
@@ -540,7 +532,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test
public void testLowercaseExpandedTerms() {
createIndex("test");
@@ -561,7 +552,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test //https://github.com/elasticsearch/elasticsearch/issues/3540
+ // Issue #3540
public void testDateRangeInQueryString() {
//the mapping needs to be provided upfront otherwise we are not sure how many failures we get back
//as with dynamic mappings some shards might be lacking behind and parse a different query
@@ -589,7 +580,7 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test // https://github.com/elasticsearch/elasticsearch/issues/7880
+ // Issue #7880
public void testDateRangeInQueryStringWithTimeZone_7880() {
//the mapping needs to be provided upfront otherwise we are not sure how many failures we get back
//as with dynamic mappings some shards might be lacking behind and parse a different query
@@ -608,7 +599,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test // https://github.com/elasticsearch/elasticsearch/issues/10477
+ // Issue #10477
public void testDateRangeInQueryStringWithTimeZone_10477() {
//the mapping needs to be provided upfront otherwise we are not sure how many failures we get back
//as with dynamic mappings some shards might be lacking behind and parse a different query
@@ -645,13 +636,11 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
- public void typeFilterTypeIndexedTests() throws Exception {
+ public void testTypeFilterTypeIndexedTests() throws Exception {
typeFilterTests("not_analyzed");
}
- @Test
- public void typeFilterTypeNotIndexedTests() throws Exception {
+ public void testTypeFilterTypeNotIndexedTests() throws Exception {
typeFilterTests("no");
}
@@ -680,13 +669,11 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setTypes("type1", "type2").setQuery(matchAllQuery()).get(), 5l);
}
- @Test
- public void idsQueryTestsIdIndexed() throws Exception {
+ public void testIdsQueryTestsIdIndexed() throws Exception {
idsQueryTests("not_analyzed");
}
- @Test
- public void idsQueryTestsIdNotIndexed() throws Exception {
+ public void testIdsQueryTestsIdNotIndexed() throws Exception {
idsQueryTests("no");
}
@@ -728,17 +715,15 @@ public class SearchQueryIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "1", "3");
}
- @Test
- public void term_indexQueryTestsIndexed() throws Exception {
- term_indexQueryTests("not_analyzed");
+ public void testTermIndexQueryIndexed() throws Exception {
+ termIndexQueryTests("not_analyzed");
}
- @Test
- public void term_indexQueryTestsNotIndexed() throws Exception {
- term_indexQueryTests("no");
+ public void testTermIndexQueryNotIndexed() throws Exception {
+ termIndexQueryTests("no");
}
- private void term_indexQueryTests(String index) throws Exception {
+ private void termIndexQueryTests(String index) throws Exception {
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
String[] indexNames = { "test1", "test2" };
for (String indexName : indexNames) {
@@ -781,8 +766,7 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
- public void filterExistsMissingTests() throws Exception {
+ public void testFilterExistsMissing() throws Exception {
createIndex("test");
indexRandom(true,
@@ -849,8 +833,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "3", "4");
}
- @Test
- public void passQueryOrFilterAsJSONStringTest() throws Exception {
+ public void testPassQueryOrFilterAsJSONString() throws Exception {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").setRefresh(true).get();
@@ -865,7 +848,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setPostFilter(wrapperFilter).get(), 1l);
}
- @Test
public void testFiltersWithCustomCacheKey() throws Exception {
createIndex("test");
@@ -884,7 +866,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test
public void testMatchQueryNumeric() throws Exception {
assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double"));
@@ -907,7 +888,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testMultiMatchQuery() throws Exception {
createIndex("test");
@@ -971,7 +951,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("1"));
}
- @Test
public void testMatchQueryZeroTermsQuery() {
assertAcked(prepareCreate("test")
.addMapping("type1", "field1", "type=string,analyzer=classic", "field2", "type=string,analyzer=classic"));
@@ -1021,7 +1000,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2l);
}
- @Test
public void testMultiMatchQueryMinShouldMatch() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("field1", new String[]{"value1", "value2", "value3"}).get();
@@ -1067,7 +1045,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("1"));
}
- @Test
public void testFuzzyQueryString() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("str", "kimchy", "date", "2012-02-01", "num", 12).get();
@@ -1088,7 +1065,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("1"));
}
- @Test
public void testQuotedQueryStringWithBoost() throws InterruptedException, ExecutionException {
float boost = 10.0f;
assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, 1));
@@ -1112,7 +1088,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(boost * searchResponse.getHits().getAt(1).score(), .1));
}
- @Test
public void testSpecialRangeSyntaxInQueryString() {
createIndex("test");
client().prepareIndex("test", "type1", "1").setSource("str", "kimchy", "date", "2012-02-01", "num", 12).get();
@@ -1143,7 +1118,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test
public void testEmptytermsQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "term", "type=string"));
@@ -1160,7 +1134,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
public void testTermsQuery() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "str", "type=string", "lng", "type=long", "dbl", "type=double"));
@@ -1228,7 +1201,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
public void testTermsLookupFilter() throws Exception {
assertAcked(prepareCreate("lookup").addMapping("type", "terms","type=string", "other", "type=string"));
assertAcked(prepareCreate("lookup2").addMapping("type",
@@ -1316,7 +1288,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 0l);
}
- @Test
public void testBasicQueryById() throws Exception {
createIndex("test");
@@ -1349,7 +1320,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertThat(searchResponse.getHits().hits().length, equalTo(2));
}
- @Test
public void testNumericTermsAndRanges() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1",
@@ -1449,7 +1419,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("1"));
}
- @Test
public void testNumericRangeFilter_2826() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1",
@@ -1488,7 +1457,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2l);
}
- @Test // see #2926
+ // see #2926
public void testMustNot() throws IOException, ExecutionException, InterruptedException {
assertAcked(prepareCreate("test")
//issue manifested only with shards>=2
@@ -1511,7 +1480,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2l);
}
- @Test // see #2994
+ // see #2994
public void testSimpleSpan() throws IOException, ExecutionException, InterruptedException {
createIndex("test");
@@ -1531,7 +1500,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 3l);
}
- @Test
public void testSpanMultiTermQuery() throws IOException {
createIndex("test");
@@ -1563,7 +1531,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(response, 3);
}
- @Test
public void testSpanNot() throws IOException, ExecutionException, InterruptedException {
createIndex("test");
@@ -1587,7 +1554,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test
public void testSimpleDFSQuery() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("s", jsonBuilder()
@@ -1642,7 +1608,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertNoFailures(response);
}
- @Test
public void testMultiFieldQueryString() {
client().prepareIndex("test", "s", "1").setSource("field1", "value1", "field2", "value2").setRefresh(true).get();
@@ -1664,7 +1629,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
// see #3881 - for extensive description of the issue
- @Test
public void testMatchQueryWithSynonyms() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -1695,7 +1659,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2);
}
- @Test
public void testMatchQueryWithStackedStems() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -1720,7 +1683,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2);
}
- @Test
public void testQueryStringWithSynonyms() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -1753,7 +1715,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 2);
}
- @Test // see https://github.com/elasticsearch/elasticsearch/issues/3898
+ // see #3898
public void testCustomWordDelimiterQueryString() {
assertAcked(client().admin().indices().prepareCreate("test")
.setSettings("analysis.analyzer.my_analyzer.type", "custom",
@@ -1780,7 +1742,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(response, 1l);
}
- @Test // see https://github.com/elasticsearch/elasticsearch/issues/3797
+ // see #3797
public void testMultiMatchLenientIssue3797() {
createIndex("test");
@@ -1800,14 +1762,12 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(searchResponse, 1l);
}
- @Test
public void testAllFieldEmptyMapping() throws Exception {
client().prepareIndex("myindex", "mytype").setId("1").setSource("{}").setRefresh(true).get();
SearchResponse response = client().prepareSearch("myindex").setQuery(matchQuery("_all", "foo")).get();
assertNoFailures(response);
}
- @Test
public void testAllDisabledButQueried() throws Exception {
createIndex("myindex");
assertAcked(client().admin().indices().preparePutMapping("myindex").setType("mytype").setSource(
@@ -1818,7 +1778,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(response, 0);
}
- @Test
public void testIndicesQuery() throws Exception {
createIndex("index1", "index2", "index3");
@@ -1852,7 +1811,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertFirstHit(searchResponse, hasId("1"));
}
- @Test // https://github.com/elasticsearch/elasticsearch/issues/2416
+ // See #2416
public void testIndicesQuerySkipParsing() throws Exception {
createIndex("simple");
assertAcked(prepareCreate("related")
@@ -1884,7 +1843,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "1", "2");
}
- @Test
public void testIndicesQueryMissingIndices() throws IOException, ExecutionException, InterruptedException {
createIndex("index1");
createIndex("index2");
@@ -1953,7 +1911,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testMinScore() throws ExecutionException, InterruptedException {
createIndex("test");
@@ -1970,7 +1927,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertSecondHit(searchResponse, hasId("1"));
}
- @Test
public void testQueryStringWithSlopAndFields() {
createIndex("test");
@@ -1999,7 +1955,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testDateProvidedAsNumber() throws ExecutionException, InterruptedException {
createIndex("test");
assertAcked(client().admin().indices().preparePutMapping("test").setType("type").setSource("field", "type=date,format=epoch_millis").get());
@@ -2012,7 +1967,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch("test").setSize(0).setQuery(rangeQuery("field").lte(-999999999999L)).get(), 3);
}
- @Test
public void testRangeQueryWithTimeZone() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "date", "type=date", "num", "type=integer"));
@@ -2107,7 +2061,6 @@ public class SearchQueryIT extends ESIntegTestCase {
}
}
- @Test
public void testSearchEmptyDoc() {
assertAcked(prepareCreate("test").setSettings("{\"index.analysis.analyzer.default.type\":\"keyword\"}"));
client().prepareIndex("test", "type1", "1").setSource("{}").get();
@@ -2116,7 +2069,7 @@ public class SearchQueryIT extends ESIntegTestCase {
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l);
}
- @Test // see #5120
+ // see #5120
public void testNGramCopyField() {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
@@ -2182,7 +2135,6 @@ public class SearchQueryIT extends ESIntegTestCase {
assertSearchHits(searchResponse, "2");
}
- @Test
public void testQueryStringParserCache() throws Exception {
createIndex("test");
indexRandom(true, false, client().prepareIndex("test", "type", "1").setSource("nameTokens", "xyz"));
diff --git a/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java b/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java
index f0a31810c4..fe9cc324f1 100644
--- a/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java
+++ b/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,7 +40,6 @@ import static org.hamcrest.Matchers.instanceOf;
*
*/
public class JavaScriptScriptEngineTests extends ESTestCase {
-
private JavaScriptScriptEngineService se;
@Before
@@ -54,14 +52,12 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
se.close();
}
- @Test
public void testSimpleEquation() {
Map<String, Object> vars = new HashMap<String, Object>();
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "js", se.compile("1 + 2")), vars).run();
assertThat(((Number) o).intValue(), equalTo(3));
}
- @Test
public void testMapAccess() {
Map<String, Object> vars = new HashMap<String, Object>();
@@ -78,7 +74,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat(((String) o), equalTo("2"));
}
- @Test
public void testJavaScriptObjectToMap() {
Map<String, Object> vars = new HashMap<String, Object>();
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testJavaScriptObjectToMap", "js",
@@ -88,7 +83,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
}
- @Test
public void testJavaScriptObjectMapInter() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> ctx = new HashMap<String, Object>();
@@ -107,7 +101,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat((String) ((Map<String, Object>) ctx.get("obj2")).get("prop2"), equalTo("value2"));
}
- @Test
public void testJavaScriptInnerArrayCreation() {
Map<String, Object> ctx = new HashMap<String, Object>();
Map<String, Object> doc = new HashMap<String, Object>();
@@ -124,7 +117,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat(((Map) unwrap.get("doc")).get("field1"), instanceOf(List.class));
}
- @Test
public void testAccessListInScript() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
@@ -150,7 +142,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat(((String) o), equalTo("value1"));
}
- @Test
public void testChangingVarsCrossExecution1() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> ctx = new HashMap<String, Object>();
@@ -168,7 +159,6 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
assertThat(((Number) o).intValue(), equalTo(2));
}
- @Test
public void testChangingVarsCrossExecution2() {
Map<String, Object> vars = new HashMap<String, Object>();
Object compiledScript = se.compile("value");
diff --git a/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTests.java b/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTests.java
index b639ed99f6..2308e666c5 100644
--- a/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTests.java
+++ b/plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.script.CompiledScript;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -39,8 +38,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class JavaScriptScriptMultiThreadedTests extends ESTestCase {
-
- @Test
public void testExecutableNoRuntimeParams() throws Exception {
final JavaScriptScriptEngineService se = new JavaScriptScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
final Object compiled = se.compile("x + y");
@@ -83,8 +80,6 @@ public class JavaScriptScriptMultiThreadedTests extends ESTestCase {
assertThat(failed.get(), equalTo(false));
}
-
- @Test
public void testExecutableWithRuntimeParams() throws Exception {
final JavaScriptScriptEngineService se = new JavaScriptScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
final Object compiled = se.compile("x + y");
@@ -127,7 +122,6 @@ public class JavaScriptScriptMultiThreadedTests extends ESTestCase {
assertThat(failed.get(), equalTo(false));
}
- @Test
public void testExecute() throws Exception {
final JavaScriptScriptEngineService se = new JavaScriptScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
final Object compiled = se.compile("x + y");
diff --git a/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java b/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java
index 979da657c5..35691357f3 100644
--- a/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java
+++ b/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java
@@ -27,7 +27,6 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -40,7 +39,6 @@ import static org.hamcrest.Matchers.instanceOf;
*
*/
public class PythonScriptEngineTests extends ESTestCase {
-
private PythonScriptEngineService se;
@Before
@@ -56,14 +54,12 @@ public class PythonScriptEngineTests extends ESTestCase {
se.close();
}
- @Test
public void testSimpleEquation() {
Map<String, Object> vars = new HashMap<String, Object>();
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "python", se.compile("1 + 2")), vars).run();
assertThat(((Number) o).intValue(), equalTo(3));
}
- @Test
public void testMapAccess() {
Map<String, Object> vars = new HashMap<String, Object>();
@@ -80,7 +76,6 @@ public class PythonScriptEngineTests extends ESTestCase {
assertThat(((String) o), equalTo("2"));
}
- @Test
public void testObjectMapInter() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> ctx = new HashMap<String, Object>();
@@ -99,9 +94,7 @@ public class PythonScriptEngineTests extends ESTestCase {
assertThat((String) ((Map<String, Object>) ctx.get("obj2")).get("prop2"), equalTo("value2"));
}
- @Test
public void testAccessListInScript() {
-
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).map();
@@ -122,7 +115,6 @@ public class PythonScriptEngineTests extends ESTestCase {
assertThat(((String) o), equalTo("value1"));
}
- @Test
public void testChangingVarsCrossExecution1() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> ctx = new HashMap<String, Object>();
@@ -139,7 +131,6 @@ public class PythonScriptEngineTests extends ESTestCase {
assertThat(((Number) o).intValue(), equalTo(2));
}
- @Test
public void testChangingVarsCrossExecution2() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> ctx = new HashMap<String, Object>();
diff --git a/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTests.java b/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTests.java
index 81ebf69b62..f0d6895561 100644
--- a/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTests.java
+++ b/plugins/lang-python/src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTests.java
@@ -25,7 +25,6 @@ import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
-import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@@ -40,7 +39,6 @@ import static org.hamcrest.Matchers.equalTo;
*
*/
public class PythonScriptMultiThreadedTests extends ESTestCase {
-
@After
public void close() {
// We need to clear some system properties
@@ -48,7 +46,6 @@ public class PythonScriptMultiThreadedTests extends ESTestCase {
System.clearProperty("python.console.encoding");
}
- @Test
public void testExecutableNoRuntimeParams() throws Exception {
final PythonScriptEngineService se = new PythonScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
final Object compiled = se.compile("x + y");
@@ -93,7 +90,7 @@ public class PythonScriptMultiThreadedTests extends ESTestCase {
}
-// @Test public void testExecutableWithRuntimeParams() throws Exception {
+// public void testExecutableWithRuntimeParams() throws Exception {
// final PythonScriptEngineService se = new PythonScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
// final Object compiled = se.compile("x + y");
// final AtomicBoolean failed = new AtomicBoolean();
@@ -135,7 +132,6 @@ public class PythonScriptMultiThreadedTests extends ESTestCase {
// assertThat(failed.get(), equalTo(false));
// }
- @Test
public void testExecute() throws Exception {
final PythonScriptEngineService se = new PythonScriptEngineService(Settings.Builder.EMPTY_SETTINGS);
final Object compiled = se.compile("x + y");
diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreServiceTests.java b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreServiceTests.java
index 7c843b52a8..995ae9256a 100644
--- a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreServiceTests.java
+++ b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreServiceTests.java
@@ -30,7 +30,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
@@ -41,12 +40,10 @@ import static org.hamcrest.Matchers.greaterThan;
numClientNodes = 0,
transportClientRatio = 0.0)
public class AzureSnapshotRestoreServiceTests extends AbstractAzureRepositoryServiceTestCase {
-
public AzureSnapshotRestoreServiceTests() {
super("/snapshot-test/repo-" + randomInt());
}
- @Test
public void testSimpleWorkflow() {
Client client = client();
logger.info("--> creating azure repository with path [{}]", basePath);
diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTests.java b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTests.java
index 237011ac4f..c0b01cee44 100644
--- a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTests.java
+++ b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTests.java
@@ -22,6 +22,7 @@ package org.elasticsearch.repositories.azure;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.microsoft.azure.storage.StorageException;
+
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
@@ -44,7 +45,6 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.store.MockFSDirectoryService;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.net.URISyntaxException;
import java.util.Locale;
@@ -63,7 +63,6 @@ import static org.hamcrest.Matchers.greaterThan;
numDataNodes = 1,
transportClientRatio = 0.0)
public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCase {
-
private String getRepositoryPath() {
String testName = "it-".concat(Strings.toUnderscoreCase(getTestName()).replaceAll("_", "-"));
return testName.contains(" ") ? Strings.split(testName, " ")[0] : testName;
@@ -101,7 +100,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
getContainerName().concat("-2"));
}
- @Test
public void testSimpleWorkflow() {
Client client = client();
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
@@ -177,7 +175,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* For issue #51: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/51
*/
- @Test
public void testMultipleSnapshots() throws URISyntaxException, StorageException {
final String indexName = "test-idx-1";
final String typeName = "doc";
@@ -234,7 +231,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
assertThat(client.prepareSearch(indexName).setSize(0).get().getHits().totalHits(), equalTo(1L));
}
- @Test
public void testMultipleRepositories() {
Client client = client();
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
@@ -303,7 +299,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* For issue #26: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/26
*/
- @Test
public void testListBlobs_26() throws StorageException, URISyntaxException {
createIndex("test-idx-1", "test-idx-2", "test-idx-3");
ensureGreen();
@@ -362,7 +357,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* For issue #28: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/28
*/
- @Test
public void testGetDeleteNonExistingSnapshot_28() throws StorageException, URISyntaxException {
ClusterAdminClient client = client().admin().cluster();
logger.info("--> creating azure repository without any path");
@@ -390,7 +384,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* For issue #21: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/21
*/
- @Test
public void testForbiddenContainerName() throws Exception {
checkContainerName("", false);
checkContainerName("es", false);
@@ -415,6 +408,7 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
// we can not create it yet.
assertBusy(new Runnable() {
+ @Override
public void run() {
try {
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo")
@@ -444,7 +438,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* Test case for issue #23: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/23
*/
- @Test
public void testNonExistingRepo_23() {
Client client = client();
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
@@ -468,7 +461,6 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
/**
* When a user remove a container you can not immediately create it again.
*/
- @Test
public void testRemoveAndCreateContainer() throws Exception {
final String container = getContainerName().concat("-testremove");
final AzureStorageService storageService = internalCluster().getInstance(AzureStorageService.class);
@@ -477,6 +469,7 @@ public class AzureSnapshotRestoreTests extends AbstractAzureWithThirdPartyTestCa
// so we might need some time to be able to create the container
assertBusy(new Runnable() {
+ @Override
public void run() {
try {
storageService.createContainer(container);
diff --git a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
index 03048c60a4..cd3584d7be 100644
--- a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
+++ b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/AWSSignersTests.java
@@ -20,14 +20,12 @@
package org.elasticsearch.cloud.aws;
import com.amazonaws.ClientConfiguration;
+
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class AWSSignersTests extends ESTestCase {
-
- @Test
public void testSigners() {
assertThat(signerTester(null), is(false));
assertThat(signerTester("QueryStringSignerType"), is(true));
diff --git a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTests.java b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTests.java
index f40065c4e2..f023b64211 100644
--- a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTests.java
+++ b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTests.java
@@ -20,7 +20,6 @@
package org.elasticsearch.cloud.aws.blobstore;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -28,15 +27,14 @@ import java.util.Arrays;
import static org.elasticsearch.common.io.Streams.copy;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
/**
* Unit test for {@link S3OutputStream}.
*/
public class S3OutputStreamTests extends ESTestCase {
-
private static final int BUFFER_SIZE = S3BlobStore.MIN_BUFFER_SIZE.bytesAsInt();
- @Test
public void testWriteLessDataThanBufferSize() throws IOException {
MockDefaultS3OutputStream out = newS3OutputStream(BUFFER_SIZE);
byte[] content = randomUnicodeOfLengthBetween(1, 512).getBytes("UTF-8");
@@ -54,7 +52,6 @@ public class S3OutputStreamTests extends ESTestCase {
}
- @Test
public void testWriteSameDataThanBufferSize() throws IOException {
int size = randomIntBetween(BUFFER_SIZE, 2 * BUFFER_SIZE);
MockDefaultS3OutputStream out = newS3OutputStream(size);
@@ -77,7 +74,6 @@ public class S3OutputStreamTests extends ESTestCase {
}
- @Test
public void testWriteExactlyNTimesMoreDataThanBufferSize() throws IOException {
int n = randomIntBetween(2, 3);
int length = n * BUFFER_SIZE;
@@ -102,7 +98,6 @@ public class S3OutputStreamTests extends ESTestCase {
assertTrue(out.isMultipart());
}
- @Test
public void testWriteRandomNumberOfBytes() throws IOException {
Integer randomBufferSize = randomIntBetween(BUFFER_SIZE, 2 * BUFFER_SIZE);
MockDefaultS3OutputStream out = newS3OutputStream(randomBufferSize);
@@ -129,11 +124,14 @@ public class S3OutputStreamTests extends ESTestCase {
}
}
- @Test(expected = IllegalArgumentException.class)
public void testWrongBufferSize() throws IOException {
Integer randomBufferSize = randomIntBetween(1, 4 * 1024 * 1024);
- MockDefaultS3OutputStream out = newS3OutputStream(randomBufferSize);
- fail("Buffer size can't be smaller than 5mb");
+ try {
+ newS3OutputStream(randomBufferSize);
+ fail("Buffer size can't be smaller than 5mb");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage(), is("Buffer size can't be smaller than 5mb"));
+ }
}
private MockDefaultS3OutputStream newS3OutputStream(int bufferSizeInBytes) {
diff --git a/plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java b/plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java
index 1c9b453a9f..9ffa1286bc 100644
--- a/plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java
+++ b/plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java
@@ -43,18 +43,18 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.store.MockFSDirectoryService;
import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.notNullValue;
/**
*/
@ClusterScope(scope = Scope.SUITE, numDataNodes = 2, numClientNodes = 0, transportClientRatio = 0.0)
abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase {
-
@Override
public Settings indexSettings() {
// During restore we frequently restore index to exactly the same state it was before, that might cause the same
@@ -83,7 +83,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
cleanRepositoryFiles(basePath);
}
- @Test @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
+ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testSimpleWorkflow() {
Client client = client();
Settings.Builder settings = Settings.settingsBuilder()
@@ -161,7 +161,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
assertThat(clusterState.getMetaData().hasIndex("test-idx-2"), equalTo(false));
}
- @Test @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
+ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testEncryption() {
Client client = client();
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", internalCluster().getInstance(Settings.class).get("repositories.s3.bucket"), basePath);
@@ -254,20 +254,21 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
* This test verifies that the test configuration is set up in a manner that
* does not make the test {@link #testRepositoryWithCustomCredentials()} pointless.
*/
- @Test(expected = RepositoryVerificationException.class)
- public void assertRepositoryWithCustomCredentialsIsNotAccessibleByDefaultCredentials() {
+ public void testRepositoryWithCustomCredentialsIsNotAccessibleByDefaultCredentials() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.private-bucket.");
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", bucketSettings.get("bucket"), basePath);
- client.admin().cluster().preparePutRepository("test-repo")
- .setType("s3").setSettings(Settings.settingsBuilder()
- .put("base_path", basePath)
- .put("bucket", bucketSettings.get("bucket"))
- ).get();
- fail("repository verification should have raise an exception!");
+ try {
+ client.admin().cluster().preparePutRepository("test-repo")
+ .setType("s3").setSettings(Settings.settingsBuilder()
+ .put("base_path", basePath)
+ .put("bucket", bucketSettings.get("bucket"))
+ ).get();
+ fail("repository verification should have raise an exception!");
+ } catch (RepositoryVerificationException e) {
+ }
}
- @Test
public void testRepositoryWithCustomCredentials() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.private-bucket.");
@@ -285,7 +286,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
assertRepositoryIsOperational(client, "test-repo");
}
- @Test @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
+ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testRepositoryWithCustomEndpointProtocol() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.external-bucket.");
@@ -306,23 +307,24 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
* This test verifies that the test configuration is set up in a manner that
* does not make the test {@link #testRepositoryInRemoteRegion()} pointless.
*/
- @Test(expected = RepositoryVerificationException.class)
- public void assertRepositoryInRemoteRegionIsRemote() {
+ public void testRepositoryInRemoteRegionIsRemote() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.remote-bucket.");
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", bucketSettings.get("bucket"), basePath);
- client.admin().cluster().preparePutRepository("test-repo")
- .setType("s3").setSettings(Settings.settingsBuilder()
- .put("base_path", basePath)
- .put("bucket", bucketSettings.get("bucket"))
- // Below setting intentionally omitted to assert bucket is not available in default region.
- // .put("region", privateBucketSettings.get("region"))
- ).get();
-
- fail("repository verification should have raise an exception!");
+ try {
+ client.admin().cluster().preparePutRepository("test-repo")
+ .setType("s3").setSettings(Settings.settingsBuilder()
+ .put("base_path", basePath)
+ .put("bucket", bucketSettings.get("bucket"))
+ // Below setting intentionally omitted to assert bucket is not available in default region.
+ // .put("region", privateBucketSettings.get("region"))
+ ).get();
+ fail("repository verification should have raise an exception!");
+ } catch (RepositoryVerificationException e) {
+ }
}
- @Test @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
+ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testRepositoryInRemoteRegion() {
Client client = client();
Settings settings = internalCluster().getInstance(Settings.class);
@@ -342,8 +344,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
/**
* Test case for issue #86: https://github.com/elasticsearch/elasticsearch-cloud-aws/issues/86
*/
- @Test
- public void testNonExistingRepo_86() {
+ public void testNonExistingRepo86() {
Client client = client();
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", internalCluster().getInstance(Settings.class).get("repositories.s3.bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
@@ -364,8 +365,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTestCase
/**
* For issue #86: https://github.com/elasticsearch/elasticsearch-cloud-aws/issues/86
*/
- @Test
- public void testGetDeleteNonExistingSnapshot_86() {
+ public void testGetDeleteNonExistingSnapshot86() {
ClusterAdminClient client = client().admin().cluster();
logger.info("--> creating s3 repository without any path");
PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo")
diff --git a/plugins/store-smb/src/test/java/org/elasticsearch/index/store/AbstractAzureFsTestCase.java b/plugins/store-smb/src/test/java/org/elasticsearch/index/store/AbstractAzureFsTestCase.java
index 770e819bd2..9e29d6f091 100644
--- a/plugins/store-smb/src/test/java/org/elasticsearch/index/store/AbstractAzureFsTestCase.java
+++ b/plugins/store-smb/src/test/java/org/elasticsearch/index/store/AbstractAzureFsTestCase.java
@@ -23,20 +23,17 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.plugin.store.smb.SMBStorePlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.junit.Test;
import java.util.Collection;
import static org.hamcrest.Matchers.is;
abstract public class AbstractAzureFsTestCase extends ESIntegTestCase {
-
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(SMBStorePlugin.class);
}
- @Test
public void testAzureFs() {
// Create an index and index some documents
createIndex("test");
diff --git a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/SmokeTestClientIT.java b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/SmokeTestClientIT.java
index 4c324b0f1a..4c5b38ca33 100644
--- a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/SmokeTestClientIT.java
+++ b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/SmokeTestClientIT.java
@@ -22,17 +22,14 @@ package org.elasticsearch.smoketest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.greaterThan;
public class SmokeTestClientIT extends ESSmokeClientTestCase {
-
/**
* Check that we are connected to a cluster named "elasticsearch".
*/
- @Test
public void testSimpleClient() {
Client client = getClient();
@@ -47,7 +44,6 @@ public class SmokeTestClientIT extends ESSmokeClientTestCase {
/**
* Create an index and index some docs
*/
- @Test
public void testPutDocument() {
Client client = getClient();