Ver código fonte

[TEST] assume assertions are enabled

Simon Willnauer 10 anos atrás
pai
commit
895a7dd03c

+ 1 - 3
core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java

@@ -74,7 +74,6 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent imple
     private final IndexQueryParserService queryParserService;
     private final MapperService mapperService;
     private final IndicesLifecycle indicesLifecycle;
-    private final IndexCache indexCache;
     private final IndexFieldDataService indexFieldDataService;
 
     private final ShardIndexingService indexingService;
@@ -98,13 +97,12 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent imple
     @Inject
     public PercolatorQueriesRegistry(ShardId shardId, @IndexSettings Settings indexSettings, IndexQueryParserService queryParserService,
                                      ShardIndexingService indexingService, IndicesLifecycle indicesLifecycle, MapperService mapperService,
-                                     IndexCache indexCache, IndexFieldDataService indexFieldDataService, ShardPercolateService shardPercolateService) {
+                                     IndexFieldDataService indexFieldDataService, ShardPercolateService shardPercolateService) {
         super(shardId, indexSettings);
         this.queryParserService = queryParserService;
         this.mapperService = mapperService;
         this.indicesLifecycle = indicesLifecycle;
         this.indexingService = indexingService;
-        this.indexCache = indexCache;
         this.indexFieldDataService = indexFieldDataService;
         this.shardPercolateService = shardPercolateService;
         this.mapUnmappedFieldsAsString = indexSettings.getAsBoolean(MAP_UNMAPPED_FIELDS_AS_STRING, false);

+ 9 - 0
core/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java

@@ -600,4 +600,13 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
         return list.subList(0, size);
     }
 
+    /**
+     * Returns true iff assertions for elasticsearch packages are enabled
+     */
+    public static boolean assertionsEnabled() {
+        boolean enabled = false;
+        assert (enabled = true);
+        return enabled;
+    }
+
 }

+ 3 - 0
plugins/delete-by-query/src/test/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponseTests.java

@@ -72,6 +72,7 @@ public class IndexDeleteByQueryResponseTests extends ElasticsearchTestCase {
 
     @Test
     public void testNegativeCounters() {
+        assumeTrue("assertions must be enable for this test to pass", assertionsEnabled());
         try {
             new IndexDeleteByQueryResponse("index", -1L, 0L, 0L, 0L);
             fail("should have thrown an assertion error concerning the negative counter");
@@ -107,6 +108,7 @@ public class IndexDeleteByQueryResponseTests extends ElasticsearchTestCase {
 
     @Test
     public void testNegativeIncrements() {
+        assumeTrue("assertions must be enable for this test to pass", assertionsEnabled());
         try {
             IndexDeleteByQueryResponse response = new IndexDeleteByQueryResponse();
             response.incrementFound(-10L);
@@ -163,4 +165,5 @@ public class IndexDeleteByQueryResponseTests extends ElasticsearchTestCase {
         assertThat(deserializedResponse.getMissing(), equalTo(response.getMissing()));
         assertThat(deserializedResponse.getFailed(), equalTo(response.getFailed()));
     }
+
 }