Skip to content

Apache Lucene open-source search software

Removed RandomSeed; simply extend LuceneTestCase instead.

David Wayne Smiley8fc20e2b7784
diff --git a/modules/spatial/src/test/org/apache/lucene/spatial/RandomSeed.java b/modules/spatial/src/test/org/apache/lucene/spatial/RandomSeed.java
deleted file mode 100644
index bd030a0339e..00000000000
--- a/modules/spatial/src/test/org/apache/lucene/spatial/RandomSeed.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.lucene.spatial;
-
-/**
- * Reads "tests.seed" system property to initialized a global final constant.
- * @author David Smiley - [email protected]
- */
-public class RandomSeed {
- private static final long _seed;
- static {
- _seed = Long.parseLong(System.getProperty("tests.seed", "" + System.currentTimeMillis()));
- System.out.println("tests.seed="+_seed);
- }
- public static long seed() {
- return _seed;
- }
- private RandomSeed() {}
-}
diff --git a/modules/spatial/src/test/org/apache/lucene/spatial/base/distance/TestDistances.java b/modules/spatial/src/test/org/apache/lucene/spatial/base/distance/TestDistances.java
index abcfd78ecca..77005481775 100644
--- a/modules/spatial/src/test/org/apache/lucene/spatial/base/distance/TestDistances.java
+++ b/modules/spatial/src/test/org/apache/lucene/spatial/base/distance/TestDistances.java
@@ -17,26 +17,20 @@
package org.apache.lucene.spatial.base.distance;
-import org.apache.lucene.spatial.RandomSeed;
import org.apache.lucene.spatial.base.context.SpatialContext;
import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;
-import org.apache.lucene.spatial.base.shape.SpatialRelation;
import org.apache.lucene.spatial.base.shape.Point;
import org.apache.lucene.spatial.base.shape.Rectangle;
+import org.apache.lucene.spatial.base.shape.SpatialRelation;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Before;
import org.junit.Test;
-import java.util.Random;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
/**
* @author David Smiley - [email protected]
*/
-public class TestDistances {
+public class TestDistances extends LuceneTestCase {
- private final Random random = new Random(RandomSeed.seed());
//NOTE! These are sometimes modified by tests.
private SpatialContext ctx;
private double EPS;
@@ -225,7 +219,6 @@ public class TestDistances {
for (double[] pair : lats) {
assertEquals("input "+pair[0],pair[1],ctx.normY(pair[0]),0);
}
- Random random = new Random(RandomSeed.seed());
for(int i = -1000; i < 1000; i += random.nextInt(10)*10) {
double d = ctx.normY(i);
assertTrue(i + " " + d, d >= -90 && d <= 90);
@@ -241,7 +234,6 @@ public class TestDistances {
for (double[] pair : lons) {
assertEquals("input "+pair[0],pair[1],ctx.normX(pair[0]),0);
}
- Random random = new Random(RandomSeed.seed());
for(int i = -1000; i < 1000; i += random.nextInt(10)*10) {
double d = ctx.normX(i);
assertTrue(i + " " + d, d >= -180 && d < 180);
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 ace7ceec5e1..02eecb86700 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
@@ -17,32 +17,25 @@
package org.apache.lucene.spatial.base.shape;
-import org.apache.lucene.spatial.RandomSeed;
import org.apache.lucene.spatial.base.context.SpatialContext;
import org.apache.lucene.spatial.base.distance.DistanceCalculator;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Before;
import java.util.Random;
-import static org.apache.lucene.spatial.base.shape.SpatialRelation.CONTAINS;
-import static org.apache.lucene.spatial.base.shape.SpatialRelation.DISJOINT;
-import static org.apache.lucene.spatial.base.shape.SpatialRelation.WITHIN;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.apache.lucene.spatial.base.shape.SpatialRelation.*;
/**
* @author David Smiley - [email protected]
*/
-public abstract class AbstractTestShapes {
- protected Random random;
+public abstract class AbstractTestShapes extends LuceneTestCase {
protected SpatialContext ctx;
private static final double EPS = 10e-9;
@Before
public void beforeClass() {
- random = new Random(RandomSeed.seed());
ctx = getContext();
}