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 2012/04/16 04:56:44 UTC
svn commit: r1326468 - in
/lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core:
TestBugInSomething.java TestRandomChains.java
Author: rmuir
Date: Mon Apr 16 02:56:43 2012
New Revision: 1326468
URL: http://svn.apache.org/viewvc?rev=1326468&view=rev
Log:
LUCENE-3990: don't extend charfilter here, delegate all methods
Added:
lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java (with props)
Modified:
lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
Added: lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java?rev=1326468&view=auto
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java (added)
+++ lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java Mon Apr 16 02:56:43 2012
@@ -0,0 +1,64 @@
+package org.apache.lucene.analysis.core;
+
+import java.io.Reader;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.MockCharFilter;
+import org.apache.lucene.analysis.MockTokenFilter;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.charfilter.MappingCharFilter;
+import org.apache.lucene.analysis.charfilter.NormalizeCharMap;
+import org.apache.lucene.analysis.commongrams.CommonGramsFilter;
+import org.apache.lucene.analysis.util.CharArraySet;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class TestBugInSomething extends BaseTokenStreamTestCase {
+ public void test() throws Exception {
+ final CharArraySet cas = new CharArraySet(TEST_VERSION_CURRENT, 3, false);
+ cas.add("jjp");
+ cas.add("wlmwoknt");
+ cas.add("tcgyreo");
+
+ final NormalizeCharMap map = new NormalizeCharMap();
+ map.add("mtqlpi", "");
+ map.add("mwoknt", "jjp");
+ map.add("tcgyreo", "zpfpajyws");
+ map.add("", "eethksv");
+
+ Analyzer a = new Analyzer() {
+ @Override
+ protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
+ Tokenizer t = new MockTokenizer(new TestRandomChains.CheckThatYouDidntReadAnythingReaderWrapper(reader), MockTokenFilter.ENGLISH_STOPSET, false, -65);
+ TokenFilter f = new CommonGramsFilter(TEST_VERSION_CURRENT, t, cas);
+ return new TokenStreamComponents(t, f);
+ }
+
+ @Override
+ protected Reader initReader(Reader reader) {
+ reader = new MockCharFilter(reader, 0);
+ reader = new MappingCharFilter(map, reader);
+ return reader;
+ }
+ };
+ checkAnalysisConsistency(random(), a, false, "wmgddzunizdomqyj");
+ }
+}
Modified: lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java?rev=1326468&r1=1326467&r2=1326468&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java Mon Apr 16 02:56:43 2012
@@ -756,44 +756,77 @@ public class TestRandomChains extends Ba
}
}
- static final class CheckThatYouDidntReadAnythingReaderWrapper extends CharFilter {
- boolean readSomething = false;
+ // wants charfilter to be a filterreader...
+ // do *NOT* refactor me to be a charfilter: LUCENE-3990
+ static class CheckThatYouDidntReadAnythingReaderWrapper extends CharStream {
+ boolean readSomething;
+ CharStream in;
CheckThatYouDidntReadAnythingReaderWrapper(Reader in) {
- super(CharReader.get(in));
+ this.in = CharReader.get(in);
+ }
+
+ @Override
+ public int correctOffset(int currentOff) {
+ return in.correctOffset(currentOff);
+ }
+
+ @Override
+ public void close() throws IOException {
+ in.close();
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
readSomething = true;
- return super.read(cbuf, off, len);
+ return in.read(cbuf, off, len);
}
@Override
public int read() throws IOException {
readSomething = true;
- return super.read();
+ return in.read();
}
@Override
public int read(CharBuffer target) throws IOException {
readSomething = true;
- return super.read(target);
+ return in.read(target);
+ }
+
+ @Override
+ public void mark(int readAheadLimit) throws IOException {
+ in.mark(readAheadLimit);
+ }
+
+ @Override
+ public boolean markSupported() {
+ return in.markSupported();
}
@Override
public int read(char[] cbuf) throws IOException {
readSomething = true;
- return super.read(cbuf);
+ return in.read(cbuf);
+ }
+
+ @Override
+ public boolean ready() throws IOException {
+ return in.ready();
+ }
+
+ @Override
+ public void reset() throws IOException {
+ in.reset();
}
@Override
public long skip(long n) throws IOException {
readSomething = true;
- return super.skip(n);
+ return in.skip(n);
}
}
-
+
static class TokenizerSpec {
Tokenizer tokenizer;
String toString;