mirror of https://github.com/apache/lucene.git
LUCENE-5608: small test improvements.
Rename SpatialOpRecursivePrefixTreeTest to RandomSpatialOpFuzzyPrefixTreeTest. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1603992 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5cfa3d06a
commit
bd727b49ab
|
@ -91,8 +91,10 @@ public class QueryEqualsHashCodeTest extends LuceneTestCase {
|
|||
Object second = generator.gen(args1);//should be the same
|
||||
assertEquals(first, second);
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
second = generator.gen(args2);//now should be different
|
||||
assertNotSame(args1, args2);
|
||||
second = generator.gen(args2);//now should be different
|
||||
assertNotSame(first, second);
|
||||
assertNotSame(first.hashCode(), second.hashCode());
|
||||
}
|
||||
|
||||
private SpatialArgs makeArgs1() {
|
||||
|
|
|
@ -36,9 +36,8 @@ import org.apache.lucene.uninverting.UninvertingReader;
|
|||
import org.apache.lucene.uninverting.UninvertingReader.Type;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
|
||||
import org.apache.lucene.util.TestRuleLimitSysouts.Limit;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -63,7 +62,7 @@ public abstract class SpatialTestCase extends LuceneTestCase {
|
|||
|
||||
protected SpatialContext ctx;//subclass must initialize
|
||||
|
||||
Map<String,Type> uninvertMap = new HashMap<>();
|
||||
protected Map<String,Type> uninvertMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@Before
|
||||
|
@ -77,7 +76,6 @@ public abstract class SpatialTestCase extends LuceneTestCase {
|
|||
uninvertMap.put("bbox__maxY", Type.DOUBLE);
|
||||
uninvertMap.put("pointvector__x", Type.DOUBLE);
|
||||
uninvertMap.put("pointvector__y", Type.DOUBLE);
|
||||
uninvertMap.put("SpatialOpRecursivePrefixTreeTest", Type.SORTED);
|
||||
|
||||
directory = newDirectory();
|
||||
final Random random = random();
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -224,6 +223,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
|
|||
// }
|
||||
// CheckHits.checkHits(random(), q, "", indexSearcher, expectedDocs);
|
||||
|
||||
//TopDocs is sorted but we actually don't care about the order
|
||||
TopDocs docs = indexSearcher.search(q, 1000);//calculates the score
|
||||
for (int i = 0; i < docs.scoreDocs.length; i++) {
|
||||
ScoreDoc gotSD = docs.scoreDocs[i];
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Test;
|
|||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class DateNRStrategyTest extends BaseNonFuzzySpatialOpStrategyTest {
|
||||
public class DateNRStrategyTest extends RandomSpatialOpStrategyTestCase {
|
||||
|
||||
static final int ITERATIONS = 10;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
|||
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||
import org.apache.lucene.spatial.query.SpatialArgs;
|
||||
import org.apache.lucene.spatial.query.SpatialOperation;
|
||||
import org.apache.lucene.uninverting.UninvertingReader;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -62,13 +63,23 @@ import static com.spatial4j.core.shape.SpatialRelation.DISJOINT;
|
|||
import static com.spatial4j.core.shape.SpatialRelation.INTERSECTS;
|
||||
import static com.spatial4j.core.shape.SpatialRelation.WITHIN;
|
||||
|
||||
public class SpatialOpRecursivePrefixTreeTest extends StrategyTestCase {
|
||||
/** Randomized PrefixTree test that considers the fuzziness of the
|
||||
* results introduced by grid approximation. */
|
||||
public class RandomSpatialOpFuzzyPrefixTreeTest extends StrategyTestCase {
|
||||
|
||||
static final int ITERATIONS = 10;
|
||||
|
||||
private SpatialPrefixTree grid;
|
||||
private SpatialContext ctx2D;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
//Only for Disjoint. Ugh; need to find a better way. LUCENE-5692
|
||||
uninvertMap.put(getClass().getSimpleName(), UninvertingReader.Type.SORTED);
|
||||
}
|
||||
|
||||
public void setupGrid(int maxLevels) throws IOException {
|
||||
if (randomBoolean())
|
||||
setupQuadGrid(maxLevels);
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.search.Query;
|
|||
import org.apache.lucene.spatial.StrategyTestCase;
|
||||
import org.apache.lucene.spatial.query.SpatialArgs;
|
||||
import org.apache.lucene.spatial.query.SpatialOperation;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -36,10 +35,9 @@ import static com.carrotsearch.randomizedtesting.RandomizedTest.randomIntBetween
|
|||
/** Base test harness, ideally for SpatialStrategy impls that have exact results
|
||||
* (not grid approximated), hence "not fuzzy".
|
||||
*/
|
||||
@Ignore("not actually a test: can this be renamed to *TestCase????")
|
||||
public abstract class BaseNonFuzzySpatialOpStrategyTest extends StrategyTestCase {
|
||||
public abstract class RandomSpatialOpStrategyTestCase extends StrategyTestCase {
|
||||
|
||||
//TODO this is partially redundant with StrategyTestCase.runTestQuery & testOperation
|
||||
//Note: this is partially redundant with StrategyTestCase.runTestQuery & testOperation
|
||||
|
||||
protected void testOperationRandomShapes(final SpatialOperation operation) throws IOException {
|
||||
//first show that when there's no data, a query will result in no results
|
||||
|
@ -114,18 +112,19 @@ public abstract class BaseNonFuzzySpatialOpStrategyTest extends StrategyTestCase
|
|||
for (SearchResult result : got.results) {
|
||||
String id = result.getId();
|
||||
if (!remainingExpectedIds.remove(id)) {
|
||||
fail("Shouldn't match", id, indexedShapes, queryShape);
|
||||
fail("Shouldn't match", id, indexedShapes, queryShape, operation);
|
||||
}
|
||||
}
|
||||
if (!remainingExpectedIds.isEmpty()) {
|
||||
String id = remainingExpectedIds.iterator().next();
|
||||
fail("Should have matched", id, indexedShapes, queryShape);
|
||||
fail("Should have matched", id, indexedShapes, queryShape, operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fail(String label, String id, List<Shape> indexedShapes, Shape queryShape) {
|
||||
fail(label + " I#" + id + ":" + indexedShapes.get(Integer.parseInt(id)) + " Q:" + queryShape);
|
||||
private void fail(String label, String id, List<Shape> indexedShapes, Shape queryShape, SpatialOperation operation) {
|
||||
fail("[" + operation + "] " + label
|
||||
+ " I#" + id + ":" + indexedShapes.get(Integer.parseInt(id)) + " Q:" + queryShape);
|
||||
}
|
||||
|
||||
protected void preQueryHavoc() {
|
Loading…
Reference in New Issue