mirror of https://github.com/apache/lucene.git
move test to same place as 4.x branch for easier backporting
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1366110 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bcfb01d690
commit
3d1279c06c
|
@ -1,3 +1,5 @@
|
|||
package org.apache.lucene.analysis.synonym;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -15,20 +17,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
|
||||
import org.apache.lucene.analysis.MockTokenizer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.synonym.SynonymFilterFactory;
|
||||
import org.apache.lucene.analysis.util.ResourceLoader;
|
||||
import org.apache.lucene.analysis.util.StringMockResourceLoader;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -42,25 +39,9 @@ public class TestMultiWordSynonyms extends BaseTokenStreamTestCase {
|
|||
args.put("synonyms", "synonyms.txt");
|
||||
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
|
||||
factory.init(args);
|
||||
factory.inform(new StringMockSolrResourceLoader("a b c,d"));
|
||||
factory.inform(new StringMockResourceLoader("a b c,d"));
|
||||
TokenStream ts = factory.create(new MockTokenizer(new StringReader("a e"), MockTokenizer.WHITESPACE, false));
|
||||
// This fails because ["e","e"] is the value of the token stream
|
||||
assertTokenStreamContents(ts, new String[] { "a", "e" });
|
||||
}
|
||||
|
||||
private class StringMockSolrResourceLoader implements ResourceLoader {
|
||||
String text;
|
||||
|
||||
StringMockSolrResourceLoader(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputStream openResource(String resource) throws IOException {
|
||||
return new ByteArrayInputStream(text.getBytes("UTF-8"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue