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