Yonik, Just to reduce the work you have to do: With a subclass of LuceneTestCase, you don't need to add @Test, as the internal test runner behaves like JUnit3 and runs all public methods starting with "test" (in addition to @Test annotated,m which is still supported and used). We did this, as a lot of tests were forgotten to be upgraded correctly. Now Lucene runs on JUnit4 API (with static @BeforeClass and all nice stuff, @Ignore, assume*,...), but no test had to be changed :-) Also LuceneTestCase extends Assert, so no static imports :-)
----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: yo...@apache.org [mailto:yo...@apache.org] > Sent: Tuesday, October 19, 2010 6:13 PM > To: comm...@lucene.apache.org > Subject: svn commit: r1024305 - in > /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java > TestPropInjectDefaults.java > > Author: yonik > Date: Tue Oct 19 16:12:36 2010 > New Revision: 1024305 > > URL: http://svn.apache.org/viewvc?rev=1024305&view=rev > Log: > tests: convert to junit4 > > Modified: > lucene/dev/trunk/solr/src/test/org/apache/solr/core/SolrCoreTest.java > > lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.jav > a > > Modified: > lucene/dev/trunk/solr/src/test/org/apache/solr/core/SolrCoreTest.java > URL: > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/c > ore/SolrCoreTest.java?rev=1024305&r1=1024304&r2=1024305&view=diff > ================================================================ > ============== > --- lucene/dev/trunk/solr/src/test/org/apache/solr/core/SolrCoreTest.java > (original) > +++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/SolrCoreTest.jav > +++ a Tue Oct 19 16:12:36 2010 > @@ -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 Abstra > 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 Abstra > 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 Abstra > 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 Abstra > } > > > + @Test > public void testRefCountMT() throws Exception { > SolrCore core = h.getCore(); > assertTrue("Refcount != 1", core.getOpenCount() == 1); @@ -167,6 +181,7 > @@ public class SolrCoreTest extends Abstra > 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(); > > Modified: > lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.jav > a > URL: > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/c > ore/TestPropInjectDefaults.java?rev=1024305&r1=1024304&r2=1024305&view > =diff > ================================================================ > ============== > --- > lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.jav > a (original) > +++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDe > +++ faults.java Tue Oct 19 16:12:36 2010 > @@ -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 exte > return writer; > } > } > - > + > + @Test > public void testMergePolicyDefaults() throws Exception { > ExposeWriterHandler uh = new ExposeWriterHandler(); > IndexWriter writer = uh.getWriter(); @@ -56,7 +53,7 @@ public class > TestPropInjectDefaults exte > uh.close(); > } > > - > + @Test > public void testPropsDefaults() throws Exception { > ExposeWriterHandler uh = new ExposeWriterHandler(); > IndexWriter writer = uh.getWriter(); > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org