[test] don't catch AssertionError from indexRandom(). just index and catch MapperParsingException
This commit is contained in:
parent
314e1c8a3e
commit
c10f116a84
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.IndexService;
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
||||||
import org.elasticsearch.index.query.GeoShapeQueryBuilder;
|
import org.elasticsearch.index.query.GeoShapeQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
@ -488,15 +489,14 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
ShapeBuilder shape = RandomShapeGenerator.createShape(random());
|
ShapeBuilder shape = RandomShapeGenerator.createShape(random());
|
||||||
try {
|
try {
|
||||||
indexRandom(true, client().prepareIndex("geo_points_only", "type1", "1").setSource(jsonBuilder().startObject()
|
index("geo_points_only", "type1", "1", jsonBuilder().startObject().field("location", shape).endObject());
|
||||||
.field("location", shape).endObject()));
|
} catch (MapperParsingException e) {
|
||||||
} catch (Throwable e) {
|
|
||||||
// RandomShapeGenerator created something other than a POINT type, verify the correct exception is thrown
|
// RandomShapeGenerator created something other than a POINT type, verify the correct exception is thrown
|
||||||
assertThat(e.getMessage(), containsString("MapperParsingException"));
|
assertThat(e.getCause().getMessage(), containsString("is configured for points only"));
|
||||||
assertThat(e.getMessage(), containsString("is configured for points only"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh();
|
||||||
// test that point was inserted
|
// test that point was inserted
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
.setQuery(geoIntersectionQuery("location", shape))
|
.setQuery(geoIntersectionQuery("location", shape))
|
||||||
|
|
Loading…
Reference in New Issue