Kill IndexReaderFactoryTest: the only thing it asserts is a lie. Move that (fixed) assertion to AlternateDirectoryTest where it's already true.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1511142 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2013-08-06 22:52:08 +00:00
parent a4d0cd434f
commit 1cd55ea231
2 changed files with 12 additions and 41 deletions

View File

@ -25,21 +25,29 @@ import org.apache.solr.SolrTestCaseJ4;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* test that configs can override the DirectoryFactory and
* IndexReaderFactory used in solr.
*/
public class AlternateDirectoryTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-altdirectory.xml", "schema.xml");
}
/**
* Simple test to ensure that alternate IndexReaderFactory is being used.
*/
@Test
public void testAltDirectoryUsed() throws Exception {
assertQ(req("q","*:*","qt","standard"));
assertTrue(TestFSDirectoryFactory.openCalled);
assertTrue(TestIndexReaderFactory.newReaderCalled);
}
public void testAltReaderUsed() throws Exception {
IndexReaderFactory readerFactory = h.getCore().getIndexReaderFactory();
assertNotNull("Factory is null", readerFactory);
assertEquals("readerFactory is wrong class",
AlternateDirectoryTest.TestIndexReaderFactory.class.getName(),
readerFactory.getClass().getName());
}
static public class TestFSDirectoryFactory extends StandardDirectoryFactory {
public static volatile boolean openCalled = false;

View File

@ -1,37 +0,0 @@
package org.apache.solr.core;
/*
* 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 org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
public class IndexReaderFactoryTest extends AbstractSolrTestCase {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-termindex.xml", "schema.xml");
}
/**
* Simple test to ensure that alternate IndexReaderFactory is being used.
*/
public void testAltReaderUsed() throws Exception {
IndexReaderFactory readerFactory = h.getCore().getIndexReaderFactory();
assertNotNull("Factory is null", readerFactory);
assertTrue("readerFactory is not an instanceof " + AlternateDirectoryTest.TestIndexReaderFactory.class, readerFactory instanceof StandardIndexReaderFactory);
}
}