1
0
Эх сурвалжийг харах

Cleanup tests - using assert method instead of assert keyword

Simon Willnauer 11 жил өмнө
parent
commit
0d8330b50a
69 өөрчлөгдсөн 190 нэмэгдсэн , 202 устгасан
  1. 2 2
      src/test/java/org/apache/lucene/search/postingshighlight/XPostingsHighlighterTests.java
  2. 1 1
      src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
  3. 2 2
      src/test/java/org/elasticsearch/action/termvector/AbstractTermVectorTests.java
  4. 5 5
      src/test/java/org/elasticsearch/action/termvector/GetTermVectorTests.java
  5. 2 2
      src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java
  6. 0 1
      src/test/java/org/elasticsearch/benchmark/scripts/score/BasicScriptBenchmark.java
  7. 6 6
      src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java
  8. 8 8
      src/test/java/org/elasticsearch/cluster/ClusterServiceTests.java
  9. 0 1
      src/test/java/org/elasticsearch/cluster/DiskUsageTests.java
  10. 3 3
      src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java
  11. 1 1
      src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java
  12. 2 2
      src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsTests.java
  13. 3 3
      src/test/java/org/elasticsearch/cluster/ack/AckTests.java
  14. 2 2
      src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java
  15. 6 6
      src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java
  16. 1 1
      src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java
  17. 1 1
      src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java
  18. 1 2
      src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java
  19. 2 2
      src/test/java/org/elasticsearch/common/util/SlicedDoubleListTests.java
  20. 2 2
      src/test/java/org/elasticsearch/common/util/SlicedLongListTests.java
  21. 3 4
      src/test/java/org/elasticsearch/common/util/SlicedObjectListTests.java
  22. 1 1
      src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java
  23. 1 1
      src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
  24. 2 2
      src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java
  25. 2 4
      src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java
  26. 1 1
      src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java
  27. 2 2
      src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java
  28. 6 6
      src/test/java/org/elasticsearch/get/GetActionTests.java
  29. 1 1
      src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java
  30. 1 1
      src/test/java/org/elasticsearch/index/cache/id/SimpleIdCacheTests.java
  31. 15 15
      src/test/java/org/elasticsearch/index/engine/internal/InternalEngineTests.java
  32. 1 1
      src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTests.java
  33. 1 1
      src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
  34. 8 8
      src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java
  35. 1 1
      src/test/java/org/elasticsearch/index/mapper/date/SimpleDateMappingTests.java
  36. 2 2
      src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java
  37. 4 4
      src/test/java/org/elasticsearch/index/mapper/geo/LatLonMappingGeoPointTests.java
  38. 1 1
      src/test/java/org/elasticsearch/index/mapper/id/IdMappingTests.java
  39. 1 1
      src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java
  40. 2 2
      src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java
  41. 1 1
      src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java
  42. 0 2
      src/test/java/org/elasticsearch/indices/fielddata/breaker/CircuitBreakerServiceTests.java
  43. 1 1
      src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java
  44. 5 5
      src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java
  45. 2 2
      src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java
  46. 2 2
      src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java
  47. 2 3
      src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java
  48. 1 1
      src/test/java/org/elasticsearch/percolator/PercolatorTests.java
  49. 2 2
      src/test/java/org/elasticsearch/recovery/RelocationTests.java
  50. 2 2
      src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java
  51. 3 3
      src/test/java/org/elasticsearch/routing/AliasRoutingTests.java
  52. 11 11
      src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java
  53. 1 1
      src/test/java/org/elasticsearch/script/IndexLookupTests.java
  54. 1 1
      src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java
  55. 2 2
      src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java
  56. 1 1
      src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java
  57. 10 10
      src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java
  58. 1 1
      src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java
  59. 2 2
      src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java
  60. 1 1
      src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java
  61. 3 3
      src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java
  62. 1 1
      src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java
  63. 1 4
      src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java
  64. 3 2
      src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java
  65. 16 17
      src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java
  66. 6 6
      src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java
  67. 1 1
      src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java
  68. 1 1
      src/test/java/org/elasticsearch/tribe/TribeTests.java
  69. 1 1
      src/test/java/org/elasticsearch/update/UpdateTests.java

+ 2 - 2
src/test/java/org/apache/lucene/search/postingshighlight/XPostingsHighlighterTests.java

@@ -1238,8 +1238,8 @@ public class XPostingsHighlighterTests extends ElasticsearchLuceneTestCase {
         XPostingsHighlighter highlighter = new XPostingsHighlighter(10000) {
             @Override
             protected String[][] loadFieldValues(IndexSearcher searcher, String[] fields, int[] docids, int maxLength) throws IOException {
-                assert fields.length == 1;
-                assert docids.length == 1;
+                assertThat(fields.length, equalTo(1));
+                assertThat(docids.length, equalTo(1));
                 String[][] contents = new String[1][1];
                 contents[0][0] = text;
                 return contents;

+ 1 - 1
src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java

@@ -84,7 +84,7 @@ public class BulkRequestTests extends ElasticsearchTestCase {
         String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
         try {
             new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), true, null, null, false);
-            assert false;
+            fail();
         } catch (Exception e) {
 
         }

+ 2 - 2
src/test/java/org/elasticsearch/action/termvector/AbstractTermVectorTests.java

@@ -117,7 +117,7 @@ public abstract class AbstractTermVectorTests extends ElasticsearchIntegrationTe
 
         public TestDoc(String id, TestFieldSetting[] fieldSettings, String[] fieldContent) {
             this.id = id;
-            assert fieldSettings.length == fieldContent.length;
+            assertEquals(fieldSettings.length, fieldContent.length);
             this.fieldSettings = fieldSettings;
             this.fieldContent = fieldContent;
         }
@@ -404,7 +404,7 @@ public abstract class AbstractTermVectorTests extends ElasticsearchIntegrationTe
         TopDocs search = searcher.search(new TermQuery(new Term("id", doc.id)), 1);
 
         ScoreDoc[] scoreDocs = search.scoreDocs;
-        assert (scoreDocs.length == 1);
+        assertEquals(1, scoreDocs.length);
         return directoryReader.getTermVectors(scoreDocs[0].doc);
     }
 

+ 5 - 5
src/test/java/org/elasticsearch/action/termvector/GetTermVectorTests.java

@@ -72,7 +72,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
         }
 
     }
-    
+
     @Test
     public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception {
         XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
@@ -99,7 +99,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
         assertThat(actionGet.isExists(), Matchers.equalTo(true));
 
     }
-    
+
     @Test
     public void testExistingFieldButNotInDocNPE() throws Exception {
 
@@ -125,7 +125,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
         assertThat(actionGet.isExists(), Matchers.equalTo(true));
 
     }
-    
+
 
 
     @Test
@@ -380,7 +380,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
 
     @Test
     public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws ElasticsearchException, IOException {
-        
+
         //create the test document
         int encoding = randomIntBetween(0, 2);
         String encodingString = "";
@@ -426,7 +426,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
             assertThat(docsAndPositions.nextDoc(), equalTo(0));
             List<BytesRef> curPayloads = payloads.get(term);
             assertThat(term, curPayloads, Matchers.notNullValue());
-            assert docsAndPositions != null;
+            assertNotNull(docsAndPositions);
             for (int k = 0; k < docsAndPositions.freq(); k++) {
                 docsAndPositions.nextPosition();
                 if (docsAndPositions.getPayload()!=null){

+ 2 - 2
src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java

@@ -73,7 +73,7 @@ public class IndexAliasesTests extends ElasticsearchIntegrationTest {
 //        try {
 //            logger.info("--> indexing against [alias1], should fail");
 //            client().index(indexRequest("alias1").type("type1").id("1").source(source("1", "test"))).actionGet();
-//            assert false : "index [alias1] should not exists";
+//            fail("index [alias1] should not exists");
 //        } catch (IndexMissingException e) {
 //            assertThat(e.index().name(), equalTo("alias1"));
 //        } 
@@ -111,7 +111,7 @@ public class IndexAliasesTests extends ElasticsearchIntegrationTest {
         try {
             logger.info("--> aliasing index [test] with [alias1] and filter [t]");
             admin().indices().prepareAliases().addAlias("test", "alias1", "{ t }").execute().actionGet();
-            assert false;
+            fail();
         } catch (Exception e) {
             // all is well
         }

+ 0 - 1
src/test/java/org/elasticsearch/benchmark/scripts/score/BasicScriptBenchmark.java

@@ -142,7 +142,6 @@ public class BasicScriptBenchmark {
     }
 
     static String[] getTerms(int numTerms) {
-        assert numTerms <= termsList.size();
         String[] terms = new String[numTerms];
         for (int i = 0; i < numTerms; i++) {
             terms[i] = termsList.get(i);

+ 6 - 6
src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java

@@ -103,14 +103,14 @@ public class SimpleBlocksTests extends ElasticsearchIntegrationTest {
             CreateIndexResponse r = client().admin().indices().prepareCreate(index).execute().actionGet();
             assertThat(r, notNullValue());
         } catch (ClusterBlockException e) {
-            assert false;
+            fail();
         }
     }
 
     private void canNotCreateIndex(String index) {
         try {
             client().admin().indices().prepareCreate(index).execute().actionGet();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }
@@ -123,7 +123,7 @@ public class SimpleBlocksTests extends ElasticsearchIntegrationTest {
             IndexResponse r = builder.execute().actionGet();
             assertThat(r, notNullValue());
         } catch (ClusterBlockException e) {
-            assert false;
+            fail();
         }
     }
 
@@ -132,7 +132,7 @@ public class SimpleBlocksTests extends ElasticsearchIntegrationTest {
             IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
             builder.setSource("foo", "bar");
             builder.execute().actionGet();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }
@@ -143,14 +143,14 @@ public class SimpleBlocksTests extends ElasticsearchIntegrationTest {
             IndicesExistsResponse r = client().admin().indices().prepareExists(index).execute().actionGet();
             assertThat(r, notNullValue());
         } catch (ClusterBlockException e) {
-            assert false;
+            fail();
         }
     }
 
     private void canNotIndexExists(String index) {
         try {
             IndicesExistsResponse r = client().admin().indices().prepareExists(index).execute().actionGet();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }

+ 8 - 8
src/test/java/org/elasticsearch/cluster/ClusterServiceTests.java

@@ -66,14 +66,14 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
                 try {
                     block.await();
                 } catch (InterruptedException e) {
-                    assert false;
+                    fail();
                 }
                 return currentState;
             }
 
             @Override
             public void onFailure(String source, Throwable t) {
-                assert false;
+                fail();
             }
         });
 
@@ -405,7 +405,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
                 try {
                     block1.await();
                 } catch (InterruptedException e) {
-                    assert false;
+                    fail();
                 }
                 return currentState;
             }
@@ -413,7 +413,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
             @Override
             public void onFailure(String source, Throwable t) {
                 invoked1.countDown();
-                assert false;
+                fail();
             }
         });
         invoked1.await();
@@ -428,7 +428,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
 
                 @Override
                 public void onFailure(String source, Throwable t) {
-                    assert false;
+                    fail();
                 }
             });
         }
@@ -466,7 +466,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
                 try {
                     block2.await();
                 } catch (InterruptedException e) {
-                    assert false;
+                    fail();
                 }
                 return currentState;
             }
@@ -474,7 +474,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
             @Override
             public void onFailure(String source, Throwable t) {
                 invoked3.countDown();
-                assert false;
+                fail();
             }
         });
         invoked3.await();
@@ -488,7 +488,7 @@ public class ClusterServiceTests extends ElasticsearchIntegrationTest {
 
                 @Override
                 public void onFailure(String source, Throwable t) {
-                    assert false;
+                    fail();
                 }
             });
         }

+ 0 - 1
src/test/java/org/elasticsearch/cluster/DiskUsageTests.java

@@ -47,7 +47,6 @@ public class DiskUsageTests extends ElasticsearchTestCase {
                     new DiskUsage("random", total, free);
                     fail("should never reach this");
                 } catch (IllegalStateException e) {
-                    assert true;
                 }
             } else {
                 DiskUsage du = new DiskUsage("random", total, free);

+ 3 - 3
src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java

@@ -47,7 +47,7 @@ public class SpecificMasterNodesTests extends ElasticsearchIntegrationTest {
         cluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
         try {
             assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
-            assert false : "should not be able to find master";
+            fail("should not be able to find master");
         } catch (MasterNotDiscoveredException e) {
             // all is well, no master elected
         }
@@ -61,7 +61,7 @@ public class SpecificMasterNodesTests extends ElasticsearchIntegrationTest {
 
         try {
             assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
-            assert false : "should not be able to find master";
+            fail("should not be able to find master");
         } catch (MasterNotDiscoveredException e) {
             // all is well, no master elected
         }
@@ -78,7 +78,7 @@ public class SpecificMasterNodesTests extends ElasticsearchIntegrationTest {
         cluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
         try {
             assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
-            assert false : "should not be able to find master";
+            fail("should not be able to find master");
         } catch (MasterNotDiscoveredException e) {
             // all is well, no master elected
         }

+ 1 - 1
src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java

@@ -54,7 +54,7 @@ public class UpdateSettingsValidationTests extends ElasticsearchIntegrationTest
 
         try {
             client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.refresh_interval", "")).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException ex) {
             logger.info("Error message: [{}]", ex.getMessage());
         }

+ 2 - 2
src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsTests.java

@@ -64,7 +64,7 @@ public class AckClusterUpdateSettingsTests extends ElasticsearchIntegrationTest
                 break;
             }
         }
-        assert excludedNodeId != null;
+        assertNotNull(excludedNodeId);
 
         ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings()
                 .setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
@@ -109,7 +109,7 @@ public class AckClusterUpdateSettingsTests extends ElasticsearchIntegrationTest
                 break;
             }
         }
-        assert excludedNodeId != null;
+        assertNotNull(excludedNodeId);
 
         ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s")
                 .setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();

+ 3 - 3
src/test/java/org/elasticsearch/cluster/ack/AckTests.java

@@ -292,9 +292,9 @@ public class AckTests extends ElasticsearchIntegrationTest {
             }
         }
 
-        assert fromNodeId != null;
-        assert toNodeId != null;
-        assert shardToBeMoved != null;
+        assertNotNull(fromNodeId);
+        assertNotNull(toNodeId);
+        assertNotNull(shardToBeMoved);
 
         logger.info("==> going to move shard [{}] from [{}] to [{}]", shardToBeMoved, fromNodeId, toNodeId);
         return new MoveAllocationCommand(shardToBeMoved.shardId(), fromNodeId, toNodeId);

+ 2 - 2
src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java

@@ -60,7 +60,7 @@ public class MappingMetaDataParserTests extends ElasticsearchTestCase {
         MappingMetaData.ParseContext parseContext = md.createParseContext(null, "routing_value", "1");
         try {
             md.parse(XContentFactory.xContent(bytes).createParser(bytes), parseContext);
-        assert false;
+        fail();
         } catch (MapperParsingException ex) {
             // bogus its an array
         }
@@ -70,7 +70,7 @@ public class MappingMetaDataParserTests extends ElasticsearchTestCase {
         parseContext = md.createParseContext(null, "routing_value", "1");
         try {
             md.parse(XContentFactory.xContent(bytes).createParser(bytes), parseContext);
-        assert false;
+        fail();
         } catch (MapperParsingException ex) {
             // bogus its an object
         }

+ 6 - 6
src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java

@@ -125,7 +125,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> allocating with primary flag set to false, should fail");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new AllocateAllocationCommand(new ShardId("test", 0), "node1", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
@@ -147,7 +147,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> allocate the replica shard on the primary shard node, should fail");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new AllocateAllocationCommand(new ShardId("test", 0), "node1", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
@@ -172,7 +172,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> verify that we fail when there are no unassigned shards");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new AllocateAllocationCommand(new ShardId("test", 0), "node3", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
     }
@@ -214,7 +214,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> cancel primary allocation, make sure it fails...");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand(new ShardId("test", 0), "node1", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
@@ -228,7 +228,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> cancel primary allocation, make sure it fails...");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand(new ShardId("test", 0), "node1", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
@@ -262,7 +262,7 @@ public class AllocationCommandsTests extends ElasticsearchAllocationTestCase {
         logger.info("--> cancel the primary being replicated, make sure it fails");
         try {
             allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand(new ShardId("test", 0), "node1", false)));
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 

+ 1 - 1
src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java

@@ -317,7 +317,7 @@ public class BalanceConfigurationTests extends ElasticsearchAllocationTestCase {
 
             @Override
             public void addListener(Listener listener) {
-                assert listeners[0] == null;
+                assertNull("addListener was called twice while only one time was expected", listeners[0]);
                 listeners[0] = listener;
             }
 

+ 1 - 1
src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java

@@ -116,7 +116,7 @@ public class ClusterSearchShardsTests extends ElasticsearchIntegrationTest {
                 seenTest2 = true;
                 assertThat(group.getShards().length, equalTo(2));
             } else {
-                assert false;
+                fail();
             }
         }
         assertThat(seenTest1, equalTo(true));

+ 1 - 2
src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java

@@ -31,7 +31,6 @@ import org.junit.Test;
 
 import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiLineString;
 import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiPolygon;
-import static org.junit.Assert.assertEquals;
 /**
  * Tests for {@link ShapeBuilder}
  */
@@ -155,7 +154,7 @@ public class ShapeBuilderTests extends ElasticsearchTestCase {
                 .point(-40.0, -50.0)
                 .point(40.0, -50.0)
             .close().build();
-            assert false : "Polygon self-intersection";
+            fail("Polygon self-intersection");
         } catch (Throwable e) {}
         
     }

+ 2 - 2
src/test/java/org/elasticsearch/common/util/SlicedDoubleListTests.java

@@ -96,12 +96,12 @@ public class SlicedDoubleListTests extends ElasticsearchTestCase {
         SlicedDoubleList list = new SlicedDoubleList(5);
         try {
             list.set(0, (double)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
         try {
             list.add((double)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
     }

+ 2 - 2
src/test/java/org/elasticsearch/common/util/SlicedLongListTests.java

@@ -72,12 +72,12 @@ public class SlicedLongListTests extends ElasticsearchTestCase {
         SlicedLongList list = new SlicedLongList(5);
         try {
             list.set(0, (long)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
         try {
             list.add((long)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
     }

+ 3 - 4
src/test/java/org/elasticsearch/common/util/SlicedObjectListTests.java

@@ -23,7 +23,6 @@ import org.apache.lucene.util.RamUsageEstimator;
 import org.elasticsearch.test.ElasticsearchTestCase;
 import org.junit.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 /**
  * Tests for {@link SlicedObjectList}
@@ -46,7 +45,7 @@ public class SlicedObjectListTests extends ElasticsearchTestCase {
 
         @Override
         public void grow(int newLength) {
-            assert offset == 0; // NOTE: senseless if offset != 0
+            assertThat(offset, equalTo(0)); // NOTE: senseless if offset != 0
             if (values.length >= newLength) {
                 return;
             }
@@ -124,12 +123,12 @@ public class SlicedObjectListTests extends ElasticsearchTestCase {
         TestList list = new TestList(5);
         try {
             list.set(0, (double)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
         try {
             list.add((double)4);
-            assert false;
+            fail();
         } catch (UnsupportedOperationException ex) {
         }
     }

+ 1 - 1
src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java

@@ -135,7 +135,7 @@ public class EsExecutorsTests extends ElasticsearchTestCase {
                     executed3.set(true);
                 }
             });
-            assert false : "should be rejected...";
+            fail("should be rejected...");
         } catch (EsRejectedExecutionException e) {
             // all is well
         }

+ 1 - 1
src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java

@@ -171,7 +171,7 @@ public class PrioritizedExecutorsTests extends ElasticsearchTestCase {
                 try {
                     block.await();
                 } catch (InterruptedException e) {
-                    assert false;
+                    fail();
                 }
             }
 

+ 2 - 2
src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java

@@ -53,7 +53,7 @@ public class WriteConsistencyLevelTests extends ElasticsearchIntegrationTest {
             client().prepareIndex("test", "type1", "1").setSource(source("1", "test"))
                     .setConsistencyLevel(WriteConsistencyLevel.QUORUM)
                     .setTimeout(timeValueMillis(100)).execute().actionGet();
-            assert false : "can't index, does not match consistency";
+            fail("can't index, does not match consistency");
         } catch (UnavailableShardsException e) {
             // all is well
         }
@@ -74,7 +74,7 @@ public class WriteConsistencyLevelTests extends ElasticsearchIntegrationTest {
             client().prepareIndex("test", "type1", "1").setSource(source("1", "test"))
                     .setConsistencyLevel(WriteConsistencyLevel.ALL)
                     .setTimeout(timeValueMillis(100)).execute().actionGet();
-            assert false : "can't index, does not match consistency";
+            fail("can't index, does not match consistency");
         } catch (UnavailableShardsException e) {
             // all is well
         }

+ 2 - 4
src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java

@@ -30,9 +30,7 @@ import org.junit.Test;
 
 import java.util.Date;
 
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.fail;
 
 /**
  *
@@ -93,7 +91,7 @@ public class SimpleJodaTests extends ElasticsearchTestCase {
 
         try {
             formatter.parseMillis("1970 kuku");
-            assert false : "formatting should fail";
+            fail("formatting should fail");
         } catch (IllegalArgumentException e) {
             // all is well
         }
@@ -137,7 +135,7 @@ public class SimpleJodaTests extends ElasticsearchTestCase {
 
         try {
             millis = formatter.parser().parseMillis("1970/01/01");
-            assert false;
+            fail();
         } catch (IllegalArgumentException e) {
             // it really can't parse this one
         }

+ 1 - 1
src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java

@@ -81,7 +81,7 @@ public class IndexGatewayTests extends ElasticsearchIntegrationTest {
 
 
     protected boolean isPersistentStorage() {
-        assert storeType != null;
+        assertNotNull(storeType);
         return "fs".equals(settings.get().get("index.store.type"));
     }
 

+ 2 - 2
src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java

@@ -129,7 +129,7 @@ public class LocalGatewayIndexStateTests extends ElasticsearchIntegrationTest {
         logger.info("--> trying to index into a closed index ...");
         try {
             client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimeout("1s").execute().actionGet();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }
@@ -177,7 +177,7 @@ public class LocalGatewayIndexStateTests extends ElasticsearchIntegrationTest {
         logger.info("--> trying to index into a closed index ...");
         try {
             client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimeout("1s").execute().actionGet();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }

+ 6 - 6
src/test/java/org/elasticsearch/get/GetActionTests.java

@@ -552,7 +552,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareGet("test", "type1", "1").setVersion(2).execute().actionGet();
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
         }
 
@@ -572,7 +572,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareGet("test", "type1", "1").setVersion(2).setRealtime(false).execute().actionGet();
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
         }
 
@@ -589,7 +589,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareGet("test", "type1", "1").setVersion(1).execute().actionGet();
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
         }
 
@@ -609,7 +609,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareGet("test", "type1", "1").setVersion(1).setRealtime(false).execute().actionGet();
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
         }
 
@@ -777,14 +777,14 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareGet("my-index", "my-type1", "1").setFields("field1").get();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {}
 
         client().admin().indices().prepareFlush("my-index").get();
 
         try {
             client().prepareGet("my-index", "my-type1", "1").setFields("field1").get();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {}
     }
 

+ 1 - 1
src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java

@@ -156,7 +156,7 @@ public class IndexAliasesServiceTests extends ElasticsearchTestCase {
 
         try {
             indexAliasesService.aliasFilter("unknown");
-            assert false;
+            fail();
         } catch (InvalidAliasNameException e) {
             // all is well
         }

+ 1 - 1
src/test/java/org/elasticsearch/index/cache/id/SimpleIdCacheTests.java

@@ -84,7 +84,7 @@ public class SimpleIdCacheTests extends ElasticsearchTestCase {
         writer.commit();
 
         final String parentUid = parent.get("_uid");
-        assert parentUid != null;
+        assertNotNull(parentUid);
         writer.deleteDocuments(new Term("_uid", parentUid));
 
         writer.close();

+ 15 - 15
src/test/java/org/elasticsearch/index/engine/internal/InternalEngineTests.java

@@ -810,7 +810,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(1l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -819,7 +819,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(3l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -839,7 +839,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(13l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -861,7 +861,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(1l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -870,7 +870,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(3l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -892,7 +892,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(13);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -912,7 +912,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         Engine.Delete delete = new Engine.Delete("test", "1", newUid("1")).version(1l);
         try {
             engine.delete(delete);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -921,7 +921,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         delete = new Engine.Delete("test", "1", newUid("1")).version(3l);
         try {
             engine.delete(delete);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -935,7 +935,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(2l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -965,7 +965,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         Engine.Delete delete = new Engine.Delete("test", "1", newUid("1")).version(1l);
         try {
             engine.delete(delete);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -974,7 +974,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         delete = new Engine.Delete("test", "1", newUid("1")).version(3l);
         try {
             engine.delete(delete);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -992,7 +992,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(2l);
         try {
             engine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }
@@ -1016,7 +1016,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         create = new Engine.Create(null, newUid("1"), doc);
         try {
             engine.create(create);
-            assert false;
+            fail();
         } catch (DocumentAlreadyExistsException e) {
             // all is well
         }
@@ -1034,7 +1034,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         create = new Engine.Create(null, newUid("1"), doc);
         try {
             engine.create(create);
-            assert false;
+            fail();
         } catch (DocumentAlreadyExistsException e) {
             // all is well
         }
@@ -1060,7 +1060,7 @@ public class InternalEngineTests extends ElasticsearchTestCase {
         index = new Engine.Index(null, newUid("1"), doc).version(1l).origin(REPLICA);
         try {
             replicaEngine.index(index);
-            assert false;
+            fail();
         } catch (VersionConflictEngineException e) {
             // all is well
         }

+ 1 - 1
src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTests.java

@@ -394,7 +394,7 @@ public abstract class AbstractStringFieldDataTests extends AbstractFieldDataImpl
         BytesRef previous = null;
         for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
             final int docID = topDocs.scoreDocs[i].doc;
-            assert parents.get(docID);
+            assertTrue("expected " + docID + " to be a parent", parents.get(docID));
             BytesRef cmpValue = null;
             for (int child = parents.prevSetBit(docID - 1) + 1; child < docID; ++child) {
                 String[] vals = searcher.doc(child).getValues("text");

+ 1 - 1
src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java

@@ -596,7 +596,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
 
         @Override
         public String toString(BytesRef ref) {
-            assert ref.length > 0;
+            assertTrue(ref.length > 0);
             return Double.toString(Double.parseDouble(super.toString(ref)));
         }
 

+ 8 - 8
src/test/java/org/elasticsearch/index/mapper/boost/FieldLevelBoostTests.java

@@ -104,7 +104,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("str_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -113,7 +113,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("int_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -122,7 +122,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("byte_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -131,7 +131,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("date_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -140,7 +140,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("double_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -149,7 +149,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("float_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -158,7 +158,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("long_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }
@@ -167,7 +167,7 @@ public class FieldLevelBoostTests extends ElasticsearchTestCase {
             docMapper.parse(XContentFactory.jsonBuilder().startObject()
                     .field("_id", "1").startObject("short_field").field("foo", "bar")
                     .endObject().bytes()).rootDoc();
-            assert false;
+            fail();
         } catch (MapperParsingException ex) {
             // Expected
         }

+ 1 - 1
src/test/java/org/elasticsearch/index/mapper/date/SimpleDateMappingTests.java

@@ -87,7 +87,7 @@ public class SimpleDateMappingTests extends ElasticsearchTestCase {
         
         try {
             DateFieldMapper.parseLocale("de_DE_DE_DE");
-            assert false;
+            fail();
         } catch(ElasticsearchIllegalArgumentException ex) {
             // expected
         }

+ 2 - 2
src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java

@@ -94,7 +94,7 @@ public class DynamicMappingTests extends ElasticsearchTestCase {
                     .field("field1", "value1")
                     .field("field2", "value2")
                     .bytes());
-            assert false;
+            fail();
         } catch (StrictDynamicMappingException e) {
             // all is well
         }
@@ -144,7 +144,7 @@ public class DynamicMappingTests extends ElasticsearchTestCase {
                     .field("field2", "value2")
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (StrictDynamicMappingException e) {
             // all is well
         }

+ 4 - 4
src/test/java/org/elasticsearch/index/mapper/geo/LatLonMappingGeoPointTests.java

@@ -91,7 +91,7 @@ public class LatLonMappingGeoPointTests extends ElasticsearchTestCase {
                     .startObject("point").field("lat", -91).field("lon", 1.3).endObject()
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
 
         }
@@ -102,7 +102,7 @@ public class LatLonMappingGeoPointTests extends ElasticsearchTestCase {
                     .startObject("point").field("lat", 91).field("lon", 1.3).endObject()
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
 
         }
@@ -113,7 +113,7 @@ public class LatLonMappingGeoPointTests extends ElasticsearchTestCase {
                     .startObject("point").field("lat", 1.2).field("lon", -181).endObject()
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
 
         }
@@ -124,7 +124,7 @@ public class LatLonMappingGeoPointTests extends ElasticsearchTestCase {
                     .startObject("point").field("lat", 1.2).field("lon", 181).endObject()
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
 
         }

+ 1 - 1
src/test/java/org/elasticsearch/index/mapper/id/IdMappingTests.java

@@ -57,7 +57,7 @@ public class IdMappingTests extends ElasticsearchTestCase {
                     .startObject()
                     .endObject()
                     .bytes());
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
         }
 

+ 1 - 1
src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java

@@ -51,7 +51,7 @@ public class SimpleObjectMappingTests extends ElasticsearchTestCase {
                     "      },\n" +
                     "      \"value\":\"value\"\n" +
                     "    }"));
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
             // all is well
         }

+ 2 - 2
src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java

@@ -137,7 +137,7 @@ public class DefaultSourceMappingTests extends ElasticsearchTestCase {
             mapper = MapperTestUtils.newParser().parse(null, null, defaultMapping);
             assertThat(mapper.type(), equalTo("my_type"));
             assertThat(mapper.sourceMapper().enabled(), equalTo(false));
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
             // all is well
         }
@@ -145,7 +145,7 @@ public class DefaultSourceMappingTests extends ElasticsearchTestCase {
             mapper = MapperTestUtils.newParser().parse(null, "{}", defaultMapping);
             assertThat(mapper.type(), equalTo("my_type"));
             assertThat(mapper.sourceMapper().enabled(), equalTo(false));
-            assert false;
+            fail();
         } catch (MapperParsingException e) {
             assertThat(e.getMessage(), equalTo("malformed mapping no root object found"));
             // all is well

+ 1 - 1
src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java

@@ -122,7 +122,7 @@ public class ParentQueryTests extends ElasticsearchLuceneTestCase {
                         parentValueToChildIds.put(parentValue, childIdToScore = new TreeMap<String, Float>());
                     }
                     if (!markChildAsDeleted && !filterMe) {
-                        assert !childIdToScore.containsKey(child);
+                        assertFalse("child ["+ child + "] already has a score", childIdToScore.containsKey(child));
                         childIdToScore.put(child, 1f);
                         childIdToParentId.put(Integer.valueOf(child), parentDocId);
                     }

+ 0 - 2
src/test/java/org/elasticsearch/indices/fielddata/breaker/CircuitBreakerServiceTests.java

@@ -75,7 +75,6 @@ public class CircuitBreakerServiceTests extends ElasticsearchIntegrationTest {
                         .execute().actionGet();
                 fail("should not reach this point");
             } catch (SearchPhaseExecutionException e) {
-                assert true;
             }
 
         } finally {
@@ -133,7 +132,6 @@ public class CircuitBreakerServiceTests extends ElasticsearchIntegrationTest {
                         .execute().actionGet();
                 fail("should not reach this point");
             } catch (SearchPhaseExecutionException e) {
-                assert true;
             }
 
         } finally {

+ 1 - 1
src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java

@@ -45,7 +45,7 @@ public class UpdateSettingsTests extends ElasticsearchIntegrationTest {
                             .put("index.cache.filter.type", "none") // this one can't
                     )
                     .execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
             // all is well
         }

+ 5 - 5
src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java

@@ -53,35 +53,35 @@ public class CloseIndexDisableCloseAllTests extends ElasticsearchIntegrationTest
         // Close all explicitly
         try {
             client().admin().indices().prepareClose("_all").execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
         // Close all wildcard
         try {
             client().admin().indices().prepareClose("*").execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
         // Close all wildcard
         try {
             client().admin().indices().prepareClose("test*").execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
         // Close all wildcard
         try {
             client().admin().indices().prepareClose("*", "-test1").execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 
         // Close all wildcard
         try {
             client().admin().indices().prepareClose("*", "-test1", "+test1").execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
         }
 

+ 2 - 2
src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java

@@ -80,7 +80,7 @@ public class SimpleIndexStateTests extends ElasticsearchIntegrationTest {
         logger.info("--> trying to index into a closed index ...");
         try {
             client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
-            assert false;
+            fail();
         } catch (ClusterBlockException e) {
             // all is well
         }
@@ -148,7 +148,7 @@ public class SimpleIndexStateTests extends ElasticsearchIntegrationTest {
         logger.info("--> creating test index with invalid settings ");
         try {
             client().admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("number_of_shards", "bad")).get();
-            assert false;
+            fail();
         } catch (SettingsException ex) {
             // Expected
         }

+ 2 - 2
src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java

@@ -377,7 +377,7 @@ public class SimpleIndexStatsTests extends ElasticsearchIntegrationTest {
                 builder.setTranslog(set);
                 break;
             default:
-                assert false : "new flag? " + flag;
+                fail("new flag? " + flag);
                 break;
         }
     }
@@ -417,7 +417,7 @@ public class SimpleIndexStatsTests extends ElasticsearchIntegrationTest {
             case Translog:
                 return response.getTranslog() != null;
             default:
-                assert false : "new flag? " + flag;
+                fail("new flag? " + flag);
                 return false;
         }
     }

+ 2 - 3
src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java

@@ -176,7 +176,7 @@ public class SimpleIndicesWarmerTests extends ElasticsearchIntegrationTest {
 
         try {
             client().admin().indices().prepareDeleteWarmer().setIndices("test").setNames("foo").execute().actionGet(1000);
-            assert false : "warmer foo should not exist";
+            fail("warmer foo should not exist");
         } catch (IndexWarmerMissingException ex) {
             assertThat(ex.names()[0], equalTo("foo"));
         }
@@ -327,8 +327,7 @@ public class SimpleIndicesWarmerTests extends ElasticsearchIntegrationTest {
     }
 
     static {
-        assert Version.CURRENT.luceneVersion == org.apache.lucene.util.Version.LUCENE_46 :
-                "remove me when LUCENE-5373 is fixed";
+        assertTrue("remove me when LUCENE-5373 is fixed", Version.CURRENT.luceneVersion == org.apache.lucene.util.Version.LUCENE_46);
     }
 
     @Ignore("enable me when LUCENE-5373 is fixed, see assertion above")

+ 1 - 1
src/test/java/org/elasticsearch/percolator/PercolatorTests.java

@@ -1533,7 +1533,7 @@ public class PercolatorTests extends ElasticsearchIntegrationTest {
         }
         String[] strings = new String[matches.length];
         for (int i = 0; i < matches.length; i++) {
-            assert index.equals(matches[i].getIndex().string());
+            assertEquals(index, matches[i].getIndex().string());
             strings[i] = matches[i].getId().string();
         }
         return strings;

+ 2 - 2
src/test/java/org/elasticsearch/recovery/RelocationTests.java

@@ -254,7 +254,7 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
             }
         }
         if (!ranOnce) {
-            assert false;
+            fail();
         }
     }
 
@@ -413,7 +413,7 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
             }
         }
         if (!ranOnce) {
-            assert false;
+            fail();
         }
     }
 }

+ 2 - 2
src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java

@@ -64,14 +64,14 @@ public class AliasResolveRoutingTests extends ElasticsearchIntegrationTest {
         assertThat(clusterService().state().metaData().resolveIndexRouting("0", "alias10"), equalTo("0"));
         try {
             clusterService().state().metaData().resolveIndexRouting("1", "alias10");
-            assert false : "should fail";
+            fail("should fail");
         } catch (ElasticsearchIllegalArgumentException e) {
             // all is well, we can't have two mappings, one provided, and one in the alias
         }
 
         try {
             clusterService().state().metaData().resolveIndexRouting(null, "alias0");
-            assert false : "should fail";
+            fail("should fail");
         } catch (ElasticsearchIllegalArgumentException ex) {
             // Expected
         }

+ 3 - 3
src/test/java/org/elasticsearch/routing/AliasRoutingTests.java

@@ -342,7 +342,7 @@ public class AliasRoutingTests extends ElasticsearchIntegrationTest {
         logger.info("--> indexing with id [1], with no routing, should fail");
         try {
             client().prepareIndex("test", "type1", "1").setSource("field", "value1").setRefresh(true).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchException e) {
             assertThat(e.unwrapCause(), instanceOf(RoutingMissingException.class));
         }
@@ -357,7 +357,7 @@ public class AliasRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").get();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
             }
@@ -374,7 +374,7 @@ public class AliasRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
             }

+ 11 - 11
src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java

@@ -187,7 +187,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         logger.info("--> indexing with id [1], with no routing, should fail");
         try {
             client().prepareIndex("test", "type1", "1").setSource("field", "value1").setRefresh(true).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchException e) {
             assertThat(e.unwrapCause(), instanceOf(RoutingMissingException.class));
         }
@@ -202,7 +202,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").execute().actionGet().isExists();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
@@ -220,7 +220,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").execute().actionGet().isExists();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
@@ -244,7 +244,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         logger.info("--> check failure with different routing");
         try {
             client().prepareIndex("test", "type1", "1").setRouting("1").setSource("field", "value1", "routing_field", "0").setRefresh(true).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchException e) {
             assertThat(e.unwrapCause(), instanceOf(MapperParsingException.class));
         }
@@ -254,7 +254,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").execute().actionGet().isExists();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
@@ -284,7 +284,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").execute().actionGet().isExists();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
@@ -314,7 +314,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         for (int i = 0; i < 5; i++) {
             try {
                 client().prepareGet("test", "type1", "1").execute().actionGet().isExists();
-                assert false;
+                fail();
             } catch (RoutingMissingException e) {
                 assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
                 assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
@@ -344,7 +344,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         logger.info("--> verifying get with id [1], with no routing, should fail");
         try {
             client().prepareGet("test", "type1", "1").get();
-            assert false;
+            fail();
         } catch (RoutingMissingException e) {
             assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
         }
@@ -360,7 +360,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
         try {
             client().prepareExplain("test", "type1", "2")
                     .setQuery(QueryBuilders.matchAllQuery()).get();
-            assert false;
+            fail();
         } catch (RoutingMissingException e) {
             assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[2]"));
         }
@@ -372,7 +372,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareTermVector("test", "type1", "1").get();
-            assert false;
+            fail();
         } catch (RoutingMissingException e) {
             assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
         }
@@ -384,7 +384,7 @@ public class SimpleRoutingTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareUpdate("test", "type1", "1").setDoc("field1", "value1").get();
-            assert false;
+            fail();
         } catch (RoutingMissingException e) {
             assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
         }

+ 1 - 1
src/test/java/org/elasticsearch/script/IndexLookupTests.java

@@ -618,7 +618,7 @@ public class IndexLookupTests extends ElasticsearchIntegrationTest {
             } else if (result instanceof Long) {
                 assertThat(((Long) result).intValue(), equalTo(value));
             } else {
-                assert false;
+                fail();
             }
         }
     }

+ 1 - 1
src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java

@@ -83,7 +83,7 @@ public class NestedTests extends ElasticsearchIntegrationTest {
             }
             totalChildren += numChildren[i];
         }
-        assert totalChildren > 0;
+        assertTrue(totalChildren > 0);
 
         for (int i = 0; i < numParents; i++) {
             XContentBuilder source = jsonBuilder()

+ 2 - 2
src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java

@@ -69,7 +69,7 @@ public class TransportSearchFailuresTests extends ElasticsearchIntegrationTest {
                 assertThat(searchResponse.getTotalShards(), equalTo(3));
                 assertThat(searchResponse.getSuccessfulShards(), equalTo(0));
                 assertThat(searchResponse.getFailedShards(), equalTo(3));
-                assert false : "search should fail";
+                fail("search should fail");
             } catch (ElasticsearchException e) {
                 assertThat(e.unwrapCause(), instanceOf(SearchPhaseExecutionException.class));
                 // all is well
@@ -98,7 +98,7 @@ public class TransportSearchFailuresTests extends ElasticsearchIntegrationTest {
                 assertThat(searchResponse.getTotalShards(), equalTo(3));
                 assertThat(searchResponse.getSuccessfulShards(), equalTo(0));
                 assertThat(searchResponse.getFailedShards(), equalTo(3));
-                assert false : "search should fail";
+                fail("search should fail");
             } catch (ElasticsearchException e) {
                 assertThat(e.unwrapCause(), instanceOf(SearchPhaseExecutionException.class));
                 // all is well

+ 1 - 1
src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java

@@ -351,7 +351,7 @@ public class TransportTwoNodesSearchTests extends ElasticsearchIntegrationTest {
             assertThat(searchResponse.getTotalShards(), equalTo(3));
             assertThat(searchResponse.getSuccessfulShards(), equalTo(0));
             assertThat(searchResponse.getFailedShards(), equalTo(3));
-            assert false : "search should fail";
+            fail("search should fail");
         } catch (ElasticsearchException e) {
             assertThat(e.unwrapCause(), instanceOf(SearchPhaseExecutionException.class));
             // all is well

+ 10 - 10
src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java

@@ -107,7 +107,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
                     .point(-10, 10)
                     .point(10, -10)
                     .close().build();
-            assert false : "Self intersection not detected";
+            fail("Self intersection not detected");
         } catch (InvalidShapeException e) {
         }
 
@@ -126,7 +126,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
                     .point(-5, -5).point(-5, 11).point(5, 11).point(5, -5)
                     .close().close().build();
 
-            assert false : "Self intersection not detected";
+            fail("Self intersection not detected");
         } catch (InvalidShapeException e) {
         }
 
@@ -141,7 +141,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
                     .point(-5, -6).point(5, -6).point(5, -4).point(-5, -4)
                     .close()
                     .close().build();
-            assert false : "Intersection of holes not detected";
+            fail("Intersection of holes not detected");
         } catch (InvalidShapeException e) {
         }
 
@@ -156,7 +156,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
                     .point(10, 20)
                     .point(10, -10)
                     .close().build();
-            assert false : "Self intersection not detected";
+            fail("Self intersection not detected");
         } catch (InvalidShapeException e) {
         }
 
@@ -173,7 +173,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
 //                .polygon()
 //                    .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5)
 //                .close().build();
-//            assert false : "Polygon intersection not detected";
+//            fail("Polygon intersection not detected";
 //        } catch (InvalidShapeException e) {}
 
         // Multipolygon: polygon with hole and polygon within the whole
@@ -203,7 +203,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
 //                    .point(-4, -4).point(-4, 6).point(4, 6).point(4, -4)
 //                .close()
 //                .build();
-//            assert false : "Polygon intersection not detected";
+//            fail("Polygon intersection not detected";
 //        } catch (InvalidShapeException e) {}
 
     }
@@ -211,9 +211,9 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
     @Test
     public void testShapeRelations() throws Exception {
 
-        assert intersectSupport : "Intersect relation is not supported";
-        assert disjointSupport : "Disjoint relation is not supported";
-        assert withinSupport : "within relation is not supported";
+        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()
@@ -416,7 +416,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
         BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, false, null, null).execute().actionGet();
 
         for (BulkItemResponse item : bulk.getItems()) {
-            assert !item.isFailed() : "unable to index data";
+            assertFalse("unable to index data", item.isFailed());
         }
 
         client().admin().indices().prepareRefresh().execute().actionGet();

+ 1 - 1
src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java

@@ -50,7 +50,7 @@ public class SimpleIndicesBoostSearchTests extends ElasticsearchIntegrationTest
 
         try {
             client().prepareSearch("test").setQuery(termQuery("test", "value")).execute().actionGet();
-            assert false : "should fail";
+            fail("should fail");
         } catch (Exception e) {
             // ignore, no indices
         }

+ 2 - 2
src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java

@@ -42,14 +42,14 @@ public class SimpleSearchTests extends ElasticsearchIntegrationTest {
     public void testSearchNullIndex() {
         try {
             client().prepareSearch((String) null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
 
         }
 
         try {
             client().prepareSearch((String[]) null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
-            assert false;
+            fail();
         } catch (ElasticsearchIllegalArgumentException e) {
 
         }

+ 1 - 1
src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java

@@ -308,7 +308,7 @@ public class SimpleSortTests extends ElasticsearchIntegrationTest {
         SearchResponse result = client().prepareSearch("test").setQuery(matchAllQuery()).setTrackScores(true).addSort("field1", SortOrder.ASC).execute().actionGet();
 
         for (SearchHit hit : result.getHits()) {
-            assert !Float.isNaN(hit.getScore());
+            assertFalse(Float.isNaN(hit.getScore()));
         }
     }
 

+ 3 - 3
src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java

@@ -733,20 +733,20 @@ public class SuggestSearchTests extends ElasticsearchIntegrationTest {
                 .size(1);
         try {
             searchSuggest(client(), "Xor the Got-Jewel", 5, phraseSuggestion);
-            assert false : "field does not exists";
+            fail("field does not exists");
         } catch (SearchPhaseExecutionException e) {}
 
         phraseSuggestion.clearCandidateGenerators().analyzer(null);
         try {
             searchSuggest(client(), "Xor the Got-Jewel", 5, phraseSuggestion);
-            assert false : "analyzer does only produce ngrams";
+            fail("analyzer does only produce ngrams");
         } catch (SearchPhaseExecutionException e) {
         }
 
         phraseSuggestion.analyzer("bigram");
         try {
             searchSuggest(client(), "Xor the Got-Jewel", 5, phraseSuggestion);
-            assert false : "analyzer does only produce ngrams";
+            fail("analyzer does only produce ngrams");
         } catch (SearchPhaseExecutionException e) {
         }
 

+ 1 - 1
src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java

@@ -184,7 +184,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
                     currentCluster = buildAndPutCluster(currentClusterScope, true);
                     break;
                 default:
-                    assert false : "Unknown Scope: [" + currentClusterScope + "]";
+                    fail("Unknown Scope: [" + currentClusterScope + "]");
             }
             currentCluster.beforeTest(getRandom(), getPerTestTransportClientRatio());
             wipeIndices("_all");

+ 1 - 4
src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java

@@ -18,11 +18,8 @@
  */
 package org.elasticsearch.test;
 
-import com.carrotsearch.randomizedtesting.annotations.Listeners;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
+import com.carrotsearch.randomizedtesting.annotations.*;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
-import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 import org.apache.lucene.store.MockDirectoryWrapper;

+ 3 - 2
src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java

@@ -56,6 +56,7 @@ import java.util.Set;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
@@ -161,7 +162,7 @@ public class ElasticsearchAssertions {
     }
 
     public static void assertSearchHit(SearchResponse searchResponse, int number, Matcher<SearchHit> matcher) {
-        assert number > 0;
+        assertThat(number, greaterThan(0));
         assertThat("SearchHit number must be greater than 0", number, greaterThan(0));
         assertThat(searchResponse.getHits().totalHits(), greaterThanOrEqualTo((long) number));
         assertSearchHit(searchResponse.getHits().getAt(number - 1), matcher);
@@ -324,7 +325,7 @@ public class ElasticsearchAssertions {
     }
 
     public static void assertVersionSerializable(Streamable streamable) {
-        assert Version.CURRENT.after(ElasticsearchTestCase.getPreviousVersion());
+        assertTrue(Version.CURRENT.after(ElasticsearchTestCase.getPreviousVersion()));
         assertVersionSerializable(ElasticsearchTestCase.randomVersion(), streamable);
     }
 

+ 16 - 17
src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java

@@ -19,20 +19,19 @@
 
 package org.elasticsearch.test.hamcrest;
 
+import com.spatial4j.core.shape.Shape;
+import com.spatial4j.core.shape.jts.JtsGeometry;
+import com.spatial4j.core.shape.jts.JtsPoint;
+import com.vividsolutions.jts.geom.*;
+import org.junit.Assert;
+
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import com.spatial4j.core.shape.Shape;
-import com.spatial4j.core.shape.jts.JtsGeometry;
-import com.spatial4j.core.shape.jts.JtsPoint;
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.LineString;
-import com.vividsolutions.jts.geom.MultiLineString;
-import com.vividsolutions.jts.geom.MultiPoint;
-import com.vividsolutions.jts.geom.MultiPolygon;
-import com.vividsolutions.jts.geom.Polygon;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 public class ElasticsearchGeoAssertions {
 
@@ -100,7 +99,7 @@ public class ElasticsearchGeoAssertions {
     }
 
     public static void assertEquals(Coordinate c1, Coordinate c2) {
-        assert (c1.x == c2.x && c1.y == c2.y): "expected coordinate " + c1 + " but found " + c2;
+        assertTrue("expected coordinate " + c1 + " but found " + c2, c1.x == c2.x && c1.y == c2.y);
     }
 
     private static boolean isRing(Coordinate[] c) {
@@ -108,7 +107,7 @@ public class ElasticsearchGeoAssertions {
     }
     
     public static void assertEquals(Coordinate[] c1, Coordinate[] c2) {
-        assert (c1.length == c1.length) : "expected " + c1.length + " coordinates but found " + c2.length;
+        Assert.assertEquals(c1.length, c2.length);
 
         if(isRing(c1) && isRing(c2)) {
             c1 = fixedOrderedRing(c1, true);
@@ -125,7 +124,7 @@ public class ElasticsearchGeoAssertions {
     }
 
     public static void assertEquals(Polygon p1, Polygon p2) {
-        assert (p1.getNumInteriorRing() == p2.getNumInteriorRing()) : "expect " + p1.getNumInteriorRing() + " interior ring but found " + p2.getNumInteriorRing();
+        Assert.assertEquals(p1.getNumInteriorRing(), p2.getNumInteriorRing());
 
         assertEquals(p1.getExteriorRing(), p2.getExteriorRing());
 
@@ -137,7 +136,7 @@ public class ElasticsearchGeoAssertions {
     }
 
     public static void assertEquals(MultiPolygon p1, MultiPolygon p2) {
-        assert p1.getNumGeometries() == p2.getNumGeometries(): "expected " + p1.getNumGeometries() + " geometries but found " + p2.getNumGeometries();
+        Assert.assertEquals(p1.getNumGeometries(), p2.getNumGeometries());
 
         // TODO: This test do not check all permutations. So the Test fails
         // if the inner polygons are not ordered the same way in both Multipolygons
@@ -156,7 +155,7 @@ public class ElasticsearchGeoAssertions {
             assertEquals((Polygon) s1, (Polygon) s2);
 
         } else if (s1 instanceof MultiPoint && s2 instanceof MultiPoint) {
-            assert s1.equals(s2): "Expected " + s1 + " but found " + s2;
+            Assert.assertEquals(s1, s2);
 
         } else if (s1 instanceof MultiPolygon && s2 instanceof MultiPolygon) {
             assertEquals((MultiPolygon) s1, (MultiPolygon) s2);
@@ -176,14 +175,14 @@ public class ElasticsearchGeoAssertions {
         } else if(s1 instanceof JtsPoint && s2 instanceof JtsPoint) {
             JtsPoint p1 = (JtsPoint) s1;
             JtsPoint p2 = (JtsPoint) s2;
-            assert p1.equals(p1): "expected " + p1 + " but found " + p2;
+            Assert.assertEquals(p1, p2);
         } else {
             throw new RuntimeException("equality of shape types not supported [" + s1.getClass().getName() + " and " + s2.getClass().getName() + "]");
         }
     }
 
     private static Geometry unwrap(Shape shape) {
-        assert (shape instanceof JtsGeometry): "shape is not a JTSGeometry";
+        assertThat(shape, instanceOf(JtsGeometry.class));
         return ((JtsGeometry)shape).getGeom();
     }
 

+ 6 - 6
src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java

@@ -78,7 +78,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
 
             @Override
             public void onNodeDisconnected(DiscoveryNode node) {
-                assert false : "disconnect should not be called " + node;
+                fail("disconnect should not be called " + node);
             }
         };
         serviceA.addConnectionListener(waitForConnection);
@@ -367,7 +367,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
         TransportConnectionListener disconnectListener = new TransportConnectionListener() {
             @Override
             public void onNodeConnected(DiscoveryNode node) {
-                assert false : "node connected should not be called, all connection have been done previously, node: " + node;
+                fail("node connected should not be called, all connection have been done previously, node: " + node);
             }
 
             @Override
@@ -703,7 +703,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
             @Override
             public void handleException(TransportException exp) {
                 exp.printStackTrace();
-                assert false;
+                fail();
             }
 
             @Override
@@ -755,7 +755,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
             @Override
             public void handleException(TransportException exp) {
                 exp.printStackTrace();
-                assert false;
+                fail();
             }
 
             @Override
@@ -810,7 +810,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
             @Override
             public void handleException(TransportException exp) {
                 exp.printStackTrace();
-                assert false;
+                fail();
             }
 
             @Override
@@ -861,7 +861,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
             @Override
             public void handleException(TransportException exp) {
                 exp.printStackTrace();
-                assert false;
+                fail();
             }
 
             @Override

+ 1 - 1
src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java

@@ -44,7 +44,7 @@ public class SimpleNettyTransportTests extends AbstractSimpleTransportTests {
     public void testConnectException() {
         try {
             serviceA.connectToNode(new DiscoveryNode("C", new InetSocketTransportAddress("localhost", 9876), Version.CURRENT));
-            assert false;
+            fail();
         } catch (ConnectTransportException e) {
 //            e.printStackTrace();
             // all is well

+ 1 - 1
src/test/java/org/elasticsearch/tribe/TribeTests.java

@@ -134,7 +134,7 @@ public class TribeTests extends ElasticsearchIntegrationTest {
         logger.info("make sure master level write operations fail... (we don't really have a master)");
         try {
             tribeClient.admin().indices().prepareCreate("tribe_index").setMasterNodeTimeout("10ms").get();
-            assert false;
+            fail();
         } catch (MasterNotDiscoveredException e) {
             // all is well!
         }

+ 1 - 1
src/test/java/org/elasticsearch/update/UpdateTests.java

@@ -289,7 +289,7 @@ public class UpdateTests extends ElasticsearchIntegrationTest {
 
         try {
             client().prepareUpdate("test", "type1", "1").setScript("ctx._source.field++").execute().actionGet();
-            assert false;
+            fail();
         } catch (DocumentMissingException e) {
             // all is well
         }