LUCENE-5714: Enhance TestBBoxStrategy with/without docvalues & indexed

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1609209 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2014-07-09 15:55:01 +00:00
parent 130a9ea87d
commit 9b20625f49
1 changed files with 16 additions and 2 deletions

View File

@ -24,6 +24,7 @@ import com.spatial4j.core.distance.DistanceUtils;
import com.spatial4j.core.shape.Rectangle;
import com.spatial4j.core.shape.Shape;
import com.spatial4j.core.shape.impl.RectangleImpl;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.spatial.SpatialMatchConcern;
import org.apache.lucene.spatial.prefix.RandomSpatialOpStrategyTestCase;
import org.apache.lucene.spatial.query.SpatialOperation;
@ -95,7 +96,13 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
this.ctx = factory.newSpatialContext();
}
this.strategy = new BBoxStrategy(ctx, "bbox");
//test we can disable docValues for predicate tests
if (random().nextBoolean()) {
BBoxStrategy bboxStrategy = (BBoxStrategy) strategy;
FieldType fieldType = new FieldType(bboxStrategy.getFieldType());
fieldType.setDocValueType(null);
bboxStrategy.setFieldType(fieldType);
}
for (SpatialOperation operation : SpatialOperation.values()) {
if (operation == SpatialOperation.Overlaps)
continue;//unsupported
@ -244,10 +251,17 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
public void testAreaValueSource() throws IOException {
setupGeo();
//test we can disable indexed for this test
BBoxStrategy bboxStrategy = (BBoxStrategy) strategy;
if (random().nextBoolean()) {
FieldType fieldType = new FieldType(bboxStrategy.getFieldType());
fieldType.setIndexed(false);
bboxStrategy.setFieldType(fieldType);
}
adoc("100", ctx.makeRectangle(0, 20, 40, 80));
adoc("999", (Shape) null);
commit();
BBoxStrategy bboxStrategy = (BBoxStrategy) strategy;
checkValueSource(new ShapeAreaValueSource(bboxStrategy.makeShapeValueSource(), ctx, false),
new float[]{800f, 0f}, 0f);
checkValueSource(new ShapeAreaValueSource(bboxStrategy.makeShapeValueSource(), ctx, true),//geo