mirror of https://github.com/apache/lucene.git
LUCENE-3969: Minor cleanups and code consistency
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1311278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac393486e0
commit
214ab39f68
|
@ -289,7 +289,8 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
try {
|
try {
|
||||||
return new HunspellDictionary(affixStream, dictStream, TEST_VERSION_CURRENT);
|
return new HunspellDictionary(affixStream, dictStream, TEST_VERSION_CURRENT);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new RuntimeException(ex);
|
Rethrow.rethrow(ex);
|
||||||
|
return null; // unreachable code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -377,8 +378,9 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return b.build();
|
return b.build();
|
||||||
} catch (Exception e) {
|
} catch (Exception ex) {
|
||||||
throw new RuntimeException(e);
|
Rethrow.rethrow(ex);
|
||||||
|
return null; // unreachable code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,6 +412,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
allowedTokenFilterArgs = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
|
allowedTokenFilterArgs = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
|
||||||
allowedTokenFilterArgs.addAll(argProducers.keySet());
|
allowedTokenFilterArgs.addAll(argProducers.keySet());
|
||||||
allowedTokenFilterArgs.add(TokenStream.class);
|
allowedTokenFilterArgs.add(TokenStream.class);
|
||||||
|
// TODO: fix this one, thats broken:
|
||||||
allowedTokenFilterArgs.add(CommonGramsFilter.class);
|
allowedTokenFilterArgs.add(CommonGramsFilter.class);
|
||||||
|
|
||||||
allowedCharFilterArgs = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
|
allowedCharFilterArgs = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
|
||||||
|
@ -419,7 +422,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static <T> T createRandomArg(Random random, Class<T> paramType) {
|
static <T> T newRandomArg(Random random, Class<T> paramType) {
|
||||||
final ArgProducer producer = argProducers.get(paramType);
|
final ArgProducer producer = argProducers.get(paramType);
|
||||||
assertNotNull("No producer for arguments of type " + paramType.getName() + " found", producer);
|
assertNotNull("No producer for arguments of type " + paramType.getName() + " found", producer);
|
||||||
return (T) producer.create(random);
|
return (T) producer.create(random);
|
||||||
|
@ -435,9 +438,9 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
// TODO: maybe the collator one...???
|
// TODO: maybe the collator one...???
|
||||||
args[i] = AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY;
|
args[i] = AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY;
|
||||||
} else if (paramType == AttributeSource.class) {
|
} else if (paramType == AttributeSource.class) {
|
||||||
args[i] = null; // this always gives IAE: fine
|
args[i] = new AttributeSource();
|
||||||
} else {
|
} else {
|
||||||
args[i] = createRandomArg(random, paramType);
|
args[i] = newRandomArg(random, paramType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
|
@ -452,7 +455,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
} else if (paramType == CharStream.class) {
|
} else if (paramType == CharStream.class) {
|
||||||
args[i] = CharReader.get(reader);
|
args[i] = CharReader.get(reader);
|
||||||
} else {
|
} else {
|
||||||
args[i] = createRandomArg(random, paramType);
|
args[i] = newRandomArg(random, paramType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
|
@ -465,10 +468,10 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
|
||||||
if (paramType == TokenStream.class) {
|
if (paramType == TokenStream.class) {
|
||||||
args[i] = stream;
|
args[i] = stream;
|
||||||
} else if (paramType == CommonGramsFilter.class) {
|
} else if (paramType == CommonGramsFilter.class) {
|
||||||
// CommonGramsQueryFilter takes this one explicitly
|
// TODO: fix this one, thats broken: CommonGramsQueryFilter takes this one explicitly
|
||||||
args[i] = new CommonGramsFilter(TEST_VERSION_CURRENT, stream, createRandomArg(random, CharArraySet.class));
|
args[i] = new CommonGramsFilter(TEST_VERSION_CURRENT, stream, newRandomArg(random, CharArraySet.class));
|
||||||
} else {
|
} else {
|
||||||
args[i] = createRandomArg(random, paramType);
|
args[i] = newRandomArg(random, paramType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
|
|
Loading…
Reference in New Issue