Skip to content

Commit

Permalink
Reproduce NOD pass situation
Browse files Browse the repository at this point in the history
  • Loading branch information
rRajivramachandran committed Nov 11, 2023
1 parent 62aac18 commit 6146f53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
<version>3.8.0</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
<dependencies>
<dependency>
Expand Down Expand Up @@ -154,7 +154,7 @@
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/CustomSuiteTest.java</include>
<include>**/bvt/**/*.java</include>
</includes>
</configuration>
</plugin>
Expand Down
19 changes: 17 additions & 2 deletions src/test/java/com/alibaba/json/bvt/issue_2700/Issue2784.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,31 @@
public class Issue2784 extends TestCase {
public void test_for_issue() throws Exception {
Model m = new Model();
m.time = java.time.LocalDateTime.now();
m.time = waitUntilZeroBeyondMillis();

String str = JSON.toJSONString(m);
assertEquals("{\"time\":"
+ m.time.atZone(JSON.defaultTimeZone.toZoneId()).toInstant().toEpochMilli()
+ "}", str);

Model m1 = JSON.parseObject(str, Model.class);
assertEquals(m.time, m1.time);
}

private static LocalDateTime waitUntilZeroBeyondMillis() throws InterruptedException {
while (true) {
LocalDateTime currentTime = LocalDateTime.now();
ZonedDateTime zoned = currentTime.atZone(JSON.defaultTimeZone.toZoneId());

System.out.println("SEC:"+zoned.toInstant().getNano() % 1000000);
if (zoned.toInstant().getNano() % 1000000 == 0 ) {
return currentTime;
}

// Wait for a short interval before checking again
Thread.sleep(10);
}
}

public void test_for_issue_1() throws Exception {
Model m = new Model();
m.ztime = ZonedDateTime.now();
Expand Down

0 comments on commit 6146f53

Please sign in to comment.