tests: convert to junit4

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1024305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-10-19 16:12:36 +00:00
parent ed308e6630
commit 72e081de1a
2 changed files with 31 additions and 19 deletions

View File

@ -17,22 +17,33 @@
package org.apache.solr.core; package org.apache.solr.core;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.RequestHandlerBase; import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.component.SpellCheckComponent; import org.apache.solr.handler.component.SpellCheckComponent;
import org.apache.solr.handler.component.QueryComponent; import org.apache.solr.handler.component.QueryComponent;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.plugin.SolrCoreAware; import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.*; import java.util.*;
public class SolrCoreTest extends AbstractSolrTestCase { public class SolrCoreTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
initCore("solrconfig.xml", "schema.xml");
}
public String getSchemaFile() { return "schema.xml"; } @Override
public String getSolrConfigFile() { return "solrconfig.xml"; } public void tearDown() throws Exception {
deleteCore();
super.tearDown();
}
@Test
public void testRequestHandlerRegistry() { public void testRequestHandlerRegistry() {
SolrCore core = h.getCore(); SolrCore core = h.getCore();
@ -48,6 +59,7 @@ public class SolrCoreTest extends AbstractSolrTestCase {
assertEquals( core.getRequestHandlers().get( path ), handler2 ); assertEquals( core.getRequestHandlers().get( path ), handler2 );
} }
@Test
public void testClose() throws Exception { public void testClose() throws Exception {
final CoreContainer cores = h.getCoreContainer(); final CoreContainer cores = h.getCoreContainer();
SolrCore core = cores.getCore(""); SolrCore core = cores.getCore("");
@ -55,7 +67,7 @@ public class SolrCoreTest extends AbstractSolrTestCase {
ClosingRequestHandler handler1 = new ClosingRequestHandler(); ClosingRequestHandler handler1 = new ClosingRequestHandler();
handler1.inform( core ); handler1.inform( core );
String path = "/this/is A path /that won't be registered!"; String path = "/this/is A path /that won't be registered 2!!!!!!!!!!!";
SolrRequestHandler old = core.registerRequestHandler( path, handler1 ); SolrRequestHandler old = core.registerRequestHandler( path, handler1 );
assertNull( old ); // should not be anything... assertNull( old ); // should not be anything...
assertEquals( core.getRequestHandlers().get( path ), handler1 ); assertEquals( core.getRequestHandlers().get( path ), handler1 );
@ -64,6 +76,7 @@ public class SolrCoreTest extends AbstractSolrTestCase {
assertTrue("Handler not closed", handler1.closed == true); assertTrue("Handler not closed", handler1.closed == true);
} }
@Test
public void testRefCount() throws Exception { public void testRefCount() throws Exception {
SolrCore core = h.getCore(); SolrCore core = h.getCore();
assertTrue("Refcount != 1", core.getOpenCount() == 1); assertTrue("Refcount != 1", core.getOpenCount() == 1);
@ -100,6 +113,7 @@ public class SolrCoreTest extends AbstractSolrTestCase {
} }
@Test
public void testRefCountMT() throws Exception { public void testRefCountMT() throws Exception {
SolrCore core = h.getCore(); SolrCore core = h.getCore();
assertTrue("Refcount != 1", core.getOpenCount() == 1); assertTrue("Refcount != 1", core.getOpenCount() == 1);
@ -167,6 +181,7 @@ public class SolrCoreTest extends AbstractSolrTestCase {
assertTrue("Running for too long...", service.awaitTermination(60, TimeUnit.SECONDS)); assertTrue("Running for too long...", service.awaitTermination(60, TimeUnit.SECONDS));
} }
@Test
public void testInfoRegistry() throws Exception { public void testInfoRegistry() throws Exception {
//TEst that SolrInfoMBeans are registered, including SearchComponents //TEst that SolrInfoMBeans are registered, including SearchComponents
SolrCore core = h.getCore(); SolrCore core = h.getCore();

View File

@ -22,19 +22,15 @@ import java.io.IOException;
import org.apache.lucene.index.ConcurrentMergeScheduler; import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogByteSizeMergePolicy; import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.AbstractSolrTestCase; import org.junit.BeforeClass;
import org.junit.Test;
public class TestPropInjectDefaults extends AbstractSolrTestCase { public class TestPropInjectDefaults extends SolrTestCaseJ4 {
@BeforeClass
@Override public static void beforeClass() throws Exception {
public String getSchemaFile() { initCore("solrconfig-propinject-indexdefault.xml", "schema.xml");
return "schema.xml";
}
@Override
public String getSolrConfigFile() {
return "solrconfig-propinject-indexdefault.xml";
} }
class ExposeWriterHandler extends DirectUpdateHandler2 { class ExposeWriterHandler extends DirectUpdateHandler2 {
@ -47,7 +43,8 @@ public class TestPropInjectDefaults extends AbstractSolrTestCase {
return writer; return writer;
} }
} }
@Test
public void testMergePolicyDefaults() throws Exception { public void testMergePolicyDefaults() throws Exception {
ExposeWriterHandler uh = new ExposeWriterHandler(); ExposeWriterHandler uh = new ExposeWriterHandler();
IndexWriter writer = uh.getWriter(); IndexWriter writer = uh.getWriter();
@ -56,7 +53,7 @@ public class TestPropInjectDefaults extends AbstractSolrTestCase {
uh.close(); uh.close();
} }
@Test
public void testPropsDefaults() throws Exception { public void testPropsDefaults() throws Exception {
ExposeWriterHandler uh = new ExposeWriterHandler(); ExposeWriterHandler uh = new ExposeWriterHandler();
IndexWriter writer = uh.getWriter(); IndexWriter writer = uh.getWriter();