This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new b4989ed851c Fix/build issues outside of china
b4989ed851c is described below
commit b4989ed851c544ad1647eca01b6b4a107e2a466d
Author: Christofer Dutz <[email protected]>
AuthorDate: Wed May 29 03:59:28 2024 +0200
Fix/build issues outside of china
---
.../iotdb/it/env/cluster/config/MppJVMConfig.java | 18 ++
.../it/env/cluster/node/AbstractNodeWrapper.java | 1 +
.../it/env/cluster/node/ConfigNodeWrapper.java | 1 +
.../iotdb/it/framework/IoTDBTestReporter.java | 9 +-
.../org/apache/iotdb/db/it/IoTDBFlushQueryIT.java | 7 +-
.../it/query/IoTDBSelectCompareExpressionIT.java | 10 +-
.../apache/iotdb/it/framework/IoTDBTestRunner.java | 3 +
.../filter/AbstractMonthIntervalFillFilter.java | 5 -
.../fill/filter/MonthIntervalMSFillFilter.java | 8 +-
.../fill/filter/MonthIntervalNSFillFilter.java | 12 +-
.../fill/filter/MonthIntervalUSFillFilter.java | 10 +-
.../aggregation/TimeRangeIteratorTest.java | 229 +++++++++++----------
12 files changed, 182 insertions(+), 131 deletions(-)
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppJVMConfig.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppJVMConfig.java
index 1f7a148d2d8..d9c51717cf8 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppJVMConfig.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppJVMConfig.java
@@ -28,6 +28,7 @@ public class MppJVMConfig implements JVMConfig {
private int initHeapSize;
private int maxHeapSize;
private int maxDirectMemorySize;
+ private String timezone;
@Override
public JVMConfig setInitHeapSize(int initSize) {
@@ -52,6 +53,13 @@ public class MppJVMConfig implements JVMConfig {
return this;
}
+ public JVMConfig setTimezone(String timezone) {
+ if (timezone != null) {
+ this.timezone = timezone;
+ }
+ return this;
+ }
+
public int getInitHeapSize() {
return initHeapSize;
}
@@ -64,6 +72,10 @@ public class MppJVMConfig implements JVMConfig {
return maxDirectMemorySize;
}
+ public String getTimezone() {
+ return timezone;
+ }
+
private void validate() {
if (initHeapSize > maxHeapSize) {
throw new IllegalArgumentException(
@@ -81,6 +93,7 @@ public class MppJVMConfig implements JVMConfig {
this.setInitHeapSize(config.getInitHeapSize());
this.setMaxHeapSize(config.getMaxHeapSize());
this.setMaxDirectMemorySize(config.getMaxDirectMemorySize());
+ this.setTimezone(config.getTimezone());
}
public static Builder builder() {
@@ -109,6 +122,11 @@ public class MppJVMConfig implements JVMConfig {
return this;
}
+ public Builder setTimezone(String timezone) {
+ this.config.setTimezone(timezone);
+ return this;
+ }
+
public MppJVMConfig build() {
config.validate();
return config;
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
index 45a1188a4ca..ab14613fc41 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
@@ -453,6 +453,7 @@ public abstract class AbstractNodeWrapper implements
BaseNodeWrapper {
"-Djava.rmi.server.hostname=" + getIp(),
"-Xms" + jvmConfig.getInitHeapSize() + "m",
"-Xmx" + jvmConfig.getMaxHeapSize() + "m",
+ "-Duser.timezone=" + jvmConfig.getTimezone(),
"-XX:MaxDirectMemorySize=" + jvmConfig.getMaxDirectMemorySize()
+ "m",
"-Djdk.nio.maxCachedBufferSize=262144",
"-D" + IoTDBConstant.INTEGRATION_TEST_KILL_POINTS + "=" +
killPoints.toString(),
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/ConfigNodeWrapper.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/ConfigNodeWrapper.java
index 91a53b04e0e..8cbffe06060 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/ConfigNodeWrapper.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/ConfigNodeWrapper.java
@@ -121,6 +121,7 @@ public class ConfigNodeWrapper extends AbstractNodeWrapper {
.setMaxHeapSize(EnvUtils.getIntFromSysVar(CONFIG_NODE_MAX_HEAP_SIZE,
256, clusterIndex))
.setMaxDirectMemorySize(
EnvUtils.getIntFromSysVar(CONFIG_NODE_MAX_DIRECT_MEMORY_SIZE, 256,
clusterIndex))
+ .setTimezone("Asia/Shanghai")
.build();
}
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/framework/IoTDBTestReporter.java
b/integration-test/src/main/java/org/apache/iotdb/it/framework/IoTDBTestReporter.java
index bab2b030fdd..53d33d35570 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/framework/IoTDBTestReporter.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/framework/IoTDBTestReporter.java
@@ -24,9 +24,12 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.text.NumberFormat;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.stream.Stream;
public class IoTDBTestReporter {
@@ -52,11 +55,13 @@ public class IoTDBTestReporter {
for (String l : lines) {
String[] parts = l.split("\t");
if (parts.length == 2) {
- IoTDBTestStat stat = new IoTDBTestStat(parts[1],
Double.parseDouble(parts[0]));
+ NumberFormat f =
NumberFormat.getInstance(Locale.getDefault());
+ double seconds = f.parse(parts[0]).doubleValue();
+ IoTDBTestStat stat = new IoTDBTestStat(parts[1], seconds);
stats.add(stat);
}
}
- } catch (IOException e) {
+ } catch (IOException | ParseException e) {
IoTDBTestLogger.logger.error("read stats file failed", e);
}
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFlushQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFlushQueryIT.java
index c0b063bacbf..3eb48614513 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFlushQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFlushQueryIT.java
@@ -35,6 +35,7 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Locale;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -113,14 +114,14 @@ public class IoTDBFlushQueryIT {
for (int i = 1; i <= 3; i++) {
for (int j = 10; j < 20; j++) {
- statement.execute(String.format(insertTemplate, i, j, j, j * 0.1,
j));
+ statement.execute(String.format(Locale.CHINA, insertTemplate, i, j,
j, j * 0.1, j));
}
}
statement.execute("FLUSH");
for (int i = 1; i <= 3; i++) {
for (int j = 0; j < 10; j++) {
- statement.execute(String.format(insertTemplate, i, j, j, j * 0.1,
j));
+ statement.execute(String.format(Locale.CHINA, insertTemplate, i, j,
j, j * 0.1, j));
}
}
statement.execute("FLUSH root.group1");
@@ -128,7 +129,7 @@ public class IoTDBFlushQueryIT {
for (int i = 1; i <= 3; i++) {
for (int j = 0; j < 30; j++) {
- statement.execute(String.format(insertTemplate, i, j, j, j * 0.1,
j));
+ statement.execute(String.format(Locale.CHINA, insertTemplate, i, j,
j, j * 0.1, j));
}
}
statement.execute("FLUSH root.group1 TRUE");
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBSelectCompareExpressionIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBSelectCompareExpressionIT.java
index 942357ca2ab..ddddf58725f 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBSelectCompareExpressionIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBSelectCompareExpressionIT.java
@@ -36,6 +36,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Random;
import static org.junit.Assert.assertEquals;
@@ -83,8 +84,15 @@ public class IoTDBSelectCompareExpressionIT {
boolean boolValue,
String _text) {
return String.format(
+ Locale.CHINA,
"insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (%d, %d,
%d, %f, %f, %s, %s);",
- time, intValue32, intValue64, floatValue, doubleValue, boolValue ?
"true" : "false", _text);
+ time,
+ intValue32,
+ intValue64,
+ floatValue,
+ doubleValue,
+ boolValue ? "true" : "false",
+ _text);
}
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
index ebd5c05273e..07e04514688 100644
---
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
+++
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
@@ -30,6 +30,8 @@ import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.slf4j.Logger;
+import java.util.TimeZone;
+
public class IoTDBTestRunner extends BlockJUnit4ClassRunner {
private static final Logger logger = IoTDBTestLogger.logger;
@@ -41,6 +43,7 @@ public class IoTDBTestRunner extends BlockJUnit4ClassRunner {
@Override
public void run(RunNotifier notifier) {
+ TimeZone.setDefault(TimeZone.getTimeZone("Bejing"));
listener = new IoTDBTestListener(this.getName());
notifier.addListener(listener);
super.run(notifier);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
index 99d5792eb26..24a629189ab 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
@@ -21,9 +21,7 @@ package
org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
import
org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFillFilter;
-import java.time.Instant;
import java.time.ZoneId;
-import java.time.ZoneOffset;
public abstract class AbstractMonthIntervalFillFilter implements IFillFilter {
@@ -35,12 +33,9 @@ public abstract class AbstractMonthIntervalFillFilter
implements IFillFilter {
// non-month part of time duration, its precision is same as current
time_precision
protected final long nonMonthDuration;
- protected final ZoneOffset zoneOffset;
-
AbstractMonthIntervalFillFilter(int monthDuration, long nonMonthDuration,
ZoneId zone) {
this.monthDuration = monthDuration;
this.nonMonthDuration = nonMonthDuration;
this.zone = zone;
- this.zoneOffset = zone.getRules().getOffset(Instant.now());
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
index ff601056914..c8e56a8cca9 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
@@ -22,6 +22,7 @@ package
org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.ZoneOffset;
public class MonthIntervalMSFillFilter extends AbstractMonthIntervalFillFilter
{
@@ -33,10 +34,11 @@ public class MonthIntervalMSFillFilter extends
AbstractMonthIntervalFillFilter {
public boolean needFill(long time, long previousTime) {
long smaller = Math.min(time, previousTime);
long greater = Math.max(time, previousTime);
- Instant instant = Instant.ofEpochMilli(smaller);
- LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
+ Instant smallerInstant = Instant.ofEpochMilli(smaller);
+ LocalDateTime smallerDateTime = LocalDateTime.ofInstant(smallerInstant,
zone);
+ ZoneOffset smallerOffset =
zone.getRules().getStandardOffset(smallerInstant);
long epochMilli =
-
localDateTime.plusMonths(monthDuration).toInstant(zoneOffset).toEpochMilli()
+
smallerDateTime.plusMonths(monthDuration).toInstant(smallerOffset).toEpochMilli()
+ nonMonthDuration;
return epochMilli >= greater;
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
index 563fb941eb7..b2c389a1d87 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
@@ -22,6 +22,7 @@ package
org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
public class MonthIntervalNSFillFilter extends AbstractMonthIntervalFillFilter
{
@@ -34,10 +35,15 @@ public class MonthIntervalNSFillFilter extends
AbstractMonthIntervalFillFilter {
public boolean needFill(long time, long previousTime) {
long smaller = Math.min(time, previousTime);
long greater = Math.max(time, previousTime);
- Instant instant = Instant.ofEpochSecond(smaller / 1_000_000_000L, smaller
% 1_000_000_000L);
- LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
+ Instant smallerInstant =
+ Instant.ofEpochSecond(smaller / 1_000_000_000L, smaller %
1_000_000_000L);
+ LocalDateTime smallerDateTime = LocalDateTime.ofInstant(smallerInstant,
zone);
+ ZoneOffset smallerOffset =
zone.getRules().getStandardOffset(smallerInstant);
Instant upper =
-
localDateTime.plusMonths(monthDuration).plusNanos(nonMonthDuration).toInstant(zoneOffset);
+ smallerDateTime
+ .plusMonths(monthDuration)
+ .plusNanos(nonMonthDuration)
+ .toInstant(smallerOffset);
long timeInNs =
upper.getLong(ChronoField.NANO_OF_SECOND) + upper.getEpochSecond() *
1_000_000_000L;
return timeInNs >= greater;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
index afde3e5141f..c99ede2702e 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
@@ -22,6 +22,7 @@ package
org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
import static java.time.temporal.ChronoUnit.MICROS;
@@ -36,13 +37,14 @@ public class MonthIntervalUSFillFilter extends
AbstractMonthIntervalFillFilter {
public boolean needFill(long time, long previousTime) {
long smaller = Math.min(time, previousTime);
long greater = Math.max(time, previousTime);
- Instant instant = Instant.ofEpochSecond(smaller / 1_000_000L, smaller %
1_000_000L);
- LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
+ Instant smallerInstant = Instant.ofEpochSecond(smaller / 1_000_000L,
smaller % 1_000_000L);
+ LocalDateTime smallerDateTime = LocalDateTime.ofInstant(smallerInstant,
zone);
+ ZoneOffset smallerOffset =
zone.getRules().getStandardOffset(smallerInstant);
Instant upper =
- localDateTime
+ smallerDateTime
.plusMonths(monthDuration)
.plus(nonMonthDuration, MICROS)
- .toInstant(zoneOffset);
+ .toInstant(smallerOffset);
long timeInUs =
upper.getLong(ChronoField.MICRO_OF_SECOND) + upper.getEpochSecond() *
1_000_000L;
return timeInUs >= greater;
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java
index f2f38a7b5f5..489e2fb9b86 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java
@@ -28,6 +28,7 @@ import org.junit.Assert;
import org.junit.Test;
import java.sql.Timestamp;
+import java.util.TimeZone;
public class TimeRangeIteratorTest {
private static final long MS_TO_DAY = 86400_000L;
@@ -218,116 +219,124 @@ public class TimeRangeIteratorTest {
@Test
public void testNaturalMonthTimeRange() {
- String[] res1 = {
- "[ 1604102400000 : 1606694399999 ]",
- "[ 1606694400000 : 1609372799999 ]",
- "[ 1609372800000 : 1612051199999 ]",
- "[ 1612051200000 : 1614470399999 ]",
- "[ 1614470400000 : 1617148799999 ]"
- };
- String[] res2 = {
- "[ 1604102400000 : 1604966399999 ]",
- "[ 1606694400000 : 1607558399999 ]",
- "[ 1609372800000 : 1610236799999 ]",
- "[ 1612051200000 : 1612915199999 ]",
- "[ 1614470400000 : 1615334399999 ]"
- };
- String[] res3 = {
- "[ 1604102400000 : 1606694399999 ]",
- "[ 1604966400000 : 1607558399999 ]",
- "[ 1605830400000 : 1608422399999 ]",
- "[ 1606694400000 : 1609286399999 ]",
- "[ 1607558400000 : 1610150399999 ]",
- "[ 1608422400000 : 1611014399999 ]",
- "[ 1609286400000 : 1611878399999 ]",
- "[ 1610150400000 : 1612742399999 ]",
- "[ 1611014400000 : 1613606399999 ]",
- "[ 1611878400000 : 1614470399999 ]",
- "[ 1612742400000 : 1615334399999 ]",
- "[ 1613606400000 : 1616198399999 ]",
- "[ 1614470400000 : 1617062399999 ]",
- "[ 1615334400000 : 1617148799999 ]",
- "[ 1616198400000 : 1617148799999 ]",
- "[ 1617062400000 : 1617148799999 ]"
- };
- String[] res4 = {
- "[ 1604102400000 : 1604966399999 ]",
- "[ 1604966400000 : 1605830399999 ]",
- "[ 1605830400000 : 1606694399999 ]",
- "[ 1606694400000 : 1607558399999 ]",
- "[ 1607558400000 : 1608422399999 ]",
- "[ 1608422400000 : 1609286399999 ]",
- "[ 1609286400000 : 1610150399999 ]",
- "[ 1610150400000 : 1611014399999 ]",
- "[ 1611014400000 : 1611878399999 ]",
- "[ 1611878400000 : 1612742399999 ]",
- "[ 1612742400000 : 1613606399999 ]",
- "[ 1613606400000 : 1614470399999 ]",
- "[ 1614470400000 : 1615334399999 ]",
- "[ 1615334400000 : 1616198399999 ]",
- "[ 1616198400000 : 1617062399999 ]",
- "[ 1617062400000 : 1617148799999 ]"
- };
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(1, 0),
- new TimeDuration(1, 0),
- true,
- true,
- false),
- res1);
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(1, 0),
- new TimeDuration(1, 0),
- true,
- true,
- true),
- res1);
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(0, 10 * MS_TO_DAY),
- new TimeDuration(1, 0),
- true,
- true,
- false),
- res2);
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(0, 10 * MS_TO_DAY),
- new TimeDuration(1, 0),
- true,
- true,
- true),
- res2);
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(1, 0),
- new TimeDuration(0, 10 * MS_TO_DAY),
- true,
- true,
- false),
- res3);
- checkRes(
- TimeRangeIteratorFactory.getTimeRangeIterator(
- 1604102400000L,
- 1617148800000L,
- new TimeDuration(1, 0),
- new TimeDuration(0, 10 * MS_TO_DAY),
- true,
- true,
- true),
- res4);
+ // The following test results greatly depend on the timezone the test is
run in.
+ TimeZone oldDefault = TimeZone.getDefault();
+ try {
+ TimeZone.setDefault(TimeZone.getTimeZone("Bejing"));
+
+ String[] res1 = {
+ "[ 1604102400000 : 1606694399999 ]",
+ "[ 1606694400000 : 1609372799999 ]",
+ "[ 1609372800000 : 1612051199999 ]",
+ "[ 1612051200000 : 1614470399999 ]",
+ "[ 1614470400000 : 1617148799999 ]"
+ };
+ String[] res2 = {
+ "[ 1604102400000 : 1604966399999 ]",
+ "[ 1606694400000 : 1607558399999 ]",
+ "[ 1609372800000 : 1610236799999 ]",
+ "[ 1612051200000 : 1612915199999 ]",
+ "[ 1614470400000 : 1615334399999 ]"
+ };
+ String[] res3 = {
+ "[ 1604102400000 : 1606694399999 ]",
+ "[ 1604966400000 : 1607558399999 ]",
+ "[ 1605830400000 : 1608422399999 ]",
+ "[ 1606694400000 : 1609286399999 ]",
+ "[ 1607558400000 : 1610150399999 ]",
+ "[ 1608422400000 : 1611014399999 ]",
+ "[ 1609286400000 : 1611878399999 ]",
+ "[ 1610150400000 : 1612742399999 ]",
+ "[ 1611014400000 : 1613606399999 ]",
+ "[ 1611878400000 : 1614470399999 ]",
+ "[ 1612742400000 : 1615334399999 ]",
+ "[ 1613606400000 : 1616198399999 ]",
+ "[ 1614470400000 : 1617062399999 ]",
+ "[ 1615334400000 : 1617148799999 ]",
+ "[ 1616198400000 : 1617148799999 ]",
+ "[ 1617062400000 : 1617148799999 ]"
+ };
+ String[] res4 = {
+ "[ 1604102400000 : 1604966399999 ]",
+ "[ 1604966400000 : 1605830399999 ]",
+ "[ 1605830400000 : 1606694399999 ]",
+ "[ 1606694400000 : 1607558399999 ]",
+ "[ 1607558400000 : 1608422399999 ]",
+ "[ 1608422400000 : 1609286399999 ]",
+ "[ 1609286400000 : 1610150399999 ]",
+ "[ 1610150400000 : 1611014399999 ]",
+ "[ 1611014400000 : 1611878399999 ]",
+ "[ 1611878400000 : 1612742399999 ]",
+ "[ 1612742400000 : 1613606399999 ]",
+ "[ 1613606400000 : 1614470399999 ]",
+ "[ 1614470400000 : 1615334399999 ]",
+ "[ 1615334400000 : 1616198399999 ]",
+ "[ 1616198400000 : 1617062399999 ]",
+ "[ 1617062400000 : 1617148799999 ]"
+ };
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(1, 0),
+ new TimeDuration(1, 0),
+ true,
+ true,
+ false),
+ res1);
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(1, 0),
+ new TimeDuration(1, 0),
+ true,
+ true,
+ true),
+ res1);
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(0, 10 * MS_TO_DAY),
+ new TimeDuration(1, 0),
+ true,
+ true,
+ false),
+ res2);
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(0, 10 * MS_TO_DAY),
+ new TimeDuration(1, 0),
+ true,
+ true,
+ true),
+ res2);
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(1, 0),
+ new TimeDuration(0, 10 * MS_TO_DAY),
+ true,
+ true,
+ false),
+ res3);
+ checkRes(
+ TimeRangeIteratorFactory.getTimeRangeIterator(
+ 1604102400000L,
+ 1617148800000L,
+ new TimeDuration(1, 0),
+ new TimeDuration(0, 10 * MS_TO_DAY),
+ true,
+ true,
+ true),
+ res4);
+ } finally {
+ TimeZone.setDefault(oldDefault);
+ }
}
@Test