Apache Solr open-source search software
Make TestShapesGeo a base class and randomize selection of distance calculator instead of testing all of them every time.
David Wayne Smiley5db69b3be6de
diff --git a/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/AbstractTestShapes.java b/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/AbstractTestShapes.javaindex 02eecb86700..276f4cc200d 100644--- a/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/AbstractTestShapes.java+++ b/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/AbstractTestShapes.java@@ -218,7 +218,7 @@ public abstract class AbstractTestShapes extends LuceneTestCase {default: fail(""+ic);}}- System.out.println("Laps: "+laps);+ //System.out.println("Laps: "+laps);//TODO deliberately test INTERSECTS based on known intersection point}diff --git a/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/TestShapesGeo.java b/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/TestShapesGeo.javaindex afc061ab369..23481a57e83 100644--- a/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/TestShapesGeo.java+++ b/modules/spatial/src/test/org/apache/lucene/spatial/base/shape/TestShapesGeo.java@@ -19,17 +19,17 @@ package org.apache.lucene.spatial.base.shape;import org.apache.lucene.spatial.base.context.SpatialContext;import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;-import org.apache.lucene.spatial.base.distance.*;-import org.junit.Ignore;+import org.apache.lucene.spatial.base.distance.DistanceCalculator;+import org.apache.lucene.spatial.base.distance.DistanceUnits;+import org.apache.lucene.spatial.base.distance.GeodesicSphereDistCalc;import org.junit.Test;import static org.apache.lucene.spatial.base.shape.SpatialRelation.*;-import static org.junit.Assert.assertEquals;/*** @author David Smiley - [email protected]*/-public abstract class TestShapesGeo extends AbstractTestShapes {+public class TestShapesGeo extends AbstractTestShapes {@Testpublic void testGeoRectangle() {@@ -129,37 +129,22 @@ public abstract class TestShapesGeo extends AbstractTestShapes {return ctx.getDistCalc().degreesToDistance(deg);}- @Ignore- public static class TestLawOfCosines extends TestShapesGeo {-- @Override- protected SpatialContext getContext() {- DistanceUnits units = DistanceUnits.KILOMETERS;- return new SimpleSpatialContext(units,- new GeodesicSphereDistCalc.LawOfCosines(units.earthRadius()),- SpatialContext.GEO_WORLDBOUNDS);- }- }-- public static class TestHaversine extends TestShapesGeo {-- @Override- protected SpatialContext getContext() {- DistanceUnits units = DistanceUnits.KILOMETERS;- return new SimpleSpatialContext(units,- new GeodesicSphereDistCalc.Haversine(units.earthRadius()),- SpatialContext.GEO_WORLDBOUNDS);+ @Override+ protected SpatialContext getContext() {+ DistanceUnits units = DistanceUnits.KILOMETERS;+ DistanceCalculator distCalc = new GeodesicSphereDistCalc.Haversine(units.earthRadius());//default+ switch(random.nextInt(3)) {+ case 2:+ //TODO ENABLE WHEN WORKING+ //distCalc = new GeodesicSphereDistCalc.LawOfCosines(units.earthRadius());+ break;+ case 1:+ distCalc = new GeodesicSphereDistCalc.Vincenty(units.earthRadius());+ break;}+ return new SimpleSpatialContext(units,+ distCalc,+ SpatialContext.GEO_WORLDBOUNDS);}- public static class TestVincentySphere extends TestShapesGeo {-- @Override- protected SpatialContext getContext() {- DistanceUnits units = DistanceUnits.KILOMETERS;- return new SimpleSpatialContext(units,- new GeodesicSphereDistCalc.Vincenty(units.earthRadius()),- SpatialContext.GEO_WORLDBOUNDS);- }- }}