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 04:00:46 UTC
svn commit: r1702148 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/
lucene/benchmark/
lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/
lucene/core/ lucene/core/src...
Author: rmuir
Date: Thu Sep 10 02:00:46 2015
New Revision: 1702148
URL: http://svn.apache.org/r1702148
Log:
LUCENE-6795: fix some test issues (mostly static leaks)
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
lucene/dev/branches/branch_5x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_5x/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java
lucene/dev/branches/branch_5x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
lucene/dev/branches/branch_5x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java
lucene/dev/branches/branch_5x/lucene/tools/ (props changed)
lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy
Modified: lucene/dev/branches/branch_5x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java?rev=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java Thu Sep 10 02:00:46 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/branches/branch_5x/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java?rev=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java Thu Sep 10 02:00:46 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/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java?rev=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestReadOnlyIndex.java Thu Sep 10 02:00:46 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(doTestReadOnlyIndex,
// add some basic permissions (because we are limited already - so we grant all important ones):
Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java?rev=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java Thu Sep 10 02:00:46 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/branches/branch_5x/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java?rev=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/test/org/apache/lucene/util/TestLeaveFilesIfTestFails.java Thu Sep 10 02:00:46 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/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=1702148&r1=1702147&r2=1702148&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy (original)
+++ lucene/dev/branches/branch_5x/lucene/tools/junit4/tests.policy Thu Sep 10 02:00:46 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)