mirror of https://github.com/apache/lucene.git
SOLR-1655 . testcases are modified so thatthey explicitly mention MockDataSource
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@890775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e8eb2a2d8
commit
79b97f996b
|
@ -46,9 +46,9 @@ public class TestTikaEntityProcessor extends AbstractDataImportHandlerTest {
|
|||
public void testIndexingWithTikaEntityProcessor() throws Exception {
|
||||
String conf =
|
||||
"<dataConfig>" +
|
||||
" <dataSource name=\"binary\" type=\"BinFileDataSource\"/>" +
|
||||
" <dataSource type=\"BinFileDataSource\"/>" +
|
||||
" <document>" +
|
||||
" <entity processor=\"TikaEntityProcessor\" url=\"../../../../../extraction/src/test/resources/solr-word.pdf\" dataSource=\"binary\">" +
|
||||
" <entity processor=\"TikaEntityProcessor\" url=\"../../../../../extraction/src/test/resources/solr-word.pdf\" >" +
|
||||
" <field column=\"Author\" meta=\"true\" name=\"author\"/>" +
|
||||
" <field column=\"title\" meta=\"true\" name=\"docTitle\"/>" +
|
||||
" <field column=\"text\"/>" +
|
||||
|
|
|
@ -328,11 +328,6 @@
|
|||
</requestHandler>
|
||||
|
||||
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
|
||||
<lst name="defaults">
|
||||
<lst name="datasource">
|
||||
<str name="type">MockDataSource</str>
|
||||
</lst>
|
||||
</lst>
|
||||
</requestHandler>
|
||||
|
||||
<!--
|
||||
|
|
|
@ -279,6 +279,12 @@ public class DataConfig {
|
|||
dataSources.put(p.getProperty("name"), p);
|
||||
}
|
||||
}
|
||||
if(dataSources.get(null) == null){
|
||||
for (Properties properties : dataSources.values()) {
|
||||
dataSources.put(null,properties);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getStringAttribute(Element e, String name, String def) {
|
||||
|
|
|
@ -271,7 +271,6 @@ public class DataImporter {
|
|||
}
|
||||
|
||||
DataSource getDataSourceInstance(DataConfig.Entity key, String name, Context ctx) {
|
||||
if ("null".equals(name)) return new MockDataSource();
|
||||
Properties p = dataSourceProps.get(name);
|
||||
if (p == null)
|
||||
p = config.dataSources.get(name);
|
||||
|
@ -283,15 +282,15 @@ public class DataImporter {
|
|||
throw new DataImportHandlerException(SEVERE,
|
||||
"No dataSource :" + name + " available for entity :"
|
||||
+ key.name);
|
||||
String impl = p.getProperty(TYPE);
|
||||
String type = p.getProperty(TYPE);
|
||||
DataSource dataSrc = null;
|
||||
if (impl == null) {
|
||||
if (type == null) {
|
||||
dataSrc = new JdbcDataSource();
|
||||
} else {
|
||||
try {
|
||||
dataSrc = (DataSource) DocBuilder.loadClass(impl, getCore()).newInstance();
|
||||
dataSrc = (DataSource) DocBuilder.loadClass(type, getCore()).newInstance();
|
||||
} catch (Exception e) {
|
||||
wrapAndThrow(SEVERE, e, "Invalid type for data source: " + impl);
|
||||
wrapAndThrow(SEVERE, e, "Invalid type for data source: " + type);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -298,7 +298,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
|
|||
" </document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private final String dataConfigWithDynamicTransformer = "<dataConfig>\n" +
|
||||
private final String dataConfigWithDynamicTransformer = "<dataConfig> <dataSource type=\"MockDataSource\"/>\n" +
|
||||
" <document>\n" +
|
||||
" <entity name=\"books\" query=\"select * from x\"" +
|
||||
" transformer=\"TestDocBuilder2$AddDynamicFieldTransformer\">\n" +
|
||||
|
@ -308,7 +308,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
|
|||
" </document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private final String dataConfigForSkipTransform = "<dataConfig>\n" +
|
||||
private final String dataConfigForSkipTransform = "<dataConfig> <dataSource type=\"MockDataSource\"/>\n" +
|
||||
" <document>\n" +
|
||||
" <entity name=\"books\" query=\"select * from x\"" +
|
||||
" transformer=\"TemplateTransformer\">\n" +
|
||||
|
@ -319,7 +319,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
|
|||
" </document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private final String dataConfigWithTwoEntities = "<dataConfig>\n" +
|
||||
private final String dataConfigWithTwoEntities = "<dataConfig><dataSource type=\"MockDataSource\"/>\n" +
|
||||
" <document>\n" +
|
||||
" <entity name=\"books\" query=\"select * from x\">" +
|
||||
" <field column=\"id\" />\n" +
|
||||
|
@ -331,7 +331,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
|
|||
" </document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private final String dataConfigWithCaseInsensitiveFields = "<dataConfig>\n" +
|
||||
private final String dataConfigWithCaseInsensitiveFields = "<dataConfig> <dataSource type=\"MockDataSource\"/>\n" +
|
||||
" <document onImportStart=\"TestDocBuilder2$StartEventListener\" onImportEnd=\"TestDocBuilder2$EndEventListener\">\n" +
|
||||
" <entity name=\"books\" query=\"select * from x\">\n" +
|
||||
" <field column=\"ID\" />\n" +
|
||||
|
@ -340,7 +340,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
|
|||
" </document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private final String dataConfigWithTemplatizedFieldNames = "<dataConfig>\n" +
|
||||
private final String dataConfigWithTemplatizedFieldNames = "<dataConfig><dataSource type=\"MockDataSource\"/>\n" +
|
||||
" <document>\n" +
|
||||
" <entity name=\"books\" query=\"select * from x\">\n" +
|
||||
" <field column=\"mypk\" name=\"${dih.request.mypk}\" />\n" +
|
||||
|
|
|
@ -133,6 +133,7 @@ public class TestErrorHandling extends AbstractDataImportHandlerTest {
|
|||
|
||||
private String dataConfigWithTransformer = "<dataConfig>\n" +
|
||||
" <dataSource name=\"str\" type=\"TestErrorHandling$StringDataSource\" />" +
|
||||
"<dataSource type=\"MockDataSource\"/>" +
|
||||
" <document>\n" +
|
||||
" <entity name=\"node\" dataSource=\"str\" processor=\"XPathEntityProcessor\" url=\"test\" forEach=\"/root/node\">\n" +
|
||||
" <field column=\"id\" xpath=\"/root/node/id\" />\n" +
|
||||
|
|
|
@ -218,14 +218,14 @@ public class TestSqlEntityProcessor2 extends AbstractDataImportHandlerTest {
|
|||
}
|
||||
}
|
||||
|
||||
private static String dataConfig_LastIndexTime = "<dataConfig>\n" +
|
||||
private static String dataConfig_LastIndexTime = "<dataConfig><dataSource type=\"MockDataSource\"/>\n" +
|
||||
"\t<function name=\"checkDateFormat\" class=\"org.apache.solr.handler.dataimport.TestSqlEntityProcessor2$DateFormatValidatingEvaluator\"/>\n" +
|
||||
"\t<document>\n" +
|
||||
"\t\t<entity name=\"x\" query=\"select * from x where last_modified > ${dih.functions.checkDateFormat(dih.last_index_time)}\" />\n" +
|
||||
"\t</document>\n" +
|
||||
"</dataConfig>";
|
||||
|
||||
private static String dataConfig = "<dataConfig>\n"
|
||||
private static String dataConfig = "<dataConfig><dataSource type=\"MockDataSource\"/>\n"
|
||||
+ " <document>\n"
|
||||
+ " <entity name=\"x\" pk=\"id\" query=\"select * from x\" deletedPkQuery=\"select id from x where last_modified > NOW AND deleted='true'\" deltaQuery=\"select id from x where last_modified > NOW\">\n"
|
||||
+ " <field column=\"id\" />\n"
|
||||
|
@ -234,7 +234,7 @@ public class TestSqlEntityProcessor2 extends AbstractDataImportHandlerTest {
|
|||
+ " </entity>\n" + " </entity>\n"
|
||||
+ " </document>\n" + "</dataConfig>\n";
|
||||
|
||||
private static String dataConfig_deltaimportquery = "<dataConfig>\n"
|
||||
private static String dataConfig_deltaimportquery = "<dataConfig><dataSource type=\"MockDataSource\"/>\n"
|
||||
+ " <document>\n"
|
||||
+ " <entity name=\"x\" deltaImportQuery=\"select * from x where id=${dataimporter.delta.id}\" deltaQuery=\"select id from x where last_modified > NOW\">\n"
|
||||
+ " <field column=\"id\" />\n"
|
||||
|
|
|
@ -279,7 +279,7 @@ public class TestSqlEntityProcessorDelta extends AbstractDataImportHandlerTest {
|
|||
assertQ(req("desc:goodbye"), "//*[@numFound='1']");
|
||||
}
|
||||
|
||||
private static String dataConfig_delta = "<dataConfig>\n"
|
||||
private static String dataConfig_delta = "<dataConfig><dataSource type=\"MockDataSource\"/>\n"
|
||||
+ " <document>\n"
|
||||
+ " <entity name=\"x\" transformer=\"TemplateTransformer\""
|
||||
+ " query=\"" + FULLIMPORT_QUERY + "\""
|
||||
|
|
|
@ -275,7 +275,7 @@ public class TestSqlEntityProcessorDelta2 extends AbstractDataImportHandlerTest
|
|||
assertQ(req("desc:goodbye"), "//*[@numFound='1']");
|
||||
}
|
||||
|
||||
private static String dataConfig_delta2 = "<dataConfig>\n"
|
||||
private static String dataConfig_delta2 = "<dataConfig><dataSource type=\"MockDataSource\"/>\n"
|
||||
+ " <document>\n"
|
||||
+ " <entity name=\"x\" transformer=\"TemplateTransformer\""
|
||||
+ " query=\"" + FULLIMPORT_QUERY + "\""
|
||||
|
|
|
@ -328,11 +328,6 @@
|
|||
</requestHandler>
|
||||
|
||||
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
|
||||
<lst name="defaults">
|
||||
<lst name="datasource">
|
||||
<str name="type">MockDataSource</str>
|
||||
</lst>
|
||||
</lst>
|
||||
</requestHandler>
|
||||
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<dataConfig>
|
||||
<dataSource type="MockDataSource"/>
|
||||
<document>
|
||||
<entity name="x" query="select * from x">
|
||||
<field column="id" />
|
||||
|
|
Loading…
Reference in New Issue