From 5db69b3be6de32e0239762cd28596f7418cf0980 Mon Sep 17 00:00:00 2001 From: David Wayne Smiley Date: Tue, 21 Feb 2012 06:52:08 +0000 Subject: [PATCH] Make TestShapesGeo a base class and randomize selection of distance calculator instead of testing all of them every time. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3795_lsp_spatial_module@1291615 13f79535-47bb-0310-9956-ffa450edef68 --- .../base/shape/AbstractTestShapes.java | 2 +- .../spatial/base/shape/TestShapesGeo.java | 53 +++++++------------ 2 files changed, 20 insertions(+), 35 deletions(-) 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.java index 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.java index 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 - dsmiley@mitre.org */ -public abstract class TestShapesGeo extends AbstractTestShapes { +public class TestShapesGeo extends AbstractTestShapes { @Test public 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); + @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 TestHaversine extends TestShapesGeo { - - @Override - protected SpatialContext getContext() { - DistanceUnits units = DistanceUnits.KILOMETERS; - return new SimpleSpatialContext(units, - new GeodesicSphereDistCalc.Haversine(units.earthRadius()), - 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); - } - } }