SOLR-2002: make AbstractSolrTestCase extend LuceneTestCase

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@963873 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-07-13 21:45:31 +00:00
parent 2ec25eb81a
commit 0aacad6eca
37 changed files with 210 additions and 183 deletions

View File

@ -55,6 +55,8 @@
<path refid="classpath.jetty" />
<pathelement path="target/classes" />
<pathelement path="target/test-classes" />
<pathelement location="${solr-path}/build/tests"/> <!-- include solr test code -->
<pathelement location="${solr-path}/../lucene/build/classes/test" /> <!-- include some lucene test code -->
<pathelement path="${java.class.path}"/>
</path>
@ -65,6 +67,8 @@
<pathelement path="target/extras/classes" />
<pathelement path="target/test-classes" />
<pathelement path="target/extras/test-classes" />
<pathelement location="${solr-path}/build/tests"/> <!-- include solr test code -->
<pathelement location="${solr-path}/../lucene/build/classes/test" /> <!-- include some lucene test code -->
<pathelement path="${java.class.path}"/>
</path>

View File

@ -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";

View File

@ -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 {

View File

@ -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

View File

@ -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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap(
Map<String, String> 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<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap(
Map<String, String> 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<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap(
Map<String, String> 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<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap(
Map<String, String> 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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap("query", q, "where", "id=x.id");
Map<String, String> 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<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
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);

View File

@ -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<Map<String, String>> flds = new ArrayList<Map<String, String>>();
@ -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<String, Object> row = new HashMap<String, Object>();
Clob clob = (Clob) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Clob.class}, new InvocationHandler() {

View File

@ -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 {

View File

@ -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();

View File

@ -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 {

View File

@ -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 {

View File

@ -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<String, Object> src = new HashMap<String, Object>();
src.put("A", "NA");

View File

@ -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;

View File

@ -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<String, String>();

View File

@ -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() {

View File

@ -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<String>(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<String>(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<String>(fList));
}
@SuppressWarnings("unchecked")
static List<String> 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<String> 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");

View File

@ -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<Map<String, String>> fields = new ArrayList<Map<String, String>>();
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<Map<String, Object>> i = dataSource

View File

@ -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

View File

@ -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"));

View File

@ -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();

View File

@ -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<Map<String, String>> fields = new ArrayList<Map<String, String>>();
// <field column="col1" sourceColName="a" splitBy="," />
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<String, Object> src = new HashMap<String, Object>();
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<String, Object> src = new HashMap<String, Object>();
src.put("fullName", "Mr Noble Paul");
@ -91,7 +93,7 @@ public class TestRegexTransformer {
Map<String, String> 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<String, Object> src = new HashMap<String, Object>();
@ -139,8 +141,8 @@ public class TestRegexTransformer {
VariableResolverImpl resolver = new VariableResolverImpl();
resolver.addNamespace("e", row);
Map<String, String> eAttrs = AbstractDataImportHandlerTest.createMap("name", "e");
Context context = AbstractDataImportHandlerTest.getContext(null, resolver, null, Context.FULL_DUMP, fields, eAttrs);
Map<String, String> eAttrs = AbstractDataImportHandlerTestCase.createMap("name", "e");
Context context = AbstractDataImportHandlerTestCase.getContext(null, resolver, null, Context.FULL_DUMP, fields, eAttrs);
Map<String, Object> result = new RegexTransformer().transformRow(row, context);
Assert.assertEquals(5, result.size());

View File

@ -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";

View File

@ -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<Integer> local = new ThreadLocal<Integer>();
@Test
@ -39,7 +40,7 @@ public class TestSqlEntityProcessor {
VariableResolverImpl vr = new VariableResolverImpl();
HashMap<String, String> ea = new HashMap<String, String>();
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<Map<String, Object>> rs = new ArrayList<Map<String, Object>>();
Map<String, Object> 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<Map<String, Object>> rs = new ArrayList<Map<String, Object>>();
Map<String, Object> r = null;
@ -110,7 +111,7 @@ public class TestSqlEntityProcessor {
HashMap<String, String> ea = new HashMap<String, String>();
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);

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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();

View File

@ -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<String> 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<String, String> entityAttrs = AbstractDataImportHandlerTest.createMap(
Map<String, String> 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"));

View File

@ -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 {

View File

@ -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<Map<String, String>> fields = new ArrayList<Map<String, String>>();
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();

View File

@ -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() {

View File

@ -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);

View File

@ -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="<root>\n"

View File

@ -41,6 +41,8 @@
<path refid="common.classpath" />
<pathelement path="${dest}/classes" />
<pathelement path="${dest}/test-classes" />
<pathelement location="${solr-path}/build/tests"/> <!-- include solr test code -->
<pathelement location="${solr-path}/../lucene/build/classes/test" /> <!-- include some lucene test code -->
<pathelement path="${java.class.path}"/>
</path>

View File

@ -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"

View File

@ -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();
}
}

View File

@ -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");

View File

@ -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