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/04/15 16:42:01 UTC
svn commit: r1326351 [21/22] - in /lucene/dev/trunk: ./ dev-tools/eclipse/
lucene/
lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/
lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/custom/
lucene/contrib/hig...
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java Sun Apr 15 14:41:44 2012
@@ -195,7 +195,7 @@ public class TestQPHelper extends Lucene
public StandardQueryParser getParser(Analyzer a) throws Exception {
if (a == null)
- a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true);
+ a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(a);
@@ -285,7 +285,7 @@ public class TestQPHelper extends Lucene
public Query getQueryDOA(String query, Analyzer a) throws Exception {
if (a == null)
- a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true);
+ a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(a);
qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
@@ -305,7 +305,7 @@ public class TestQPHelper extends Lucene
}
public void testConstantScoreAutoRewrite() throws Exception {
- StandardQueryParser qp = new StandardQueryParser(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ StandardQueryParser qp = new StandardQueryParser(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
Query q = qp.parse("foo*bar", "field");
assertTrue(q instanceof WildcardQuery);
assertEquals(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((MultiTermQuery) q).getRewriteMethod());
@@ -423,9 +423,9 @@ public class TestQPHelper extends Lucene
assertQueryEquals("field=a", null, "a");
assertQueryEquals("\"term germ\"~2", null, "\"term germ\"~2");
assertQueryEquals("term term term", null, "term term term");
- assertQueryEquals("t�rm term term", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false),
+ assertQueryEquals("t�rm term term", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false),
"t�rm term term");
- assertQueryEquals("�mlaut", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false), "�mlaut");
+ assertQueryEquals("�mlaut", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false), "�mlaut");
// FIXME: change MockAnalyzer to not extend CharTokenizer for this test
//assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
@@ -483,7 +483,7 @@ public class TestQPHelper extends Lucene
}
public void testPunct() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertQueryEquals("a&b", a, "a&b");
assertQueryEquals("a&&b", a, "a&&b");
assertQueryEquals(".NET", a, ".NET");
@@ -504,7 +504,7 @@ public class TestQPHelper extends Lucene
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -755,7 +755,7 @@ public class TestQPHelper extends Lucene
}
public void testEscaped() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
/*
* assertQueryEquals("\\[brackets", a, "\\[brackets");
@@ -854,7 +854,7 @@ public class TestQPHelper extends Lucene
}
public void testQueryStringEscaping() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertEscapedQueryEquals("a-b:c", a, "a\\-b\\:c");
assertEscapedQueryEquals("a+b:c", a, "a\\+b\\:c");
@@ -895,7 +895,7 @@ public class TestQPHelper extends Lucene
@Ignore("contrib queryparser shouldn't escape wildcard terms")
public void testEscapedWildcard() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
WildcardQuery q = new WildcardQuery(new Term("field", "foo\\?ba?r"));
assertEquals(q, qp.parse("foo\\?ba?r", "field"));
@@ -933,7 +933,7 @@ public class TestQPHelper extends Lucene
public void testBoost() throws Exception {
CharacterRunAutomaton stopSet = new CharacterRunAutomaton(BasicAutomata.makeString("on"));
- Analyzer oneStopAnalyzer = new MockAnalyzer(random, MockTokenizer.SIMPLE, true, stopSet, true);
+ Analyzer oneStopAnalyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, stopSet, true);
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(oneStopAnalyzer);
@@ -949,7 +949,7 @@ public class TestQPHelper extends Lucene
assertNotNull(q);
StandardQueryParser qp2 = new StandardQueryParser();
- qp2.setAnalyzer(new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
+ qp2.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
q = qp2.parse("the^3", "field");
// "the" is a stop word so the result is an empty query:
@@ -979,7 +979,7 @@ public class TestQPHelper extends Lucene
public void testCustomQueryParserWildcard() {
try {
- new QPTestParser(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).parse("a?t", "contents");
+ new QPTestParser(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).parse("a?t", "contents");
fail("Wildcard queries should not be allowed");
} catch (QueryNodeException expected) {
// expected exception
@@ -988,7 +988,7 @@ public class TestQPHelper extends Lucene
public void testCustomQueryParserFuzzy() throws Exception {
try {
- new QPTestParser(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).parse("xunit~", "contents");
+ new QPTestParser(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).parse("xunit~", "contents");
fail("Fuzzy queries should not be allowed");
} catch (QueryNodeException expected) {
// expected exception
@@ -999,7 +999,7 @@ public class TestQPHelper extends Lucene
BooleanQuery.setMaxClauseCount(2);
try {
StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
qp.parse("one two three", "field");
fail("ParseException expected due to too many boolean clauses");
@@ -1013,7 +1013,7 @@ public class TestQPHelper extends Lucene
*/
public void testPrecedence() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
Query query1 = qp.parse("A AND B OR C AND D", "field");
Query query2 = qp.parse("+A +B +C +D", "field");
@@ -1145,7 +1145,7 @@ public class TestQPHelper extends Lucene
public void testStopwords() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
CharacterRunAutomaton stopSet = new CharacterRunAutomaton(new RegExp("the|foo").toAutomaton());
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.SIMPLE, true, stopSet, true));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, stopSet, true));
Query result = qp.parse("a:the OR a:foo", "a");
assertNotNull("result is null and it shouldn't be", result);
@@ -1169,7 +1169,7 @@ public class TestQPHelper extends Lucene
public void testPositionIncrement() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
qp.setEnablePositionIncrements(true);
@@ -1190,7 +1190,7 @@ public class TestQPHelper extends Lucene
public void testMatchAllDocs() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
assertEquals(new MatchAllDocsQuery(), qp.parse("*:*", "field"));
assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)", "field"));
@@ -1202,7 +1202,7 @@ public class TestQPHelper extends Lucene
private void assertHits(int expected, String query, IndexSearcher is)
throws IOException, QueryNodeException {
StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
qp.setLocale(Locale.ENGLISH);
Query q = qp.parse(query, "date");
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SrndQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SrndQueryTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SrndQueryTest.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SrndQueryTest.java Sun Apr 15 14:41:44 2012
@@ -17,8 +17,6 @@ package org.apache.lucene.queryparser.su
* limitations under the License.
*/
-import junit.framework.Assert;
-
import org.apache.lucene.queryparser.surround.parser.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java Sun Apr 15 14:41:44 2012
@@ -39,7 +39,12 @@ public class Test02Boolean extends Lucen
"a c e a b c"
};
- SingleFieldTestDb db1 = new SingleFieldTestDb(random, docs1, fieldName);
+ public void setUp() throws Exception {
+ super.setUp();
+ db1 = new SingleFieldTestDb(random(), docs1, fieldName);
+ }
+
+ SingleFieldTestDb db1;
public void normalTest1(String query, int[] expdnrs) throws Exception {
BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db1, fieldName, this,
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java Sun Apr 15 14:41:44 2012
@@ -26,6 +26,7 @@ public class Test03Distance extends Luce
public static void main(String args[]) {
TestRunner.run(new TestSuite(Test03Distance.class));
}
+
boolean verbose = false;
int maxBasicQueries = 16;
@@ -58,8 +59,16 @@ public class Test03Distance extends Luce
"a c e a b c"
};
- SingleFieldTestDb db1 = new SingleFieldTestDb(random, docs1, fieldName);
+ SingleFieldTestDb db1;
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ db1 = new SingleFieldTestDb(random(), docs1, fieldName);
+ db2 = new SingleFieldTestDb(random(), docs2, fieldName);
+ db3 = new SingleFieldTestDb(random(), docs3, fieldName);
+ }
+
private void distanceTst(String query, int[] expdnrs, SingleFieldTestDb db) throws Exception {
BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db, fieldName, this,
new BasicQueryFactory(maxBasicQueries));
@@ -179,7 +188,7 @@ public class Test03Distance extends Luce
""
};
- SingleFieldTestDb db2 = new SingleFieldTestDb(random, docs2, fieldName);
+ SingleFieldTestDb db2;
public void distanceTest2(String query, int[] expdnrs) throws Exception {
distanceTst(query, expdnrs, db2);
@@ -227,7 +236,7 @@ public class Test03Distance extends Luce
""
};
- SingleFieldTestDb db3 = new SingleFieldTestDb(random, docs3, fieldName);
+ SingleFieldTestDb db3;
public void distanceTest3(String query, int[] expdnrs) throws Exception {
distanceTst(query, expdnrs, db3);
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java Sun Apr 15 14:41:44 2012
@@ -199,7 +199,7 @@ public abstract class QueryParserTestBas
public Query getQueryDOA(String query, Analyzer a)
throws Exception {
if (a == null)
- a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true);
+ a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", a);
qp.setDefaultOperator(QueryParserBase.AND_OPERATOR);
return qp.parse(query);
@@ -320,8 +320,8 @@ public abstract class QueryParserTestBas
public void testSimple() throws Exception {
assertQueryEquals("term term term", null, "term term term");
- assertQueryEquals("türm term term", new MockAnalyzer(random), "türm term term");
- assertQueryEquals("ümlaut", new MockAnalyzer(random), "ümlaut");
+ assertQueryEquals("türm term term", new MockAnalyzer(random()), "türm term term");
+ assertQueryEquals("ümlaut", new MockAnalyzer(random()), "ümlaut");
// FIXME: enhance MockAnalyzer to be able to support this
// it must no longer extend CharTokenizer
@@ -381,7 +381,7 @@ public abstract class QueryParserTestBas
assertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null,
"+(title:dog title:cat) -author:\"bob dole\"");
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random()));
// make sure OR is the default:
assertEquals(QueryParserBase.OR_OPERATOR, qp.getDefaultOperator());
qp.setDefaultOperator(QueryParserBase.AND_OPERATOR);
@@ -391,7 +391,7 @@ public abstract class QueryParserTestBas
}
public void testPunct() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertQueryEquals("a&b", a, "a&b");
assertQueryEquals("a&&b", a, "a&&b");
assertQueryEquals(".NET", a, ".NET");
@@ -411,7 +411,7 @@ public abstract class QueryParserTestBas
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, true);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -539,7 +539,7 @@ public abstract class QueryParserTestBas
assertEquals(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((TermRangeQuery)getQuery("[ a TO z]", null)).getRewriteMethod());
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
assertEquals(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE,((TermRangeQuery)qp.parse("[ a TO z]")).getRewriteMethod());
@@ -610,7 +610,7 @@ public abstract class QueryParserTestBas
final String defaultField = "default";
final String monthField = "month";
final String hourField = "hour";
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
// set a field specific date resolution
qp.setDateResolution(monthField, DateTools.Resolution.MONTH);
@@ -643,7 +643,7 @@ public abstract class QueryParserTestBas
}
public void testEscaped() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
/*assertQueryEquals("\\[brackets", a, "\\[brackets");
assertQueryEquals("\\[brackets", null, "brackets");
@@ -737,7 +737,7 @@ public abstract class QueryParserTestBas
}
public void testQueryStringEscaping() throws Exception {
- Analyzer a = new MockAnalyzer(random, MockTokenizer.WHITESPACE, false);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertEscapedQueryEquals("a-b:c", a, "a\\-b\\:c");
assertEscapedQueryEquals("a+b:c", a, "a\\+b\\:c");
@@ -823,7 +823,7 @@ public abstract class QueryParserTestBas
public void testBoost()
throws Exception {
CharacterRunAutomaton stopWords = new CharacterRunAutomaton(BasicAutomata.makeString("on"));
- Analyzer oneStopAnalyzer = new MockAnalyzer(random, MockTokenizer.SIMPLE, true, stopWords, true);
+ Analyzer oneStopAnalyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, stopWords, true);
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
@@ -836,7 +836,7 @@ public abstract class QueryParserTestBas
q = qp.parse("\"on\"^1.0");
assertNotNull(q);
- QueryParser qp2 = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
+ QueryParser qp2 = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
q = qp2.parse("the^3");
// "the" is a stop word so the result is an empty query:
assertNotNull(q);
@@ -865,7 +865,7 @@ public abstract class QueryParserTestBas
public void testCustomQueryParserWildcard() {
try {
- new QPTestParser("contents", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).parse("a?t");
+ new QPTestParser("contents", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).parse("a?t");
fail("Wildcard queries should not be allowed");
} catch (ParseException expected) {
// expected exception
@@ -874,7 +874,7 @@ public abstract class QueryParserTestBas
public void testCustomQueryParserFuzzy() throws Exception {
try {
- new QPTestParser("contents", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).parse("xunit~");
+ new QPTestParser("contents", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).parse("xunit~");
fail("Fuzzy queries should not be allowed");
} catch (ParseException expected) {
// expected exception
@@ -884,7 +884,7 @@ public abstract class QueryParserTestBas
public void testBooleanQuery() throws Exception {
BooleanQuery.setMaxClauseCount(2);
try {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
qp.parse("one two three");
fail("ParseException expected due to too many boolean clauses");
} catch (ParseException expected) {
@@ -896,7 +896,7 @@ public abstract class QueryParserTestBas
* This test differs from TestPrecedenceQueryParser
*/
public void testPrecedence() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
Query query1 = qp.parse("A AND B OR C AND D");
Query query2 = qp.parse("+A +B +C +D");
assertEquals(query1, query2);
@@ -932,7 +932,7 @@ public abstract class QueryParserTestBas
public void testStarParsing() throws Exception {
final int[] type = new int[1];
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)) {
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)) {
@Override
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
// override error checking of superclass
@@ -991,13 +991,13 @@ public abstract class QueryParserTestBas
}
public void testEscapedWildcard() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
WildcardQuery q = new WildcardQuery(new Term("field", "foo\\?ba?r"));
assertEquals(q, qp.parse("foo\\?ba?r"));
}
public void testRegexps() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
RegexpQuery q = new RegexpQuery(new Term("field", "[a-z][123]"));
assertEquals(q, qp.parse("/[a-z][123]/"));
qp.setLowercaseExpandedTerms(true);
@@ -1025,7 +1025,7 @@ public abstract class QueryParserTestBas
public void testStopwords() throws Exception {
CharacterRunAutomaton stopSet = new CharacterRunAutomaton(new RegExp("the|foo").toAutomaton());
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new MockAnalyzer(random, MockTokenizer.SIMPLE, true, stopSet, true));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, stopSet, true));
Query result = qp.parse("a:the OR a:foo");
assertNotNull("result is null and it shouldn't be", result);
assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
@@ -1041,7 +1041,7 @@ public abstract class QueryParserTestBas
}
public void testPositionIncrement() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true));
qp.setEnablePositionIncrements(true);
String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
// 0 2 5 7 8
@@ -1058,7 +1058,7 @@ public abstract class QueryParserTestBas
}
public void testMatchAllDocs() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));
assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)"));
BooleanQuery bq = (BooleanQuery)qp.parse("+*:* -*:*");
@@ -1067,7 +1067,7 @@ public abstract class QueryParserTestBas
}
private void assertHits(int expected, String query, IndexSearcher is) throws ParseException, IOException {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "date", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "date", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
qp.setLocale(Locale.ENGLISH);
Query q = qp.parse(query);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
@@ -1085,7 +1085,7 @@ public abstract class QueryParserTestBas
// "match"
public void testPositionIncrements() throws Exception {
Directory dir = newDirectory();
- Analyzer a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
+ Analyzer a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, a));
Document doc = new Document();
doc.add(newField("f", "the wizard of ozzy", TextField.TYPE_UNSTORED));
@@ -1248,13 +1248,13 @@ public abstract class QueryParserTestBas
}
public void testDistanceAsEditsParsing() throws Exception {
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random()));
FuzzyQuery q = (FuzzyQuery) qp.parse("foobar~2");
assertEquals(2f, q.getMinSimilarity(), 0.0001f);
}
public void testPhraseQueryToString() throws ParseException {
- Analyzer analyzer = new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
+ Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", analyzer);
qp.setEnablePositionIncrements(true);
PhraseQuery q = (PhraseQuery)qp.parse("\"this hi this is a test is\"");
@@ -1263,7 +1263,7 @@ public abstract class QueryParserTestBas
public void testParseWildcardAndPhraseQueries() throws ParseException {
String field = "content";
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, field, new MockAnalyzer(random));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, field, new MockAnalyzer(random()));
qp.setAllowLeadingWildcard(true);
String prefixQueries[][] = {
@@ -1302,7 +1302,7 @@ public abstract class QueryParserTestBas
new CharacterRunAutomaton(new RegExp("[sS][tT][oO][pP]").toAutomaton());
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field",
- new MockAnalyzer(random, MockTokenizer.WHITESPACE, false, stopStopList, false));
+ new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false, stopStopList, false));
PhraseQuery phraseQuery = new PhraseQuery();
phraseQuery.add(new Term("field", "1"));
@@ -1318,7 +1318,7 @@ public abstract class QueryParserTestBas
assertEquals(phraseQuery, qp.parse("\"1 stop 2\""));
qp = new QueryParser(TEST_VERSION_CURRENT, "field",
- new MockAnalyzer(random, MockTokenizer.WHITESPACE, false, stopStopList, true));
+ new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false, stopStopList, true));
qp.setEnablePositionIncrements(true);
phraseQuery = new PhraseQuery();
@@ -1329,7 +1329,7 @@ public abstract class QueryParserTestBas
public void testMatchAllQueryParsing() throws Exception {
// test simple parsing of MatchAllDocsQuery
- QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "key", new MockAnalyzer(random));
+ QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "key", new MockAnalyzer(random()));
assertEquals(new MatchAllDocsQuery(), qp.parse(new MatchAllDocsQuery().toString()));
// test parsing with non-default boost
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java Sun Apr 15 14:41:44 2012
@@ -54,7 +54,7 @@ public class TestParser extends LuceneTe
@BeforeClass
public static void beforeClass() throws Exception {
// TODO: rewrite test (this needs to set QueryParser.enablePositionIncrements, too, for work with CURRENT):
- Analyzer analyzer = new MockAnalyzer(random, MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET, false);
+ Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET, false);
//initialize the parser
builder = new CorePlusExtensionsParser("contents", analyzer);
Modified: lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java (original)
+++ lucene/dev/trunk/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java Sun Apr 15 14:41:44 2012
@@ -45,7 +45,7 @@ import java.util.StringTokenizer;
public class TestQueryTemplateManager extends LuceneTestCase {
private CoreParser builder;
- private final Analyzer analyzer = new MockAnalyzer(random);
+ private Analyzer analyzer;
private IndexSearcher searcher;
private IndexReader reader;
private Directory dir;
@@ -141,6 +141,7 @@ public class TestQueryTemplateManager ex
public void setUp() throws Exception {
super.setUp();
+ analyzer = new MockAnalyzer(random());
//Create an index
dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
Modified: lucene/dev/trunk/modules/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (original)
+++ lucene/dev/trunk/modules/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java Sun Apr 15 14:41:44 2012
@@ -32,8 +32,7 @@ import org.junit.After;
import org.junit.Before;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
public abstract class SpatialTestCase extends LuceneTestCase {
@@ -46,6 +45,7 @@ public abstract class SpatialTestCase ex
@Before
public void setUp() throws Exception {
super.setUp();
+ Random random = random();
directory = newDirectory();
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java Sun Apr 15 14:41:44 2012
@@ -33,8 +33,8 @@ public class TestDirectSpellChecker exte
public void testInternalLevenshteinDistance() throws Exception {
DirectSpellChecker spellchecker = new DirectSpellChecker();
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.KEYWORD, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.KEYWORD, true));
String[] termsToAdd = { "metanoia", "metanoian", "metanoiai", "metanoias", "metanoið" };
for (int i = 0; i < termsToAdd.length; i++) {
@@ -63,8 +63,8 @@ public class TestDirectSpellChecker exte
DirectSpellChecker spellChecker = new DirectSpellChecker();
spellChecker.setMinQueryLength(0);
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
Document doc = new Document();
@@ -128,8 +128,8 @@ public class TestDirectSpellChecker exte
public void testOptions() throws Exception {
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
Document doc = new Document();
doc.add(newField("text", "foobar", TextField.TYPE_UNSTORED));
@@ -195,8 +195,8 @@ public class TestDirectSpellChecker exte
public void testBogusField() throws Exception {
DirectSpellChecker spellChecker = new DirectSpellChecker();
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
Document doc = new Document();
@@ -219,8 +219,8 @@ public class TestDirectSpellChecker exte
public void testTransposition() throws Exception {
DirectSpellChecker spellChecker = new DirectSpellChecker();
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
Document doc = new Document();
@@ -244,8 +244,8 @@ public class TestDirectSpellChecker exte
public void testTransposition2() throws Exception {
DirectSpellChecker spellChecker = new DirectSpellChecker();
Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- new MockAnalyzer(random, MockTokenizer.SIMPLE, true));
+ RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
+ new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
Document doc = new Document();
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java Sun Apr 15 14:41:44 2012
@@ -49,7 +49,7 @@ public class TestLuceneDictionary extend
public void setUp() throws Exception {
super.setUp();
store = newDirectory();
- IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
+ IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)));
Document doc;
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java Sun Apr 15 14:41:44 2012
@@ -54,7 +54,7 @@ public class TestSpellChecker extends Lu
//create a user index
userindex = newDirectory();
IndexWriter writer = new IndexWriter(userindex, new IndexWriterConfig(
- TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ TEST_VERSION_CURRENT, new MockAnalyzer(random())));
for (int i = 0; i < 1000; i++) {
Document doc = new Document();
@@ -412,7 +412,7 @@ public class TestSpellChecker extends Lu
assertEquals(4, searchers.size());
int num_field2 = this.numdoc();
assertEquals(num_field2, num_field1 + 1);
- int numThreads = 5 + LuceneTestCase.random.nextInt(5);
+ int numThreads = 5 + random().nextInt(5);
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
for (int i = 0; i < numThreads; i++) {
@@ -421,7 +421,7 @@ public class TestSpellChecker extends Lu
workers[i] = spellCheckWorker;
}
- int iterations = 5 + random.nextInt(5);
+ int iterations = 5 + random().nextInt(5);
for (int i = 0; i < iterations; i++) {
Thread.sleep(100);
// concurrently reset the spell index
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java Sun Apr 15 14:41:44 2012
@@ -17,6 +17,7 @@
package org.apache.lucene.search.suggest;
import java.io.File;
+import java.util.Random;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;
@@ -78,6 +79,7 @@ public class PersistenceTest extends Luc
lookup.load(new FileInputStream(new File(storeDir, "lookup.dat")));
// Assert validity.
+ Random random = random();
long previous = Long.MIN_VALUE;
for (TermFreq k : keys) {
List<LookupResult> list = lookup.lookup(_TestUtil.bytesToCharSequence(k.term, random), false, 1);
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestBytesRefList.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestBytesRefList.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestBytesRefList.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestBytesRefList.java Sun Apr 15 14:41:44 2012
@@ -18,9 +18,7 @@ package org.apache.lucene.search.suggest
*/
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
import org.apache.lucene.search.suggest.BytesRefList;
import org.apache.lucene.util.BytesRef;
@@ -29,8 +27,9 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.util._TestUtil;
public class TestBytesRefList extends LuceneTestCase {
-
+
public void testAppend() throws IOException {
+ Random random = random();
BytesRefList list = new BytesRefList();
List<String> stringList = new ArrayList<String>();
for (int j = 0; j < 2; j++) {
@@ -69,8 +68,9 @@ public class TestBytesRefList extends Lu
}
}
}
-
+
public void testSort() throws IOException {
+ Random random = random();
BytesRefList list = new BytesRefList();
List<String> stringList = new ArrayList<String>();
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java Sun Apr 15 14:41:44 2012
@@ -30,7 +30,7 @@ import org.apache.lucene.util.LuceneTest
public class TestHighFrequencyDictionary extends LuceneTestCase {
public void testEmpty() throws Exception {
Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
writer.commit();
writer.close();
IndexReader ir = DirectoryReader.open(dir);
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestTermFreqIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestTermFreqIterator.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestTermFreqIterator.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/TestTermFreqIterator.java Sun Apr 15 14:41:44 2012
@@ -20,6 +20,7 @@ package org.apache.lucene.search.suggest
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
+import java.util.Random;
import java.util.TreeMap;
import org.apache.lucene.search.spell.TermFreqIterator;
@@ -40,6 +41,7 @@ public class TestTermFreqIterator extend
}
public void testTerms() throws Exception {
+ Random random = random();
int num = atLeast(10000);
Comparator<BytesRef> comparator = random.nextBoolean() ? BytesRef.getUTF8SortedAsUnicodeComparator() : BytesRef.getUTF8SortedAsUTF16Comparator();
@@ -88,6 +90,7 @@ public class TestTermFreqIterator extend
byte[] buffer = new byte[0];
ByteArrayDataOutput output = new ByteArrayDataOutput(buffer);
+ final Random random = new Random(random().nextLong());
for (int i = 0; i < num; i++) {
BytesRef spare;
long weight;
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/BytesRefSortersTest.java Sun Apr 15 14:41:44 2012
@@ -35,8 +35,8 @@ public class BytesRefSortersTest extends
private void check(BytesRefSorter sorter) throws Exception {
for (int i = 0; i < 100; i++) {
- byte [] current = new byte [random.nextInt(256)];
- random.nextBytes(current);
+ byte [] current = new byte [random().nextInt(256)];
+ random().nextBytes(current);
sorter.add(new BytesRef(current));
}
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTCompletionTest.java Sun Apr 15 14:41:44 2012
@@ -71,19 +71,19 @@ public class FSTCompletionTest extends L
}
public void testExactMatchHighPriority() throws Exception {
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("two", random), 1),
+ assertMatchEquals(completion.lookup(stringToCharSequence("two"), 1),
"two/1.0");
}
public void testExactMatchLowPriority() throws Exception {
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("one", random), 2),
+ assertMatchEquals(completion.lookup(stringToCharSequence("one"), 2),
"one/0.0",
"oneness/1.0");
}
public void testExactMatchReordering() throws Exception {
// Check reordering of exact matches.
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("four", random), 4),
+ assertMatchEquals(completion.lookup(stringToCharSequence("four"), 4),
"four/0.0",
"fourblah/1.0",
"fourteen/1.0",
@@ -92,49 +92,49 @@ public class FSTCompletionTest extends L
public void testRequestedCount() throws Exception {
// 'one' is promoted after collecting two higher ranking results.
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("one", random), 2),
+ assertMatchEquals(completion.lookup(stringToCharSequence("one"), 2),
"one/0.0",
"oneness/1.0");
// 'four' is collected in a bucket and then again as an exact match.
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("four", random), 2),
+ assertMatchEquals(completion.lookup(stringToCharSequence("four"), 2),
"four/0.0",
"fourblah/1.0");
// Check reordering of exact matches.
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("four", random), 4),
+ assertMatchEquals(completion.lookup(stringToCharSequence("four"), 4),
"four/0.0",
"fourblah/1.0",
"fourteen/1.0",
"fourier/0.0");
// 'one' is at the top after collecting all alphabetical results.
- assertMatchEquals(completionAlphabetical.lookup(_TestUtil.stringToCharSequence("one", random), 2),
+ assertMatchEquals(completionAlphabetical.lookup(stringToCharSequence("one"), 2),
"one/0.0",
"oneness/1.0");
// 'one' is not promoted after collecting two higher ranking results.
FSTCompletion noPromotion = new FSTCompletion(completion.getFST(), true, false);
- assertMatchEquals(noPromotion.lookup(_TestUtil.stringToCharSequence("one", random), 2),
+ assertMatchEquals(noPromotion.lookup(stringToCharSequence("one"), 2),
"oneness/1.0",
"onerous/1.0");
// 'one' is at the top after collecting all alphabetical results.
- assertMatchEquals(completionAlphabetical.lookup(_TestUtil.stringToCharSequence("one", random), 2),
+ assertMatchEquals(completionAlphabetical.lookup(stringToCharSequence("one"), 2),
"one/0.0",
"oneness/1.0");
}
public void testMiss() throws Exception {
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("xyz", random), 1));
+ assertMatchEquals(completion.lookup(stringToCharSequence("xyz"), 1));
}
public void testAlphabeticWithWeights() throws Exception {
- assertEquals(0, completionAlphabetical.lookup(_TestUtil.stringToCharSequence("xyz", random), 1).size());
+ assertEquals(0, completionAlphabetical.lookup(stringToCharSequence("xyz"), 1).size());
}
public void testFullMatchList() throws Exception {
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("one", random), Integer.MAX_VALUE),
+ assertMatchEquals(completion.lookup(stringToCharSequence("one"), Integer.MAX_VALUE),
"oneness/1.0",
"onerous/1.0",
"onesimus/1.0",
@@ -148,14 +148,14 @@ public class FSTCompletionTest extends L
builder.add(new BytesRef(key), 0);
FSTCompletion lookup = builder.build();
- List<Completion> result = lookup.lookup(_TestUtil.stringToCharSequence(key, random), 1);
+ List<Completion> result = lookup.lookup(stringToCharSequence(key), 1);
assertEquals(1, result.size());
}
public void testLargeInputConstantWeights() throws Exception {
FSTCompletionLookup lookup = new FSTCompletionLookup(10, true);
- Random r = random;
+ Random r = random();
List<TermFreq> keys = new ArrayList<TermFreq>();
for (int i = 0; i < 5000; i++) {
keys.add(new TermFreq(_TestUtil.randomSimpleString(r), -1));
@@ -167,7 +167,7 @@ public class FSTCompletionTest extends L
// are.
Long previous = null;
for (TermFreq tf : keys) {
- Long current = ((Number)lookup.get(_TestUtil.bytesToCharSequence(tf.term, random))).longValue();
+ Long current = ((Number)lookup.get(_TestUtil.bytesToCharSequence(tf.term, random()))).longValue();
if (previous != null) {
assertEquals(previous, current);
}
@@ -181,11 +181,11 @@ public class FSTCompletionTest extends L
FSTCompletionLookup lookup = new FSTCompletionLookup();
lookup.build(new TermFreqArrayIterator(input));
for (TermFreq tf : input) {
- assertNotNull("Not found: " + tf.term.toString(), lookup.get(_TestUtil.bytesToCharSequence(tf.term, random)));
- assertEquals(tf.term.utf8ToString(), lookup.lookup(_TestUtil.bytesToCharSequence(tf.term, random), true, 1).get(0).key.toString());
+ assertNotNull("Not found: " + tf.term.toString(), lookup.get(_TestUtil.bytesToCharSequence(tf.term, random())));
+ assertEquals(tf.term.utf8ToString(), lookup.lookup(_TestUtil.bytesToCharSequence(tf.term, random()), true, 1).get(0).key.toString());
}
- List<LookupResult> result = lookup.lookup(_TestUtil.stringToCharSequence("wit", random), true, 5);
+ List<LookupResult> result = lookup.lookup(stringToCharSequence("wit"), true, 5);
assertEquals(5, result.size());
assertTrue(result.get(0).key.toString().equals("wit")); // exact match.
assertTrue(result.get(1).key.toString().equals("with")); // highest count.
@@ -193,14 +193,14 @@ public class FSTCompletionTest extends L
public void testEmptyInput() throws Exception {
completion = new FSTCompletionBuilder().build();
- assertMatchEquals(completion.lookup(_TestUtil.stringToCharSequence("", random), 10));
+ assertMatchEquals(completion.lookup(stringToCharSequence(""), 10));
}
public void testRandom() throws Exception {
List<TermFreq> freqs = new ArrayList<TermFreq>();
- Random rnd = random;
+ Random rnd = random();
for (int i = 0; i < 2500 + rnd.nextInt(2500); i++) {
- int weight = random.nextInt(100);
+ int weight = rnd.nextInt(100);
freqs.add(new TermFreq("" + rnd.nextLong(), weight));
}
@@ -211,13 +211,17 @@ public class FSTCompletionTest extends L
final String term = tf.term.utf8ToString();
for (int i = 1; i < term.length(); i++) {
String prefix = term.substring(0, i);
- for (LookupResult lr : lookup.lookup(_TestUtil.stringToCharSequence(prefix, random), true, 10)) {
+ for (LookupResult lr : lookup.lookup(stringToCharSequence(prefix), true, 10)) {
assertTrue(lr.key.toString().startsWith(prefix));
}
}
}
}
+ private CharSequence stringToCharSequence(String prefix) {
+ return _TestUtil.stringToCharSequence(prefix, random());
+ }
+
private void assertMatchEquals(List<Completion> res, String... expected) {
String [] result = new String [res.size()];
for (int i = 0; i < res.size(); i++) {
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/TestSort.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/TestSort.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/TestSort.java Sun Apr 15 14:41:44 2012
@@ -85,8 +85,8 @@ public class TestSort extends LuceneTest
private byte[][] generateRandom(int howMuchData) {
ArrayList<byte[]> data = new ArrayList<byte[]>();
while (howMuchData > 0) {
- byte [] current = new byte [random.nextInt(256)];
- random.nextBytes(current);
+ byte [] current = new byte [random().nextInt(256)];
+ random().nextBytes(current);
data.add(current);
howMuchData -= current.length;
}
Modified: lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java (original)
+++ lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/WFSTCompletionTest.java Sun Apr 15 14:41:44 2012
@@ -17,13 +17,7 @@ package org.apache.lucene.search.suggest
* limitations under the License.
*/
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import java.util.*;
import org.apache.lucene.search.suggest.Lookup.LookupResult;
import org.apache.lucene.search.suggest.TermFreq;
@@ -41,6 +35,7 @@ public class WFSTCompletionTest extends
new TermFreq("barbara", 6)
};
+ Random random = new Random(random().nextLong());
WFSTCompletionLookup suggester = new WFSTCompletionLookup();
suggester.build(new TermFreqArrayIterator(keys));
@@ -88,7 +83,7 @@ public class WFSTCompletionTest extends
while (true) {
// TODO: would be nice to fix this slowCompletor/comparator to
// use full range, but we might lose some coverage too...
- s = _TestUtil.randomSimpleString(random);
+ s = _TestUtil.randomSimpleString(random());
if (!slowCompletor.containsKey(s)) {
break;
}
@@ -98,16 +93,16 @@ public class WFSTCompletionTest extends
allPrefixes.add(s.substring(0, j));
}
// we can probably do Integer.MAX_VALUE here, but why worry.
- int weight = random.nextInt(1<<24);
+ int weight = random().nextInt(1<<24);
slowCompletor.put(s, (long)weight);
keys[i] = new TermFreq(s, weight);
}
WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);
suggester.build(new TermFreqArrayIterator(keys));
-
+
+ Random random = new Random(random().nextLong());
for (String prefix : allPrefixes) {
-
final int topN = _TestUtil.nextInt(random, 1, 10);
List<LookupResult> r = suggester.lookup(_TestUtil.stringToCharSequence(prefix, random), false, topN);
Modified: lucene/dev/trunk/solr/contrib/contrib-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/contrib-build.xml?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/contrib-build.xml (original)
+++ lucene/dev/trunk/solr/contrib/contrib-build.xml Sun Apr 15 14:41:44 2012
@@ -25,9 +25,6 @@
<target name="compile-core" depends="compile-solr-core,compile-solrj,common-solr.compile-core"/>
- <!-- redefine common-solr.test, and exclude 'validate-solr' dependency, since it should only run at solr/ level -->
- <target name="test" depends="compile-test,junit-mkdir,junit-sequential,junit-parallel" description="Runs unit tests"/>
-
<dirname file="${ant.file}" property="antfile.dir"/>
<available property="contrib.has.webapp" type="dir" file="${antfile.dir}/src/webapp" />
Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestEphemeralCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestEphemeralCache.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestEphemeralCache.java (original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestEphemeralCache.java Sun Apr 15 14:41:44 2012
@@ -45,7 +45,7 @@ public class TestEphemeralCache extends
public void test() throws Exception {
assertFullImport(getDataConfigDotXml());
}
-
+
@SuppressWarnings("unchecked")
private void setupMockData() {
List parentRows = new ArrayList();
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Sun Apr 15 14:41:44 2012
@@ -221,20 +221,20 @@ public class TestDistributedSearch exten
stress=0; // turn off stress... we want to tex max combos in min time
for (int i=0; i<25*RANDOM_MULTIPLIER; i++) {
- String f = fieldNames[random.nextInt(fieldNames.length)];
- if (random.nextBoolean()) f = t1; // the text field is a really interesting one to facet on (and it's multi-valued too)
+ String f = fieldNames[random().nextInt(fieldNames.length)];
+ if (random().nextBoolean()) f = t1; // the text field is a really interesting one to facet on (and it's multi-valued too)
// we want a random query and not just *:* so we'll get zero counts in facets also
// TODO: do a better random query
- String q = random.nextBoolean() ? "*:*" : "id:(1 3 5 7 9 11 13) OR id:[100 TO " + random.nextInt(50) + "]";
+ String q = random().nextBoolean() ? "*:*" : "id:(1 3 5 7 9 11 13) OR id:[100 TO " + random().nextInt(50) + "]";
- int nolimit = random.nextBoolean() ? -1 : 10000; // these should be equivalent
+ int nolimit = random().nextBoolean() ? -1 : 10000; // these should be equivalent
// if limit==-1, we should always get exact matches
- query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","count", "facet.mincount",random.nextInt(5), "facet.offset",random.nextInt(10));
- query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","index", "facet.mincount",random.nextInt(5), "facet.offset",random.nextInt(10));
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","count", "facet.mincount",random().nextInt(5), "facet.offset",random().nextInt(10));
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","index", "facet.mincount",random().nextInt(5), "facet.offset",random().nextInt(10));
// for index sort, we should get exact results for mincount <= 1
- query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.sort","index", "facet.mincount",random.nextInt(2), "facet.offset",random.nextInt(10), "facet.limit",random.nextInt(11)-1);
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.sort","index", "facet.mincount",random().nextInt(2), "facet.offset",random().nextInt(10), "facet.limit",random().nextInt(11)-1);
}
stress = backupStress; // restore stress
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestGroupingSearch.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestGroupingSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestGroupingSearch.java Sun Apr 15 14:41:44 2012
@@ -555,7 +555,7 @@ public class TestGroupingSearch extends
while (--indexIter >= 0) {
- int indexSize = random.nextInt(25 * RANDOM_MULTIPLIER);
+ int indexSize = random().nextInt(25 * RANDOM_MULTIPLIER);
//indexSize=2;
List<FldType> types = new ArrayList<FldType>();
types.add(new FldType("id",ONE_ONE, new SVal('A','Z',4,4)));
@@ -611,17 +611,17 @@ public class TestGroupingSearch extends
for (int qiter=0; qiter<queryIter; qiter++) {
- String groupField = types.get(random.nextInt(types.size())).fname;
+ String groupField = types.get(random().nextInt(types.size())).fname;
- int rows = random.nextInt(10)==0 ? random.nextInt(model.size()+2) : random.nextInt(11)-1;
- int start = random.nextInt(5)==0 ? random.nextInt(model.size()+2) : random.nextInt(5); // pick a small start normally for better coverage
- int group_limit = random.nextInt(10)==0 ? random.nextInt(model.size()+2) : random.nextInt(11)-1;
- int group_offset = random.nextInt(10)==0 ? random.nextInt(model.size()+2) : random.nextInt(2); // pick a small start normally for better coverage
+ int rows = random().nextInt(10)==0 ? random().nextInt(model.size()+2) : random().nextInt(11)-1;
+ int start = random().nextInt(5)==0 ? random().nextInt(model.size()+2) : random().nextInt(5); // pick a small start normally for better coverage
+ int group_limit = random().nextInt(10)==0 ? random().nextInt(model.size()+2) : random().nextInt(11)-1;
+ int group_offset = random().nextInt(10)==0 ? random().nextInt(model.size()+2) : random().nextInt(2); // pick a small start normally for better coverage
String[] stringSortA = new String[1];
Comparator<Doc> sortComparator = createSort(h.getCore().getSchema(), types, stringSortA);
String sortStr = stringSortA[0];
- Comparator<Doc> groupComparator = random.nextBoolean() ? sortComparator : createSort(h.getCore().getSchema(), types, stringSortA);
+ Comparator<Doc> groupComparator = random().nextBoolean() ? sortComparator : createSort(h.getCore().getSchema(), types, stringSortA);
String groupSortStr = stringSortA[0];
// since groupSortStr defaults to sortStr, we need to normalize null to "score desc" if
@@ -657,10 +657,10 @@ public class TestGroupingSearch extends
List<Grp> sortedGroups = new ArrayList<Grp>(groups.values());
Collections.sort(sortedGroups, groupComparator==sortComparator ? createFirstDocComparator(sortComparator) : createMaxDocComparator(sortComparator));
- boolean includeNGroups = random.nextBoolean();
+ boolean includeNGroups = random().nextBoolean();
Object modelResponse = buildGroupedResult(h.getCore().getSchema(), sortedGroups, start, rows, group_offset, group_limit, includeNGroups);
- boolean truncateGroups = random.nextBoolean();
+ boolean truncateGroups = random().nextBoolean();
Map<String, Integer> facetCounts = new TreeMap<String, Integer>();
if (truncateGroups) {
for (Grp grp : sortedGroups) {
@@ -694,7 +694,7 @@ public class TestGroupingSearch extends
expectedFacetResponse.add(stringIntegerEntry.getValue());
}
- int randomPercentage = random.nextInt(101);
+ int randomPercentage = random().nextInt(101);
// TODO: create a random filter too
SolrQueryRequest req = req("group","true","wt","json","indent","true", "echoParams","all", "q","{!func}score_f", "group.field",groupField
,sortStr==null ? "nosort":"sort", sortStr ==null ? "": sortStr
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestJoin.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestJoin.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestJoin.java Sun Apr 15 14:41:44 2012
@@ -151,7 +151,7 @@ public class TestJoin extends SolrTestCa
while (--indexIter >= 0) {
- int indexSize = random.nextInt(20 * RANDOM_MULTIPLIER);
+ int indexSize = random().nextInt(20 * RANDOM_MULTIPLIER);
List<FldType> types = new ArrayList<FldType>();
types.add(new FldType("id",ONE_ONE, new SVal('A','Z',4,4)));
@@ -172,16 +172,16 @@ public class TestJoin extends SolrTestCa
for (int qiter=0; qiter<queryIter; qiter++) {
String fromField;
String toField;
- if (random.nextInt(100) < 5) {
+ if (random().nextInt(100) < 5) {
// pick random fields 5% of the time
- fromField = types.get(random.nextInt(types.size())).fname;
+ fromField = types.get(random().nextInt(types.size())).fname;
// pick the same field 50% of the time we pick a random field (since other fields won't match anything)
- toField = (random.nextInt(100) < 50) ? fromField : types.get(random.nextInt(types.size())).fname;
+ toField = (random().nextInt(100) < 50) ? fromField : types.get(random().nextInt(types.size())).fname;
} else {
// otherwise, pick compatible fields that have a chance of matching indexed tokens
- String[] group = compat[random.nextInt(compat.length)];
- fromField = group[random.nextInt(group.length)];
- toField = group[random.nextInt(group.length)];
+ String[] group = compat[random().nextInt(compat.length)];
+ fromField = group[random().nextInt(group.length)];
+ toField = group[random().nextInt(group.length)];
}
Map<Comparable, Set<Comparable>> pivot = pivots.get(fromField+"/"+toField);
@@ -210,7 +210,7 @@ public class TestJoin extends SolrTestCa
SolrQueryRequest req = req("wt","json","indent","true", "echoParams","all",
"q","{!join from="+fromField+" to="+toField
- + (random.nextInt(4)==0 ? " fromIndex=collection1" : "")
+ + (random().nextInt(4)==0 ? " fromIndex=collection1" : "")
+"}*:*"
);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/analysis/LegacyHTMLStripCharFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/analysis/LegacyHTMLStripCharFilterTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/analysis/LegacyHTMLStripCharFilterTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/analysis/LegacyHTMLStripCharFilterTest.java Sun Apr 15 14:41:44 2012
@@ -273,12 +273,12 @@ public class LegacyHTMLStripCharFilterTe
};
int numRounds = RANDOM_MULTIPLIER * 10000;
- checkRandomData(random, analyzer, numRounds);
+ checkRandomData(random(), analyzer, numRounds);
}
public void testRandomBrokenHTML() throws Exception {
int maxNumElements = 10000;
- String text = _TestUtil.randomHtmlishString(random, maxNumElements);
+ String text = _TestUtil.randomHtmlishString(random(), maxNumElements);
Reader reader
= new LegacyHTMLStripCharFilter(CharReader.get(new StringReader(text)));
while (reader.read() != -1);
@@ -290,11 +290,11 @@ public class LegacyHTMLStripCharFilterTe
int maxNumWords = 10000;
int minWordLength = 3;
int maxWordLength = 20;
- int numWords = _TestUtil.nextInt(random, minNumWords, maxNumWords);
- switch (_TestUtil.nextInt(random, 0, 4)) {
+ int numWords = _TestUtil.nextInt(random(), minNumWords, maxNumWords);
+ switch (_TestUtil.nextInt(random(), 0, 4)) {
case 0: {
for (int wordNum = 0 ; wordNum < numWords ; ++wordNum) {
- text.append(_TestUtil.randomUnicodeString(random, maxWordLength));
+ text.append(_TestUtil.randomUnicodeString(random(), maxWordLength));
text.append(' ');
}
break;
@@ -302,14 +302,14 @@ public class LegacyHTMLStripCharFilterTe
case 1: {
for (int wordNum = 0 ; wordNum < numWords ; ++wordNum) {
text.append(_TestUtil.randomRealisticUnicodeString
- (random, minWordLength, maxWordLength));
+ (random(), minWordLength, maxWordLength));
text.append(' ');
}
break;
}
default: { // ASCII 50% of the time
for (int wordNum = 0 ; wordNum < numWords ; ++wordNum) {
- text.append(_TestUtil.randomSimpleString(random));
+ text.append(_TestUtil.randomSimpleString(random()));
text.append(' ');
}
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Sun Apr 15 14:41:44 2012
@@ -56,7 +56,6 @@ import org.apache.solr.util.DefaultSolrT
/**
*
*/
-
public class BasicDistributedZkTest extends AbstractDistributedZkTestCase {
private static final String DEFAULT_COLLECTION = "collection1";
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Sun Apr 15 14:41:44 2012
@@ -42,15 +42,12 @@ import org.junit.Ignore;
@Ignore("ignore while investigating jenkins fails")
public class ChaosMonkeyNothingIsSafeTest extends FullSolrCloudTest {
-
@BeforeClass
public static void beforeSuperClass() throws Exception {
-
}
@AfterClass
public static void afterSuperClass() throws Exception {
-
}
@Before
@@ -237,7 +234,7 @@ public class ChaosMonkeyNothingIsSafeTes
while (true && !stop) {
++i;
- if (doDeletes && random.nextBoolean() && deletes.size() > 0) {
+ if (doDeletes && random().nextBoolean() && deletes.size() > 0) {
Integer delete = deletes.remove(0);
try {
numDeletes++;
@@ -271,7 +268,7 @@ public class ChaosMonkeyNothingIsSafeTes
fails.incrementAndGet();
}
- if (doDeletes && random.nextBoolean()) {
+ if (doDeletes && random().nextBoolean()) {
deletes.add(i);
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Sun Apr 15 14:41:44 2012
@@ -49,7 +49,6 @@ public class FullSolrCloudDistribCmdsTes
@BeforeClass
public static void beforeSuperClass() throws Exception {
-
}
public FullSolrCloudDistribCmdsTest() {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java Sun Apr 15 14:41:44 2012
@@ -185,7 +185,7 @@ public class FullSolrCloudTest extends A
chaosMonkey = new ChaosMonkey(zkServer, zkStateReader,
DEFAULT_COLLECTION, shardToJetty, shardToClient, shardToLeaderClient,
- shardToLeaderJetty, random);
+ shardToLeaderJetty, random());
}
// wait until shards have started registering...
@@ -1270,7 +1270,7 @@ public class FullSolrCloudTest extends A
while (true && !stop) {
++i;
- if (doDeletes && random.nextBoolean() && deletes.size() > 0) {
+ if (doDeletes && random().nextBoolean() && deletes.size() > 0) {
Integer delete = deletes.remove(0);
try {
numDeletes++;
@@ -1293,7 +1293,7 @@ public class FullSolrCloudTest extends A
fails.incrementAndGet();
}
- if (doDeletes && random.nextBoolean()) {
+ if (doDeletes && random().nextBoolean()) {
deletes.add(i);
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Sun Apr 15 14:41:44 2012
@@ -324,7 +324,7 @@ public class LeaderElectionTest extends
public void run() {
int count = atLeast(5);
for (int i = 1; i < count; i++) {
- int launchIn = random.nextInt(500);
+ int launchIn = random().nextInt(500);
ClientThread thread = null;
try {
thread = new ClientThread(i);
@@ -348,7 +348,7 @@ public class LeaderElectionTest extends
int j;
try {
// always 1 we won't kill...
- j = random.nextInt(threads.size() - 2);
+ j = random().nextInt(threads.size() - 2);
} catch(IllegalArgumentException e) {
continue;
}
@@ -378,7 +378,7 @@ public class LeaderElectionTest extends
try {
Thread.sleep(50);
int j;
- j = random.nextInt(threads.size());
+ j = random().nextInt(threads.size());
try {
threads.get(j).zkClient.getSolrZooKeeper().pauseCnxn(
ZkTestServer.TICK_TIME * 2);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Sun Apr 15 14:41:44 2012
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -259,9 +260,9 @@ public class OverseerTest extends SolrTe
String zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
- final int nodeCount = random.nextInt(50)+50; //how many simulated nodes (num of threads)
- final int coreCount = random.nextInt(100)+100; //how many cores to register
- final int sliceCount = random.nextInt(20)+1; //how many slices
+ final int nodeCount = random().nextInt(50)+50; //how many simulated nodes (num of threads)
+ final int coreCount = random().nextInt(100)+100; //how many cores to register
+ final int sliceCount = random().nextInt(20)+1; //how many slices
ZkTestServer server = new ZkTestServer(zkDir);
@@ -645,8 +646,9 @@ public class OverseerTest extends SolrTe
} catch (Throwable t) {
//t.printStackTrace();
}
+ Random rnd = random();
while (run) {
- if(random.nextInt(20)==1){
+ if(rnd.nextInt(20)==1){
try {
overseerClient.close();
overseerClient = electNewOverseer(zkAddress);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Sun Apr 15 14:41:44 2012
@@ -773,7 +773,7 @@ public class TestReplicationHandler exte
String configFile = "solrconfig-master1.xml";
boolean addNumberToKeepInRequest = true;
String backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM;
- if(random.nextBoolean()) {
+ if(random().nextBoolean()) {
configFile = "solrconfig-master1-keepOneBackup.xml";
addNumberToKeepInRequest = false;
backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_INIT_PARAM;
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java Sun Apr 15 14:41:44 2012
@@ -46,12 +46,13 @@ public class DistributedSpellCheckCompon
}
private String saveProp;
+
@Override
public void setUp() throws Exception {
// this test requires FSDir
saveProp = System.getProperty("solr.directoryFactory");
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
- requestHandlerName = random.nextBoolean() ? "spellCheckCompRH" : "spellCheckCompRH_Direct";
+ requestHandlerName = random().nextBoolean() ? "spellCheckCompRH" : "spellCheckCompRH_Direct";
super.setUp();
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java Sun Apr 15 14:41:44 2012
@@ -153,7 +153,7 @@ public class TermVectorComponentTest ext
StringBuilder expected = new StringBuilder("/termVectors/doc-0/test_posofftv/anoth=={");
boolean first = true;
for (int i = 0; i < options.length; i++) {
- final boolean use = random.nextBoolean();
+ final boolean use = random().nextBoolean();
if (use) {
if (!first) {
expected.append(", ");
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java Sun Apr 15 14:41:44 2012
@@ -42,7 +42,7 @@ public class SimpleFacetsTest extends So
static int random_dupe_percent = 25; // some duplicates in the index to create deleted docs
static void randomCommit(int percent_chance) {
- if (random.nextInt(100) <= percent_chance)
+ if (random().nextInt(100) <= percent_chance)
assertU(commit());
}
@@ -52,7 +52,7 @@ public class SimpleFacetsTest extends So
static void add_doc(String... fieldsAndValues) {
do {
pendingDocs.add(fieldsAndValues);
- } while (random.nextInt(100) <= random_dupe_percent);
+ } while (random().nextInt(100) <= random_dupe_percent);
// assertU(adoc(fieldsAndValues));
// randomCommit(random_commit_percent);
@@ -69,7 +69,7 @@ public class SimpleFacetsTest extends So
indexFacetPrefixSingleValued();
indexSimpleGroupedFacetCounts();
- Collections.shuffle(pendingDocs, random);
+ Collections.shuffle(pendingDocs, random());
for (String[] doc : pendingDocs) {
assertU(adoc(doc));
randomCommit(random_commit_percent);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java Sun Apr 15 14:41:44 2012
@@ -152,13 +152,13 @@ public class SpatialFilterTest extends S
int postFilterCount = DelegatingCollector.setLastDelegateCount;
// throw in a random into the main query to prevent most cache hits
- assertQ(req("fl", "id", "q","*:* OR foo_i:" + random.nextInt(100), "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName +"}",
+ assertQ(req("fl", "id", "q","*:* OR foo_i:" + random().nextInt(100), "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName +"}",
"pt", pt, "d", String.valueOf(distance)),
tests);
assertEquals(postFilterCount, DelegatingCollector.setLastDelegateCount); // post filtering shouldn't be used
// try uncached
- assertQ(req("fl", "id", "q","*:* OR foo_i:" + random.nextInt(100), "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName + " cache=false" + "}",
+ assertQ(req("fl", "id", "q","*:* OR foo_i:" + random().nextInt(100), "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName + " cache=false" + "}",
"pt", pt, "d", String.valueOf(distance)),
tests);
assertEquals(postFilterCount, DelegatingCollector.setLastDelegateCount); // post filtering shouldn't be used
@@ -166,7 +166,7 @@ public class SpatialFilterTest extends S
// try post filtered for fields that support it
if (fieldName.endsWith("ll")) {
- assertQ(req("fl", "id", "q","*:* OR foo_i:" + random.nextInt(100)+100, "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName + " cache=false cost=150" + "}",
+ assertQ(req("fl", "id", "q","*:* OR foo_i:" + random().nextInt(100)+100, "rows", "1000", "fq", "{!"+method+" sfield=" +fieldName + " cache=false cost=150" + "}",
"pt", pt, "d", String.valueOf(distance)),
tests);
assertEquals(postFilterCount + 1, DelegatingCollector.setLastDelegateCount); // post filtering *should* have been used
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestDocSet.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestDocSet.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestDocSet.java Sun Apr 15 14:41:44 2012
@@ -42,9 +42,15 @@ import org.apache.lucene.util.OpenBitSet
*
*/
public class TestDocSet extends LuceneTestCase {
- Random rand = random;
+ Random rand;
float loadfactor;
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ rand = random();
+ }
+
public OpenBitSet getRandomSet(int sz, int bitsToSet) {
OpenBitSet bs = new OpenBitSet(sz);
if (sz==0) return bs;