You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2015/03/02 22:05:55 UTC

svn commit: r1663432 - in /lucene/dev/branches/branch_5x: dev-tools/idea/.idea/libraries/ lucene/ lucene/analysis/uima/ lucene/core/src/test/org/apache/lucene/document/ lucene/core/src/test/org/apache/lucene/util/ lucene/core/src/test/org/apache/lucene...

Author: dweiss
Date: Mon Mar  2 21:05:54 2015
New Revision: 1663432

URL: http://svn.apache.org/r1663432
Log:
LUCENE-6238: minimize tests.policy (upgrade of randomizedtesting, system properties are
read-only).


Added:
    lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.12.jar.sha1   (with props)
    lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.12.jar.sha1   (with props)
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleRestoreSystemProperties.java   (with props)
    lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.12.jar.sha1   (with props)
    lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.12.jar.sha1   (with props)
Removed:
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java
    lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.6.jar.sha1
    lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.6.jar.sha1
    lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.6.jar.sha1
    lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.6.jar.sha1
Modified:
    lucene/dev/branches/branch_5x/dev-tools/idea/.idea/libraries/JUnit.xml
    lucene/dev/branches/branch_5x/lucene/analysis/uima/build.xml
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java
    lucene/dev/branches/branch_5x/lucene/ivy-settings.xml
    lucene/dev/branches/branch_5x/lucene/ivy-versions.properties
    lucene/dev/branches/branch_5x/lucene/replicator/build.xml
    lucene/dev/branches/branch_5x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
    lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy

Modified: lucene/dev/branches/branch_5x/dev-tools/idea/.idea/libraries/JUnit.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/dev-tools/idea/.idea/libraries/JUnit.xml?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/dev-tools/idea/.idea/libraries/JUnit.xml (original)
+++ lucene/dev/branches/branch_5x/dev-tools/idea/.idea/libraries/JUnit.xml Mon Mar  2 21:05:54 2015
@@ -2,7 +2,7 @@
   <library name="JUnit">
     <CLASSES>
       <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/junit-4.10.jar!/" />
-      <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-2.1.6.jar!/" />
+      <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-2.1.12.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES />

Modified: lucene/dev/branches/branch_5x/lucene/analysis/uima/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/analysis/uima/build.xml?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/analysis/uima/build.xml (original)
+++ lucene/dev/branches/branch_5x/lucene/analysis/uima/build.xml Mon Mar  2 21:05:54 2015
@@ -24,7 +24,10 @@
   </description>
 	
   <property name="tests.userdir" value="src/test-files"/>
+  <!-- TODO: why is this limited to one JVM? -->
   <property name="tests.jvms.override" value="1" />
+  <!-- TODO: go fix this in uima, its stupid -->
+  <property name="tests.policy" location="../../tools/junit4/solr-tests.policy"/>
 
   <path id="uimajars">
     <fileset dir="lib"/>

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java Mon Mar  2 21:05:54 2015
@@ -5,11 +5,6 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.junit.Rule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
-
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -28,10 +23,6 @@ import com.carrotsearch.randomizedtestin
  * limitations under the License.
  */
 public class TestDateTools extends LuceneTestCase {
-  @Rule
-  public TestRule testRules = 
-    RuleChain.outerRule(new SystemPropertiesRestoreRule());
-
   public void testStringToDate() throws ParseException {
     
     Date d = null;

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java Mon Mar  2 21:05:54 2015
@@ -22,7 +22,6 @@ import java.util.concurrent.CountDownLat
 import org.apache.lucene.util.junitcompat.WithNestedTests;
 import org.junit.Assert;
 import org.junit.BeforeClass;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.Description;
 import org.junit.runner.JUnitCore;
@@ -37,17 +36,11 @@ import com.carrotsearch.randomizedtestin
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 
 /**
  * @see TestRuleIgnoreAfterMaxFailures
- * @see SystemPropertiesInvariantRule
  */
 public class TestMaxFailuresRule extends WithNestedTests {
-  @Rule
-  public SystemPropertiesRestoreRule restoreSysProps = new SystemPropertiesRestoreRule();
-
   public TestMaxFailuresRule() {
     super(true);
   }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java Mon Mar  2 21:05:54 2015
@@ -18,7 +18,6 @@ package org.apache.lucene.util.junitcomp
  */
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.JUnitCore;

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java Mon Mar  2 21:05:54 2015
@@ -29,6 +29,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures;
 import org.apache.lucene.util.TestRuleIgnoreTestSuites;
 import org.apache.lucene.util.TestRuleMarkFailure;
+import org.apache.lucene.util.TestRuleRestoreSystemProperties;
 import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.After;
 import org.junit.Assert;
@@ -44,7 +45,6 @@ import org.junit.runner.notification.Fai
 import com.carrotsearch.randomizedtesting.RandomizedRunner;
 import com.carrotsearch.randomizedtesting.RandomizedTest;
 import com.carrotsearch.randomizedtesting.SysGlobals;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
 
 /**
@@ -124,7 +124,7 @@ public abstract class WithNestedTests {
   {
     final TestRuleMarkFailure marker = new TestRuleMarkFailure();
     rules = RuleChain
-      .outerRule(new SystemPropertiesRestoreRule())
+      .outerRule(new TestRuleRestoreSystemProperties(TestRuleIgnoreTestSuites.PROPERTY_RUN_NESTED))
       .around(new TestRuleAdapter() {
         @Override
         protected void afterAlways(List<Throwable> errors) throws Throwable {

Modified: lucene/dev/branches/branch_5x/lucene/ivy-settings.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/ivy-settings.xml?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/ivy-settings.xml (original)
+++ lucene/dev/branches/branch_5x/lucene/ivy-settings.xml Mon Mar  2 21:05:54 2015
@@ -40,7 +40,9 @@
 
     <!-- you might need to tweak this from china so it works -->
     <ibiblio name="working-chinese-mirror" root="http://uk.maven.org/maven2" m2compatible="true" />
-    
+
+    <ibiblio name="rr-snapshot" root="https://oss.sonatype.org/content/repositories/comcarrotsearch-1039" m2compatible="true" />
+
     <!--
     <filesystem name="local-maven-2" m2compatible="true" local="true">
       <artifact
@@ -53,6 +55,7 @@
     <chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
       <resolver ref="local"/>
       <!-- <resolver ref="local-maven-2" /> -->
+      <resolver ref="rr-snapshot"/>
       <resolver ref="main"/>
       <resolver ref="maven.restlet.org" />
       <resolver ref="sonatype-releases" />

Modified: lucene/dev/branches/branch_5x/lucene/ivy-versions.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/ivy-versions.properties?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/ivy-versions.properties (original)
+++ lucene/dev/branches/branch_5x/lucene/ivy-versions.properties Mon Mar  2 21:05:54 2015
@@ -7,7 +7,7 @@
 /cglib/cglib-nodep = 2.2
 /com.adobe.xmp/xmpcore = 5.1.2
 
-com.carrotsearch.randomizedtesting.version = 2.1.6
+com.carrotsearch.randomizedtesting.version = 2.1.12
 /com.carrotsearch.randomizedtesting/junit4-ant = ${com.carrotsearch.randomizedtesting.version}
 /com.carrotsearch.randomizedtesting/randomizedtesting-runner = ${com.carrotsearch.randomizedtesting.version}
 

Added: lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.12.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.12.jar.sha1?rev=1663432&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.12.jar.sha1 (added)
+++ lucene/dev/branches/branch_5x/lucene/licenses/junit4-ant-2.1.12.jar.sha1 Mon Mar  2 21:05:54 2015
@@ -0,0 +1 @@
+09847aac214a15628aaa49f45daedcc14b856d1b

Added: lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.12.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.12.jar.sha1?rev=1663432&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.12.jar.sha1 (added)
+++ lucene/dev/branches/branch_5x/lucene/licenses/randomizedtesting-runner-2.1.12.jar.sha1 Mon Mar  2 21:05:54 2015
@@ -0,0 +1 @@
+a31b5efc13b29ad7cbb2ca0f35980f2e152d5845

Modified: lucene/dev/branches/branch_5x/lucene/replicator/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/replicator/build.xml?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/replicator/build.xml (original)
+++ lucene/dev/branches/branch_5x/lucene/replicator/build.xml Mon Mar  2 21:05:54 2015
@@ -21,6 +21,9 @@
     Files replication utility
   </description>
 
+  <!-- TODO: go fix this in jetty, its stupid -->
+  <property name="tests.policy" location="../tools/junit4/solr-tests.policy"/>
+
   <import file="../module-build.xml"/>
 
   <path id="classpath">

Modified: lucene/dev/branches/branch_5x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java Mon Mar  2 21:05:54 2015
@@ -48,10 +48,6 @@ import org.junit.rules.TestRule;
 import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 
 public class HttpReplicatorTest extends ReplicatorTestCase {
-  @Rule
-  public TestRule testRules = 
-    RuleChain.outerRule(new SystemPropertiesRestoreRule());
-
   private Path clientWorkDir;
   private Replicator serverReplicator;
   private IndexWriter writer;

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Mon Mar  2 21:05:54 2015
@@ -81,7 +81,6 @@ import com.carrotsearch.randomizedtestin
 import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
 import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
 import com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
@@ -419,16 +418,6 @@ public abstract class LuceneTestCase ext
     LEAVE_TEMPORARY = defaultValue;
   }
 
-  /**
-   * These property keys will be ignored in verification of altered properties.
-   * @see SystemPropertiesInvariantRule
-   * @see #ruleChain
-   * @see #classRules
-   */
-  private static final String [] IGNORED_INVARIANT_PROPERTIES = {
-    "user.timezone", "java.rmi.server.randomIDs"
-  };
-
   /** Filesystem-based {@link Directory} implementations. */
   private static final List<String> FS_DIRECTORIES = Arrays.asList(
     "SimpleFSDirectory",
@@ -583,8 +572,20 @@ public abstract class LuceneTestCase ext
         return !(name.equals("setUp") || name.equals("tearDown"));
       }
     })
-    .around(new SystemPropertiesInvariantRule(IGNORED_INVARIANT_PROPERTIES))
     .around(classNameRule = new TestRuleStoreClassName())
+    .around(new TestRuleRestoreSystemProperties(
+        // Enlist all properties to which we have write access (security manager);
+        // these should be restored to previous state, no matter what the outcome of the test.
+
+        // We reset the default locale and timezone; these properties change as a side-effect
+        "user.language",
+        "user.timezone",
+        
+        // TODO: these should, ideally, be moved to Solr's base class.
+        "solr.directoryFactory",
+        "solr.solr.home",
+        "solr.data.dir"
+        ))
     .around(classEnvRule = new TestRuleSetupAndRestoreClassEnv());
 
 
@@ -611,7 +612,6 @@ public abstract class LuceneTestCase ext
     .outerRule(testFailureMarker)
     .around(ignoreAfterMaxFailures)
     .around(threadAndTestNameRule)
-    .around(new SystemPropertiesInvariantRule(IGNORED_INVARIANT_PROPERTIES))
     .around(new TestRuleSetupAndRestoreInstanceEnv())
     .around(parentChainCallRule);
 

Added: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleRestoreSystemProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleRestoreSystemProperties.java?rev=1663432&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleRestoreSystemProperties.java (added)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleRestoreSystemProperties.java Mon Mar  2 21:05:54 2015
@@ -0,0 +1,78 @@
+package org.apache.lucene.util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
+
+/*
+ * 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.
+ */
+
+/**
+ * Restore a given set of system properties to a snapshot taken at the beginning
+ * of the rule.
+ * 
+ * This is semantically similar to {@link SystemPropertiesRestoreRule} but
+ * the list of properties to restore must be provided explicitly (because the security
+ * manager prevents us from accessing the whole set of properties).
+ * 
+ * All properties to be restored must have r/w property permission.
+ */
+public class TestRuleRestoreSystemProperties extends TestRuleAdapter {  
+  private final String[] propertyNames;
+  private final Map<String, String> restore = new HashMap<String, String>();
+
+  public TestRuleRestoreSystemProperties(String... propertyNames) {
+    this.propertyNames = propertyNames;
+    
+    if (propertyNames.length == 0) {
+      throw new IllegalArgumentException("No properties to restore? Odd.");
+    }
+  }
+
+  @Override
+  protected void before() throws Throwable {
+    super.before();
+
+    assert restore.isEmpty();
+    for (String key : propertyNames) {
+      restore.put(key, System.getProperty(key));
+    }
+  }
+  
+  @Override
+  protected void afterAlways(List<Throwable> errors) throws Throwable {
+    for (String key : propertyNames) {
+      try {
+        String value = restore.get(key);
+        if (value == null) {
+          System.clearProperty(key);
+        } else {
+          System.setProperty(key, value);
+        }
+      } catch (SecurityException e) {
+        // We should have permission to write but if we don't, record the error
+        errors.add(e);
+      }
+    }
+    restore.clear();
+
+    super.afterAlways(errors);
+  }
+}

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java Mon Mar  2 21:05:54 2015
@@ -20,10 +20,8 @@ package org.apache.lucene.util;
 import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Locale;
-import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 import java.util.TimeZone;
@@ -38,7 +36,6 @@ import org.apache.lucene.codecs.cheapbas
 import org.apache.lucene.codecs.compressing.CompressingCodec;
 import org.apache.lucene.codecs.lucene50.Lucene50Codec;
 import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat.Mode;
 import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat;
 import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
 import org.apache.lucene.index.RandomCodec;
@@ -68,11 +65,6 @@ import static org.apache.lucene.util.Luc
  * doesn't fit anywhere else).
  */
 final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {
-  /**
-   * Restore these system property values.
-   */
-  private HashMap<String, String> restoreProperties = new HashMap<>();
-
   private Codec savedCodec;
   private Locale savedLocale;
   private TimeZone savedTimeZone;
@@ -116,15 +108,10 @@ final class TestRuleSetupAndRestoreClass
     // enable this by default, for IDE consistency with ant tests (as it's the default from ant)
     // TODO: really should be in solr base classes, but some extend LTC directly.
     // we do this in beforeClass, because some tests currently disable it
-    restoreProperties.put("solr.directoryFactory", System.getProperty("solr.directoryFactory"));
     if (System.getProperty("solr.directoryFactory") == null) {
       System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockDirectoryFactory");
     }
 
-    // Restore more Solr properties. 
-    restoreProperties.put("solr.solr.home", System.getProperty("solr.solr.home"));
-    restoreProperties.put("solr.data.dir", System.getProperty("solr.data.dir"));
-
     // if verbose: print some debugging stuff about which codecs are loaded.
     if (VERBOSE) {
       Set<String> codecs = Codec.availableCodecs();
@@ -224,9 +211,6 @@ final class TestRuleSetupAndRestoreClass
     locale = testLocale.equals("random") ? randomLocale : localeForName(testLocale);
     Locale.setDefault(locale);
 
-    // TimeZone.getDefault will set user.timezone to the default timezone of the user's locale.
-    // So store the original property value and restore it at end.
-    restoreProperties.put("user.timezone", System.getProperty("user.timezone"));
     savedTimeZone = TimeZone.getDefault();
     TimeZone randomTimeZone = randomTimeZone(random());
     timeZone = testTimeZone.equals("random") ? randomTimeZone : TimeZone.getTimeZone(testTimeZone);
@@ -291,15 +275,6 @@ final class TestRuleSetupAndRestoreClass
    */
   @Override
   protected void after() throws Exception {
-    for (Map.Entry<String,String> e : restoreProperties.entrySet()) {
-      if (e.getValue() == null) {
-        System.clearProperty(e.getKey());
-      } else {
-        System.setProperty(e.getKey(), e.getValue());
-      }
-    }
-    restoreProperties.clear();
-
     Codec.setDefault(savedCodec);
     InfoStream.setDefault(savedInfoStream);
     if (savedLocale != null) Locale.setDefault(savedLocale);

Modified: lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy?rev=1663432&r1=1663431&r2=1663432&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy (original)
+++ lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy Mon Mar  2 21:05:54 2015
@@ -74,8 +74,20 @@ grant {
   permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
   
   // read access to all system properties:
-  // needed by junit4 BootstrapEvent (it calls System.getProperties, used by ant xml reporting?)
-  permission java.util.PropertyPermission "*", "read,write";
+  permission java.util.PropertyPermission "*", "read";
+  // write access to only these:
+  // locale randomization
+  permission java.util.PropertyPermission "user.language", "write";
+  // timezone randomization
+  permission java.util.PropertyPermission "user.timezone", "write";
+
+  // used by nested tests? (e.g. TestLeaveFilesIfTestFails). TODO: look into this
+  permission java.util.PropertyPermission "tests.runnested", "write";
+
+  // solr properties. TODO: move these out to SolrTestCase
+  permission java.util.PropertyPermission "solr.data.dir", "write";
+  permission java.util.PropertyPermission "solr.solr.home", "write";
+  permission java.util.PropertyPermission "solr.directoryFactory", "write";
 
   // replicator: jetty tests require some network permissions:
   // all possibilities of accepting/binding/connecting on localhost with ports >= 1024:

Added: lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.12.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.12.jar.sha1?rev=1663432&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.12.jar.sha1 (added)
+++ lucene/dev/branches/branch_5x/solr/licenses/junit4-ant-2.1.12.jar.sha1 Mon Mar  2 21:05:54 2015
@@ -0,0 +1 @@
+09847aac214a15628aaa49f45daedcc14b856d1b

Added: lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.12.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.12.jar.sha1?rev=1663432&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.12.jar.sha1 (added)
+++ lucene/dev/branches/branch_5x/solr/licenses/randomizedtesting-runner-2.1.12.jar.sha1 Mon Mar  2 21:05:54 2015
@@ -0,0 +1 @@
+a31b5efc13b29ad7cbb2ca0f35980f2e152d5845