Skip to content

Commit

Permalink
Added test case for java.sql.Date
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstadler committed Jun 21, 2022
1 parent 61ded9a commit f3f2d52
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/src/test/java/org/apache/struts2/components/DateTest.java
Expand Up @@ -81,6 +81,28 @@ public void testDefaultFormat() {
assertEquals(expected, writer.toString());
}

public void testJavaSqlDate() {
// given
Date date = new Date(stack);
date.setDateFormatter(new SimpleDateFormatAdapter());

java.sql.Date now = new java.sql.Date(System.currentTimeMillis());

String expected = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, ActionContext.getContext().getLocale()).format(now);
context.put("myDate", now);

Writer writer = new StringWriter();

// when
date.setName("myDate");
date.setNice(false);
date.start(writer);
date.end(writer, "");

// then
assertEquals(expected, writer.toString());
}

@Override
public void setUp() throws Exception {
super.setUp();
Expand Down

0 comments on commit f3f2d52

Please sign in to comment.