Index: lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java	(revision 1360332)
+++ lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java	(working copy)
@@ -31,6 +31,7 @@
 import org.apache.lucene.codecs.PostingsFormat;
 import org.apache.lucene.codecs.appending.AppendingCodec;
 import org.apache.lucene.codecs.lucene40.Lucene40Codec;
+import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat;
 import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
 import org.apache.lucene.index.RandomCodec;
 import org.apache.lucene.search.RandomSimilarityProvider;
@@ -167,9 +168,13 @@
       assert (codec instanceof PreFlexRWCodec) : "fix your classpath to have tests-framework.jar before lucene-core.jar";
       PREFLEX_IMPERSONATION_IS_ACTIVE = true;
     } else */ if (!"random".equals(TEST_POSTINGSFORMAT)) {
-      codec = new Lucene40Codec() {
-        private final PostingsFormat format = PostingsFormat.forName(TEST_POSTINGSFORMAT);
-        
+      final PostingsFormat format;
+      if ("MockRandom".equals(TEST_POSTINGSFORMAT)) {
+        format = new MockRandomPostingsFormat(random);
+      } else {
+        format = PostingsFormat.forName(TEST_POSTINGSFORMAT);
+      }
+      codec = new Lucene40Codec() {       
         @Override
         public PostingsFormat getPostingsFormatForField(String field) {
           return format;
Index: lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java	(revision 1360332)
+++ lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java	(working copy)
@@ -79,6 +79,7 @@
 import org.apache.lucene.store.IOContext;
 import org.junit.Assert;
 
+import com.carrotsearch.randomizedtesting.RandomizedContext;
 import com.carrotsearch.randomizedtesting.generators.RandomInts;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 
@@ -731,8 +732,12 @@
     }
     String newSuffix = suffix == null ? ".tmp" : suffix;
     File result;
+    // just pull one long always: we don't want to rely upon what may or may not
+    // already exist. otherwise tests might not reproduce, depending on when you last
+    // ran 'ant clean'
+    final Random random = new Random(RandomizedContext.current().getRandom().nextLong());
     do {
-      result = genTempFile(prefix, newSuffix, directory);
+      result = genTempFile(random, prefix, newSuffix, directory);
     } while (!result.createNewFile());
     return result;
   }
@@ -746,12 +751,12 @@
   private static class TempFileLocker {};
   private static TempFileLocker tempFileLocker = new TempFileLocker();
 
-  private static File genTempFile(String prefix, String suffix, File directory) {
+  private static File genTempFile(Random random, String prefix, String suffix, File directory) {
     int identify = 0;
 
     synchronized (tempFileLocker) {
       if (counter == 0) {
-        int newInt = new Random().nextInt();
+        int newInt = random.nextInt();
         counter = ((newInt / 65535) & 0xFFFF) + 0x2710;
         counterBase = counter;
       }
Index: lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java	(revision 1360332)
+++ lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java	(working copy)
@@ -71,13 +71,22 @@
   private final String SEED_EXT = "sd";
   
   public MockRandomPostingsFormat() {
-    // just for reading, we are gonna setSeed from the .seed file... right?
-    this(new Random());
+    // This ctor should *only* be used at read-time: get NPE if you use it!
+    this(null);
   }
   
   public MockRandomPostingsFormat(Random random) {
     super("MockRandom");
-    this.seedRandom = new Random(random.nextLong());
+    if (random == null) {
+      this.seedRandom = new Random(0L) {
+        @Override
+        protected int next(int arg0) {
+          throw new IllegalStateException("Please use MockRandomPostingsFormat(Random)");
+        }
+      };
+    } else {
+      this.seedRandom = new Random(random.nextLong());
+    }
   }
 
   // Chooses random IntStreamFactory depending on file's extension
Index: lucene/build.xml
===================================================================
--- lucene/build.xml	(revision 1360332)
+++ lucene/build.xml	(working copy)
@@ -176,7 +176,7 @@
     <license-check-macro dir="${basedir}" />
   </target>
 
-  <target name="check-forbidden-apis" depends="compile-tools,compile-test,load-custom-tasks,-check-forbidden-jdk-apis,-check-system-out" description="Check forbidden API calls in compiled class files"/>
+  <target name="check-forbidden-apis" depends="compile-tools,compile-test,load-custom-tasks,-check-forbidden-jdk-apis,-check-forbidden-test-apis,-check-system-out" description="Check forbidden API calls in compiled class files"/>
 
   <target name="-check-forbidden-jdk-apis">
     <forbidden-apis> 
@@ -188,6 +188,15 @@
     </forbidden-apis>
   </target>
 
+  <target name="-check-forbidden-test-apis">
+    <forbidden-apis> 
+      <apiFileSet dir="${custom-tasks.dir}/forbiddenApis">
+        <include name="tests.txt" />
+      </apiFileSet>
+      <fileset dir="${basedir}/build" includes="**/classes/test/**/*.class,test-framework/**/*.class" />
+    </forbidden-apis>
+  </target>
+
   <target name="-check-system-out">
     <forbidden-apis apiFile="${custom-tasks.dir}/forbiddenApis/system-out.txt">
       <fileset dir="${basedir}/build">
Index: lucene/tools/forbiddenApis/tests.txt
===================================================================
--- lucene/tools/forbiddenApis/tests.txt	(revision 0)
+++ lucene/tools/forbiddenApis/tests.txt	(working copy)
@@ -0,0 +1,7 @@
+# Use RandomizedRunner's random instead
+java.util.Random#<init>()
+
+# Don't depend on wall clock times
+# TODO: fix tests that do this!
+#java.lang.System#currentTimeMillis()
+#java.lang.System#nanoTime()

Property changes on: lucene/tools/forbiddenApis/tests.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
