Skip to content

Commit c3ab6f7

Browse files
author
Christoph Büscher
authored
Add note how to run locale sensitive unit test (#49491)
Some unit test checking locale sensitive functionality require the -Djava.locale.providers=SPI,COMPAT flag to be set. When running tests though gradle we pass this already to the BuildPlugin, but running from the IDE this might need to be set manually. Adding a note explaining this to the CONTRIBUTING.md doc and leaving a note in the test comment of SearchQueryIT.testRangeQueryWithLocaleMapping which is a test we know that suffers from this issue.
1 parent 4f1ebfa commit c3ab6f7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ For IntelliJ, go to
153153
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
154154
`VM Arguments`.
155155

156+
Some tests related to locale testing also require the flag
157+
`-Djava.locale.providers` to be set. Set the VM options/VM arguments for
158+
IntelliJ or Eclipse like describe above to use
159+
`-Djava.locale.providers=SPI,COMPAT`.
156160

157161
### Java Language Formatting Guidelines
158162

server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,18 @@ public void testRangeQueryWithTimeZone() throws Exception {
15691569
assertThat(searchResponse.getHits().getAt(0).getId(), is("4"));
15701570
}
15711571

1572+
/**
1573+
* Test range with a custom locale, e.g. "de" in this case. Documents here mention the day of week
1574+
* as "Mi" for "Mittwoch (Wednesday" and "Do" for "Donnerstag (Thursday)" and the month in the query
1575+
* as "Dez" for "Dezember (December)".
1576+
* Note: this test currently needs the JVM arg `-Djava.locale.providers=SPI,COMPAT` to be set.
1577+
* When running with gradle this is done implicitly through the BuildPlugin, but when running from
1578+
* an IDE this might need to be set manually in the run configuration. See also CONTRIBUTING.md section
1579+
* on "Configuring IDEs And Running Tests".
1580+
*/
15721581
public void testRangeQueryWithLocaleMapping() throws Exception {
15731582
assumeTrue("need java 9 for testing ",JavaVersion.current().compareTo(JavaVersion.parse("9")) >= 0);
1583+
assert ("SPI,COMPAT".equals(System.getProperty("java.locale.providers"))) : "`-Djava.locale.providers=SPI,COMPAT` needs to be set";
15741584

15751585
assertAcked(prepareCreate("test")
15761586
.addMapping("type1", jsonBuilder().startObject().startObject("properties").startObject("date_field")

0 commit comments

Comments
 (0)