From 6b0a62569bfb5c8e20746eead6723a3ea23e443f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 22 Oct 2013 22:38:32 +0200 Subject: [PATCH] Fix broken test in MvcNamespaceTests The testDefaultConfig() method in MvcNamespaceTests creates a new Date() in its test fixture but then performs an assertion against a hard coded data string of "2013-10-21". This test therefore only passed yesterday, on October 21, 2013. This commit addresses this by changing the hard coded date string to one based on the current date. Issue: SPR-10665, SPR-8826 --- .../web/servlet/config/MvcNamespaceTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 19d38dc35e..5629d14e2a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -19,6 +19,8 @@ package org.springframework.web.servlet.config; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -161,8 +163,8 @@ public class MvcNamespaceTests { testController.testBind(now, null, null); MvcUrls mvcUrls = this.appContext.getBean(MvcUrls.class); UriComponents uriComponents = mvcUrls.linkToMethodOn(testController); - - assertEquals("http://localhost/?date=2013-10-21", uriComponents.toUriString()); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + assertEquals("http://localhost/?date=" + dateFormat.format(now), uriComponents.toUriString()); } finally { RequestContextHolder.resetRequestAttributes();