You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2015/09/10 03:48:35 UTC

svn commit: r1702144 - in /lucene/dev/trunk/lucene: analysis/common/src/test/org/apache/lucene/analysis/hunspell/ benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/ core/src/test/org/apache/lucene/index/ queryparser/src/test/org/apache/lucene...

Author: rmuir
Date: Thu Sep 10 01:48:34 2015
New Revision: 1702144

URL: http://svn.apache.org/r1702144
Log:
LUCENE-6795: fix some test issues (mostly static leaks)

Modified:
    lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
    lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java
    lucene/dev/trunk/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
    lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java
    lucene/dev/trunk/lucene/tools/junit4/tests.policy

Modified: lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java (original)
+++ lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java Thu Sep 10 01:48:34 2015
@@ -27,11 +27,17 @@ import java.util.List;
 import org.apache.lucene.util.CharsRef;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
+import org.junit.AfterClass;
 
 /** base class for hunspell stemmer tests */
-abstract class StemmerTestBase extends LuceneTestCase {
+public abstract class StemmerTestBase extends LuceneTestCase {
   private static Stemmer stemmer;
   
+  @AfterClass
+  public static void afterClass() {
+    stemmer = null;
+  }
+  
   static void init(String affix, String dictionary) throws IOException, ParseException {
     init(false, affix, dictionary);
   }

Modified: lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java (original)
+++ lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java Thu Sep 10 01:48:34 2015
@@ -31,6 +31,7 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.Version;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 /** Tests the functionality of {@link AddIndexesTask}. */
@@ -56,6 +57,11 @@ public class AddIndexesTaskTest extends
     }
   }
   
+  @AfterClass
+  public static void afterClassAddIndexesTaskTest() {
+    testDir = inputDir = null;
+  }
+  
   private PerfRunData createPerfRunData() throws Exception {
     Properties props = new Properties();
     props.setProperty("writer.version", Version.LATEST.toString());

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java Thu Sep 10 01:48:34 2015
@@ -34,6 +34,7 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.util.LuceneTestCase;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 public class TestReadOnlyIndex extends LuceneTestCase {
@@ -59,6 +60,11 @@ public class TestReadOnlyIndex extends L
     analyzer.close();
   }
   
+  @AfterClass
+  public static void afterClass() throws Exception {
+    indexPath = null;
+  }
+  
   public void testReadOnlyIndex() throws Exception {
     runWithRestrictedPermissions(this::doTestReadOnlyIndex,
         // add some basic permissions (because we are limited already - so we grant all important ones):

Modified: lucene/dev/trunk/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java (original)
+++ lucene/dev/trunk/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java Thu Sep 10 01:48:34 2015
@@ -71,7 +71,7 @@ public class TestNumericQueryParser exte
   private static Locale LOCALE;
   private static TimeZone TIMEZONE;
   private static Map<String,Number> RANDOM_NUMBER_MAP;
-  final private static EscapeQuerySyntax ESCAPER = new EscapeQuerySyntaxImpl();
+  private static EscapeQuerySyntax ESCAPER = new EscapeQuerySyntaxImpl();
   final private static String DATE_FIELD_NAME = "date";
   private static int DATE_STYLE;
   private static int TIME_STYLE;
@@ -526,6 +526,11 @@ public class TestNumericQueryParser exte
     directory.close();
     directory = null;
     qp = null;
+    LOCALE = null;
+    TIMEZONE = null;
+    NUMBER_FORMAT = null;
+    DATE_FORMAT = null;
+    ESCAPER = null;
   }
   
 }

Modified: lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java Thu Sep 10 01:48:34 2015
@@ -1,82 +0,0 @@
-package org.apache.lucene.util;
-
-/*
- * 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.
- */
-
-import java.io.IOException;
-import java.nio.channels.SeekableByteChannel;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
-
-import org.apache.lucene.util.Constants;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.LuceneTestCase;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-
-import com.carrotsearch.randomizedtesting.RandomizedTest;
-
-public class TestLeaveFilesIfTestFails extends WithNestedTests {
-  public TestLeaveFilesIfTestFails() {
-    super(true);
-  }
-  
-  public static class Nested1 extends WithNestedTests.AbstractNestedTest {
-    static Path file;
-    public void testDummy() {
-      file = createTempDir("leftover");
-      fail();
-    }
-  }
-
-  @Test
-  public void testLeaveFilesIfTestFails() throws IOException {
-    Result r = JUnitCore.runClasses(Nested1.class);
-    Assert.assertEquals(1, r.getFailureCount());
-    Assert.assertTrue(Nested1.file != null && Files.exists(Nested1.file));
-    IOUtils.rm(Nested1.file);
-  }
-  
-  public static class Nested2 extends WithNestedTests.AbstractNestedTest {
-    static Path file;
-    static Path parent;
-    static SeekableByteChannel openFile;
-
-    @SuppressWarnings("deprecation")
-    public void testDummy() throws Exception {
-      file = createTempDir("leftover").resolve("child.locked");
-      openFile = Files.newByteChannel(file, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
-
-      parent = LuceneTestCase.getBaseTempDirForTestClass();
-    }
-  }
-
-  @Test
-  public void testWindowsUnremovableFile() throws IOException {
-    RandomizedTest.assumeTrue("Requires Windows.", Constants.WINDOWS);
-    RandomizedTest.assumeFalse(LuceneTestCase.LEAVE_TEMPORARY);
-
-    Result r = JUnitCore.runClasses(Nested2.class);
-    Assert.assertEquals(1, r.getFailureCount());
-
-    Nested2.openFile.close();
-    IOUtils.rm(Nested2.parent);
-  }  
-}

Modified: lucene/dev/trunk/lucene/tools/junit4/tests.policy
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/tools/junit4/tests.policy?rev=1702144&r1=1702143&r2=1702144&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/tools/junit4/tests.policy (original)
+++ lucene/dev/trunk/lucene/tools/junit4/tests.policy Thu Sep 10 01:48:34 2015
@@ -57,12 +57,6 @@ grant {
   permission java.lang.RuntimePermission "getStackTrace";
   // needed for mock filesystems in tests
   permission java.lang.RuntimePermission "fileSystemProvider";
-  // needed for mock filesystems in tests (to capture implCloseChannel) 
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
-  // needed by junit nested compat tests (due to static fields reflection), TODO clean these up:
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.util.calendar";
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.util.locale";
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.fs";
   // needed by queryparser/ NLS., TODO clean this up:
   permission java.lang.RuntimePermission "accessClassInPackage.sun.util";
   // needed for test of IOUtils.spins (maybe it can be avoided)