diff --git a/solr/contrib/dataimporthandler/build.xml b/solr/contrib/dataimporthandler/build.xml index 9f295ab993e..8c18c01ec5f 100644 --- a/solr/contrib/dataimporthandler/build.xml +++ b/solr/contrib/dataimporthandler/build.xml @@ -55,6 +55,8 @@ + + @@ -65,6 +67,8 @@ + + diff --git a/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java b/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java index 5a5220e3761..cc3c806f510 100644 --- a/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java @@ -17,6 +17,8 @@ package org.apache.solr.handler.dataimport; import junit.framework.Assert; + +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrInputDocument; import org.junit.Ignore; import org.junit.Test; @@ -45,7 +47,7 @@ import java.util.Map; * @see org.apache.solr.handler.dataimport.MailEntityProcessor * @since solr 1.4 */ -public class TestMailEntityProcessor { +public class TestMailEntityProcessor extends SolrTestCaseJ4 { // Credentials private static final String user = "user"; diff --git a/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java b/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java index d2adc5a2ee8..863329039b6 100644 --- a/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java @@ -23,7 +23,7 @@ import org.junit.Before; * @version $Id$ * @since solr 1.5 */ -public class TestTikaEntityProcessor extends AbstractDataImportHandlerTest { +public class TestTikaEntityProcessor extends AbstractDataImportHandlerTestCase { @Before public void setUp() throws Exception { diff --git a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTestCase.java similarity index 99% rename from solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java rename to solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTestCase.java index 2572a10427f..a814e02d10e 100644 --- a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTestCase.java @@ -37,7 +37,7 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public abstract class AbstractDataImportHandlerTest extends +public abstract class AbstractDataImportHandlerTestCase extends AbstractSolrTestCase { @Override diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java index 391eb6f8a7e..718385495f5 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestCachedSqlEntityProcessor.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -32,24 +33,24 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestCachedSqlEntityProcessor { +public class TestCachedSqlEntityProcessor extends SolrTestCaseJ4 { @Test public void withoutWhereClause() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "id")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "desc")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "id")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "desc")); String q = "select * from x where id=${x.id}"; - Map entityAttrs = AbstractDataImportHandlerTest.createMap( + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap( "query", q); MockDataSource ds = new MockDataSource(); VariableResolverImpl vr = new VariableResolverImpl(); - vr.addNamespace("x", AbstractDataImportHandlerTest.createMap("id", 1)); - Context context = AbstractDataImportHandlerTest.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); + vr.addNamespace("x", AbstractDataImportHandlerTestCase.createMap("id", 1)); + Context context = AbstractDataImportHandlerTestCase.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); List> rows = new ArrayList>(); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", "one")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "one")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "another one")); MockDataSource.setIterator(vr.replaceTokens(q), rows.iterator()); EntityProcessor csep = new EntityProcessorWrapper( new CachedSqlEntityProcessor(), null); @@ -79,19 +80,19 @@ public class TestCachedSqlEntityProcessor { @Test public void withoutWhereClauseWithTransformers() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "id")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "desc")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "id")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "desc")); String q = "select * from x where id=${x.id}"; - Map entityAttrs = AbstractDataImportHandlerTest.createMap( + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap( "query", q, "transformer", UppercaseTransformer.class.getName()); MockDataSource ds = new MockDataSource(); VariableResolverImpl vr = new VariableResolverImpl(); - vr.addNamespace("x", AbstractDataImportHandlerTest.createMap("id", 1)); - Context context = AbstractDataImportHandlerTest.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); + vr.addNamespace("x", AbstractDataImportHandlerTestCase.createMap("id", 1)); + Context context = AbstractDataImportHandlerTestCase.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); List> rows = new ArrayList>(); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", "one")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "one")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "another one")); MockDataSource.setIterator(vr.replaceTokens(q), rows.iterator()); EntityProcessor csep = new EntityProcessorWrapper( new CachedSqlEntityProcessor(), null); @@ -122,19 +123,19 @@ public class TestCachedSqlEntityProcessor { @Test public void withoutWhereClauseWithMultiRowTransformer() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "id")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "desc")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "id")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "desc")); String q = "select * from x where id=${x.id}"; - Map entityAttrs = AbstractDataImportHandlerTest.createMap( + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap( "query", q, "transformer", DoubleTransformer.class.getName()); MockDataSource ds = new MockDataSource(); VariableResolverImpl vr = new VariableResolverImpl(); - vr.addNamespace("x", AbstractDataImportHandlerTest.createMap("id", 1)); - Context context = AbstractDataImportHandlerTest.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); + vr.addNamespace("x", AbstractDataImportHandlerTestCase.createMap("id", 1)); + Context context = AbstractDataImportHandlerTestCase.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); List> rows = new ArrayList>(); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", "one")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "one")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "another one")); MockDataSource.setIterator(vr.replaceTokens(q), rows.iterator()); EntityProcessor csep = new EntityProcessorWrapper( new CachedSqlEntityProcessor(), null); @@ -189,43 +190,43 @@ public class TestCachedSqlEntityProcessor { @Test public void withWhereClause() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "id")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "desc")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "id")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "desc")); String q = "select * from x"; - Map entityAttrs = AbstractDataImportHandlerTest.createMap( + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap( "query", q, EntityProcessorBase.CACHE_KEY,"id", EntityProcessorBase.CACHE_LOOKUP ,"x.id"); MockDataSource ds = new MockDataSource(); VariableResolverImpl vr = new VariableResolverImpl(); - Map xNamespace = AbstractDataImportHandlerTest.createMap("id", 0); + Map xNamespace = AbstractDataImportHandlerTestCase.createMap("id", 0); vr.addNamespace("x", xNamespace); - Context context = AbstractDataImportHandlerTest.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); + Context context = AbstractDataImportHandlerTestCase.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); doWhereTest(q, context, ds, xNamespace); } @Test public void withKeyAndLookup() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "id")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "desc")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "id")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "desc")); String q = "select * from x"; - Map entityAttrs = AbstractDataImportHandlerTest.createMap("query", q, "where", "id=x.id"); + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap("query", q, "where", "id=x.id"); MockDataSource ds = new MockDataSource(); VariableResolverImpl vr = new VariableResolverImpl(); - Map xNamespace = AbstractDataImportHandlerTest.createMap("id", 0); + Map xNamespace = AbstractDataImportHandlerTestCase.createMap("id", 0); vr.addNamespace("x", xNamespace); - Context context = AbstractDataImportHandlerTest.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); + Context context = AbstractDataImportHandlerTestCase.getContext(null, vr, ds, Context.FULL_DUMP, fields, entityAttrs); doWhereTest(q, context, ds, xNamespace); } private void doWhereTest(String q, Context context, MockDataSource ds, Map xNamespace) { List> rows = new ArrayList>(); - rows.add(AbstractDataImportHandlerTest.createMap("id", 1, "desc", "one")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 2, "desc", "two")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 2, "desc", + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 1, "desc", "one")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 2, "desc", "two")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 2, "desc", "another two")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 3, "desc", "three")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 3, "desc", "another three")); - rows.add(AbstractDataImportHandlerTest.createMap("id", 3, "desc", "another another three")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 3, "desc", "three")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 3, "desc", "another three")); + rows.add(AbstractDataImportHandlerTestCase.createMap("id", 3, "desc", "another another three")); MockDataSource.setIterator(q, rows.iterator()); EntityProcessor csep = new EntityProcessorWrapper(new CachedSqlEntityProcessor(), null); csep.init(context); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestClobTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestClobTransformer.java index a3820926646..40c278b4403 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestClobTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestClobTransformer.java @@ -17,6 +17,8 @@ package org.apache.solr.handler.dataimport; import junit.framework.Assert; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Test; import java.io.StringReader; @@ -33,7 +35,7 @@ import java.util.*; * @see org.apache.solr.handler.dataimport.ClobTransformer * @since solr 1.4 */ -public class TestClobTransformer { +public class TestClobTransformer extends SolrTestCaseJ4 { @Test public void simple() throws Exception { List> flds = new ArrayList>(); @@ -43,7 +45,7 @@ public class TestClobTransformer { f.put(ClobTransformer.CLOB, "true"); f.put(DataImporter.NAME, "description"); flds.add(f); - Context ctx = AbstractDataImportHandlerTest.getContext(null, new VariableResolverImpl(), null, Context.FULL_DUMP, flds, Collections.EMPTY_MAP); + Context ctx = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), null, Context.FULL_DUMP, flds, Collections.EMPTY_MAP); Transformer t = new ClobTransformer(); Map row = new HashMap(); Clob clob = (Clob) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Clob.class}, new InvocationHandler() { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDataConfig.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDataConfig.java index f69c8096297..d61e683abc0 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDataConfig.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDataConfig.java @@ -33,7 +33,7 @@ import java.util.List; * @version $Id$ * @since solr 1.3 */ -public class TestDataConfig extends AbstractDataImportHandlerTest { +public class TestDataConfig extends AbstractDataImportHandlerTestCase { @Override public void setUp() throws Exception { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDateFormatTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDateFormatTransformer.java index 7ebd2efd343..783d7e75038 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDateFormatTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDateFormatTransformer.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -30,28 +31,28 @@ import java.util.*; * @version $Id$ * @since solr 1.3 */ -public class TestDateFormatTransformer { +public class TestDateFormatTransformer extends SolrTestCaseJ4 { @Test @SuppressWarnings("unchecked") public void testTransformRow_SingleRow() throws Exception { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "lastModified")); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "dateAdded", RegexTransformer.SRC_COL_NAME, "lastModified", DateFormatTransformer.DATE_TIME_FMT, "MM/dd/yyyy")); SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); Date now = format.parse(format.format(new Date())); - Map row = AbstractDataImportHandlerTest.createMap("lastModified", format + Map row = AbstractDataImportHandlerTestCase.createMap("lastModified", format .format(now)); VariableResolverImpl resolver = new VariableResolverImpl(); resolver.addNamespace("e", row); - Context context = AbstractDataImportHandlerTest.getContext(null, resolver, + Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, null); new DateFormatTransformer().transformRow(row, context); Assert.assertEquals(now, row.get("dateAdded")); @@ -61,9 +62,9 @@ public class TestDateFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_MultipleRows() throws Exception { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "lastModified")); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "dateAdded", RegexTransformer.SRC_COL_NAME, "lastModified", DateFormatTransformer.DATE_TIME_FMT, "MM/dd/yyyy hh:mm:ss.SSS")); @@ -80,7 +81,7 @@ public class TestDateFormatTransformer { VariableResolverImpl resolver = new VariableResolverImpl(); resolver.addNamespace("e", row); - Context context = AbstractDataImportHandlerTest.getContext(null, resolver, + Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, null); new DateFormatTransformer().transformRow(row, context); List output = new ArrayList(); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java index a4809fbcc7f..e02252d686c 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java @@ -16,8 +16,9 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrInputDocument; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.createMap; import org.junit.Assert; import org.junit.Test; @@ -31,7 +32,7 @@ import java.util.*; * @version $Id$ * @since solr 1.3 */ -public class TestDocBuilder { +public class TestDocBuilder extends SolrTestCaseJ4 { @Test public void loadClass() throws Exception { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java index f769dfb0a42..f86935cedd2 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java @@ -36,7 +36,7 @@ import java.io.File; * @version $Id$ * @since solr 1.3 */ -public class TestDocBuilder2 extends AbstractDataImportHandlerTest { +public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase { @Before public void setUp() throws Exception { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEntityProcessorBase.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEntityProcessorBase.java index 811979d2eca..ace217608a6 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEntityProcessorBase.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEntityProcessorBase.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -32,7 +33,7 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestEntityProcessorBase { +public class TestEntityProcessorBase extends SolrTestCaseJ4 { @Test public void multiTransformer() { @@ -43,7 +44,7 @@ public class TestEntityProcessorBase { fields.add(TestRegexTransformer.getField("A", null, null, null, null)); fields.add(TestRegexTransformer.getField("B", null, null, null, null)); - Context context = AbstractDataImportHandlerTest.getContext(null, null, new MockDataSource(), Context.FULL_DUMP, + Context context = AbstractDataImportHandlerTestCase.getContext(null, null, new MockDataSource(), Context.FULL_DUMP, fields, entity); Map src = new HashMap(); src.put("A", "NA"); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java index 111ae297920..616968be6df 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java @@ -29,7 +29,7 @@ import java.util.Properties; * @version $Id$ * @since solr 1.4 */ -public class TestErrorHandling extends AbstractDataImportHandlerTest { +public class TestErrorHandling extends AbstractDataImportHandlerTestCase { public void testMalformedStreamingXml() throws Exception { StringDataSource.xml = malformedXml; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java index 2da63bba81a..f14fb23fab7 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java @@ -17,8 +17,9 @@ package org.apache.solr.handler.dataimport; import static org.junit.Assert.assertEquals; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.net.URLEncoder; @@ -33,7 +34,7 @@ import junit.framework.Assert; * @version $Id$ * @since solr 1.3 */ -public class TestEvaluatorBag { +public class TestEvaluatorBag extends SolrTestCaseJ4 { private static final String ENCODING = "UTF-8"; VariableResolverImpl resolver; @@ -44,6 +45,7 @@ public class TestEvaluatorBag { @Before public void setUp() throws Exception { + super.setUp(); resolver = new VariableResolverImpl(); sqlTests = new HashMap(); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFieldReader.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFieldReader.java index ac92190c435..4748e68712f 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFieldReader.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFieldReader.java @@ -17,11 +17,12 @@ package org.apache.solr.handler.dataimport; import junit.framework.Assert; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.createMap; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Test; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,7 +33,7 @@ import java.util.Map; * @see org.apache.solr.handler.dataimport.FieldReaderDataSource * @since 1.4 */ -public class TestFieldReader { +public class TestFieldReader extends SolrTestCaseJ4 { @Test public void simple() { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFileListEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFileListEntityProcessor.java index d2bcd607af0..fa4a3585dc2 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFileListEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestFileListEntityProcessor.java @@ -16,6 +16,7 @@ package org.apache.solr.handler.dataimport; * limitations under the License. */ +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -32,7 +33,7 @@ import java.util.*; * @version $Id$ * @since solr 1.3 */ -public class TestFileListEntityProcessor { +public class TestFileListEntityProcessor extends SolrTestCaseJ4 { @Test @SuppressWarnings("unchecked") @@ -44,10 +45,10 @@ public class TestFileListEntityProcessor { createFile(tmpdir, "a.xml", "a.xml".getBytes(), false); createFile(tmpdir, "b.xml", "b.xml".getBytes(), false); createFile(tmpdir, "c.props", "c.props".getBytes(), false); - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, "xml$", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath()); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), null, Context.FULL_DUMP, Collections.EMPTY_LIST, attrs); FileListEntityProcessor fileListEntityProcessor = new FileListEntityProcessor(); fileListEntityProcessor.init(c); @@ -87,7 +88,7 @@ public class TestFileListEntityProcessor { minLength = content.length; smallestFile = "c.props"; } - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, ".*", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.BIGGER_THAN, String.valueOf(minLength)); @@ -97,7 +98,7 @@ public class TestFileListEntityProcessor { l.add(new File(tmpdir, "a.xml").getAbsolutePath()); l.add(new File(tmpdir, "b.xml").getAbsolutePath()); Assert.assertEquals(l, new HashSet(fList)); - attrs = AbstractDataImportHandlerTest.createMap( + attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, ".*", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.SMALLER_THAN, String.valueOf(minLength+1)); @@ -105,19 +106,19 @@ public class TestFileListEntityProcessor { l.clear(); l.add(new File(tmpdir, smallestFile).getAbsolutePath()); Assert.assertEquals(l, new HashSet(fList)); - attrs = AbstractDataImportHandlerTest.createMap( + attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, ".*", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.SMALLER_THAN, "${a.x}"); VariableResolverImpl resolver = new VariableResolverImpl(); - resolver.addNamespace("a", AbstractDataImportHandlerTest.createMap("x", "4")); + resolver.addNamespace("a", AbstractDataImportHandlerTestCase.createMap("x", "4")); fList = getFiles(resolver, attrs); Assert.assertEquals(l, new HashSet(fList)); } @SuppressWarnings("unchecked") static List getFiles(VariableResolverImpl resolver, Map attrs) { - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, Collections.EMPTY_LIST, attrs); FileListEntityProcessor fileListEntityProcessor = new FileListEntityProcessor(); fileListEntityProcessor.init(c); @@ -140,13 +141,13 @@ public class TestFileListEntityProcessor { createFile(tmpdir, "a.xml", "a.xml".getBytes(), true); createFile(tmpdir, "b.xml", "b.xml".getBytes(), true); createFile(tmpdir, "c.props", "c.props".getBytes(), true); - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, "xml$", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.OLDER_THAN, "'NOW'"); List fList = getFiles(null, attrs); Assert.assertEquals(2, fList.size()); - attrs = AbstractDataImportHandlerTest.createMap( + attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, ".xml$", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.NEWER_THAN, "'NOW-2HOURS'"); @@ -154,13 +155,13 @@ public class TestFileListEntityProcessor { Assert.assertEquals(2, fList.size()); // Use a variable for newerThan - attrs = AbstractDataImportHandlerTest.createMap( + attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, ".xml$", FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath(), FileListEntityProcessor.NEWER_THAN, "${a.x}"); VariableResolverImpl resolver = new VariableResolverImpl(); String lastMod = DataImporter.DATE_TIME_FORMAT.get().format(new Date(System.currentTimeMillis() - 50000)); - resolver.addNamespace("a", AbstractDataImportHandlerTest.createMap("x", lastMod)); + resolver.addNamespace("a", AbstractDataImportHandlerTestCase.createMap("x", lastMod)); createFile(tmpdir, "t.xml", "t.xml".getBytes(), false); fList = getFiles(resolver, attrs); Assert.assertEquals(1, fList.size()); @@ -179,7 +180,7 @@ public class TestFileListEntityProcessor { createFile(childdir, "a.xml", "a.xml".getBytes(), true); createFile(childdir, "b.xml", "b.xml".getBytes(), true); createFile(childdir, "c.props", "c.props".getBytes(), true); - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( FileListEntityProcessor.FILE_NAME, "^.*\\.xml$", FileListEntityProcessor.BASE_DIR, childdir.getAbsolutePath(), FileListEntityProcessor.RECURSIVE, "true"); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestJdbcDataSource.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestJdbcDataSource.java index 08ac625b8d7..b4c54b19c7d 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestJdbcDataSource.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestJdbcDataSource.java @@ -23,6 +23,7 @@ import java.util.*; import javax.sql.DataSource; +import org.apache.solr.SolrTestCaseJ4; import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.*; @@ -39,7 +40,7 @@ import org.junit.*; * @version $Id$ * @since solr 1.3 */ -public class TestJdbcDataSource { +public class TestJdbcDataSource extends SolrTestCaseJ4 { Driver driver; DataSource dataSource; Connection connection; @@ -47,7 +48,7 @@ public class TestJdbcDataSource { JdbcDataSource jdbcDataSource = new JdbcDataSource(); List> fields = new ArrayList>(); - Context context = AbstractDataImportHandlerTest.getContext(null, null, + Context context = AbstractDataImportHandlerTestCase.getContext(null, null, jdbcDataSource, Context.FULL_DUMP, fields, null); Properties props = new Properties(); @@ -55,7 +56,8 @@ public class TestJdbcDataSource { String sysProp = System.getProperty("java.naming.factory.initial"); @Before - public void SetUp() throws ClassNotFoundException { + public void setUp() throws Exception { + super.setUp(); System.setProperty("java.naming.factory.initial", MockInitialContextFactory.class.getName()); @@ -66,12 +68,13 @@ public class TestJdbcDataSource { } @After - public void tearDown() { + public void tearDown() throws Exception { if (sysProp == null) { System.getProperties().remove("java.naming.factory.initial"); } else { System.setProperty("java.naming.factory.initial", sysProp); } + super.tearDown(); } @Test @@ -161,7 +164,7 @@ public class TestJdbcDataSource { f.put("type", "float"); flds.add(f); - Context c = AbstractDataImportHandlerTest.getContext(null, null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, dataSource, Context.FULL_DUMP, flds, null); dataSource.init(c, p); Iterator> i = dataSource diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestLineEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestLineEntityProcessor.java index 1a8d96ccbb3..2674d0622c8 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestLineEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestLineEntityProcessor.java @@ -16,6 +16,7 @@ package org.apache.solr.handler.dataimport; * limitations under the License. */ +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -31,7 +32,7 @@ import java.util.*; * @version $Id$ * @since solr 1.4 */ -public class TestLineEntityProcessor { +public class TestLineEntityProcessor extends SolrTestCaseJ4 { @Test /************************************************************************/ @@ -44,13 +45,13 @@ public class TestLineEntityProcessor { * /> */ - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( LineEntityProcessor.URL, "dummy.lis", LineEntityProcessor.ACCEPT_LINE_REGEX, null, LineEntityProcessor.SKIP_LINE_REGEX, null ); - Context c = AbstractDataImportHandlerTest.getContext( + Context c = AbstractDataImportHandlerTestCase.getContext( null, //parentEntity new VariableResolverImpl(), //resolver getDataSource(filecontents), //parentDataSource @@ -84,13 +85,13 @@ public class TestLineEntityProcessor { * acceptLineRegex="xml" * /> */ - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( LineEntityProcessor.URL, "dummy.lis", LineEntityProcessor.ACCEPT_LINE_REGEX, "xml", LineEntityProcessor.SKIP_LINE_REGEX, null ); - Context c = AbstractDataImportHandlerTest.getContext( + Context c = AbstractDataImportHandlerTestCase.getContext( null, //parentEntity new VariableResolverImpl(), //resolver getDataSource(filecontents), //parentDataSource @@ -122,13 +123,13 @@ public class TestLineEntityProcessor { * omitLineRegex="\\.xsd" * /> */ - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( LineEntityProcessor.URL, "dummy.lis", LineEntityProcessor.ACCEPT_LINE_REGEX, "\\.xml", LineEntityProcessor.SKIP_LINE_REGEX, "\\.xsd" ); - Context c = AbstractDataImportHandlerTest.getContext( + Context c = AbstractDataImportHandlerTestCase.getContext( null, //parentEntity new VariableResolverImpl(), //resolver getDataSource(filecontents), //parentDataSource @@ -159,12 +160,12 @@ public class TestLineEntityProcessor { * omitLineRegex="\\.xsd" * /> */ - Map attrs = AbstractDataImportHandlerTest.createMap( + Map attrs = AbstractDataImportHandlerTestCase.createMap( LineEntityProcessor.URL, "dummy.lis", LineEntityProcessor.SKIP_LINE_REGEX, "\\.xsd" ); - Context c = AbstractDataImportHandlerTest.getContext( + Context c = AbstractDataImportHandlerTestCase.getContext( null, //parentEntity new VariableResolverImpl(), //resolver getDataSource(filecontents), //parentDataSource diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestNumberFormatTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestNumberFormatTransformer.java index 09d877d466d..1038f5d6127 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestNumberFormatTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestNumberFormatTransformer.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -33,7 +34,7 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestNumberFormatTransformer { +public class TestNumberFormatTransformer extends SolrTestCaseJ4 { private char GROUPING_SEP = new DecimalFormatSymbols().getGroupingSeparator(); private char DECIMAL_SEP = new DecimalFormatSymbols().getDecimalSeparator(); @@ -42,12 +43,12 @@ public class TestNumberFormatTransformer { public void testTransformRow_SingleNumber() { char GERMAN_GROUPING_SEP = new DecimalFormatSymbols(Locale.GERMANY).getGroupingSeparator(); List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); - l.add(AbstractDataImportHandlerTest.createMap("column", "localizedNum", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "localizedNum", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER, NumberFormatTransformer.LOCALE, "de-DE")); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap("num", "123" + GROUPING_SEP + "567", "localizedNum", "123" + GERMAN_GROUPING_SEP + "567"); + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap("num", "123" + GROUPING_SEP + "567", "localizedNum", "123" + GERMAN_GROUPING_SEP + "567"); new NumberFormatTransformer().transformRow(m, c); Assert.assertEquals(new Long(123567), m.get("num")); Assert.assertEquals(new Long(123567), m.get("localizedNum")); @@ -57,27 +58,27 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_MultipleNumbers() throws Exception { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "inputs")); - fields.add(AbstractDataImportHandlerTest.createMap(DataImporter.COLUMN, + fields.add(AbstractDataImportHandlerTestCase.createMap(DataImporter.COLUMN, "outputs", RegexTransformer.SRC_COL_NAME, "inputs", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); List inputs = new ArrayList(); inputs.add("123" + GROUPING_SEP + "567"); inputs.add("245" + GROUPING_SEP + "678"); - Map row = AbstractDataImportHandlerTest.createMap("inputs", inputs); + Map row = AbstractDataImportHandlerTestCase.createMap("inputs", inputs); VariableResolverImpl resolver = new VariableResolverImpl(); resolver.addNamespace("e", row); - Context context = AbstractDataImportHandlerTest.getContext(null, resolver, null, Context.FULL_DUMP, fields, null); + Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, null); new NumberFormatTransformer().transformRow(row, context); List output = new ArrayList(); output.add(new Long(123567)); output.add(new Long(245678)); - Map outputRow = AbstractDataImportHandlerTest.createMap("inputs", inputs, + Map outputRow = AbstractDataImportHandlerTestCase.createMap("inputs", inputs, "outputs", output); Assert.assertEquals(outputRow, row); @@ -87,10 +88,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput1_Number() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap("num", "123" + GROUPING_SEP + "5a67"); + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap("num", "123" + GROUPING_SEP + "5a67"); new NumberFormatTransformer().transformRow(m, c); } @@ -98,10 +99,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput2_Number() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap("num", "123" + GROUPING_SEP + "567b"); + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap("num", "123" + GROUPING_SEP + "567b"); new NumberFormatTransformer().transformRow(m, c); } @@ -109,10 +110,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput2_Currency() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.CURRENCY)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap("num", "123" + GROUPING_SEP + "567b"); + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap("num", "123" + GROUPING_SEP + "567b"); new NumberFormatTransformer().transformRow(m, c); } @@ -120,10 +121,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput1_Percent() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.PERCENT)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap("num", "123" + GROUPING_SEP + "5a67"); + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap("num", "123" + GROUPING_SEP + "5a67"); new NumberFormatTransformer().transformRow(m, c); } @@ -131,10 +132,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput3_Currency() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.CURRENCY)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap( + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap( "num", "123" + DECIMAL_SEP + "456" + DECIMAL_SEP + "789"); new NumberFormatTransformer().transformRow(m, c); } @@ -143,10 +144,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_InvalidInput3_Number() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap( + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap( "num", "123" + DECIMAL_SEP + "456" + DECIMAL_SEP + "789"); new NumberFormatTransformer().transformRow(m, c); } @@ -155,10 +156,10 @@ public class TestNumberFormatTransformer { @SuppressWarnings("unchecked") public void testTransformRow_MalformedInput_Number() { List l = new ArrayList(); - l.add(AbstractDataImportHandlerTest.createMap("column", "num", + l.add(AbstractDataImportHandlerTestCase.createMap("column", "num", NumberFormatTransformer.FORMAT_STYLE, NumberFormatTransformer.NUMBER)); - Context c = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, l, null); - Map m = AbstractDataImportHandlerTest.createMap( + Context c = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, l, null); + Map m = AbstractDataImportHandlerTestCase.createMap( "num", "123" + GROUPING_SEP + GROUPING_SEP + "789"); new NumberFormatTransformer().transformRow(m, c); Assert.assertEquals(new Long(123789), m.get("num")); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestPlainTextEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestPlainTextEntityProcessor.java index c641404d3d5..998fcee6370 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestPlainTextEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestPlainTextEntityProcessor.java @@ -17,7 +17,9 @@ package org.apache.solr.handler.dataimport; import junit.framework.Assert; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.createMap; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Test; import java.io.StringReader; @@ -30,7 +32,7 @@ import java.util.Properties; * @see org.apache.solr.handler.dataimport.PlainTextEntityProcessor * @since solr 1.4 */ -public class TestPlainTextEntityProcessor { +public class TestPlainTextEntityProcessor extends SolrTestCaseJ4 { @Test public void simple() { DataImporter di = new DataImporter(); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestRegexTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestRegexTransformer.java index 96df44e2a2e..ba882d916a8 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestRegexTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestRegexTransformer.java @@ -20,8 +20,10 @@ import static org.apache.solr.handler.dataimport.RegexTransformer.REGEX; import static org.apache.solr.handler.dataimport.RegexTransformer.GROUP_NAMES; import static org.apache.solr.handler.dataimport.RegexTransformer.REPLACE_WITH; import static org.apache.solr.handler.dataimport.DataImporter.COLUMN; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.getContext; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.createMap; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.getContext; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -36,14 +38,14 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestRegexTransformer { +public class TestRegexTransformer extends SolrTestCaseJ4 { @Test public void commaSeparated() { List> fields = new ArrayList>(); // fields.add(getField("col1", "string", null, "a", ",")); - Context context = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, fields, null); + Context context = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, fields, null); Map src = new HashMap(); src.put("a", "a,bb,cc,d"); @@ -63,7 +65,7 @@ public class TestRegexTransformer { m.put(GROUP_NAMES,",firstName,lastName"); m.put(REGEX,"(\\w*) (\\w*) (\\w*)"); fields.add(m); - Context context = AbstractDataImportHandlerTest.getContext(null, null, null, Context.FULL_DUMP, fields, null); + Context context = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, fields, null); Map src = new HashMap(); src.put("fullName", "Mr Noble Paul"); @@ -91,7 +93,7 @@ public class TestRegexTransformer { Map fld = getField("name", "string", "'", null, null); fld.put(REPLACE_WITH, "''"); fields.add(fld); - Context context = AbstractDataImportHandlerTest.getContext(null, null, + Context context = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, fields, null); Map src = new HashMap(); @@ -139,8 +141,8 @@ public class TestRegexTransformer { VariableResolverImpl resolver = new VariableResolverImpl(); resolver.addNamespace("e", row); - Map eAttrs = AbstractDataImportHandlerTest.createMap("name", "e"); - Context context = AbstractDataImportHandlerTest.getContext(null, resolver, null, Context.FULL_DUMP, fields, eAttrs); + Map eAttrs = AbstractDataImportHandlerTestCase.createMap("name", "e"); + Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, eAttrs); Map result = new RegexTransformer().transformRow(row, context); Assert.assertEquals(5, result.size()); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java index b8dea989534..bf464e649e4 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -42,7 +43,7 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestScriptTransformer { +public class TestScriptTransformer extends SolrTestCaseJ4 { @Test @Ignore @@ -65,7 +66,7 @@ public class TestScriptTransformer { entity.put("name", "hello"); entity.put("transformer", "script:" + funcName); - AbstractDataImportHandlerTest.TestContext context = AbstractDataImportHandlerTest.getContext(null, null, null, + AbstractDataImportHandlerTestCase.TestContext context = AbstractDataImportHandlerTestCase.getContext(null, null, null, Context.FULL_DUMP, fields, entity); context.script = script; context.scriptlang = "JavaScript"; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor.java index 7e850c71f72..a8c03431a07 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -29,7 +30,7 @@ import java.util.*; * @version $Id$ * @since solr 1.3 */ -public class TestSqlEntityProcessor { +public class TestSqlEntityProcessor extends SolrTestCaseJ4 { private static ThreadLocal local = new ThreadLocal(); @Test @@ -39,7 +40,7 @@ public class TestSqlEntityProcessor { VariableResolverImpl vr = new VariableResolverImpl(); HashMap ea = new HashMap(); ea.put("query", "SELECT * FROM A"); - Context c = AbstractDataImportHandlerTest.getContext(null, vr, getDs(rows), + Context c = AbstractDataImportHandlerTestCase.getContext(null, vr, getDs(rows), Context.FULL_DUMP, null, ea); sep.init(c); int count = 0; @@ -62,7 +63,7 @@ public class TestSqlEntityProcessor { ea.put("query", "SELECT * FROM A"); ea.put("transformer", T.class.getName()); - sep.init(AbstractDataImportHandlerTest.getContext(null, vr, getDs(rows), + sep.init(AbstractDataImportHandlerTestCase.getContext(null, vr, getDs(rows), Context.FULL_DUMP, null, ea)); List> rs = new ArrayList>(); Map r = null; @@ -86,7 +87,7 @@ public class TestSqlEntityProcessor { ea.put("query", "SELECT * FROM A"); ea.put("transformer", T3.class.getName()); - sep.init(AbstractDataImportHandlerTest.getContext(null, vr, getDs(rows), + sep.init(AbstractDataImportHandlerTestCase.getContext(null, vr, getDs(rows), Context.FULL_DUMP, null, ea)); List> rs = new ArrayList>(); Map r = null; @@ -110,7 +111,7 @@ public class TestSqlEntityProcessor { HashMap ea = new HashMap(); ea.put("query", "SELECT * FROM A"); ea.put("transformer", T2.class.getName()); - sep.init(AbstractDataImportHandlerTest.getContext(null, vr, getDs(rows), + sep.init(AbstractDataImportHandlerTestCase.getContext(null, vr, getDs(rows), Context.FULL_DUMP, null, ea)); local.set(0); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java index 01509a13263..35ddad0b240 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java @@ -32,7 +32,7 @@ import java.text.ParseException; * @version $Id$ * @since solr 1.3 */ -public class TestSqlEntityProcessor2 extends AbstractDataImportHandlerTest { +public class TestSqlEntityProcessor2 extends AbstractDataImportHandlerTestCase { @Override public String getSchemaFile() { return "dataimport-schema.xml"; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java index 9925991645c..2adcf04c4f3 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java @@ -32,7 +32,7 @@ import java.util.List; * @version $Id: TestSqlEntityProcessor2.java 723824 2008-12-05 19:14:11Z shalin $ * @since solr 1.3 */ -public class TestSqlEntityProcessorDelta extends AbstractDataImportHandlerTest { +public class TestSqlEntityProcessorDelta extends AbstractDataImportHandlerTestCase { private static final String FULLIMPORT_QUERY = "select * from x"; private static final String DELTA_QUERY = "select id from x where last_modified > NOW"; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java index def30826735..841b8d45385 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java @@ -32,7 +32,7 @@ import java.util.List; * @version $Id: TestSqlEntityProcessor2.java 723824 2008-12-05 19:14:11Z shalin $ * @since solr 1.3 */ -public class TestSqlEntityProcessorDelta2 extends AbstractDataImportHandlerTest { +public class TestSqlEntityProcessorDelta2 extends AbstractDataImportHandlerTestCase { private static final String FULLIMPORT_QUERY = "select * from x"; private static final String DELTA_QUERY = "select id from x where last_modified > NOW"; diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateString.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateString.java index 706ac0755f9..3dc984d36c7 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateString.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateString.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -32,7 +33,7 @@ import java.util.regex.Pattern; * @version $Id$ * @since solr 1.3 */ -public class TestTemplateString { +public class TestTemplateString extends SolrTestCaseJ4 { @Test public void testSimple() { VariableResolverImpl vri = new VariableResolverImpl(); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateTransformer.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateTransformer.java index 7fbf9ac9e23..05c0a5dedf8 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateTransformer.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestTemplateTransformer.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -32,28 +33,28 @@ import java.util.Arrays; * @version $Id$ * @since solr 1.3 */ -public class TestTemplateTransformer { +public class TestTemplateTransformer extends SolrTestCaseJ4 { @Test @SuppressWarnings("unchecked") public void testTransformRow() { List fields = new ArrayList(); - fields.add(AbstractDataImportHandlerTest.createMap("column", "firstName")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "lastName")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "middleName")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "name", + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "firstName")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "lastName")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "middleName")); + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "name", TemplateTransformer.TEMPLATE, "${e.lastName}, ${e.firstName} ${e.middleName}")); - fields.add(AbstractDataImportHandlerTest.createMap("column", "emails", + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "emails", TemplateTransformer.TEMPLATE, "${e.mail}")); // test reuse of template output in another template - fields.add(AbstractDataImportHandlerTest.createMap("column", "mrname", + fields.add(AbstractDataImportHandlerTestCase.createMap("column", "mrname", TemplateTransformer.TEMPLATE,"Mr ${e.name}")); List mails = Arrays.asList(new String[]{"a@b.com", "c@d.com"}); - Map row = AbstractDataImportHandlerTest.createMap( + Map row = AbstractDataImportHandlerTestCase.createMap( "firstName", "Shalin", "middleName", "Shekhar", "lastName", "Mangar", @@ -61,10 +62,10 @@ public class TestTemplateTransformer { VariableResolverImpl resolver = new VariableResolverImpl(); resolver.addNamespace("e", row); - Map entityAttrs = AbstractDataImportHandlerTest.createMap( + Map entityAttrs = AbstractDataImportHandlerTestCase.createMap( "name", "e"); - Context context = AbstractDataImportHandlerTest.getContext(null, resolver, + Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, entityAttrs); new TemplateTransformer().transformRow(row, context); Assert.assertEquals("Mangar, Shalin Shekhar", row.get("name")); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestThreaded.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestThreaded.java index daa6f6e80fc..0690c79fb3e 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestThreaded.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestThreaded.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.Map; -public class TestThreaded extends AbstractDataImportHandlerTest { +public class TestThreaded extends AbstractDataImportHandlerTestCase { @Test @SuppressWarnings("unchecked") public void testCompositePk_FullImport() throws Exception { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestURLDataSource.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestURLDataSource.java index e76648969b8..df3d5d8c0ca 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestURLDataSource.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestURLDataSource.java @@ -24,13 +24,14 @@ import java.util.Properties; import junit.framework.Assert; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Test; -public class TestURLDataSource { +public class TestURLDataSource extends SolrTestCaseJ4 { private List> fields = new ArrayList>(); private URLDataSource dataSource = new URLDataSource(); private VariableResolverImpl variableResolver = new VariableResolverImpl(); - private Context context = AbstractDataImportHandlerTest.getContext(null, variableResolver, + private Context context = AbstractDataImportHandlerTestCase.getContext(null, variableResolver, dataSource, Context.FULL_DUMP, fields, null); private Properties initProps = new Properties(); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java index bfae693224a..c711a238e6c 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java @@ -18,6 +18,7 @@ package org.apache.solr.handler.dataimport; import org.junit.Assert; import org.junit.Test; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.util.DateMathParser; import java.text.SimpleDateFormat; @@ -31,7 +32,7 @@ import java.util.*; * @version $Id$ * @since solr 1.3 */ -public class TestVariableResolver { +public class TestVariableResolver extends SolrTestCaseJ4 { @Test public void testSimpleNamespace() { diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java index cf4b1619a1f..76e41be55a7 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java @@ -16,7 +16,9 @@ */ package org.apache.solr.handler.dataimport; -import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap; +import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.createMap; + +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -37,7 +39,7 @@ import java.util.concurrent.TimeUnit; * @version $Id$ * @since solr 1.3 */ -public class TestXPathEntityProcessor { +public class TestXPathEntityProcessor extends SolrTestCaseJ4 { boolean simulateSlowReader; boolean simulateSlowResultProcessor; int rowsToRead = -1; @@ -56,7 +58,7 @@ public class TestXPathEntityProcessor { fields.add(createMap("column", "title", "xpath", "/catalog/cd/title")); fields.add(createMap("column", "artist", "xpath", "/catalog/cd/artist")); fields.add(createMap("column", "year", "xpath", "/catalog/cd/year")); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), getDataSource(cdData), Context.FULL_DUMP, fields, entityAttrs); XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor(); xPathEntityProcessor.init(c); @@ -79,7 +81,7 @@ public class TestXPathEntityProcessor { XPathEntityProcessor.FOR_EACH, "/root"); List fields = new ArrayList(); fields.add(createMap("column", "a", "xpath", "/root/a", DataImporter.MULTI_VALUED, "true")); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), getDataSource(testXml), Context.FULL_DUMP, fields, entityAttrs); XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor(); xPathEntityProcessor.init(c); @@ -99,7 +101,7 @@ public class TestXPathEntityProcessor { XPathEntityProcessor.FOR_EACH, "/root"); List fields = new ArrayList(); fields.add(createMap("column", "a", "xpath", "/root/a" ,"flatten","true")); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), getDataSource(testXmlFlatten), Context.FULL_DUMP, fields, entityAttrs); XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor(); xPathEntityProcessor.init(c); @@ -124,7 +126,7 @@ public class TestXPathEntityProcessor { fields.add(createMap("column", "title", "xpath", "/catalog/cd/title")); fields.add(createMap("column", "artist", "xpath", "/catalog/cd/artist")); fields.add(createMap("column", "year", "xpath", "/catalog/cd/year")); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), getDataSource(cdData), Context.FULL_DUMP, fields, entityAttrs); XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor() { private int count; @@ -219,7 +221,7 @@ public class TestXPathEntityProcessor { Map entityAttrs = createMap("name", "e", XPathEntityProcessor.USE_SOLR_ADD_SCHEMA, "true", "xsl", "" + new File(tmpdir, "x.xsl").getAbsolutePath(), "url", "cd.xml"); - Context c = AbstractDataImportHandlerTest.getContext(null, + Context c = AbstractDataImportHandlerTestCase.getContext(null, new VariableResolverImpl(), getDataSource(cdData), Context.FULL_DUMP, null, entityAttrs); XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor(); xPathEntityProcessor.init(c); diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java index 8365ecff767..e0eb143881b 100644 --- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java +++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java @@ -16,6 +16,7 @@ */ package org.apache.solr.handler.dataimport; +import org.apache.solr.SolrTestCaseJ4; import org.junit.Assert; import org.junit.Test; @@ -30,7 +31,7 @@ import java.util.Map; * @version $Id$ * @since solr 1.3 */ -public class TestXPathRecordReader { +public class TestXPathRecordReader extends SolrTestCaseJ4 { @Test public void basic() { String xml="\n" diff --git a/solr/contrib/extraction/build.xml b/solr/contrib/extraction/build.xml index 8c403ef3071..09dd5430c23 100644 --- a/solr/contrib/extraction/build.xml +++ b/solr/contrib/extraction/build.xml @@ -41,6 +41,8 @@ + + diff --git a/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java b/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java index b9c1e154e77..0b1c2a844bc 100644 --- a/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java +++ b/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java @@ -47,6 +47,7 @@ import org.xml.sax.SAXException; public class TestArbitraryIndexDir extends AbstractSolrTestCase{ public void setUp() throws Exception { + super.setUp(); dataDir = new File(System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr" diff --git a/solr/src/test/org/apache/solr/core/TestBadConfig.java b/solr/src/test/org/apache/solr/core/TestBadConfig.java index e0e8f2442e4..54a742da392 100644 --- a/solr/src/test/org/apache/solr/core/TestBadConfig.java +++ b/solr/src/test/org/apache/solr/core/TestBadConfig.java @@ -17,12 +17,7 @@ package org.apache.solr.core; -import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.util.AbstractSolrTestCase; -import org.apache.solr.util.TestHarness; -import org.junit.BeforeClass; - -import java.io.File; public class TestBadConfig extends AbstractSolrTestCase { @@ -30,22 +25,14 @@ public class TestBadConfig extends AbstractSolrTestCase { public String getSolrConfigFile() { return "bad_solrconfig.xml"; } public void setUp() throws Exception { - - dataDir = new File(System.getProperty("java.io.tmpdir") - + System.getProperty("file.separator") - + getClass().getName()); - dataDir.mkdirs(); + ignoreException("unset.sys.property"); try { - SolrTestCaseJ4.ignoreException("unset.sys.property"); - - solrConfig = new SolrConfig(getSolrConfigFile()); - h = new TestHarness( dataDir.getAbsolutePath(), - solrConfig, - getSchemaFile()); + super.setUp(); fail("Exception should have been thrown"); } catch (Exception e) { assertTrue(e.getMessage().contains("unset.sys.property")); - SolrTestCaseJ4.resetExceptionIgnores(); + } finally { + resetExceptionIgnores(); } } diff --git a/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java index b5b0f578e8a..d019d25c6ef 100644 --- a/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -616,6 +616,7 @@ public class TestReplicationHandler extends TestCase { } public void setUp() throws Exception { + super.setUp(); System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop2", "proptwo"); diff --git a/solr/src/java/org/apache/solr/util/AbstractSolrTestCase.java b/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java similarity index 98% rename from solr/src/java/org/apache/solr/util/AbstractSolrTestCase.java rename to solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java index fe63b3357c0..143c709a9a6 100644 --- a/solr/src/java/org/apache/solr/util/AbstractSolrTestCase.java +++ b/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java @@ -19,6 +19,7 @@ package org.apache.solr.util; +import org.apache.lucene.util.LuceneTestCase; import org.apache.solr.core.SolrConfig; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrInputDocument; @@ -30,7 +31,6 @@ 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; import java.io.*; @@ -51,7 +51,7 @@ import java.util.ArrayList; * @see #setUp * @see #tearDown */ -public abstract class AbstractSolrTestCase extends TestCase { +public abstract class AbstractSolrTestCase extends LuceneTestCase { protected SolrConfig solrConfig; /** * Harness initialized by initTestHarness. @@ -103,6 +103,7 @@ public abstract class AbstractSolrTestCase extends TestCase { private String factoryProp; public void setUp() throws Exception { + super.setUp(); log.info("####SETUP_START " + getName()); ignoreException("ignore_exception"); factoryProp = System.getProperty("solr.directoryFactory"); @@ -178,6 +179,7 @@ public abstract class AbstractSolrTestCase extends TestCase { } resetExceptionIgnores(); + super.tearDown(); } /** Validates an update XML String is successful