LUCENE-6978: Fix usage of Locale#toString in DIH

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1726311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2016-01-22 21:05:40 +00:00
parent 09e4595501
commit 4efccce1f1
3 changed files with 7 additions and 7 deletions

View File

@ -135,14 +135,14 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH", defaultLocale); SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH", defaultLocale);
String sdf = sdfDate.format(twoDaysAgo(defaultLocale, TimeZone.getDefault())); String sdf = sdfDate.format(twoDaysAgo(defaultLocale, TimeZone.getDefault()));
String dfe = dateFormatEval.evaluate( String dfe = dateFormatEval.evaluate(
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale + "'", context); "'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale.toLanguageTag() + "'", context);
assertEquals(sdf,dfe); assertEquals(sdf,dfe);
for(String tzStr : TimeZone.getAvailableIDs()) { for(String tzStr : TimeZone.getAvailableIDs()) {
TimeZone tz = TimeZone.getTimeZone(tzStr); TimeZone tz = TimeZone.getTimeZone(tzStr);
sdfDate.setTimeZone(tz); sdfDate.setTimeZone(tz);
sdf = sdfDate.format(twoDaysAgo(defaultLocale, tz)); sdf = sdfDate.format(twoDaysAgo(defaultLocale, tz));
dfe = dateFormatEval.evaluate( dfe = dateFormatEval.evaluate(
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale + "','" + tzStr + "'", context); "'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale.toLanguageTag() + "','" + tzStr + "'", context);
assertEquals(sdf,dfe); assertEquals(sdf,dfe);
} }
} }
@ -157,7 +157,7 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", context)); dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", context));
assertEquals( assertEquals(
new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale).format(d), new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale).format(d),
dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale + "'", context)); dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale.toLanguageTag() + "'", context));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale);
for(String tzStr : TimeZone.getAvailableIDs()) { for(String tzStr : TimeZone.getAvailableIDs()) {
TimeZone tz = TimeZone.getTimeZone(tzStr); TimeZone tz = TimeZone.getTimeZone(tzStr);
@ -165,7 +165,7 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
assertEquals( assertEquals(
sdf.format(d), sdf.format(d),
dateFormatEval.evaluate( dateFormatEval.evaluate(
"A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale + "', '" + tzStr + "'", context)); "A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale.toLanguageTag() + "', '" + tzStr + "'", context));
} }

View File

@ -64,7 +64,7 @@ public class TestVariableResolverEndToEnd extends AbstractDIHJdbcTestCase {
@Override @Override
protected String generateConfig() { protected String generateConfig() {
String thirdLocaleParam = random().nextBoolean() ? "" : (", '" + Locale.getDefault() + "'"); String thirdLocaleParam = random().nextBoolean() ? "" : (", '" + Locale.getDefault().toLanguageTag() + "'");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<dataConfig> \n"); sb.append("<dataConfig> \n");
sb.append("<dataSource name=\"hsqldb\" driver=\"${dataimporter.request.dots.in.hsqldb.driver}\" url=\"jdbc:hsqldb:mem:.\" /> \n"); sb.append("<dataSource name=\"hsqldb\" driver=\"${dataimporter.request.dots.in.hsqldb.driver}\" url=\"jdbc:hsqldb:mem:.\" /> \n");

View File

@ -163,7 +163,7 @@ public final class SolrCellBuilder implements CommandBuilder {
} }
this.solrContentHandlerFactory = getSolrContentHandlerFactory(factoryClass, dateFormats, config); this.solrContentHandlerFactory = getSolrContentHandlerFactory(factoryClass, dateFormats, config);
this.locale = getLocale(getConfigs().getString(config, "locale", "")); this.locale = getLocale(getConfigs().getString(config, "locale", null));
this.mediaTypeToParserMap = new HashMap<>(); this.mediaTypeToParserMap = new HashMap<>();
//MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes(); // FIXME getMediaTypeRegistry.normalize() //MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes(); // FIXME getMediaTypeRegistry.normalize()
@ -329,7 +329,7 @@ public final class SolrCellBuilder implements CommandBuilder {
@SuppressForbidden(reason = "Usage of outdated locale parsing with Locale#toString() because of backwards compatibility") @SuppressForbidden(reason = "Usage of outdated locale parsing with Locale#toString() because of backwards compatibility")
private Locale getLocale(String name) { private Locale getLocale(String name) {
if (name == null || name.isEmpty()) { if (name == null) {
return Locale.ROOT; return Locale.ROOT;
} }
for (Locale locale : Locale.getAvailableLocales()) { for (Locale locale : Locale.getAvailableLocales()) {