66import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
77import static org .springframework .test .web .servlet .setup .MockMvcBuilders .standaloneSetup ;
88
9+ import java .util .Date ;
10+ import java .util .TimeZone ;
11+
912import org .junit .Before ;
1013import org .junit .Test ;
1114import org .springframework .format .support .DefaultFormattingConversionService ;
1417
1518public class ConvertControllerTests {
1619
20+ private static String TIMEZONE ;
21+
22+ static {
23+ TimeZone timezone = TimeZone .getDefault ();
24+ boolean inDaylight = timezone .inDaylightTime (new Date ());
25+ TIMEZONE = TimeZone .getDefault ().getDisplayName (inDaylight , TimeZone .SHORT );
26+ }
27+
1728 private MockMvc mockMvc ;
1829
1930 @ Before
@@ -36,7 +47,7 @@ public void primitive() throws Exception {
3647 @ Test
3748 public void date () throws Exception {
3849 this .mockMvc .perform (get ("/convert/date/2010-07-04" ))
39- .andExpect (content ().string ("Converted date Sun Jul 04 00:00:00 EDT 2010" ));
50+ .andExpect (content ().string ("Converted date Sun Jul 04 00:00:00 " + TIMEZONE + " 2010" ));
4051 }
4152
4253 @ Test
@@ -54,7 +65,9 @@ public void collection2() throws Exception {
5465 @ Test
5566 public void formattedCollection () throws Exception {
5667 this .mockMvc .perform (get ("/convert/formattedCollection?values=2010-07-04,2011-07-04" ))
57- .andExpect (content ().string ("Converted formatted collection [Sun Jul 04 00:00:00 EDT 2010, Mon Jul 04 00:00:00 EDT 2011]" ));
68+ .andExpect (content ().string (
69+ "Converted formatted collection [Sun Jul 04 00:00:00 "
70+ + TIMEZONE + " 2010, Mon Jul 04 00:00:00 " + TIMEZONE + " 2011]" ));
5871 }
5972
6073 @ Test
@@ -79,7 +92,7 @@ public void beanPrimitive() throws Exception {
7992 @ Test
8093 public void beanDate () throws Exception {
8194 this .mockMvc .perform (get ("/convert/bean?date=2010-07-04" ))
82- .andExpect (content ().string ("Converted JavaBean date=Sun Jul 04 00:00:00 EDT 2010" ));
95+ .andExpect (content ().string ("Converted JavaBean date=Sun Jul 04 00:00:00 " + TIMEZONE + " 2010" ));
8396 }
8497
8598 @ Test
@@ -98,7 +111,8 @@ public void beanCollection() throws Exception {
98111 public void beanFormattedCollection () throws Exception {
99112 this .mockMvc .perform (get ("/convert/bean?formattedList[0]=2010-07-04&formattedList[1]=2011-07-04" ))
100113 .andExpect (content ().string (
101- "Converted JavaBean formattedList=[Sun Jul 04 00:00:00 EDT 2010, Mon Jul 04 00:00:00 EDT 2011]" ));
114+ "Converted JavaBean formattedList=[Sun Jul 04 00:00:00 " + TIMEZONE
115+ + " 2010, Mon Jul 04 00:00:00 " + TIMEZONE + " 2011]" ));
102116 }
103117
104118 @ Test
0 commit comments