mirror of https://github.com/apache/lucene.git
collation tests: try to find less jre bugs and just test thread safety
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1098532 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0b5ba4404c
commit
a75e5282c7
|
@ -257,27 +257,6 @@ public abstract class CollationTestBase extends LuceneTestCase {
|
|||
}
|
||||
assertEquals(expectedResult, buff.toString());
|
||||
}
|
||||
|
||||
private String randomString() {
|
||||
// ideally we could do this!
|
||||
// return _TestUtil.randomUnicodeString(random);
|
||||
//
|
||||
// http://bugs.icu-project.org/trac/ticket/8060
|
||||
// http://bugs.icu-project.org/trac/ticket/7732
|
||||
// ...
|
||||
//
|
||||
// as a workaround, just test the BMP for now (and avoid 0xFFFF etc)
|
||||
int length = _TestUtil.nextInt(random, 0, 10);
|
||||
char chars[] = new char[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (random.nextBoolean()) {
|
||||
chars[i] = (char) _TestUtil.nextInt(random, 0, 0xD7FF);
|
||||
} else {
|
||||
chars[i] = (char) _TestUtil.nextInt(random, 0xE000, 0xFFFD);
|
||||
}
|
||||
}
|
||||
return new String(chars, 0, length);
|
||||
}
|
||||
|
||||
public void assertThreadSafe(final Analyzer analyzer) throws Exception {
|
||||
int numTestPoints = 100;
|
||||
|
@ -289,7 +268,7 @@ public abstract class CollationTestBase extends LuceneTestCase {
|
|||
// and ensure they are the same as the ones we produced in serial fashion.
|
||||
|
||||
for (int i = 0; i < numTestPoints; i++) {
|
||||
String term = randomString();
|
||||
String term = _TestUtil.randomSimpleString(random);
|
||||
TokenStream ts = analyzer.reusableTokenStream("fake", new StringReader(term));
|
||||
TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);
|
||||
BytesRef bytes = termAtt.getBytesRef();
|
||||
|
|
|
@ -87,8 +87,7 @@ public class TestCollationKeyAnalyzer extends CollationTestBase {
|
|||
public void testThreadSafe() throws Exception {
|
||||
int iters = 20 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < iters; i++) {
|
||||
Locale locale = randomLocale(random);
|
||||
Collator collator = Collator.getInstance(locale);
|
||||
Collator collator = Collator.getInstance(Locale.GERMAN);
|
||||
collator.setStrength(Collator.PRIMARY);
|
||||
assertThreadSafe(new CollationKeyAnalyzer(TEST_VERSION_CURRENT, collator));
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.lucene.collation;
|
|||
|
||||
|
||||
import com.ibm.icu.text.Collator;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.index.codecs.CodecProvider;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -88,7 +89,7 @@ public class TestICUCollationKeyAnalyzer extends CollationTestBase {
|
|||
public void testThreadSafe() throws Exception {
|
||||
int iters = 20 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < iters; i++) {
|
||||
Locale locale = randomLocale(random);
|
||||
Locale locale = Locale.GERMAN;
|
||||
Collator collator = Collator.getInstance(locale);
|
||||
collator.setStrength(Collator.IDENTICAL);
|
||||
assertThreadSafe(new ICUCollationKeyAnalyzer(TEST_VERSION_CURRENT, collator));
|
||||
|
|
Loading…
Reference in New Issue