mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 19:15:06 +00:00
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:
parent
09e4595501
commit
4efccce1f1
@ -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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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");
|
||||||
|
@ -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()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user