From 72e081de1ae7ce7ead51f40745c05b8c4609988e Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Tue, 19 Oct 2010 16:12:36 +0000 Subject: [PATCH] tests: convert to junit4 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1024305 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/core/SolrCoreTest.java | 27 ++++++++++++++----- .../solr/core/TestPropInjectDefaults.java | 23 +++++++--------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/solr/src/test/org/apache/solr/core/SolrCoreTest.java b/solr/src/test/org/apache/solr/core/SolrCoreTest.java index 9c6a6099a9c..481d8c25be5 100755 --- a/solr/src/test/org/apache/solr/core/SolrCoreTest.java +++ b/solr/src/test/org/apache/solr/core/SolrCoreTest.java @@ -17,22 +17,33 @@ package org.apache.solr.core; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.handler.RequestHandlerBase; import org.apache.solr.handler.component.SpellCheckComponent; import org.apache.solr.handler.component.QueryComponent; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.response.SolrQueryResponse; -import org.apache.solr.util.AbstractSolrTestCase; import org.apache.solr.util.plugin.SolrCoreAware; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.concurrent.*; 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"; } - public String getSolrConfigFile() { return "solrconfig.xml"; } - + @Override + public void tearDown() throws Exception { + deleteCore(); + super.tearDown(); + } + + @Test public void testRequestHandlerRegistry() { SolrCore core = h.getCore(); @@ -48,6 +59,7 @@ public class SolrCoreTest extends AbstractSolrTestCase { assertEquals( core.getRequestHandlers().get( path ), handler2 ); } + @Test public void testClose() throws Exception { final CoreContainer cores = h.getCoreContainer(); SolrCore core = cores.getCore(""); @@ -55,7 +67,7 @@ public class SolrCoreTest extends AbstractSolrTestCase { ClosingRequestHandler handler1 = new ClosingRequestHandler(); 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 ); assertNull( old ); // should not be anything... assertEquals( core.getRequestHandlers().get( path ), handler1 ); @@ -64,6 +76,7 @@ public class SolrCoreTest extends AbstractSolrTestCase { assertTrue("Handler not closed", handler1.closed == true); } + @Test public void testRefCount() throws Exception { SolrCore core = h.getCore(); assertTrue("Refcount != 1", core.getOpenCount() == 1); @@ -100,6 +113,7 @@ public class SolrCoreTest extends AbstractSolrTestCase { } + @Test public void testRefCountMT() throws Exception { SolrCore core = h.getCore(); 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)); } + @Test public void testInfoRegistry() throws Exception { //TEst that SolrInfoMBeans are registered, including SearchComponents SolrCore core = h.getCore(); diff --git a/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java b/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java index ffebf5a3847..632ae1a325c 100644 --- a/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java +++ b/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java @@ -22,19 +22,15 @@ import java.io.IOException; import org.apache.lucene.index.ConcurrentMergeScheduler; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.LogByteSizeMergePolicy; +import org.apache.solr.SolrTestCaseJ4; 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 { - - @Override - public String getSchemaFile() { - return "schema.xml"; - } - - @Override - public String getSolrConfigFile() { - return "solrconfig-propinject-indexdefault.xml"; +public class TestPropInjectDefaults extends SolrTestCaseJ4 { + @BeforeClass + public static void beforeClass() throws Exception { + initCore("solrconfig-propinject-indexdefault.xml", "schema.xml"); } class ExposeWriterHandler extends DirectUpdateHandler2 { @@ -47,7 +43,8 @@ public class TestPropInjectDefaults extends AbstractSolrTestCase { return writer; } } - + + @Test public void testMergePolicyDefaults() throws Exception { ExposeWriterHandler uh = new ExposeWriterHandler(); IndexWriter writer = uh.getWriter(); @@ -56,7 +53,7 @@ public class TestPropInjectDefaults extends AbstractSolrTestCase { uh.close(); } - + @Test public void testPropsDefaults() throws Exception { ExposeWriterHandler uh = new ExposeWriterHandler(); IndexWriter writer = uh.getWriter();