You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/05/02 14:32:55 UTC
svn commit: r1098541 - in /lucene/dev/branches/branch_3x/lucene/backwards:
./ src/test-framework/org/apache/lucene/util/
src/test/org/apache/lucene/collation/
Author: rmuir
Date: Mon May 2 12:32:53 2011
New Revision: 1098541
URL: http://svn.apache.org/viewvc?rev=1098541&view=rev
Log:
collation tests: try to find less jre bugs and just test thread safety
Modified:
lucene/dev/branches/branch_3x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java
lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/CollationTestBase.java
lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/TestCollationKeyAnalyzer.java
Modified: lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java?rev=1098541&r1=1098540&r2=1098541&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java Mon May 2 12:32:53 2011
@@ -176,6 +176,19 @@ public class _TestUtil {
return buf.toString();
}
+ public static String randomSimpleString(Random r) {
+ final int end = r.nextInt(10);
+ if (end == 0) {
+ // allow 0 length
+ return "";
+ }
+ final char[] buffer = new char[end];
+ for (int i = 0; i < end; i++) {
+ buffer[i] = (char) _TestUtil.nextInt(r, 97, 102);
+ }
+ return new String(buffer, 0, end);
+ }
+
/** Returns random string, including full unicode range. */
public static String randomUnicodeString(Random r) {
return randomUnicodeString(r, 20);
Modified: lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/CollationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/CollationTestBase.java?rev=1098541&r1=1098540&r2=1098541&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/CollationTestBase.java (original)
+++ lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/CollationTestBase.java Mon May 2 12:32:53 2011
@@ -265,27 +265,6 @@ public abstract class CollationTestBase
}
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;
@@ -297,7 +276,7 @@ public abstract class CollationTestBase
// 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));
CharTermAttribute encodedBytes = ts.addAttribute(CharTermAttribute.class);
ts.reset();
Modified: lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/TestCollationKeyAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/TestCollationKeyAnalyzer.java?rev=1098541&r1=1098540&r2=1098541&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/TestCollationKeyAnalyzer.java (original)
+++ lucene/dev/branches/branch_3x/lucene/backwards/src/test/org/apache/lucene/collation/TestCollationKeyAnalyzer.java Mon May 2 12:32:53 2011
@@ -83,8 +83,7 @@ public class TestCollationKeyAnalyzer ex
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(collator));
}