This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/main by this push:
new 0956cd3cc WW-5686 test(core): stop DateTest.testJavaSqlDate racing the
clock (#1929)
0956cd3cc is described below
commit 0956cd3cceeaa67bc34433287a51b7807e8466fb
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sun Sep 13 16:54:36 2026 +0200
WW-5686 test(core): stop DateTest.testJavaSqlDate racing the clock (#1929)
Date.end completes a java.sql.Date with LocalTime.now(), while the test
built its expected string from a java.sql.Date captured moments earlier,
so the two disagreed whenever the wall clock crossed a second boundary.
Use a fixed value and a date-only format: the test now asserts the part
of the output the value actually determines. The rendering itself is
unchanged here; restoring start-of-day is WW-5738 at 8.0.0.
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
core/src/test/java/org/apache/struts2/components/DateTest.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/core/src/test/java/org/apache/struts2/components/DateTest.java
b/core/src/test/java/org/apache/struts2/components/DateTest.java
index 03d5dd564..ec7004478 100644
--- a/core/src/test/java/org/apache/struts2/components/DateTest.java
+++ b/core/src/test/java/org/apache/struts2/components/DateTest.java
@@ -87,21 +87,19 @@ public class DateTest extends StrutsInternalTestCase {
Date date = new Date(stack);
date.setDateFormatter(new SimpleDateFormatAdapter());
- java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
-
- String expected = prepareFormat().format(now);
- context.put("myDate", now);
+ context.put("myDate", java.sql.Date.valueOf("2024-03-15"));
Writer writer = new StringWriter();
// when
date.setName("myDate");
date.setNice(false);
+ date.setFormat("yyyy-MM-dd");
date.start(writer);
date.end(writer, "");
// then
- assertEquals(expected, writer.toString());
+ assertEquals("2024-03-15", writer.toString());
}
public void testJavaSqlTime() {