X-Git-Url: https://git.mdrn.pl/pylucene.git/blobdiff_plain/a2e61f0c04805cfcb8706176758d1283c7e3a55c..aaeed5504b982cf3545252ab528713250aa33eed:/lucene-java-3.4.0/lucene/contrib/demo/src/test/org/apache/lucene/demo/TestDemo.java?ds=sidebyside diff --git a/lucene-java-3.4.0/lucene/contrib/demo/src/test/org/apache/lucene/demo/TestDemo.java b/lucene-java-3.4.0/lucene/contrib/demo/src/test/org/apache/lucene/demo/TestDemo.java deleted file mode 100644 index d2bd59d..0000000 --- a/lucene-java-3.4.0/lucene/contrib/demo/src/test/org/apache/lucene/demo/TestDemo.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.lucene.demo; - -/** - * 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. - */ - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintStream; - -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util._TestUtil; - -public class TestDemo extends LuceneTestCase { - - private void testOneSearch(File indexPath, String query, int expectedHitCount) throws Exception { - PrintStream outSave = System.out; - try { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - PrintStream fakeSystemOut = new PrintStream(bytes); - System.setOut(fakeSystemOut); - SearchFiles.main(new String[] {"-query", query, "-index", indexPath.getPath()}); - fakeSystemOut.flush(); - String output = bytes.toString(); // intentionally use default encoding - assertTrue("output=" + output, output.contains(expectedHitCount + " total matching documents")); - } finally { - System.setOut(outSave); - } - } - - public void testIndexSearch() throws Exception { - File dir = getDataFile("test-files/docs"); - File indexDir = _TestUtil.getTempDir("ContribDemoTest"); - IndexFiles.main(new String[] { "-create", "-docs", dir.getPath(), "-index", indexDir.getPath()}); - testOneSearch(indexDir, "apache", 3); - testOneSearch(indexDir, "patent", 8); - testOneSearch(indexDir, "lucene", 0); - testOneSearch(indexDir, "gnu", 6); - testOneSearch(indexDir, "derivative", 8); - testOneSearch(indexDir, "license", 13); - } -}