[TEST] assume assertions are enabled

This commit is contained in:
Simon Willnauer 2015-06-22 11:24:46 +02:00
parent af4b7ee000
commit 895a7dd03c
3 changed files with 13 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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()));
}
}