This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a5f007c2302 Convert `Locale` when executing JapaneseDate related unit
tests (#29385)
a5f007c2302 is described below
commit a5f007c23024bfc3ac806c403f12a3dc5a4c47a0
Author: Ling Hengqian <[email protected]>
AuthorDate: Wed Dec 13 06:44:54 2023 +0800
Convert `Locale` when executing JapaneseDate related unit tests (#29385)
---
.../common-config/builtin-algorithm/expr.cn.md | 1 -
.../common-config/builtin-algorithm/expr.en.md | 1 -
.../IntervalInlineExpressionParserTest.java | 34 +++++++++++++---------
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git
a/docs/document/content/user-manual/common-config/builtin-algorithm/expr.cn.md
b/docs/document/content/user-manual/common-config/builtin-algorithm/expr.cn.md
index ced2b0c7120..53867413f8f 100644
---
a/docs/document/content/user-manual/common-config/builtin-algorithm/expr.cn.md
+++
b/docs/document/content/user-manual/common-config/builtin-algorithm/expr.cn.md
@@ -48,7 +48,6 @@ weight = 10
6. `DU` 代表 datetime upper 的缩写,意为时间上界值,格式与 `SP` 定义的时间戳格式一致。
7. `C` 代表 chronology 的缩写,意为日历系统,必须遵循 Java
`java.time.chrono.Chronology#getId()` 的格式。
例如:`Japanese`,`Minguo`,`ThaiBuddhist`。存在默认值为 `ISO`。
-受 https://bugs.openjdk.org/browse/JDK-8068571 影响,`Japanese` 仅在 JDK 11+ 上可用。
类型:INTERVAL
diff --git
a/docs/document/content/user-manual/common-config/builtin-algorithm/expr.en.md
b/docs/document/content/user-manual/common-config/builtin-algorithm/expr.en.md
index 1b66ad46d95..4bfa4e9c914 100644
---
a/docs/document/content/user-manual/common-config/builtin-algorithm/expr.en.md
+++
b/docs/document/content/user-manual/common-config/builtin-algorithm/expr.en.md
@@ -56,7 +56,6 @@ It must follow the enumeration value of Java
`java.time.temporal.ChronoUnit#toSt
6. `DU` stands for the abbreviation of datetime upper, which means the upper
bound value of time. The format is consistent with the timestamp format defined
by `SP`.
7. `C` stands for the abbreviation of chronology, which means calendar system
and must follow the format of Java `java.time.chrono.Chronology#getId()`.
For example: `Japanese`, `Minguo`, `ThaiBuddhist`. There is a default value of
`ISO`.
-Affected by https://bugs.openjdk.org/browse/JDK-8068571, `Japanese` is only
available on JDK 11+.
Type: INTERVAL
diff --git
a/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
b/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
index 438e4c39108..01758a4a748 100644
---
a/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
+++
b/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
@@ -21,10 +21,9 @@ import
org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledForJreRange;
-import org.junit.jupiter.api.condition.JRE;
import java.util.List;
+import java.util.Locale;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
@@ -84,21 +83,28 @@ public class IntervalInlineExpressionParserTest {
/**
* Background reference <a
href="https://bugs.openjdk.org/browse/JDK-8068571">JDK-8068571</a>.
- * Unable to parse `GGGGyy_MM_dd` due to OpenJDK 21.0.1 limitation.
+ * Unable to parse `GGGGyy_MM_dd` due to {@link
java.time.chrono.JapaneseChronology} limitation.
+ *
+ * @see java.time.chrono.JapaneseChronology
*/
@Test
- @EnabledForJreRange(min = JRE.JAVA_11, max = JRE.OTHER)
void assertEvaluateForJapaneseDate() {
- List<String> expectedBYGGGGyyyy =
getResultList("P=ds-0.t_order_;SP=GGGGyyyy_MM_dd;DIA=1;DIU=Days;DL=平成0001_12_05;DU=平成0001_12_06;C=Japanese");
- assertThat(expectedBYGGGGyyyy.size(), is(2));
- assertThat(expectedBYGGGGyyyy, hasItems("ds-0.t_order_平成0001_12_05",
"ds-0.t_order_平成0001_12_06"));
- List<String> expectedByGGGGyyy =
getResultList("P=ds-0.t_order_;SP=GGGGyyy_MM_dd;DIA=1;DIU=Days;DL=平成001_12_05;DU=平成001_12_06;C=Japanese");
- assertThat(expectedByGGGGyyy.size(), is(2));
- assertThat(expectedByGGGGyyy, hasItems("ds-0.t_order_平成001_12_05",
"ds-0.t_order_平成001_12_06"));
- List<String> expectedByGGGGy =
getResultList("P=ds-0.t_order_;SP=GGGGy_MM_dd;DIA=1;DIU=Days;DL=平成1_12_05;DU=平成1_12_06;C=Japanese");
- assertThat(expectedByGGGGy.size(), is(2));
- assertThat(expectedByGGGGy, hasItems("ds-0.t_order_平成1_12_05",
"ds-0.t_order_平成1_12_06"));
- assertThrows(RuntimeException.class, () ->
getResultList("P=ds-0.t_order_;SP=GGGGyy_MM_dd;DIA=1;DIU=Days;DL=平成01_12_05;DU=平成01_12_06;C=Japanese"));
+ Locale originLocale = Locale.getDefault();
+ try {
+ Locale.setDefault(Locale.JAPAN);
+ List<String> expectedBYGGGGyyyy =
getResultList("P=ds-0.t_order_;SP=GGGGyyyy_MM_dd;DIA=1;DIU=Days;DL=平成0001_12_05;DU=平成0001_12_06;C=Japanese");
+ assertThat(expectedBYGGGGyyyy.size(), is(2));
+ assertThat(expectedBYGGGGyyyy,
hasItems("ds-0.t_order_平成0001_12_05", "ds-0.t_order_平成0001_12_06"));
+ List<String> expectedByGGGGyyy =
getResultList("P=ds-0.t_order_;SP=GGGGyyy_MM_dd;DIA=1;DIU=Days;DL=平成001_12_05;DU=平成001_12_06;C=Japanese");
+ assertThat(expectedByGGGGyyy.size(), is(2));
+ assertThat(expectedByGGGGyyy, hasItems("ds-0.t_order_平成001_12_05",
"ds-0.t_order_平成001_12_06"));
+ List<String> expectedByGGGGy =
getResultList("P=ds-0.t_order_;SP=GGGGy_MM_dd;DIA=1;DIU=Days;DL=平成1_12_05;DU=平成1_12_06;C=Japanese");
+ assertThat(expectedByGGGGy.size(), is(2));
+ assertThat(expectedByGGGGy, hasItems("ds-0.t_order_平成1_12_05",
"ds-0.t_order_平成1_12_06"));
+ assertThrows(RuntimeException.class, () ->
getResultList("P=ds-0.t_order_;SP=GGGGyy_MM_dd;DIA=1;DIU=Days;DL=平成01_12_05;DU=平成01_12_06;C=Japanese"));
+ } finally {
+ Locale.setDefault(originLocale);
+ }
}
private List<String> getResultList(final String inlineExpression) {