Apache Lucene open-source search software
add some javadocs to the test-framework analysis components
Robert Muirba7845ae74e4
diff --git a/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.java b/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.javaindex c5bb9f26448..382e2f42ce5 100644--- a/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.java+++ b/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.java@@ -30,7 +30,15 @@ import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;/**- * Base class for all Lucene unit tests that use TokenStreams.+ * Base class for all Lucene unit tests that use TokenStreams.+ * <p>+ * When writing unit tests for analysis components, its highly recommended+ * to use the helper methods here (especially in conjunction with {@link MockAnalyzer} or+ * {@link MockTokenizer}), as they contain many assertions and checks to+ * catch bugs.+ *+ * @see MockAnalyzer+ * @see MockTokenizer*/public abstract class BaseTokenStreamTestCase extends LuceneTestCase {// some helpers to test Analyzers and TokenStreams:diff --git a/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java b/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.javaindex 3818d071f99..b94e3846733 100644--- a/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java+++ b/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java@@ -27,6 +27,19 @@ import org.apache.lucene.util.automaton.CharacterRunAutomaton;/*** Analyzer for testing+ * <p>+ * This analyzer is a replacement for Whitespace/Simple/KeywordAnalyzers+ * for unit tests. If you are testing a custom component such as a queryparser+ * or analyzer-wrapper that consumes analysis streams, its a great idea to test+ * it with this analyzer instead. MockAnalyzer has the following behavior:+ * <ul>+ * <li>By default, the assertions in {@link MockTokenizer} are turned on for extra+ * checks that the consumer is consuming properly. These checks can be disabled+ * with {@link #setEnableChecks(boolean)}.+ * <li>Payload data is randomly injected into the stream for more thorough testing+ * of payloads.+ * </ul>+ * @see MockTokenizer*/public final class MockAnalyzer extends Analyzer {private final CharacterRunAutomaton runAutomaton;diff --git a/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java b/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.javaindex 5b9f7a016c8..fb4c0530ee1 100644--- a/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java+++ b/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java@@ -26,7 +26,16 @@ import org.apache.lucene.util.automaton.CharacterRunAutomaton;import org.apache.lucene.util.automaton.RegExp;/**- * Automaton-based tokenizer for testing. Optionally lowercases.+ * Tokenizer for testing.+ * <p>+ * This tokenizer is a replacement for {@link #WHITESPACE}, {@link #SIMPLE}, and {@link #KEYWORD}+ * tokenizers. If you are writing a component such as a TokenFilter, its a great idea to test+ * it wrapping this tokenizer instead for extra checks. This tokenizer has the following behavior:+ * <ul>+ * <li>An internal state-machine is used for checking consumer consistency. These checks can+ * be disabled with {@link #setEnableChecks(boolean)}.+ * <li>For convenience, optionally lowercases terms that it outputs.+ * </ul>*/public class MockTokenizer extends Tokenizer {/** Acts Similar to WhitespaceTokenizer */