From ac7576a81c41387a86e8977b354b5931f3b03b4e Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Wed, 10 Nov 2004 13:59:23 +0000 Subject: [PATCH] small refactoring git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150637 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/TestMultiPhraseQuery.java | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java b/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java index a2339818129..5b380f4efa3 100644 --- a/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java +++ b/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java @@ -37,40 +37,23 @@ import java.util.LinkedList; * @author Otis Gospodnetic, Daniel Naber * @version $Id$ */ -public class TestMultiPhraseQuery - extends TestCase +public class TestMultiPhraseQuery extends TestCase { public TestMultiPhraseQuery(String name) { super(name); } - /** - * - */ - public void testPhrasePrefix() - throws IOException + public void testPhrasePrefix() throws IOException { RAMDirectory indexStore = new RAMDirectory(); IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true); - Document doc1 = new Document(); - Document doc2 = new Document(); - Document doc3 = new Document(); - Document doc4 = new Document(); - Document doc5 = new Document(); - Document doc6 = new Document(); - doc1.add(new Field("body", "blueberry pie", Field.Store.YES, Field.Index.TOKENIZED)); - doc2.add(new Field("body", "blueberry strudel", Field.Store.YES, Field.Index.TOKENIZED)); - doc3.add(new Field("body", "blueberry pizza", Field.Store.YES, Field.Index.TOKENIZED)); - doc4.add(new Field("body", "blueberry chewing gum", Field.Store.YES, Field.Index.TOKENIZED)); - doc5.add(new Field("body", "bluebird pizza", Field.Store.YES, Field.Index.TOKENIZED)); - doc6.add(new Field("body", "piccadilly circus", Field.Store.YES, Field.Index.TOKENIZED)); - writer.addDocument(doc1); - writer.addDocument(doc2); - writer.addDocument(doc3); - writer.addDocument(doc4); - writer.addDocument(doc5); - writer.addDocument(doc6); + add("blueberry pie", writer); + add("blueberry strudel", writer); + add("blueberry pizza", writer); + add("blueberry chewing gum", writer); + add("bluebird pizza", writer); + add("piccadilly circus", writer); writer.optimize(); writer.close(); @@ -135,4 +118,11 @@ public class TestMultiPhraseQuery } } + + private void add(String s, IndexWriter writer) throws IOException + { + Document doc = new Document(); + doc.add(new Field("body", s, Field.Store.YES, Field.Index.TOKENIZED)); + writer.addDocument(doc); + } }