You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/10/19 18:12:36 UTC

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.java

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/core/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.java 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.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java?rev=1024305&r1=1024304&r2=1024305&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestPropInjectDefaults.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();



Re: svn commit: r1024305 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java TestPropInjectDefaults.java

Posted by Grant Ingersoll <gs...@apache.org>.
+1.  Which reminds me, I need to commit that patch that makes the tests jar part of the release so that they can be used downstream by others that are building on Lucene/Solr


On Oct 19, 2010, at 1:09 PM, Mark Miller wrote:

> The work you guys have done with our base test classes is just
> fantastic. A ton of stuff that should have really gone into junit itself
> - I reuse it for other projects now.
> 
> - Mark
> 
> On 10/19/10 12:24 PM, Uwe Schindler wrote:
>> 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: uwe@thetaphi.de
>> 
>> 
>>> -----Original Message-----
>>> From: yonik@apache.org [mailto:yonik@apache.org]
>>> Sent: Tuesday, October 19, 2010 6:13 PM
>>> To: commits@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-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 

--------------------------
Grant Ingersoll
http://www.lucidimagination.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: svn commit: r1024305 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java TestPropInjectDefaults.java

Posted by Mark Miller <ma...@gmail.com>.
The work you guys have done with our base test classes is just
fantastic. A ton of stuff that should have really gone into junit itself
- I reuse it for other projects now.

- Mark

On 10/19/10 12:24 PM, Uwe Schindler wrote:
> 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: uwe@thetaphi.de
> 
> 
>> -----Original Message-----
>> From: yonik@apache.org [mailto:yonik@apache.org]
>> Sent: Tuesday, October 19, 2010 6:13 PM
>> To: commits@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-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: svn commit: r1024305 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java TestPropInjectDefaults.java

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Tue, Oct 19, 2010 at 12:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> 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"

Ah cool, thanks for the update!

-Yonik
http://www.lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: svn commit: r1024305 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java TestPropInjectDefaults.java

Posted by Robert Muir <rc...@gmail.com>.
On Tue, Oct 19, 2010 at 12:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> 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 :-)
>

Well, just for thoroughness you might have to slightly change some
Junit3 tests (for example, ones on very old patches).
In most cases the junit3-style tests will work just fine, but there
are two cases where you will get a compile error:

1. Tests that have constructors like this:

public TestToken(String name) {
  super(name);
}

in this case just delete these useless constructors

2. Tests that have setUp or tearDown as protected (not public!)

protected void setUp() throws Exception {
  ...
}

in this case, these must be changed to public, since setUp() is public
in LuceneTestCase (and must be for the @Before to work).

If this is confusing, see
https://issues.apache.org/jira/browse/LUCENE-2642 for some examples of
tests that were changed in this way.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: svn commit: r1024305 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/core: SolrCoreTest.java TestPropInjectDefaults.java

Posted by Uwe Schindler <uw...@thetaphi.de>.
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: uwe@thetaphi.de


> -----Original Message-----
> From: yonik@apache.org [mailto:yonik@apache.org]
> Sent: Tuesday, October 19, 2010 6:13 PM
> To: commits@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-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org