TokenStream stream = factory.create(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false));
assertTokenStreamContents(stream, new String[] { "aaa", "BBB" }, new int[] { 3, 2 });
// Now force case
stream = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
stream = new KeepWordFilter(true, stream, new CharArraySet(TEST_VERSION_CURRENT,words, false));
assertTokenStreamContents(stream, new String[] { "aaa" }, new int[] { 3 });
// Test Stopwords (ignoreCase via the setter instead)
factory = new KeepWordFilterFactory();
args = new HashMap<String, String>(DEFAULT_VERSION_PARAM);
factory.init( args );
factory.inform( loader );
factory.setIgnoreCase(true);
factory.setWords( words );
assertTrue(factory.isIgnoreCase());
assertFalse(factory.isEnablePositionIncrements());
stream = factory.create(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false));
assertTokenStreamContents(stream, new String[] { "aaa", "BBB" }, new int[] { 1, 1 });
// Now force case and posIncr
factory = new KeepWordFilterFactory();
args = new HashMap<String, String>(DEFAULT_VERSION_PARAM);
args.put( "ignoreCase", "false" );
args.put( "enablePositionIncrements", "true" );
factory.init( args );
factory.inform( loader );
factory.setWords( words );
assertFalse(factory.isIgnoreCase());
assertTrue(factory.isEnablePositionIncrements());
stream = factory.create(new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false));
assertTokenStreamContents(stream, new String[] { "aaa" }, new int[] { 3 });
// Now force case
stream = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
stream = new KeepWordFilter(false, stream, new CharArraySet(TEST_VERSION_CURRENT,words, false));
assertTokenStreamContents(stream, new String[] { "aaa" }, new int[] { 1 });
}