use junit plain formatter by default, log start + end of tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@819413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-09-27 21:39:03 +00:00
parent 250924d72e
commit 9989774d33
5 changed files with 67 additions and 15 deletions

View File

@ -400,7 +400,7 @@
<jvmarg line="${args}"/>
<formatter type="brief" usefile="false" if="junit.details"/>
<classpath refid="test.run.classpath"/>
<formatter type="xml"/>
<formatter type="${junit.formatter}"/>
<batchtest fork="yes" todir="${junit.output.dir}" if="runall">
<fileset dir="src/test" includes="${junit.includes}"/>
</batchtest>

View File

@ -102,6 +102,7 @@
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
<property name="junit.output.dir" location="${common.dir}/${dest}/test-results"/>
<property name="junit.reports" location="${common.dir}/${dest}/test-results/reports"/>
<property name="junit.formatter" value="plain"/>
<!-- Maven properties -->
<property name="maven.build.dir" value="${basedir}/build/maven"/>

View File

@ -28,6 +28,8 @@ import org.apache.solr.request.*;
import org.apache.solr.util.TestHarness;
import org.xml.sax.SAXException;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import junit.framework.TestCase;
import javax.xml.xpath.XPathExpressionException;
@ -95,26 +97,53 @@ public abstract class AbstractSolrTestCase extends TestCase {
* </ul>
*
*/
public static Logger log = LoggerFactory.getLogger(AbstractSolrTestCase.class);
public void setUp() throws Exception {
log.info("####SETUP_START " + getName());
dataDir = new File(System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator")
+ getClass().getName() + "-" + System.currentTimeMillis());
+ System.getProperty("file.separator")
+ getClass().getName() + "-" + System.currentTimeMillis());
dataDir.mkdirs();
solrConfig = h.createConfig(getSolrConfigFile());
h = new TestHarness( dataDir.getAbsolutePath(),
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
String configFile = getSolrConfigFile();
if (configFile != null) {
solrConfig = h.createConfig(getSolrConfigFile());
h = new TestHarness( dataDir.getAbsolutePath(),
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
}
log.info("####SETUP_END " + getName());
}
/** Subclasses that override setUp can optionally call this method
* to log the fact that their setUp process has ended.
*/
public void postSetUp() {
log.info("####POSTSETUP " + getName());
}
/** Subclasses that override tearDown can optionally call this method
* to log the fact that the tearDown process has started. This is necessary
* since subclasses will want to call super.tearDown() at the *end* of their
* tearDown method.
*/
public void preTearDown() {
log.info("####PRETEARDOWN " + getName());
}
/**
* Shuts down the test harness, and makes the best attempt possible
* to delete dataDir, unless the system property "solr.test.leavedatadir"
* is set.
*/
public void tearDown() throws Exception {
log.info("####TEARDOWN_START " + getName());
if (h != null) { h.close(); }
String skip = System.getProperty("solr.test.leavedatadir");
if (null != skip && 0 != skip.trim().length()) {

View File

@ -44,7 +44,15 @@ import junit.framework.TestCase;
* @version $Id$
* @since solr 1.3
*/
public class TestDistributedSearch extends TestCase {
public class TestDistributedSearch extends AbstractSolrTestCase {
public String getSchemaFile() {
return null;
}
public String getSolrConfigFile() {
return null;
}
static Random r = new Random(0);
File testDir;
@ -75,22 +83,24 @@ public class TestDistributedSearch extends TestCase {
String missingField="missing_but_valid_field_t";
String invalidField="invalid_field_not_in_schema";
@Override public void setUp() throws Exception
{
super.setUp();
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
testDir = new File(System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator")
+ getClass().getName() + "-" + System.currentTimeMillis());
testDir.mkdirs();
super.postSetUp();
}
@Override public void tearDown() throws Exception
{
super.preTearDown();
destroyServers();
AbstractSolrTestCase.recurseDelete(testDir);
super.tearDown();
}

View File

@ -40,7 +40,15 @@ import java.net.URL;
* @version $Id$
* @since 1.4
*/
public class TestReplicationHandler extends TestCase {
public class TestReplicationHandler extends AbstractSolrTestCase {
public String getSchemaFile() {
return null;
}
public String getSolrConfigFile() {
return null;
}
private static final String CONF_DIR = "." + File.separator + "solr" + File.separator + "conf" + File.separator;
private static final String SLAVE_CONFIG = CONF_DIR + "solrconfig-slave.xml";
@ -51,7 +59,9 @@ public class TestReplicationHandler extends TestCase {
String context = "/solr";
public void setUp() throws Exception {
super.setUp();
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@ -65,10 +75,12 @@ public class TestReplicationHandler extends TestCase {
@Override
public void tearDown() throws Exception {
super.preTearDown();
masterJetty.stop();
slaveJetty.stop();
master.tearDown();
slave.tearDown();
super.tearDown();
}
private JettySolrRunner createJetty(SolrInstance instance) throws Exception {