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 2012/05/15 20:47:48 UTC
svn commit: r1338826 [1/3] - in /lucene/dev/trunk: dev-tools/eclipse/
dev-tools/idea/.idea/libraries/ dev-tools/maven/ lucene/
lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/
lucene/core/src/test/org/apache/lucene/document/ lucene/c...
Author: dweiss
Date: Tue May 15 18:47:45 2012
New Revision: 1338826
URL: http://svn.apache.org/viewvc?rev=1338826&view=rev
Log:
LUCENE-4047: Cleanup of LuceneTestCase: moved blocks of initialization/ cleanup code into JUnit instance and class rules.
Added:
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java
lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.5.0.jar.sha1
lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar.sha1
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/AbstractBeforeAfterRule.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableDirectory.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableFile.java (contents, props changed)
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleFieldCacheSanity.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleIcuHack.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleMarkFailure.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleReportUncaughtExceptions.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/UncaughtExceptionsRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreInstanceEnv.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupTeardownChained.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleStoreClassName.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleThreadAndTestName.java
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ValidateAssertionsRequired.java (contents, props changed)
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ValidateNoInstanceHooksOverrides.java (contents, props changed)
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/NoStaticHooksShadowing.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ValidateNoStaticHooksShadowing.java (contents, props changed)
- copied, changed from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/NoStaticHooksShadowing.java
Removed:
lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.4.0.jar.sha1
lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.4.0.jar.sha1
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/InternalAssumptionViolatedException.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/NoStaticHooksShadowing.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RandomNoSetSeed.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/SystemPropertiesInvariantRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/SystemPropertiesRestoreRule.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/UncaughtExceptionsRule.java
Modified:
lucene/dev/trunk/dev-tools/eclipse/dot.classpath
lucene/dev/trunk/dev-tools/idea/.idea/libraries/JUnit.xml
lucene/dev/trunk/dev-tools/maven/pom.xml.template
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTermRangeFilter.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java
lucene/dev/trunk/lucene/test-framework/ivy.xml
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LineFileDocs.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestRandomFaceting.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServer.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java
Modified: lucene/dev/trunk/dev-tools/eclipse/dot.classpath
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/eclipse/dot.classpath?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/eclipse/dot.classpath (original)
+++ lucene/dev/trunk/dev-tools/eclipse/dot.classpath Tue May 15 18:47:45 2012
@@ -170,6 +170,6 @@
<classpathentry kind="lib" path="solr/contrib/velocity/lib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="solr/contrib/velocity/lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lucene/test-framework/lib/randomizedtesting-runner-1.4.0.jar"/>
+ <classpathentry kind="lib" path="lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: lucene/dev/trunk/dev-tools/idea/.idea/libraries/JUnit.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/idea/.idea/libraries/JUnit.xml?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/idea/.idea/libraries/JUnit.xml (original)
+++ lucene/dev/trunk/dev-tools/idea/.idea/libraries/JUnit.xml Tue May 15 18:47:45 2012
@@ -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-1.3.0.jar!/" />
+ <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
Modified: lucene/dev/trunk/dev-tools/maven/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/maven/pom.xml.template?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/maven/pom.xml.template (original)
+++ lucene/dev/trunk/dev-tools/maven/pom.xml.template Tue May 15 18:47:45 2012
@@ -383,7 +383,7 @@
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
- <version>1.4.0</version>
+ <version>1.5.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue May 15 18:47:45 2012
@@ -960,6 +960,9 @@ Documentation
Build
+* LUCENE-4047: Cleanup of LuceneTestCase: moved blocks of initialization/ cleanup
+ code into JUnit instance and class rules. (Dawid Weiss)
+
* LUCENE-4016: Require ANT 1.8.2+ for the build.
* LUCENE-3808: Refactoring of testing infrastructure to use randomizedtesting
Modified: lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java (original)
+++ lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java Tue May 15 18:47:45 2012
@@ -86,7 +86,7 @@ public class DocMakerTest extends Benchm
Config config = new Config(props);
PerfRunData runData = new PerfRunData(config);
- TaskSequence tasks = new TaskSequence(runData, getName(), null, false);
+ TaskSequence tasks = new TaskSequence(runData, getTestName(), null, false);
tasks.addTask(new CreateIndexTask(runData));
tasks.addTask(new AddDocTask(runData));
tasks.addTask(new CloseIndexTask(runData));
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java Tue May 15 18:47:45 2012
@@ -2,18 +2,15 @@ package org.apache.lucene.document;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-import java.util.Locale;
+import java.util.*;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.SystemPropertiesRestoreRule;
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
* contributor license agreements. See the NOTICE file distributed with
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java Tue May 15 18:47:45 2012
@@ -70,7 +70,7 @@ public class TestDuelingCodecs extends L
// so this would make assertEquals complicated.
leftCodec = Codec.forName("SimpleText");
- rightCodec = new RandomCodec(random(), null);
+ rightCodec = new RandomCodec(random());
leftDir = newDirectory();
rightDir = newDirectory();
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java Tue May 15 18:47:45 2012
@@ -53,12 +53,17 @@ public class TestPostingsOffsets extends
public void setUp() throws Exception {
super.setUp();
+
// Currently only SimpleText and Lucene40 can index offsets into postings:
- assumeTrue("codec does not support offsets", Codec.getDefault().getName().equals("SimpleText") || Codec.getDefault().getName().equals("Lucene40"));
+ String codecName = Codec.getDefault().getName();
+ assumeTrue("Codec does not support offsets: " + codecName,
+ codecName.equals("SimpleText") ||
+ codecName.equals("Lucene40"));
+
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
- if (Codec.getDefault().getName().equals("Lucene40")) {
- // sep etc are not implemented
+ if (codecName.equals("Lucene40")) {
+ // Sep etc are not implemented
switch(random().nextInt(4)) {
case 0: iwc.setCodec(_TestUtil.alwaysPostingsFormat(new Lucene40PostingsFormat())); break;
case 1: iwc.setCodec(_TestUtil.alwaysPostingsFormat(new MemoryPostingsFormat())); break;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Tue May 15 18:47:45 2012
@@ -84,7 +84,7 @@ public class TestBooleanMinShouldMatch e
public void verifyNrHits(Query q, int expected) throws Exception {
ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
if (expected != h.length) {
- printHits(getName(), h, s);
+ printHits(getTestName(), h, s);
}
assertEquals("result count", expected, h.length);
//System.out.println("TEST: now check");
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java Tue May 15 18:47:45 2012
@@ -17,7 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
@@ -25,9 +24,12 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
+
/**
* https://issues.apache.org/jira/browse/LUCENE-1974
*
@@ -36,7 +38,6 @@ import org.junit.BeforeClass;
* BooleanScorer.score(Collector collector, int max, int firstDocID)
*
* Line 273, end=8192, subScorerDocID=11378, then more got false?
- *
*/
public class TestPrefixInBooleanQuery extends LuceneTestCase {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java Tue May 15 18:47:45 2012
@@ -603,7 +603,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " IntParser");
+ assertSaneFieldCaches(getTestName() + " IntParser");
fc.purgeAllCaches();
sort.setSort (new SortField ("parser", new FieldCache.FloatParser(){
@@ -612,7 +612,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " FloatParser");
+ assertSaneFieldCaches(getTestName() + " FloatParser");
fc.purgeAllCaches();
sort.setSort (new SortField ("parser", new FieldCache.LongParser(){
@@ -621,7 +621,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " LongParser");
+ assertSaneFieldCaches(getTestName() + " LongParser");
fc.purgeAllCaches();
sort.setSort (new SortField ("parser", new FieldCache.DoubleParser(){
@@ -630,7 +630,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " DoubleParser");
+ assertSaneFieldCaches(getTestName() + " DoubleParser");
fc.purgeAllCaches();
sort.setSort (new SortField ("parser", new FieldCache.ByteParser(){
@@ -639,7 +639,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " ByteParser");
+ assertSaneFieldCaches(getTestName() + " ByteParser");
fc.purgeAllCaches();
sort.setSort (new SortField ("parser", new FieldCache.ShortParser(){
@@ -648,7 +648,7 @@ public class TestSort extends LuceneTest
}
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
- assertSaneFieldCaches(getName() + " ShortParser");
+ assertSaneFieldCaches(getTestName() + " ShortParser");
fc.purgeAllCaches();
}
@@ -1229,7 +1229,7 @@ public class TestSort extends LuceneTest
// up to this point, all of the searches should have "sane"
// FieldCache behavior, and should have reused hte cache in several cases
- assertSaneFieldCaches(getName() + " various");
+ assertSaneFieldCaches(getTestName() + " various");
// next we'll check Locale based (String[]) for 'string', so purge first
FieldCache.DEFAULT.purgeAllCaches();
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTermRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTermRangeFilter.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTermRangeFilter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTermRangeFilter.java Tue May 15 18:47:45 2012
@@ -36,7 +36,6 @@ public class TestTermRangeFilter extends
@Test
public void testRangeFilterId() throws IOException {
-
IndexReader reader = signedIndexReader;
IndexSearcher search = newSearcher(reader);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java Tue May 15 18:47:45 2012
@@ -17,17 +17,21 @@ package org.apache.lucene.store;
* limitations under the License.
*/
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
-
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
-public class TestDirectory extends LuceneTestCase {
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
+public class TestDirectory extends LuceneTestCase {
public void testDetectClose() throws Throwable {
- Directory[] dirs = new Directory[] { new RAMDirectory(), new SimpleFSDirectory(TEMP_DIR), new NIOFSDirectory(TEMP_DIR) };
+ Directory[] dirs = new Directory[] {
+ new RAMDirectory(),
+ new SimpleFSDirectory(TEMP_DIR),
+ new NIOFSDirectory(TEMP_DIR)
+ };
+
for (Directory dir : dirs) {
dir.close();
try {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java Tue May 15 18:47:45 2012
@@ -60,14 +60,11 @@ public class TestWindowsMMap extends Luc
return fb.toString();
}
- private final static String storePathname =
- _TestUtil.getTempDir("testLuceneMmap").getAbsolutePath();
-
public void testMmapIndex() throws Exception {
// sometimes the directory is not cleaned by rmDir, because on Windows it
// may take some time until the files are finally dereferenced. So clean the
// directory up front, or otherwise new IndexWriter will fail.
- File dirPath = new File(storePathname);
+ File dirPath = _TestUtil.getTempDir("testLuceneMmap");
rmDir(dirPath);
MMapDirectory dir = new MMapDirectory(dirPath, null);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java Tue May 15 18:47:45 2012
@@ -108,7 +108,8 @@ public class TestFieldCacheSanityChecker
FieldCacheSanityChecker.checkSanity(cache.getCacheEntries());
if (0 < insanity.length)
- dumpArray(getTestLabel() + " INSANITY", insanity, System.err);
+ dumpArray(getTestClass().getName() + "#" + getTestName()
+ + " INSANITY", insanity, System.err);
assertEquals("shouldn't be any cache insanity", 0, insanity.length);
cache.purgeAllCaches();
Added: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java?rev=1338826&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java (added)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java Tue May 15 18:47:45 2012
@@ -0,0 +1,65 @@
+package org.apache.lucene.util.junitcompat;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+
+/**
+ * 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.
+ */
+
+public class TestBeforeAfterOverrides extends WithNestedTests {
+ public TestBeforeAfterOverrides() {
+ super(true);
+ }
+
+ public static class Before1 extends WithNestedTests.AbstractNestedTest {
+ @Before
+ public void before() {}
+ }
+ public static class Before2 extends Before1 {}
+ public static class Before3 extends Before2 {
+ @Before
+ public void before() {}
+ }
+
+ public static class After1 extends WithNestedTests.AbstractNestedTest {
+ @After
+ public void after() {}
+ }
+ public static class After2 extends Before1 {}
+ public static class After3 extends Before2 {
+ @After
+ public void after() {}
+ }
+
+ @Test
+ public void testBefore() {
+ Result result = JUnitCore.runClasses(Before3.class);
+ Assert.assertEquals(1, result.getFailureCount());
+ Assert.assertTrue(result.getFailures().get(0).getTrace().contains("There are overridden methods"));
+ }
+
+ @Test
+ public void testAfter() {
+ Result result = JUnitCore.runClasses(Before3.class);
+ Assert.assertEquals(1, result.getFailureCount());
+ Assert.assertTrue(result.getFailures().get(0).getTrace().contains("There are overridden methods"));
+ }
+}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java Tue May 15 18:47:45 2012
@@ -25,7 +25,6 @@ import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
@@ -119,14 +118,14 @@ public class TestReproduceMessage extend
super(true);
}
- @Test @Ignore
+ @Test
public void testAssumeBeforeClass() throws Exception {
type = SoreType.ASSUMPTION;
where = SorePoint.BEFORE_CLASS;
Assert.assertTrue(runAndReturnSyserr().isEmpty());
}
- @Test @Ignore
+ @Test
public void testAssumeInitializer() throws Exception {
type = SoreType.ASSUMPTION;
where = SorePoint.INITIALIZER;
@@ -161,7 +160,7 @@ public class TestReproduceMessage extend
Assert.assertTrue(runAndReturnSyserr().isEmpty());
}
- @Test @Ignore
+ @Test
public void testAssumeAfterClass() throws Exception {
type = SoreType.ASSUMPTION;
where = SorePoint.AFTER_CLASS;
@@ -172,14 +171,14 @@ public class TestReproduceMessage extend
* FAILURES
*/
- @Test @Ignore
+ @Test
public void testFailureBeforeClass() throws Exception {
type = SoreType.FAILURE;
where = SorePoint.BEFORE_CLASS;
Assert.assertTrue(runAndReturnSyserr().contains("NOTE: reproduce with:"));
}
- @Test @Ignore
+ @Test
public void testFailureInitializer() throws Exception {
type = SoreType.FAILURE;
where = SorePoint.INITIALIZER;
@@ -228,7 +227,7 @@ public class TestReproduceMessage extend
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
}
- @Test @Ignore
+ @Test
public void testFailureAfterClass() throws Exception {
type = SoreType.FAILURE;
where = SorePoint.AFTER_CLASS;
@@ -239,14 +238,14 @@ public class TestReproduceMessage extend
* ERRORS
*/
- @Test @Ignore
+ @Test
public void testErrorBeforeClass() throws Exception {
type = SoreType.ERROR;
where = SorePoint.BEFORE_CLASS;
Assert.assertTrue(runAndReturnSyserr().contains("NOTE: reproduce with:"));
}
- @Test @Ignore
+ @Test
public void testErrorInitializer() throws Exception {
type = SoreType.ERROR;
where = SorePoint.INITIALIZER;
@@ -293,7 +292,7 @@ public class TestReproduceMessage extend
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
}
- @Test @Ignore
+ @Test
public void testErrorAfterClass() throws Exception {
type = SoreType.ERROR;
where = SorePoint.AFTER_CLASS;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java Tue May 15 18:47:45 2012
@@ -1,22 +1,16 @@
package org.apache.lucene.util.junitcompat;
-import java.util.Locale;
-import java.util.Random;
-import java.util.TimeZone;
+import java.util.*;
-import org.apache.lucene.util.SystemPropertiesRestoreRule;
import org.apache.lucene.util._TestUtil;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.*;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import com.carrotsearch.randomizedtesting.RandomizedContext;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSystemPropertiesInvariantRule.java Tue May 15 18:47:45 2012
@@ -19,14 +19,15 @@ package org.apache.lucene.util.junitcomp
import java.util.Properties;
-import org.apache.lucene.util.SystemPropertiesInvariantRule;
-import org.apache.lucene.util.SystemPropertiesRestoreRule;
import org.junit.*;
import org.junit.rules.TestRule;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+
/**
* @see SystemPropertiesRestoreRule
* @see SystemPropertiesInvariantRule
Modified: lucene/dev/trunk/lucene/test-framework/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/ivy.xml?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/ivy.xml (original)
+++ lucene/dev/trunk/lucene/test-framework/ivy.xml Tue May 15 18:47:45 2012
@@ -23,8 +23,8 @@
<dependency org="org.apache.ant" name="ant-junit" rev="1.7.1" transitive="false"/>
<dependency org="junit" name="junit" rev="4.10" transitive="false"/>
- <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="1.4.0" transitive="false" />
- <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="1.4.0" transitive="false"/>
+ <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="1.5.0" transitive="false" />
+ <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="1.5.0" transitive="false"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
</dependencies>
Added: lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.5.0.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.5.0.jar.sha1?rev=1338826&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.5.0.jar.sha1 (added)
+++ lucene/dev/trunk/lucene/test-framework/lib/junit4-ant-1.5.0.jar.sha1 Tue May 15 18:47:45 2012
@@ -0,0 +1 @@
+4e920288c2d2cd39b7e15f3abcaa3c5e2213ec9c
Added: lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar.sha1?rev=1338826&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar.sha1 (added)
+++ lucene/dev/trunk/lucene/test-framework/lib/randomizedtesting-runner-1.5.0.jar.sha1 Tue May 15 18:47:45 2012
@@ -0,0 +1 @@
+378731cc7f26d45b68a6e5f600d4c7d071d165b1
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java Tue May 15 18:47:45 2012
@@ -50,15 +50,14 @@ import org.apache.lucene.util._TestUtil;
* and reproducable.
*/
public class RandomCodec extends Lucene40Codec {
- /** shuffled list of postingsformats to use for new mappings */
+ /** Shuffled list of postings formats to use for new mappings */
private List<PostingsFormat> formats = new ArrayList<PostingsFormat>();
+
/** memorized field->postingsformat mappings */
// note: we have to sync this map even though its just for debugging/toString,
// otherwise DWPT's .toString() calls that iterate over the map can
// cause concurrentmodificationexception if indexwriter's infostream is on
private Map<String,PostingsFormat> previousMappings = Collections.synchronizedMap(new HashMap<String,PostingsFormat>());
- /** set of codec names to avoid */
- private final Set<String> avoidCodecs;
private final int perFieldSeed;
@Override
@@ -78,35 +77,42 @@ public class RandomCodec extends Lucene4
}
public RandomCodec(Random random, Set<String> avoidCodecs) {
- this.avoidCodecs = avoidCodecs;
this.perFieldSeed = random.nextInt();
// TODO: make it possible to specify min/max iterms per
// block via CL:
int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
- add(new Lucene40PostingsFormat(minItemsPerBlock, maxItemsPerBlock));
- // TODO: make it possible to specify min/max iterms per
- // block via CL:
+
+ // TODO: make it possible to specify min/max iterms per block via CL:
minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
maxItemsPerBlock = 2*(Math.max(1, minItemsPerBlock-1)) + random.nextInt(100);
- add(new Pulsing40PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock));
- add(new MockSepPostingsFormat());
- add(new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)));
- add(new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)));
- add(new MockRandomPostingsFormat(random));
- add(new NestedPulsingPostingsFormat());
- add(new Lucene40WithOrds());
- add(new SimpleTextPostingsFormat());
- add(new MemoryPostingsFormat(random.nextBoolean()));
+ add(avoidCodecs,
+ new Lucene40PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
+ new Pulsing40PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
+ new MockSepPostingsFormat(),
+ new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)),
+ new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)),
+ new MockRandomPostingsFormat(random),
+ new NestedPulsingPostingsFormat(),
+ new Lucene40WithOrds(),
+ new SimpleTextPostingsFormat(),
+ new MemoryPostingsFormat(random.nextBoolean()));
+
Collections.shuffle(formats, random);
}
-
- private final void add(PostingsFormat p) {
- if (avoidCodecs == null || !avoidCodecs.contains(p.getName())) {
- formats.add(p);
+
+ public RandomCodec(Random random) {
+ this(random, Collections.<String> emptySet());
+ }
+
+ private final void add(Set<String> avoidCodecs, PostingsFormat... postings) {
+ for (PostingsFormat p : postings) {
+ if (!avoidCodecs.contains(p.getName())) {
+ formats.add(p);
+ }
}
}
-
+
@Override
public String toString() {
return super.toString() + ": " + previousMappings.toString();
Copied: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/AbstractBeforeAfterRule.java (from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/AbstractBeforeAfterRule.java?p2=lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/AbstractBeforeAfterRule.java&p1=lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java&r1=1338668&r2=1338826&rev=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/StoreClassNameRule.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/AbstractBeforeAfterRule.java Tue May 15 18:47:45 2012
@@ -1,5 +1,15 @@
package org.apache.lucene.util;
+import java.util.ArrayList;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.MultipleFailureException;
+import org.junit.runners.model.Statement;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,40 +27,37 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-public class StoreClassNameRule implements TestRule {
- private volatile Description description;
-
+/**
+ * A {@link TestRule} that guarantees the execution of {@link #after} even
+ * if an exception has been thrown from delegate {@link Statement}. This is much
+ * like {@link AfterClass} or {@link After} annotations but can be used with
+ * {@link RuleChain} to guarantee the order of execution.
+ */
+abstract class AbstractBeforeAfterRule implements TestRule {
@Override
public Statement apply(final Statement s, final Description d) {
- if (!d.isSuite()) {
- throw new IllegalArgumentException("This is a @ClassRule (applies to suites only).");
- }
-
return new Statement() {
- @Override
public void evaluate() throws Throwable {
+ before();
+
+ final ArrayList<Throwable> errors = new ArrayList<Throwable>();
try {
- description = d;
s.evaluate();
- } finally {
- description = null;
+ } catch (Throwable t) {
+ errors.add(t);
}
+
+ try {
+ after();
+ } catch (Throwable t) {
+ errors.add(t);
+ }
+
+ MultipleFailureException.assertEmpty(errors);
}
};
}
-
- /**
- * Returns the test class currently executing in this rule.
- */
- public Class<?> getTestClass() {
- Description localDescription = description;
- if (localDescription == null) {
- throw new RuntimeException("The rule is not currently executing.");
- }
- return localDescription.getTestClass();
- }
+
+ protected void before() throws Exception {}
+ protected void after() throws Exception {}
}
Added: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableDirectory.java?rev=1338826&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableDirectory.java (added)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableDirectory.java Tue May 15 18:47:45 2012
@@ -0,0 +1,54 @@
+package org.apache.lucene.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.junit.Assert;
+
+/**
+ * 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.
+ */
+
+/**
+ * Attempts to close a {@link MockDirectoryWrapper}.
+ *
+ * @see LuceneTestCase#newDirectory(java.util.Random)
+ */
+final class CloseableDirectory implements Closeable {
+ private final MockDirectoryWrapper dir;
+ private final TestRuleMarkFailure failureMarker;
+
+ public CloseableDirectory(MockDirectoryWrapper dir,
+ TestRuleMarkFailure failureMarker) {
+ this.dir = dir;
+ this.failureMarker = failureMarker;
+ }
+
+ @Override
+ public void close() throws IOException {
+ // We only attempt to check open/closed state if there were no other test
+ // failures.
+ try {
+ if (failureMarker.wasSuccessful() && dir.isOpen()) {
+ Assert.fail("Directory not closed: " + dir);
+ }
+ } finally {
+ // TODO: perform real close of the delegate: LUCENE-4058
+ // dir.close();
+ }
+ }
+}
Copied: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableFile.java (from r1338668, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableFile.java?p2=lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableFile.java&p1=lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java&r1=1338668&r2=1338826&rev=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/RequireAssertions.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/CloseableFile.java Tue May 15 18:47:45 2012
@@ -1,5 +1,7 @@
package org.apache.lucene.util;
+import java.io.*;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -7,9 +9,9 @@ package org.apache.lucene.util;
* 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
- *
+ *
+ * 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.
@@ -17,19 +19,30 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import com.carrotsearch.randomizedtesting.ClassValidator;
-
/**
- * Require assertions for Lucene/Solr packages.
+ * A {@link Closeable} that attempts to remove a given file/folder.
*/
-public class RequireAssertions implements ClassValidator {
+final class CloseableFile implements Closeable {
+ private final File file;
+
+ public CloseableFile(File file) {
+ this.file = file;
+ }
+
@Override
- public void validate(Class<?> clazz) throws Throwable {
- try {
- assert false;
- throw new RuntimeException("Enable assertions globally (-ea) or for Solr/Lucene subpackages only.");
- } catch (AssertionError e) {
- // Ok, enabled.
- }
+ public void close() throws IOException {
+ if (file.exists()) {
+ try {
+ _TestUtil.rmDir(file);
+ } catch (IOException e) {
+ // Ignore the exception from rmDir.
+ }
+
+ // Re-check.
+ if (file.exists()) {
+ throw new IOException(
+ "Could not remove: " + file.getAbsolutePath());
+ }
+ }
}
-}
+}
\ No newline at end of file
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LineFileDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LineFileDocs.java?rev=1338826&r1=1338825&r2=1338826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LineFileDocs.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LineFileDocs.java Tue May 15 18:47:45 2012
@@ -27,7 +27,6 @@ import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.Random;